Files
zeekayandHanzo Dev b1cc108c9f gofmt
Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 01:51:51 -07:00

48 lines
1.2 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package versionjson
import (
"fmt"
"github.com/go-json-experiment/json"
"github.com/go-json-experiment/json/jsontext"
"github.com/spf13/cobra"
"github.com/luxfi/constants"
"github.com/luxfi/ids"
"github.com/luxfi/node/version"
"github.com/luxfi/node/vms/example/xsvm"
)
type vmVersions struct {
Name string `json:"name"`
VMID ids.ID `json:"vmid"`
Version *version.Semantic `json:"version"`
RPCChainVM uint64 `json:"rpcchainvm"`
}
func Command() *cobra.Command {
return &cobra.Command{
Use: "version-json",
Short: "Prints out the version in json format",
RunE: versionFunc,
}
}
func versionFunc(*cobra.Command, []string) error {
versions := vmVersions{
Name: constants.XSVMName,
VMID: constants.XSVMID,
Version: xsvm.Version,
RPCChainVM: uint64(version.RPCChainVMProtocol),
}
jsonBytes, err := json.Marshal(versions, jsontext.WithIndent(" "))
if err != nil {
return fmt.Errorf("failed to marshal versions: %w", err)
}
fmt.Println(string(jsonBytes))
return nil
}