-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add gas used and transactions fee #1
base: main
Are you sure you want to change the base?
Conversation
}) | ||
|
||
test("stake(1000) while maturing", () => { | ||
let address = "0x0000000000000000000000000000000000000000" | ||
|
||
// create a user with 500 maturing | ||
let user = new User(address) | ||
let user = loadOrCreate(Address.fromString(address)) |
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.
Since graphprotocol/graph-tooling@629176c the code generation of graph-cli does not assign default values for entities, so we need to initialize ourselves all properties.
@@ -0,0 +1 @@ | |||
.gitignore |
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.
This is a symlink to .gitignore
|
||
export function handleRewarded(event: Rewarded): void { | ||
let reward = event.params.userReward.plus(event.params.beneficiaryReward) | ||
|
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.
Refacto: similar code from block.ts
and block-1.0.ts
have been moved to block-common.ts
user.totalTransactionFee = user.totalTransactionFee.plus( | ||
block.transactionFee | ||
) |
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.
In this big code block that was moved, those 3 lines were added
let s = summary.loadOrCreate() | ||
s.totalBlocks++ | ||
s.totalReward = s.totalReward.plus(reward) | ||
s.totalTransactionFee = s.totalTransactionFee.plus(block.transactionFee) |
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.
In this big code block that was moved, this line was also added
@@ -90,6 +90,7 @@ dataSources: | |||
handler: handleNewChain | |||
- event: "Rewarded(indexed uint256,indexed address,indexed address,uint256)" | |||
handler: handleRewarded | |||
receipt: true |
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.
This is how we ask the Graph Node to fetch the receipt and pass it down to the Subgraph event
This PR adds new properties to the following entities:
gasUsed
andtransactionFee
toBlock
, withtransactionFee = gasUsed x gasPrice
totalTransactionFee
toUser
totalTransactionFee
toSummary
This change was made possible thanks to graphprotocol/graph-node#3218 and the new
TransactionReceipt
that is now available in the AssemblyScript API version 0.0.7: https://thegraph.com/docs/en/developer/assemblyscript-api/#versionsMics
A Dockerfile was added for convenience to test the subgraph without the need to download matchstick binary. It is based on the one found in the documentation.