mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49: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);
|
||||
|
||||
// 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[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[]> {
|
||||
const allContracts = [];
|
||||
|
||||
try {
|
||||
let startAtKey: Uint8Array | undefined = undefined;
|
||||
do {
|
||||
const { contracts, pagination }: QueryContractsByCodeResponse =
|
||||
await this.forceGetQueryClient().wasm.listContractsByCodeId(codeId, startAtKey);
|
||||
const loadedContracts = contracts || [];
|
||||
loadedContracts.reverse();
|
||||
allContracts.unshift(...loadedContracts);
|
||||
startAtKey = pagination?.nextKey;
|
||||
} while (startAtKey?.length !== 0);
|
||||
} catch (_e: any) {
|
||||
throw new Error(_e);
|
||||
}
|
||||
let startAtKey: Uint8Array | undefined = undefined;
|
||||
do {
|
||||
const { contracts, pagination }: QueryContractsByCodeResponse =
|
||||
await this.forceGetQueryClient().wasm.listContractsByCodeId(codeId, startAtKey);
|
||||
const loadedContracts = contracts || [];
|
||||
allContracts.unshift(...loadedContracts);
|
||||
startAtKey = pagination?.nextKey;
|
||||
} while (startAtKey?.length !== 0 && startAtKey !== undefined);
|
||||
|
||||
return allContracts;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user