Skip to content

Commit

Permalink
Adds blockheight
Browse files Browse the repository at this point in the history
  • Loading branch information
seandotau committed Apr 26, 2023
1 parent 38564a1 commit f434a44
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions BNB Smart Chain/bsc-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ For the `subql-starter` project, you can try to query with the following code to

```graphql
query {
transfers(first: 5, orderBy: VALUE_DESC) {
transfers(first: 5, orderBy: BLOCK_HEIGHT_ASC) {
nodes {
id
value
to
blockHeight
from
to
value
contractAddress
}
}
Expand Down
3 changes: 3 additions & 0 deletions BNB Smart Chain/bsc-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
"@subql/types": "latest",
"ethers": "^5.7.2",
"typescript": "4.5.5"
},
"resolutions":{
"@polkadot/util": "11.1.3"
}
}
6 changes: 4 additions & 2 deletions BNB Smart Chain/bsc-starter/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

type Transfer @entity {
id: ID! # Transaction hash
value: BigInt!
blockHeight: String
to: String!
from: String!
value: BigInt!
contractAddress: String!
}

type Approval @entity {
id: ID! # Transaction hash
value: BigInt!
blockHeight: String
owner: String!
spender: String!
value: BigInt!
contractAddress: String!
}
4 changes: 3 additions & 1 deletion BNB Smart Chain/bsc-starter/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export async function handleLog(log: TransferLog): Promise<void> {
logger.info(`New transfer transaction log at block ${log.blockNumber}`);
const transfer = Transfer.create({
id: log.transactionHash,
value: log.args.value.toBigInt(),
blockHeight: log.blockNumber.toString(),
from: log.args.from,
to: log.args.to,
value: log.args.value.toBigInt(),
contractAddress: log.address,
});

Expand All @@ -21,6 +22,7 @@ export async function handleTransaction(tx: ApproveTransaction): Promise<void> {
logger.info(`New Approval transaction at block ${tx.blockNumber}`);
const approval = Approval.create({
id: tx.hash,
blockHeight: tx.blockNumber.toString(),
owner: tx.from,
spender: await tx.args[0],
value: BigInt(await tx.args[1].toString()),
Expand Down

0 comments on commit f434a44

Please sign in to comment.