From 808ea94008e1d6d65602b4d8a9136cceffac5eea Mon Sep 17 00:00:00 2001 From: kieled <68655454+kieled@users.noreply.github.com> Date: Wed, 24 Jul 2024 20:29:19 +0300 Subject: [PATCH] fix balances (ordinal + cardinal), fix fee on signPsbt page (#95) --- package.json | 2 +- src/ui/hooks/provider.ts | 9 +++++---- src/ui/pages/main/wallet/account-panel/component.tsx | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4d71e7bb..c3cafaa5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nintondo-extension", - "version": "0.2.5.1", + "version": "0.2.5.2", "private": true, "scripts": { "dev": "bun build.ts --watch", diff --git a/src/ui/hooks/provider.ts b/src/ui/hooks/provider.ts index 0f91cf9f..cc1f1750 100644 --- a/src/ui/hooks/provider.ts +++ b/src/ui/hooks/provider.ts @@ -118,7 +118,7 @@ export const useDecodePsbtInputs = () => { ); psbt.txOutputs.forEach((f, i) => { - totalOutputValue += f.value / 10 ** 8; + totalOutputValue += f.value; outputFields.push({ important: currentAccount?.address === f.address, input: false, @@ -139,7 +139,7 @@ export const useDecodePsbtInputs = () => { let value: IFieldValue; const inputValue = locationValue[outpoint] / 10 ** 8; - totalInputValue += inputValue; + totalInputValue += locationValue[outpoint]; if (psbt.data.inputs[i].sighashType === 131) { const foundInscriptions = await apiController.getInscription({ @@ -177,10 +177,11 @@ export const useDecodePsbtInputs = () => { return inputFields.concat(outputFields); }); + const fields = await Promise.all(result); const fee = totalInputValue - totalOutputValue; return { - fields: await Promise.all(result), - fee: fee < 0 ? "0" : toFixed(fee), + fields, + fee: fee < 0 ? "0" : toFixed(fee / 10 ** 8), }; }, [apiController, currentAccount, notificationController]); }; diff --git a/src/ui/pages/main/wallet/account-panel/component.tsx b/src/ui/pages/main/wallet/account-panel/component.tsx index bd2799ef..9c7f24ec 100644 --- a/src/ui/pages/main/wallet/account-panel/component.tsx +++ b/src/ui/pages/main/wallet/account-panel/component.tsx @@ -19,7 +19,7 @@ const AccountPanel = () => { const cardinalBalance = currentAccount?.balance ?? 0; const ordinalBalance = currentAccount?.inscriptionBalance ?? 0; - const balance = (cardinalBalance + ordinalBalance) / 10 ** 8; + const balance = (cardinalBalance / 10 ** 8 + ordinalBalance); return (