Use an unverified query for getting the sequence number for signing

This commit is contained in:
Ethan Frey 2021-02-09 15:30:43 +01:00
parent 5400c3ac8c
commit 1f9b03a254
2 changed files with 9 additions and 1 deletions

View File

@ -139,7 +139,7 @@ export class SigningStargateClient extends StargateClient {
throw new Error("Failed to retrieve account from signer");
}
const pubkey = encodeSecp256k1Pubkey(accountFromSigner.pubkey);
const accountFromChain = await this.getAccount(signerAddress);
const accountFromChain = await this.getAccountUnverified(signerAddress);
if (!accountFromChain) {
throw new Error("Account not found");
}

View File

@ -149,11 +149,19 @@ export class StargateClient {
return status.syncInfo.latestBlockHeight;
}
// this is nice to display data to the user, but is slower
public async getAccount(searchAddress: string): Promise<Account | null> {
const account = await this.queryClient.auth.account(searchAddress);
return account ? accountFromProto(account) : null;
}
// if we just need to get the sequence for signing a transaction, let's make this faster
// (no need to wait a block before submitting)
public async getAccountUnverified(searchAddress: string): Promise<Account | null> {
const account = await this.queryClient.auth.unverified.account(searchAddress);
return account ? accountFromProto(account) : null;
}
public async getSequence(address: string): Promise<SequenceResponse | null> {
const account = await this.getAccount(address);
if (account) {