Skip to content

Commit 511ffaa

Browse files
committed
feat: support both eth_secp256k1 and ethsecp256k1 algorithms in pubkey encoding
1 parent bd5c756 commit 511ffaa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/cosmwasm-stargate/src/signingcosmwasmclient.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,12 @@ export class SigningCosmWasmClient extends CosmWasmClient {
704704
if (!accountFromSigner) {
705705
throw new Error("Failed to retrieve account from signer");
706706
}
707-
const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));
707+
let pubkey;
708+
if (accountFromSigner.algo == "eth_secp256k1" || accountFromSigner.algo == "ethsecp256k1" ) {
709+
pubkey = encodePubkey(encodeEthSecp256k1Pubkey(accountFromSigner.pubkey));
710+
} else {
711+
pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));
712+
}
708713
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
709714
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
710715
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight);
@@ -751,7 +756,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
751756
throw new Error("Failed to retrieve account from signer");
752757
}
753758
let pubkey;
754-
if (accountFromSigner.algo == "eth_secp256k1") {
759+
if (accountFromSigner.algo == "eth_secp256k1" || accountFromSigner.algo == "ethsecp256k1" ) {
755760
pubkey = encodePubkey(encodeEthSecp256k1Pubkey(accountFromSigner.pubkey));
756761
} else {
757762
pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));

0 commit comments

Comments
 (0)