getInterchain: perChain + chains options (default first anchor per chain); bump 1.5.0
transaction.getInterchain / block.getInterchain take an optional
{ perChain?, chains? } that maps to prime-node's ?perChain=&chains= params.
Default (no options) returns one anchor per chain. Shared buildInterchainQuery
helper + InterchainOptions type, exported; jest-tested.
This commit is contained in:
27
tests/interchain.test.ts
Normal file
27
tests/interchain.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { buildInterchainQuery } from '../src/interchain';
|
||||
|
||||
describe('buildInterchainQuery', () => {
|
||||
it('returns empty string with no options', () => {
|
||||
expect(buildInterchainQuery()).toBe('');
|
||||
expect(buildInterchainQuery({})).toBe('');
|
||||
});
|
||||
|
||||
it('encodes perChain (including 0 for all)', () => {
|
||||
expect(buildInterchainQuery({ perChain: 1 })).toBe('?perChain=1');
|
||||
expect(buildInterchainQuery({ perChain: 0 })).toBe('?perChain=0');
|
||||
});
|
||||
|
||||
it('joins chains with commas', () => {
|
||||
expect(buildInterchainQuery({ chains: ['1', '0'] })).toBe('?chains=1,0');
|
||||
});
|
||||
|
||||
it('combines perChain and chains', () => {
|
||||
expect(buildInterchainQuery({ perChain: 2, chains: ['1', '0'] })).toBe(
|
||||
'?perChain=2&chains=1,0'
|
||||
);
|
||||
});
|
||||
|
||||
it('ignores an empty chains array', () => {
|
||||
expect(buildInterchainQuery({ chains: [] })).toBe('');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user