From 984af3c6d4555f6c8e7b748bffd8ea89abd7c7e1 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Fri, 4 Mar 2022 16:46:39 +0100 Subject: [PATCH] Lots of debugging for EventButton parsing --- src/eventButton.js | 59 +++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/eventButton.js b/src/eventButton.js index d3fc015..bc221cb 100644 --- a/src/eventButton.js +++ b/src/eventButton.js @@ -13,6 +13,9 @@ const withdrawStakeColour = "rgba(102, 3, 10, 0.3)"; const stakeColour = "rgba(71, 23, 122, 0.3)"; const claimColour = "rgba(77, 91, 42, 0.3)"; +const thresholdStaking = 0.001; +const thresholdFees = 0.00009; + const EventButton = (obj) => { const dispatch = useDispatch(); // Data shared among all events in this transaction @@ -44,8 +47,8 @@ const EventButton = (obj) => { transactionCaller = eventObj.data.delegator.toLowerCase(); transactionFrom = eventObj.data.oldDelegate.toLowerCase(); transactionTo = eventObj.data.newDelegate.toLowerCase(); - transactionAmount = parseFloat(eventObj.data.bondedAmount); - transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount); + transactionAmount = parseFloat(eventObj.data.bondedAmount) / 1000000000000000000; + transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount) / 1000000000000000000; hasBondTransaction = true; } // Unbond: defines transactionWhen. Defines transactionAmount as X / 1000000000000000000 LPT @@ -72,15 +75,15 @@ const EventButton = (obj) => { if (eventObj.name === "Rebond") { // transactionCaller might get overwritten by TranserBond, but might as well set them if (isOnlyBondRelated) { - transactionCaller = eventObj.data.delegate.toLowerCase(); - transactionFrom = eventObj.data.delegator.toLowerCase(); + transactionTo = eventObj.data.delegate.toLowerCase(); + transactionCaller = eventObj.data.delegator.toLowerCase(); transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000; } hasRebondTransaction = true; } // TranscoderActivated: defines transactionName as a stake claim. Defines transactionWhen - if (eventObj.name === "EarningsClaimed" && !hasActivation) { + if (eventObj.name === "EarningsClaimed" && !hasActivation && !hasBondTransaction) { transactionName = "Claim"; transactionWhen = eventObj.data.endRound; transactionFrom = eventObj.data.delegate; @@ -131,14 +134,15 @@ const EventButton = (obj) => { }) // If we only had a bond transaction and nothing else, this is a stake - if (isOnlyBondRelated) { - if (hasBondTransaction) { - transactionName = "Stake"; - thisColour = stakeColour; - } else if (hasRebondTransaction) { - console.log("Filtering out lone Rebond"); - return null; - } + if (hasBondTransaction) { + transactionName = "Stake"; + thisColour = stakeColour; + } + + // Lone Rebond, treat as new stake + if (hasRebondTransaction && transactionName == "") { + transactionName = "Rebond"; + thisColour = stakeColour; } // Check name filter on transactionCaller, transactionFrom, transactionTo @@ -184,6 +188,12 @@ const EventButton = (obj) => { } count++; } + if (obj.stakeActivated) { + if (transactionName === "Rebond") { + isFiltered = false; + } + count++; + } if (obj.delegatorRewardActivated) { if (transactionName === "Claim") { isFiltered = false; @@ -213,13 +223,13 @@ const EventButton = (obj) => { return null; } let claimString = "claimed "; - if (transactionAmount > 0.001){ + if (transactionAmount > thresholdStaking) { claimString += transactionAmount.toFixed(2) + " LPT staking rewards"; - if (transactionAdditionalAmount > 0.00009){ + if (transactionAdditionalAmount > thresholdFees) { claimString += " and " } } - if (transactionAdditionalAmount > 0.00009){ + if (transactionAdditionalAmount > thresholdFees) { claimString += transactionAdditionalAmount.toFixed(4) + " Eth fee rewards"; } eventSpecificInfo = @@ -236,18 +246,24 @@ const EventButton = (obj) => { if (transactionFrom == "0x0000000000000000000000000000000000000000") { eventSpecificInfo =
-

staked {(transactionAmount / 1000000000000000000).toFixed(2)} LPT to

+

staked {transactionAmount.toFixed(2)} LPT to

} else { eventSpecificInfo =
-

moved {(transactionAmount / 1000000000000000000).toFixed(2)} LPT stake:

+

moved {transactionAmount.toFixed(2)} LPT stake:

to

} + } else if (transactionName === "Rebond") { + eventSpecificInfo = +
+

increased their stake with {transactionAmount.toFixed(2)} LPT at

+ +
} else if (transactionName === "Withdraw") { eventSpecificInfo =
@@ -257,7 +273,7 @@ const EventButton = (obj) => { if (hasBondTransaction) { eventSpecificInfo =
-

activated with a self stake of {(transactionAmount / 1000000000000000000).toFixed(2)} LPT and will become active in round {transactionWhen}

+

activated with a self stake of {transactionAmount.toFixed(2)} LPT and will become active in round {transactionWhen}

} else { // If there was no bond transaction, display fewer information @@ -267,10 +283,9 @@ const EventButton = (obj) => {
} } else { + console.log("UNIMPLEMENTED " + thisURL); console.log(thisData); - eventSpecificInfo =
-

UNIMPLEMENTED

-
+ return null; } // IF ON MOBILE