mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Fix Tests & Beautify Code
This commit is contained in:
parent
6d6fe29ad0
commit
03f783194f
@ -275,9 +275,9 @@ describe("CosmWasmClient", () => {
|
|||||||
const expectedAddresses = deployedHackatom.instances.map((info) => info.address);
|
const expectedAddresses = deployedHackatom.instances.map((info) => info.address);
|
||||||
|
|
||||||
// Test first 3 instances we get from scripts/wasmd/init.sh. There may me more than that in the result.
|
// Test first 3 instances we get from scripts/wasmd/init.sh. There may me more than that in the result.
|
||||||
expect(result[0]).toEqual(expectedAddresses[2]);
|
expect(result[0]).toEqual(expectedAddresses[0]);
|
||||||
expect(result[1]).toEqual(expectedAddresses[1]);
|
expect(result[1]).toEqual(expectedAddresses[1]);
|
||||||
expect(result[2]).toEqual(expectedAddresses[0]);
|
expect(result[2]).toEqual(expectedAddresses[2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -342,20 +342,14 @@ export class CosmWasmClient {
|
|||||||
*/
|
*/
|
||||||
public async getContracts(codeId: number): Promise<readonly string[]> {
|
public async getContracts(codeId: number): Promise<readonly string[]> {
|
||||||
const allContracts = [];
|
const allContracts = [];
|
||||||
|
let startAtKey: Uint8Array | undefined = undefined;
|
||||||
try {
|
do {
|
||||||
let startAtKey: Uint8Array | undefined = undefined;
|
const { contracts, pagination }: QueryContractsByCodeResponse =
|
||||||
do {
|
await this.forceGetQueryClient().wasm.listContractsByCodeId(codeId, startAtKey);
|
||||||
const { contracts, pagination }: QueryContractsByCodeResponse =
|
const loadedContracts = contracts || [];
|
||||||
await this.forceGetQueryClient().wasm.listContractsByCodeId(codeId, startAtKey);
|
allContracts.unshift(...loadedContracts);
|
||||||
const loadedContracts = contracts || [];
|
startAtKey = pagination?.nextKey;
|
||||||
loadedContracts.reverse();
|
} while (startAtKey?.length !== 0 && startAtKey !== undefined);
|
||||||
allContracts.unshift(...loadedContracts);
|
|
||||||
startAtKey = pagination?.nextKey;
|
|
||||||
} while (startAtKey?.length !== 0);
|
|
||||||
} catch (_e: any) {
|
|
||||||
throw new Error(_e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return allContracts;
|
return allContracts;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user