mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
A bit more cleanup
This commit is contained in:
parent
8699e2e8f7
commit
49070f668f
@ -443,7 +443,7 @@ describe("RestClient", () => {
|
||||
expect((myInfo.init_msg as any).beneficiary).toEqual(beneficiaryAddress);
|
||||
|
||||
// make sure random addresses don't give useful info
|
||||
client
|
||||
await client
|
||||
.getContractInfo(beneficiaryAddress)
|
||||
.then(() => fail("this shouldn't succeed"))
|
||||
.catch(error => expect(error).toMatch(`No contract with address ${beneficiaryAddress}`));
|
||||
@ -507,22 +507,20 @@ describe("RestClient", () => {
|
||||
expect(verifier).toEqual(faucetAddress);
|
||||
|
||||
// invalid query syntax throws an error
|
||||
await client
|
||||
.queryContractSmart(contractAddress, { nosuchkey: {} })
|
||||
.then(() => fail("shouldn't succeed"))
|
||||
.catch(() => {});
|
||||
// TODO: debug rest server. Here I get:
|
||||
// Expected Error: Request failed with status code 500 to match 'Parse Error:'
|
||||
// .catch(error => expect(error).toMatch(`not found: contract`));
|
||||
await client.queryContractSmart(contractAddress, { nosuchkey: {} }).then(
|
||||
() => fail("shouldn't succeed"),
|
||||
error => expect(error).toBeTruthy(),
|
||||
);
|
||||
// TODO: debug rest server. I expect a 'Parse Error', but get
|
||||
// Request failed with status code 500 to match 'Parse Error:'
|
||||
|
||||
// invalid address throws an error
|
||||
await client
|
||||
.queryContractSmart(noContract, { verifier: {} })
|
||||
.then(() => fail("shouldn't succeed"))
|
||||
.catch(() => {});
|
||||
// TODO: debug rest server. Here I get:
|
||||
// Expected Error: Request failed with status code 500 to match 'Parse Error:'
|
||||
// .catch(error => expect(error).toMatch(`not found: contract`));
|
||||
await client.queryContractSmart(noContract, { verifier: {} }).then(
|
||||
() => fail("shouldn't succeed"),
|
||||
error => expect(error).toBeTruthy(),
|
||||
);
|
||||
// TODO: debug rest server. I expect a 'not found', but get
|
||||
// Request failed with status code 500 to match 'Parse Error:'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -246,15 +246,17 @@ export class RestClient {
|
||||
public async listContractAddresses(): Promise<readonly string[]> {
|
||||
const path = `/wasm/contract`;
|
||||
const responseData = await this.get(path);
|
||||
// answer may be null (empty array)
|
||||
return parseWasmResponse(responseData as WasmResponse) || [];
|
||||
// answer may be null (go's encoding of empty array)
|
||||
const addresses: string[] | null = parseWasmResponse(responseData as WasmResponse);
|
||||
return addresses || [];
|
||||
}
|
||||
|
||||
// throws error if no contract at this address
|
||||
public async getContractInfo(address: string): Promise<ContractInfo> {
|
||||
const path = `/wasm/contract/${address}`;
|
||||
const responseData = await this.get(path);
|
||||
const info = parseWasmResponse(responseData as WasmResponse);
|
||||
// rest server returns null if no data for the address
|
||||
const info: ContractInfo | null = parseWasmResponse(responseData as WasmResponse);
|
||||
if (!info) {
|
||||
throw new Error(`No contract with address ${address}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user