Lots of debugging for EventButton parsing

This commit is contained in:
Marco van Dijk 2022-03-04 16:46:39 +01:00
parent 30f7295c7c
commit 984af3c6d4

View File

@ -13,6 +13,9 @@ const withdrawStakeColour = "rgba(102, 3, 10, 0.3)";
const stakeColour = "rgba(71, 23, 122, 0.3)"; const stakeColour = "rgba(71, 23, 122, 0.3)";
const claimColour = "rgba(77, 91, 42, 0.3)"; const claimColour = "rgba(77, 91, 42, 0.3)";
const thresholdStaking = 0.001;
const thresholdFees = 0.00009;
const EventButton = (obj) => { const EventButton = (obj) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
// Data shared among all events in this transaction // Data shared among all events in this transaction
@ -44,8 +47,8 @@ const EventButton = (obj) => {
transactionCaller = eventObj.data.delegator.toLowerCase(); transactionCaller = eventObj.data.delegator.toLowerCase();
transactionFrom = eventObj.data.oldDelegate.toLowerCase(); transactionFrom = eventObj.data.oldDelegate.toLowerCase();
transactionTo = eventObj.data.newDelegate.toLowerCase(); transactionTo = eventObj.data.newDelegate.toLowerCase();
transactionAmount = parseFloat(eventObj.data.bondedAmount); transactionAmount = parseFloat(eventObj.data.bondedAmount) / 1000000000000000000;
transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount); transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount) / 1000000000000000000;
hasBondTransaction = true; hasBondTransaction = true;
} }
// Unbond: defines transactionWhen. Defines transactionAmount as X / 1000000000000000000 LPT // Unbond: defines transactionWhen. Defines transactionAmount as X / 1000000000000000000 LPT
@ -72,15 +75,15 @@ const EventButton = (obj) => {
if (eventObj.name === "Rebond") { if (eventObj.name === "Rebond") {
// transactionCaller might get overwritten by TranserBond, but might as well set them // transactionCaller might get overwritten by TranserBond, but might as well set them
if (isOnlyBondRelated) { if (isOnlyBondRelated) {
transactionCaller = eventObj.data.delegate.toLowerCase(); transactionTo = eventObj.data.delegate.toLowerCase();
transactionFrom = eventObj.data.delegator.toLowerCase(); transactionCaller = eventObj.data.delegator.toLowerCase();
transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000; transactionAmount = parseFloat(eventObj.data.amount) / 1000000000000000000;
} }
hasRebondTransaction = true; hasRebondTransaction = true;
} }
// TranscoderActivated: defines transactionName as a stake claim. Defines transactionWhen // TranscoderActivated: defines transactionName as a stake claim. Defines transactionWhen
if (eventObj.name === "EarningsClaimed" && !hasActivation) { if (eventObj.name === "EarningsClaimed" && !hasActivation && !hasBondTransaction) {
transactionName = "Claim"; transactionName = "Claim";
transactionWhen = eventObj.data.endRound; transactionWhen = eventObj.data.endRound;
transactionFrom = eventObj.data.delegate; 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 we only had a bond transaction and nothing else, this is a stake
if (isOnlyBondRelated) {
if (hasBondTransaction) { if (hasBondTransaction) {
transactionName = "Stake"; transactionName = "Stake";
thisColour = stakeColour; thisColour = stakeColour;
} else if (hasRebondTransaction) {
console.log("Filtering out lone Rebond");
return null;
} }
// Lone Rebond, treat as new stake
if (hasRebondTransaction && transactionName == "") {
transactionName = "Rebond";
thisColour = stakeColour;
} }
// Check name filter on transactionCaller, transactionFrom, transactionTo // Check name filter on transactionCaller, transactionFrom, transactionTo
@ -184,6 +188,12 @@ const EventButton = (obj) => {
} }
count++; count++;
} }
if (obj.stakeActivated) {
if (transactionName === "Rebond") {
isFiltered = false;
}
count++;
}
if (obj.delegatorRewardActivated) { if (obj.delegatorRewardActivated) {
if (transactionName === "Claim") { if (transactionName === "Claim") {
isFiltered = false; isFiltered = false;
@ -213,13 +223,13 @@ const EventButton = (obj) => {
return null; return null;
} }
let claimString = "claimed "; let claimString = "claimed ";
if (transactionAmount > 0.001){ if (transactionAmount > thresholdStaking) {
claimString += transactionAmount.toFixed(2) + " LPT staking rewards"; claimString += transactionAmount.toFixed(2) + " LPT staking rewards";
if (transactionAdditionalAmount > 0.00009){ if (transactionAdditionalAmount > thresholdFees) {
claimString += " and " claimString += " and "
} }
} }
if (transactionAdditionalAmount > 0.00009){ if (transactionAdditionalAmount > thresholdFees) {
claimString += transactionAdditionalAmount.toFixed(4) + " Eth fee rewards"; claimString += transactionAdditionalAmount.toFixed(4) + " Eth fee rewards";
} }
eventSpecificInfo = eventSpecificInfo =
@ -236,18 +246,24 @@ const EventButton = (obj) => {
if (transactionFrom == "0x0000000000000000000000000000000000000000") { if (transactionFrom == "0x0000000000000000000000000000000000000000") {
eventSpecificInfo = eventSpecificInfo =
<div className="rowAlignLeft"> <div className="rowAlignLeft">
<p> staked {(transactionAmount / 1000000000000000000).toFixed(2)} LPT to </p> <p> staked {transactionAmount.toFixed(2)} LPT to </p>
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button> <button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button>
</div> </div>
} else { } else {
eventSpecificInfo = eventSpecificInfo =
<div className="rowAlignLeft"> <div className="rowAlignLeft">
<p> moved {(transactionAmount / 1000000000000000000).toFixed(2)} LPT stake: </p> <p> moved {transactionAmount.toFixed(2)} LPT stake: </p>
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionFrom)) }} >{transactionFrom}</button> <button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionFrom)) }} >{transactionFrom}</button>
<p> to </p> <p> to </p>
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button> <button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button>
</div> </div>
} }
} else if (transactionName === "Rebond") {
eventSpecificInfo =
<div className="rowAlignLeft">
<p> increased their stake with {transactionAmount.toFixed(2)} LPT at </p>
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button>
</div>
} else if (transactionName === "Withdraw") { } else if (transactionName === "Withdraw") {
eventSpecificInfo = eventSpecificInfo =
<div className="rowAlignLeft"> <div className="rowAlignLeft">
@ -257,7 +273,7 @@ const EventButton = (obj) => {
if (hasBondTransaction) { if (hasBondTransaction) {
eventSpecificInfo = eventSpecificInfo =
<div className="rowAlignLeft"> <div className="rowAlignLeft">
<p>activated with a self stake of {(transactionAmount / 1000000000000000000).toFixed(2)} LPT and will become active in round {transactionWhen}</p> <p>activated with a self stake of {transactionAmount.toFixed(2)} LPT and will become active in round {transactionWhen}</p>
</div> </div>
} else { } else {
// If there was no bond transaction, display fewer information // If there was no bond transaction, display fewer information
@ -267,10 +283,9 @@ const EventButton = (obj) => {
</div> </div>
} }
} else { } else {
console.log("UNIMPLEMENTED " + thisURL);
console.log(thisData); console.log(thisData);
eventSpecificInfo = <div className="row"> return null;
<p>UNIMPLEMENTED</p>
</div>
} }
// IF ON MOBILE // IF ON MOBILE