From 22cbe2b2044d679de010646fe2389031bd68e86a Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 18 Mar 2021 08:56:56 +0100 Subject: [PATCH] Remove unnecessary pubkey check Since pubkey is not queried from the blockchain anymore, we don't need this check. --- .../cosmwasm-stargate/src/signingcosmwasmclient.ts | 10 +++------- packages/stargate/src/signingstargateclient.ts | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index 8294751310..e4d12d71e6 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -344,17 +344,13 @@ export class SigningCosmWasmClient extends CosmWasmClient { if (!accountFromSigner) { throw new Error("Failed to retrieve account from signer"); } - const pubkey = encodeSecp256k1Pubkey(accountFromSigner.pubkey); + const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey)); const accountFromChain = await this.getAccount(signerAddress); if (!accountFromChain) { throw new Error("Account not found"); } const { accountNumber, sequence } = accountFromChain; - if (!pubkey) { - throw new Error("Pubkey not known"); - } const chainId = await this.getChainId(); - const pubkeyAny = encodePubkey(pubkey); const txBody = { messages: messages, memo: memo, @@ -366,7 +362,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { const gasLimit = Int53.fromString(fee.gas).toNumber(); if (isOfflineDirectSigner(this.signer)) { - const authInfoBytes = makeAuthInfoBytes([pubkeyAny], fee.amount, gasLimit, sequence); + const authInfoBytes = makeAuthInfoBytes([pubkey], fee.amount, gasLimit, sequence); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc); const txRaw = TxRaw.fromPartial({ @@ -394,7 +390,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber(); const signedSequence = Int53.fromString(signed.sequence).toNumber(); const signedAuthInfoBytes = makeAuthInfoBytes( - [pubkeyAny], + [pubkey], signed.fee.amount, signedGasLimit, signedSequence, diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index cf7e12aa05..3b08d9f14b 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -138,17 +138,13 @@ export class SigningStargateClient extends StargateClient { if (!accountFromSigner) { throw new Error("Failed to retrieve account from signer"); } - const pubkey = encodeSecp256k1Pubkey(accountFromSigner.pubkey); + const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey)); const accountFromChain = await this.getAccountUnverified(signerAddress); if (!accountFromChain) { throw new Error("Account not found"); } const { accountNumber, sequence } = accountFromChain; - if (!pubkey) { - throw new Error("Pubkey not known"); - } const chainId = await this.getChainId(); - const pubkeyAny = encodePubkey(pubkey); const txBody = { messages: messages, memo: memo, @@ -160,7 +156,7 @@ export class SigningStargateClient extends StargateClient { const gasLimit = Int53.fromString(fee.gas).toNumber(); if (isOfflineDirectSigner(this.signer)) { - const authInfoBytes = makeAuthInfoBytes([pubkeyAny], fee.amount, gasLimit, sequence); + const authInfoBytes = makeAuthInfoBytes([pubkey], fee.amount, gasLimit, sequence); const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber); const { signature, signed } = await this.signer.signDirect(signerAddress, signDoc); const txRaw = TxRaw.fromPartial({ @@ -188,7 +184,7 @@ export class SigningStargateClient extends StargateClient { const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber(); const signedSequence = Int53.fromString(signed.sequence).toNumber(); const signedAuthInfoBytes = makeAuthInfoBytes( - [pubkeyAny], + [pubkey], signed.fee.amount, signedGasLimit, signedSequence,