Add support for using auto fee calculation #22

Merged
nabarun merged 19 commits from deep-stack/registry-sdk:iv-add-tx-info-test into main 2024-09-06 09:07:58 +00:00
4 changed files with 14 additions and 14 deletions
Showing only changes of commit e88105f67b - Show all commits

View File

@ -13,7 +13,7 @@ jest.setTimeout(90 * 1000);
const bondTests = () => { const bondTests = () => {
let registry: Registry; let registry: Registry;
let bond: any; let bond0: { id: string, owner: string };
const publishNewWatcherVersion = async (bondId: string) => { const publishNewWatcherVersion = async (bondId: string) => {
let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH); let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
@ -30,11 +30,11 @@ const bondTests = () => {
expect(bondId).toBeDefined(); expect(bondId).toBeDefined();
await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee); await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee);
[bond] = await registry.getBondsByIds([bondId]); [bond0] = await registry.getBondsByIds([bondId]);
}); });
describe('With bond created', () => { describe('With bond created', () => {
let bond1: any; let bond1: { id: string, owner: string };
beforeAll(async () => { beforeAll(async () => {
let bondId1 = await registry.getNextBondId(privateKey); let bondId1 = await registry.getNextBondId(privateKey);
@ -71,14 +71,14 @@ const bondTests = () => {
const { id: bondId2 } = await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, otherAccount.getPrivateKey(), fee); const { id: bondId2 } = await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, otherAccount.getPrivateKey(), fee);
const [owner1Bonds] = await registry.queryBondsByOwner(bond.owner); const [owner1Bonds] = await registry.queryBondsByOwners([bond0.owner]);
const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond.id); const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond0.id);
const owner1Bond2 = owner1Bonds.bonds.filter((b: any) => b.id === bond1.id); const owner1Bond2 = owner1Bonds.bonds.filter((b: any) => b.id === bond1.id);
expect(owner1Bond1).toBeDefined(); expect(owner1Bond1).toBeDefined();
expect(owner1Bond2).toBeDefined(); expect(owner1Bond2).toBeDefined();
const [bond2] = await registry.getBondsByIds([bondId2]); const [bond2] = await registry.getBondsByIds([bondId2]);
const [owner2Bonds] = await registry.queryBondsByOwner(bond2.owner); const [owner2Bonds] = await registry.queryBondsByOwners([bond2.owner]);
expect(owner2Bonds.bonds).toHaveLength(1); expect(owner2Bonds.bonds).toHaveLength(1);
const owner2Bond = owner2Bonds.bonds.filter((b: any) => b.id === bondId2); const owner2Bond = owner2Bonds.bonds.filter((b: any) => b.id === bondId2);
expect(owner2Bond).toBeDefined(); expect(owner2Bond).toBeDefined();

View File

@ -31,7 +31,7 @@ const configTests = () => {
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
// Check that bond gets created // Check that bond gets created
const [result] = await registry.queryBondsByOwner([testAccount.address]); const [result] = await registry.queryBondsByOwners([testAccount.address]);
expect(result.bonds).toHaveLength(1); expect(result.bonds).toHaveLength(1);
}); });
@ -49,7 +49,7 @@ const configTests = () => {
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
// Check that bond gets created (gas price ignored) // Check that bond gets created (gas price ignored)
const [result] = await registry.queryBondsByOwner([testAccount.address]); const [result] = await registry.queryBondsByOwners([testAccount.address]);
expect(result.bonds).toHaveLength(2); expect(result.bonds).toHaveLength(2);
}); });
@ -62,7 +62,7 @@ const configTests = () => {
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey()); await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey());
// Check that bond gets created (gas price ignored) // Check that bond gets created (gas price ignored)
const [result] = await registry.queryBondsByOwner([testAccount.address]); const [result] = await registry.queryBondsByOwners([testAccount.address]);
expect(result.bonds).toHaveLength(3); expect(result.bonds).toHaveLength(3);
}); });
@ -77,7 +77,7 @@ const configTests = () => {
await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees);
// Check that bond gets created (gas price ignored) // Check that bond gets created (gas price ignored)
const [result] = await registry.queryBondsByOwner([testAccount.address]); const [result] = await registry.queryBondsByOwners([testAccount.address]);
expect(result.bonds).toHaveLength(4); expect(result.bonds).toHaveLength(4);
}); });
@ -95,7 +95,7 @@ const configTests = () => {
} }
// Check that bond doesn't get created // Check that bond doesn't get created
const [result] = await registry.queryBondsByOwner([testAccount.address]); const [result] = await registry.queryBondsByOwners([testAccount.address]);
expect(result.bonds).toHaveLength(4); expect(result.bonds).toHaveLength(4);
}); });
}; };

View File

@ -201,8 +201,8 @@ export class Registry {
/** /**
* Query bonds by owner(s). * Query bonds by owner(s).
*/ */
async queryBondsByOwner (owners: string[]) { async queryBondsByOwners (owners: string[]) {
return this._client.queryBondsByOwner(owners); return this._client.queryBondsByOwners(owners);
} }
/** /**

View File

@ -447,7 +447,7 @@ export class RegistryClient {
/** /**
* Get bonds by owner(s). * Get bonds by owner(s).
*/ */
async queryBondsByOwner (ownerAddresses: string[]) { async queryBondsByOwners (ownerAddresses: string[]) {
const query = `query ($ownerAddresses: [String!]) { const query = `query ($ownerAddresses: [String!]) {
queryBondsByOwner(ownerAddresses: $ownerAddresses) { queryBondsByOwner(ownerAddresses: $ownerAddresses) {
owner owner