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.
48 lines
1.3 KiB
Go
48 lines
1.3 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/formatting"
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/rpc"
|
|
"github.com/luxfi/sdk/constants"
|
|
"github.com/luxfi/vm/api"
|
|
)
|
|
|
|
// WalletClient for interacting with exchangevm managed wallet.
|
|
//
|
|
// Deprecated: Transactions should be issued using the
|
|
// `luxfi/node/wallet/chain/x.Wallet` utility.
|
|
type WalletClient struct {
|
|
Requester rpc.EndpointRequester
|
|
}
|
|
|
|
// NewWalletClient returns an Exchange VM wallet client for interacting with
|
|
// exchangevm managed wallet
|
|
//
|
|
// Deprecated: Transactions should be issued using the
|
|
// `luxfi/node/wallet/chain/x.Wallet` utility.
|
|
func NewWalletClient(uri, chain string) *WalletClient {
|
|
return &WalletClient{
|
|
Requester: rpc.NewEndpointRequester(constants.Chain(uri, chain) + "/wallet"),
|
|
}
|
|
}
|
|
|
|
// IssueTx issues a transaction to a node and returns the TxID
|
|
func (c *WalletClient) IssueTx(ctx context.Context, txBytes []byte, options ...rpc.Option) (ids.ID, error) {
|
|
txStr, err := formatting.Encode(formatting.Hex, txBytes)
|
|
if err != nil {
|
|
return ids.Empty, err
|
|
}
|
|
res := &api.JSONTxID{}
|
|
err = c.Requester.SendRequest(ctx, "wallet.issueTx", &api.FormattedTx{
|
|
Tx: txStr,
|
|
Encoding: formatting.Hex,
|
|
}, res, options...)
|
|
return res.TxID, err
|
|
}
|