From e88105f67b3ef902ebd932ca4951e9ae7353cf55 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 6 Sep 2024 12:24:46 +0530 Subject: [PATCH] Rename method to query bonds by owners --- src/bond.test.ts | 12 ++++++------ src/config.test.ts | 10 +++++----- src/index.ts | 4 ++-- src/registry-client.ts | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bond.test.ts b/src/bond.test.ts index 2eb2898..9d5400a 100644 --- a/src/bond.test.ts +++ b/src/bond.test.ts @@ -13,7 +13,7 @@ jest.setTimeout(90 * 1000); const bondTests = () => { let registry: Registry; - let bond: any; + let bond0: { id: string, owner: string }; const publishNewWatcherVersion = async (bondId: string) => { let watcher = await ensureUpdatedConfig(WATCHER_YML_PATH); @@ -30,11 +30,11 @@ const bondTests = () => { expect(bondId).toBeDefined(); await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, privateKey, fee); - [bond] = await registry.getBondsByIds([bondId]); + [bond0] = await registry.getBondsByIds([bondId]); }); describe('With bond created', () => { - let bond1: any; + let bond1: { id: string, owner: string }; beforeAll(async () => { 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 [owner1Bonds] = await registry.queryBondsByOwner(bond.owner); - const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond.id); + const [owner1Bonds] = await registry.queryBondsByOwners([bond0.owner]); + const owner1Bond1 = owner1Bonds.bonds.filter((b: any) => b.id === bond0.id); const owner1Bond2 = owner1Bonds.bonds.filter((b: any) => b.id === bond1.id); expect(owner1Bond1).toBeDefined(); expect(owner1Bond2).toBeDefined(); 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); const owner2Bond = owner2Bonds.bonds.filter((b: any) => b.id === bondId2); expect(owner2Bond).toBeDefined(); diff --git a/src/config.test.ts b/src/config.test.ts index be0df9f..6516889 100644 --- a/src/config.test.ts +++ b/src/config.test.ts @@ -31,7 +31,7 @@ const configTests = () => { await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); // Check that bond gets created - const [result] = await registry.queryBondsByOwner([testAccount.address]); + const [result] = await registry.queryBondsByOwners([testAccount.address]); expect(result.bonds).toHaveLength(1); }); @@ -49,7 +49,7 @@ const configTests = () => { await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); // 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); }); @@ -62,7 +62,7 @@ const configTests = () => { await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey()); // 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); }); @@ -77,7 +77,7 @@ const configTests = () => { await registry.createBond({ denom: DENOM, amount: '100000' }, testAccount.getPrivateKey(), testFees); // 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); }); @@ -95,7 +95,7 @@ const configTests = () => { } // 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); }); }; diff --git a/src/index.ts b/src/index.ts index 298dc65..4ea8b7d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -201,8 +201,8 @@ export class Registry { /** * Query bonds by owner(s). */ - async queryBondsByOwner (owners: string[]) { - return this._client.queryBondsByOwner(owners); + async queryBondsByOwners (owners: string[]) { + return this._client.queryBondsByOwners(owners); } /** diff --git a/src/registry-client.ts b/src/registry-client.ts index 08ebefa..a1cdde1 100644 --- a/src/registry-client.ts +++ b/src/registry-client.ts @@ -447,7 +447,7 @@ export class RegistryClient { /** * Get bonds by owner(s). */ - async queryBondsByOwner (ownerAddresses: string[]) { + async queryBondsByOwners (ownerAddresses: string[]) { const query = `query ($ownerAddresses: [String!]) { queryBondsByOwner(ownerAddresses: $ownerAddresses) { owner