GetInterchain: perChain + chains options (default first anchor per chain)

Transaction.GetInterchain and Block.GetInterchain take variadic options
(client.WithPerChain / client.WithChains, re-exported as sdk.WithPerChain /
sdk.WithChains) that map to the new prime-node ?perChain=&chains= query params.
Backward compatible: existing no-option calls get the default (one anchor per
chain). client.InterchainQuery builds the suffix; unit-tested.
This commit is contained in:
2026-06-05 10:54:45 -04:00
parent 7d8e23768f
commit 17057ad1f2
7 changed files with 162 additions and 4 deletions

View File

@@ -56,9 +56,14 @@ func (tc *TransactionClient) Get(ctx context.Context, transactionID string) (*mo
// validated its prime block and the public-chain interchain anchors those
// validator blocks were bundled into. If the transaction is still pending (not
// yet in a block) the trace's slices are empty.
func (tc *TransactionClient) GetInterchain(ctx context.Context, transactionID string) (*models.InterchainTrace, error) {
//
// By default it returns the first anchor per public chain (anchor proofs are
// chained, so the earliest per chain is the meaningful one). Use
// client.WithPerChain / client.WithChains to return more anchors per chain or
// restrict to specific chains.
func (tc *TransactionClient) GetInterchain(ctx context.Context, transactionID string, opts ...client.InterchainOption) (*models.InterchainTrace, error) {
var resp models.InterchainTrace
path := fmt.Sprintf("/api/v1/transaction/%s/interchain", transactionID)
path := fmt.Sprintf("/api/v1/transaction/%s/interchain%s", transactionID, client.InterchainQuery(opts...))
err := tc.client.Get(ctx, path, &resp)
if err != nil {
return nil, err