From 55b3feff94ad252eaedb2de0ff8a0fd070c6f804 Mon Sep 17 00:00:00 2001 From: byeongsu-hong Date: Tue, 27 Feb 2024 23:06:54 +0900 Subject: [PATCH] fix: addPad --- script/commands/contract.ts | 6 +----- script/commands/warp.ts | 6 +----- script/shared/config.ts | 6 +++++- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/script/commands/contract.ts b/script/commands/contract.ts index 80312e9a..0bfb7d74 100644 --- a/script/commands/contract.ts +++ b/script/commands/contract.ts @@ -33,11 +33,7 @@ contractCmd { dispatch: { dest_domain: parseInt(destDomain), - recipient_addr: addPad( - recipientAddr.startsWith("0x") - ? recipientAddr.slice(2) - : recipientAddr - ), + recipient_addr: addPad(recipientAddr), msg_body: Buffer.from(msgBody, "utf-8").toString("hex"), }, }, diff --git a/script/commands/warp.ts b/script/commands/warp.ts index f6e22d2c..4593d8ed 100644 --- a/script/commands/warp.ts +++ b/script/commands/warp.ts @@ -163,11 +163,7 @@ async function handleLink(_: any, cmd: Command) { const linkResp = await executeContract(deps.client, route, { set_route: { domain: opts.targetDomain, - route: addPad( - opts.warpAddress.startsWith("0x") - ? opts.warpAddress.slice(2) - : opts.warpAddress - ), + route: addPad(opts.warpAddress), }, }); diff --git a/script/shared/config.ts b/script/shared/config.ts index 59fe2419..3cff4b90 100644 --- a/script/shared/config.ts +++ b/script/shared/config.ts @@ -13,6 +13,7 @@ import { } from "@cosmjs/proto-signing"; import { GasPrice, SigningStargateClient } from "@cosmjs/stargate"; import { Secp256k1, keccak256 } from "@cosmjs/crypto"; +import { addPad } from "./utils"; export type IsmType = | { @@ -156,7 +157,10 @@ export async function getSigningClient( const wallet = signer.split(" ").length > 1 ? await DirectSecp256k1HdWallet.fromMnemonic(signer, { prefix: hrp }) - : await DirectSecp256k1Wallet.fromKey(Buffer.from(signer, "hex"), hrp); + : await DirectSecp256k1Wallet.fromKey( + Buffer.from(addPad(signer), "hex"), + hrp + ); const [account] = await wallet.getAccounts(); const gasPrice = GasPrice.fromString(`${gas.price}${gas.denom}`);