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

22
client/interchain_test.go Normal file
View File

@@ -0,0 +1,22 @@
package client
import "testing"
func TestInterchainQuery(t *testing.T) {
cases := []struct {
name string
opts []InterchainOption
want string
}{
{"none", nil, ""},
{"perChain1", []InterchainOption{WithPerChain(1)}, "?perChain=1"},
{"perChain0 (all)", []InterchainOption{WithPerChain(0)}, "?perChain=0"},
{"chains", []InterchainOption{WithChains("1", "0")}, "?chains=1,0"},
{"both", []InterchainOption{WithPerChain(2), WithChains("1", "0")}, "?perChain=2&chains=1,0"},
}
for _, c := range cases {
if got := InterchainQuery(c.opts...); got != c.want {
t.Errorf("%s: InterchainQuery = %q, want %q", c.name, got, c.want)
}
}
}