-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show how many tokens a user has delegated #82
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ export function handleDelegateVotesChanged( | |
let entity = new DelegateVotesChanged( | ||
event.transaction.hash.concatI32(event.logIndex.toI32()) | ||
) | ||
entity.delegator = event.transaction.from | ||
entity.delegate = event.params.delegate | ||
entity.previousBalance = wadToDecimal(event.params.previousBalance) | ||
entity.newBalance = wadToDecimal(event.params.newBalance) | ||
|
@@ -62,10 +63,14 @@ export function handleDelegateVotesChanged( | |
entity.blockTimestamp = event.block.timestamp | ||
entity.transactionHash = event.transaction.hash | ||
|
||
const delegator = loadOrCreateAccount(entity.delegator) | ||
delegator.tokensDelegatedFrom = entity.newBalance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be new - prev? Current approach would reflect the total amount including others There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no "others"; a user can only delegate their current balance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was under the impression that |
||
|
||
const delegateId = addressToBytes(event.params.delegate) | ||
const delegate = loadOrCreateAccount(delegateId) | ||
delegate.tokensDelegated = delegate.tokensDelegated.plus(changeInBalance) | ||
delegate.tokensDelegatedTo = delegate.tokensDelegatedTo.plus(changeInBalance) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this value just be equivalent to newBalance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I just renamed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, but was just suggesting that we could simplify the logic by setting to just |
||
|
||
delegator.save() | ||
delegate.save() | ||
entity.save() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I got this line wrong; delegator should be
event.transaction.to
.