feat: add gas used and transactions fee#1
Open
alexandre-abrioux wants to merge 14 commits intocartesi:mainfrom
Open
feat: add gas used and transactions fee#1alexandre-abrioux wants to merge 14 commits intocartesi:mainfrom
alexandre-abrioux wants to merge 14 commits intocartesi:mainfrom
Conversation
|
|
||
| // create a user with 500 maturing | ||
| let user = new User(address) | ||
| let user = loadOrCreate(Address.fromString(address)) |
Author
There was a problem hiding this comment.
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 No newline at end of file | |||
Author
There was a problem hiding this comment.
This is a symlink to .gitignore
|
|
||
| export function handleRewarded(event: Rewarded): void { | ||
| let reward = event.params.userReward.plus(event.params.beneficiaryReward) | ||
|
|
Author
There was a problem hiding this comment.
Refacto: similar code from block.ts and block-1.0.ts have been moved to block-common.ts
Comment on lines
+70
to
+72
| user.totalTransactionFee = user.totalTransactionFee.plus( | ||
| block.transactionFee | ||
| ) |
Author
There was a problem hiding this comment.
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) |
Author
There was a problem hiding this comment.
In this big code block that was moved, this line was also added
| handler: handleNewChain | ||
| - event: "Rewarded(indexed uint256,indexed address,indexed address,uint256)" | ||
| handler: handleRewarded | ||
| receipt: true |
Author
There was a problem hiding this comment.
This is how we ask the Graph Node to fetch the receipt and pass it down to the Subgraph event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds new properties to the following entities:
gasUsedandtransactionFeetoBlock, withtransactionFee = gasUsed x gasPricetotalTransactionFeetoUsertotalTransactionFeetoSummaryThis change was made possible thanks to graphprotocol/graph-node#3218 and the new
TransactionReceiptthat 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.