cosmwasm-stargate: Harmonise CosmWasmClient.getAccount method

This commit is contained in:
willclarktech 2021-03-30 16:13:00 +02:00
parent 7d038cd216
commit d3d24fdf0f
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7

View File

@ -109,20 +109,25 @@ export class CosmWasmClient {
}
public async getAccount(searchAddress: string): Promise<Account | null> {
const account = await this.forceGetQueryClient().auth.account(searchAddress);
return account ? accountFromAny(account) : null;
try {
const account = await this.forceGetQueryClient().auth.account(searchAddress);
return account ? accountFromAny(account) : null;
} catch (error) {
if (/rpc error: code = NotFound/i.test(error)) {
return null;
}
throw error;
}
}
public async getSequence(address: string): Promise<SequenceResponse | null> {
const account = await this.getAccount(address);
if (account) {
return {
accountNumber: account.accountNumber,
sequence: account.sequence,
};
} else {
return null;
}
return account
? {
accountNumber: account.accountNumber,
sequence: account.sequence,
}
: null;
}
public async getBlock(height?: number): Promise<Block> {