diff --git a/src/eventButton.js b/src/eventButton.js index ce08b72..be55db2 100644 --- a/src/eventButton.js +++ b/src/eventButton.js @@ -1,59 +1,144 @@ import React from "react"; +const activationColour = "rgba(23, 60, 122, 0.3)"; +const rewardColour = "rgba(20, 99, 29, 0.3)"; +const updateColour = "rgba(122, 63, 23, 0.3)"; +const withdrawStakeColour = "rgba(102, 3, 10, 0.3)"; +const stakeColour = "rgba(71, 23, 122, 0.3)"; + const EventButton = (obj) => { + // Data shared among all events in this transaction + const thisURL = obj.transactionUrl; + const thisTransaction = obj.transactionHash; + const thisData = obj.events; + const thisIndex = obj.idx; + // Abstraction of all events in this transaction + let transactionName = ""; + let transactionCaller = ""; + let transactionFrom = ""; + let transactionTo = ""; + let transactionAmount = 0; + let transactionAdditionalAmount = 0; + let transactionWhen = 0; + let hasBondTransaction = false; + let isOnlyBond = true; + let thisColour = ""; + + + // Which we will fill in by going over all of the events once + thisData.map(eventObj => { + // Bond: contains amount the transaction is about and who is participating + if (eventObj.name == "Bond") { + transactionCaller = eventObj.data.delegator; + transactionFrom = eventObj.data.oldDelegate; + transactionTo = eventObj.data.newDelegate; + transactionAmount = parseFloat(eventObj.data.bondedAmount); + transactionAdditionalAmount = parseFloat(eventObj.data.additionalAmount); + hasBondTransaction = true; + } + // TranscoderActivated: defines transactionName. Defines transactionAmount as X * 7e-18 LPT + if (eventObj.name == "TranscoderActivated") { + transactionName = "Activated"; + transactionWhen = eventObj.data.activationRound; + if (!hasBondTransaction) { + transactionCaller = eventObj.data.transcoder; + } + thisColour = activationColour; + isOnlyBond = false; + } + // TranscoderActivated: defines transactionName. Defines transactionAmount as X / 1000000000000000000 LPT + if (eventObj.name == "Reward") { + transactionName = "Reward"; + transactionCaller = eventObj.data.transcoder; + transactionAmount = eventObj.data.amount / 1000000000000000000; + thisColour = rewardColour; + isOnlyBond = false; + } + // TranscoderUpdate: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut + if (eventObj.name == "TranscoderUpdate") { + transactionName = "Update"; + transactionCaller = eventObj.data.transcoder; + transactionAmount = eventObj.data.rewardCut / 10000; + transactionAdditionalAmount = 100 - (eventObj.data.feeShare / 10000); + thisColour = updateColour; + isOnlyBond = false; + } + // WithdrawStake: defines transactionName. Defines transactionAmount as rewardCut and transactionAdditionalAmount as feeCut + if (eventObj.name == "WithdrawStake") { + transactionName = "Withdraw"; + transactionCaller = eventObj.data.delegator; + transactionAmount = eventObj.data.amount / 1000000000000000000; + transactionWhen = eventObj.data.withdrawRound; + thisColour = withdrawStakeColour; + isOnlyBond = false; + } + }) + + // If we only had a bond transaction and nothing else, this is a stake + if (hasBondTransaction && isOnlyBond){ + transactionName = "Stake"; + thisColour = stakeColour; + } + let eventSpecificInfo; - if (obj.name == "EarningsClaimed") { - eventSpecificInfo =
(Round {obj.data.endRound}) Claim: {obj.data.delegator} earned {(obj.data.rewards / 1000000000000000000).toFixed(4)} Eth @ Orchestrator {obj.data.delegate}
-(Round {obj.data.withdrawRound}) Unbond: {obj.data.delegator} unbonded {(obj.data.amount / 1000000000000000000).toFixed(4)} Eth @ Orchestrator {obj.data.delegate}
-TransferBond: transfered bond worth {(obj.data.amount / 1000000000000000000).toFixed(4)} Eth from {obj.data.oldDelegator} to {obj.data.newDelegator}
-{obj.data.delegator} delegated {(obj.data.bondedAmount / 1000000000000000000).toFixed(4)} LPT from {obj.data.oldDelegate} to {obj.data.newDelegate}
-Rebond: {obj.data.delegator} @ {obj.data.delegate}
-{obj.data.recipient} claimed stake
-{obj.data.delegator} withdrew stake worth {(obj.data.amount / 1000000000000000000).toFixed(4)} LPT in round {obj.data.withdrawRound}
-O {obj.data.transcoder} called reward for {(obj.data.amount / 1000000000000000000).toFixed(4)} LPT
-O {obj.data.transcoder} changed their rewardCut to {(obj.data.rewardCut / 10000).toFixed(2)}% and their feeCut to {(100 - (obj.data.feeShare / 10000)).toFixed(2)}%
-O {obj.data.transcoder} activated and will become active in {obj.data.activationRound}
-called reward worth {transactionAmount.toFixed(2)} LPT. nice
+called reward worth {transactionAmount.toFixed(2)} LPT
+changed their reward commission to {transactionAmount.toFixed(2)}% and their fee commission to {transactionAdditionalAmount.toFixed(2)}%
+changed stake from {transactionFrom} to {transactionTo} of {(transactionAmount * 7e-18).toFixed(2)} LPT
+withdrew {(transactionAmount * 7e-18).toFixed(2)} LPT in round {transactionWhen}
+{transactionCaller} activated with a self stake of {(transactionAmount * 7e-18).toFixed(2)} LPT and will become active in round {transactionWhen}
+reactivated and will become active in round {transactionWhen}
+UNIMPLEMENTED: {obj.event}
+UNIMPLEMENTED
{transactionCaller}
+ + {eventSpecificInfo} +