Refactor getting private key

This commit is contained in:
Shreerang Kale 2025-05-06 11:02:06 +05:30
parent 9df58b9511
commit 7229e6c97c

View File

@ -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
</Button>
</View>
</>