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

@@ -128,8 +128,27 @@ All API methods accept a `context.Context` as their first parameter for timeout
- `Create(ctx, req)` - Create a new transaction
- `CreateBulk(ctx, req)` - Create multiple transactions
- `Get(ctx, transactionID)` - Get transaction by ID
- `GetInterchain(ctx, transactionID, opts...)` - Trace a transaction's interchain anchors
- `List(ctx)` - List all transactions
#### Interchain trace options
`Transaction.GetInterchain` and `Block.GetInterchain` trace a prime block to the
public-chain anchors covering it. By default they return the **first anchor per
chain** (anchor proofs are chained, so the earliest per chain is the meaningful
one). Tune with functional options:
```go
// Default: first anchor per chain (ETH, BTC, …)
trace, _ := client.Block.GetInterchain(ctx, "42")
// Up to 3 anchors per chain
trace, _ = client.Block.GetInterchain(ctx, "42", sdk.WithPerChain(3))
// All anchors, only the ETH-mainnet chain ("1"); "0" = BTC
trace, _ = client.Block.GetInterchain(ctx, "42", sdk.WithPerChain(0), sdk.WithChains("1"))
```
### Transaction Type
- `Create(ctx, req)` - Create a new transaction type
- `Get(ctx, txnType)` - Get transaction type by name