From 741942194f7b884289538335ad109db9e0c045bf Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 14 Aug 2024 10:14:20 +0530 Subject: [PATCH] Accept keys with or without hex prefix --- src/util/common.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/common.ts b/src/util/common.ts index 0c1923b..cc0bdd6 100644 --- a/src/util/common.ts +++ b/src/util/common.ts @@ -6,11 +6,16 @@ export const getConnectionInfo = (argv: Arguments, config: any) => { const result = { ...config, + userKey: stripHexPrefix(config.userKey), ...clean({ server, userKey, bondId, txKey, chainId }), - privateKey: txKey || userKey || config.userKey, + privateKey: stripHexPrefix(txKey || userKey || config.userKey), gas: String(gas || config.gas), fees: String(fees || config.fees) }; return result; }; + +function stripHexPrefix (hex: string): string { + return hex && hex.startsWith('0x') ? hex.slice(2) : hex; +}