From 4af23e687858c90df55cfd698a3c6b5e7ce3109b Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Thu, 13 Oct 2022 20:59:54 +0100 Subject: [PATCH] Use on-chain pubkey type if available --- src/utils/SigningClient.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/SigningClient.mjs b/src/utils/SigningClient.mjs index 583fd462..2e27537e 100644 --- a/src/utils/SigningClient.mjs +++ b/src/utils/SigningClient.mjs @@ -279,14 +279,14 @@ function SigningClient(network, signer) { if (!accountFromSigner) { throw new Error("Failed to retrieve account from signer"); } - const pubkey = accountFromSigner.pubkey; + const signerPubkey = accountFromSigner.pubkey; return AuthInfo.encode({ signerInfos: [ { publicKey: { - typeUrl: pubkeyTypeUrl(), + typeUrl: pubkeyTypeUrl(account.pub_key), value: PubKey.encode({ - key: pubkey, + key: signerPubkey, }).finish(), }, sequence: Long.fromNumber(sequence, true), @@ -297,7 +297,9 @@ function SigningClient(network, signer) { }).finish() } - function pubkeyTypeUrl(){ + function pubkeyTypeUrl(pub_key){ + if(pub_key && pub_key['@type']) return pub_key['@type'] + if(network.path === 'injective'){ return '/injective.crypto.v1beta1.ethsecp256k1.PubKey' }