Files
zeekayandHanzo Dev 4b18e04aac Ask the node for /v1/chain, the only chain prefix it still serves
The node moved every chain route from /v1/bc/<alias> to /v1/chain/<alias> and
deleted the old prefix, so every call this SDK made against a current node was
a 404. The segment is constants.ChainAliasPrefix, which went from "bc" to
"chain" in luxfi/constants v1.6.4.

Call sites that already went through constants.Chain moved with the pin. These
nine spelled the prefix out longhand instead of asking the composer, so they
stayed behind: five endpoint helpers in models, the default APIEndpoint in
config, the two URLs ux prints, and two doc examples that would have sent a
reader at a deleted route.

The wallet's test double mounted /v1/bc/P and /v1/bc/X, so it answered the
route the node had dropped and would have gone on passing against a node that
no longer exists. It now serves what the node serves, and the assertion that
the SDK must not touch X in P-only mode checks the live path -- against the old
one it could never fire again.

That file has not compiled since the X/C opt-in decomplect removed
isXChainNotEnabled, so none of these tests were running. Its test went with the
function it covered.

Chain() no longer claims the node answers both spellings. It does not.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-30 15:00:58 -07:00

41 lines
1.7 KiB
Go

// Copyright (C) 2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
//go:build livedial
// dial.go wires the LIVE EVM transport (luxfi/evm/ethclient) into the SDK.
//
// It is behind the `livedial` build tag because luxfi/evm is a heavy node-side
// module: with GOWORK=off (the SDK's CI lane) its published version drags in a
// luxfi/upgrade pin that does not resolve standalone — the same reason the lux
// workspace force-replaces luxfi/upgrade in go.work. The CORE SDK (encoders,
// receipt/proof codecs, the Client over the EVMBackend interface, all tests)
// therefore compiles and tests with NO luxfi/evm dependency, so default
// `GOWORK=off go test ./...` stays green. Build/import this file only inside the
// lux workspace (where evm resolves) or with `-tags livedial`:
//
// c, err := aichain.Dial("https://api.lux.network/v1/chain/C/rpc", privKeyHex)
//
// Everywhere else, construct the Client directly from any EVMBackend
// (aichain.NewClient) — luxfi/evm/ethclient.Client satisfies that interface, so
// callers already holding a node client pass it straight through with no tag.
package aichain
import (
"fmt"
"github.com/luxfi/evm/ethclient"
)
// Dial connects to an EVM JSON-RPC endpoint (the C-Chain RPC) and returns a
// ready Client signing with privKeyHex. Wire a ReceiptStore via WithReceiptStore
// to enable the Tier-2 WaitReceipt / Infer convenience. luxfi/evm/ethclient.Client
// satisfies EVMBackend directly, so it is passed straight through.
func Dial(rpcURL, privKeyHex string, opts ...Option) (*Client, error) {
ec, err := ethclient.Dial(rpcURL)
if err != nil {
return nil, fmt.Errorf("aichain: dial %s: %w", rpcURL, err)
}
return NewClient(ec, privKeyHex, opts...)
}