From 7229e6c97c1c8be915a0fc6f8f14415bf6b98e29 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Tue, 6 May 2025 11:02:06 +0530 Subject: [PATCH] Refactor getting private key --- src/screens/SignTxEmbed.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/screens/SignTxEmbed.tsx b/src/screens/SignTxEmbed.tsx index 60cfc15..e6bdfa5 100644 --- a/src/screens/SignTxEmbed.tsx +++ b/src/screens/SignTxEmbed.tsx @@ -133,8 +133,10 @@ export const SignTxEmbed = () => { // Balance Check // Use a temporary read-only client for balance + const { privKey } = await getPathKey(`${network.namespace}:${network.chainId}`, account.index) + const tempWallet = await DirectSecp256k1Wallet.fromKey( - new Uint8Array(Buffer.from((await getPathKey(`${network.namespace}:${network.chainId}`, account.index)).privKey.replace(/^0x/, ''), 'hex')), + new Uint8Array(Buffer.from(privKey.replace(/^0x/, ''), 'hex')), network.addressPrefix ); @@ -222,6 +224,7 @@ export const SignTxEmbed = () => { try { const { privKey } = await getPathKey(`${requestedNetwork.namespace}:${chainId}`, account.index); + const privateKeyBytes = Buffer.from(privKey.replace(/^0x/, ''), 'hex'); const wallet = await DirectSecp256k1Wallet.fromKey(new Uint8Array(privateKeyBytes), requestedNetwork.addressPrefix); // Wrap in Uint8Array @@ -370,7 +373,7 @@ export const SignTxEmbed = () => { disabled={isTxLoading} style={{ marginTop: 10 }} > - Reject + Reject