mirror of
https://github.com/luxfi/sdk.git
synced 2026-10-30 15:19:23 +00:00
Three drifts, none of which failed to compile and none of which failed a test, because a JSON-RPC address and a JSON-RPC method name are strings. The prefix. The node serves /v1 and nothing else — "the legacy /ext prefix is gone", server/http/server.go — and twelve places here spelled /ext. Every P-chain and X-chain call in this SDK was a 404. The service. vms/xvm/vm.go registers the X-chain under "xvm". Eleven methods here said "exchangevm", while buildGenesis in the same package said "xvm" — the disagreement was already visible in the source. The field. vms/platformvm/service.go reads netID; eleven types here sent and read chainID. This one does not even fail: the node finds no netID, leaves the id empty, and an empty id is the primary network, so asking an L1 for its validators quietly answers with the wrong set. The prefix drift is the one worth naming, because twelve copies is what made it twelve bugs. constants.Route is now the one place this SDK composes a node address, and Chain reads ChainAliasPrefix rather than spelling the segment, because that segment MOVED — it was "bc" and is "chain", and the node serves both only until its callers have rolled. exchangevm had no tests at all. It has one now, and it is about the two things that were wrong: the name on the wire and the path it goes to.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package exchangevm
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/rpc"
|
|
"github.com/luxfi/sdk/constants"
|
|
)
|
|
|
|
var _ StaticClient = (*staticClient)(nil)
|
|
|
|
// StaticClient for interacting with the XVM static api
|
|
type StaticClient interface {
|
|
BuildGenesis(ctx context.Context, args *BuildGenesisArgs, options ...rpc.Option) (*BuildGenesisReply, error)
|
|
}
|
|
|
|
// staticClient is an implementation of an XVM client for interacting with the
|
|
// xvm static api
|
|
type staticClient struct {
|
|
requester rpc.EndpointRequester
|
|
}
|
|
|
|
// NewClient returns an XVM client for interacting with the xvm static api
|
|
func NewStaticClient(uri string) StaticClient {
|
|
return &staticClient{requester: rpc.NewEndpointRequester(
|
|
constants.VM(uri, "xvm"),
|
|
)}
|
|
}
|
|
|
|
func (c *staticClient) BuildGenesis(ctx context.Context, args *BuildGenesisArgs, options ...rpc.Option) (resp *BuildGenesisReply, err error) {
|
|
resp = &BuildGenesisReply{}
|
|
err = c.requester.SendRequest(ctx, "xvm.buildGenesis", args, resp, options...)
|
|
return resp, err
|
|
}
|