From 814e987abed7dbde2fbb4dccdfb05edf499e65f9 Mon Sep 17 00:00:00 2001 From: jordan Date: Thu, 13 Jun 2024 11:55:47 -0700 Subject: [PATCH 1/2] fix totals and perc collection --- src/components/voting/ConfirmationPanel.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/voting/ConfirmationPanel.tsx b/src/components/voting/ConfirmationPanel.tsx index 96ed36e3..507564c7 100644 --- a/src/components/voting/ConfirmationPanel.tsx +++ b/src/components/voting/ConfirmationPanel.tsx @@ -49,7 +49,7 @@ export const ConfirmationPanel = ({ const totalPercent = useMemo( () => form.values.ships.reduce((acc, curr) => { - return acc + Number(curr.shipPerc); + return acc + parseFloat(curr.shipPerc.toFixed(2)); }, 0), [form.values] ); @@ -127,11 +127,20 @@ export const ConfirmationPanel = ({ (choice) => choice.shipId === ship.shipId )?.id; + const perc = ship.shipPerc || 0; + + console.log('perc', perc); + + const percToInt = parseFloat((perc * 1e6).toFixed()); + + console.log('percToInt', percToInt); + const tokenAmount = - (userTokenData.totalUserTokenBalance * - BigInt(Number(ship.shipPerc) * 1e6)) / + (userTokenData.totalUserTokenBalance * BigInt(percToInt)) / BigInt(100 * 1e6); + console.log('tokenAmount', tokenAmount); + const pinRes = await pinJSONToIPFS({ voteReason: ship.shipComment, }); @@ -199,6 +208,7 @@ export const ConfirmationPanel = ({ }, }); } catch (error: any) { + console.error(error); notifications.show({ title: 'Error', message: `Vote submission failed: ${error.message}`, From d7cda4887994e90b7dfb8892f41d4b6de7b5ed71 Mon Sep 17 00:00:00 2001 From: jordan Date: Thu, 13 Jun 2024 12:06:32 -0700 Subject: [PATCH 2/2] fix display error --- src/components/voting/ConfirmationPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/voting/ConfirmationPanel.tsx b/src/components/voting/ConfirmationPanel.tsx index 507564c7..6f040d9e 100644 --- a/src/components/voting/ConfirmationPanel.tsx +++ b/src/components/voting/ConfirmationPanel.tsx @@ -49,7 +49,7 @@ export const ConfirmationPanel = ({ const totalPercent = useMemo( () => form.values.ships.reduce((acc, curr) => { - return acc + parseFloat(curr.shipPerc.toFixed(2)); + return Number((acc + Number(curr.shipPerc.toFixed(2))).toFixed(2)); }, 0), [form.values] );