mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2026-04-20 12:25:10 +02:00
Lots of debugging for EventButton parsing
This commit is contained in:
parent
30f7295c7c
commit
984af3c6d4
@ -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 =
|
||||
<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>
|
||||
</div>
|
||||
} else {
|
||||
eventSpecificInfo =
|
||||
<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>
|
||||
<p> to </p>
|
||||
<button className="selectOrch" onClick={() => { dispatch(getOrchestratorInfo(transactionTo)) }} >{transactionTo}</button>
|
||||
</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") {
|
||||
eventSpecificInfo =
|
||||
<div className="rowAlignLeft">
|
||||
@ -257,7 +273,7 @@ const EventButton = (obj) => {
|
||||
if (hasBondTransaction) {
|
||||
eventSpecificInfo =
|
||||
<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>
|
||||
} else {
|
||||
// If there was no bond transaction, display fewer information
|
||||
@ -267,10 +283,9 @@ const EventButton = (obj) => {
|
||||
</div>
|
||||
}
|
||||
} else {
|
||||
console.log("UNIMPLEMENTED " + thisURL);
|
||||
console.log(thisData);
|
||||
eventSpecificInfo = <div className="row">
|
||||
<p>UNIMPLEMENTED</p>
|
||||
</div>
|
||||
return null;
|
||||
}
|
||||
|
||||
// IF ON MOBILE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user