Skip to content
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

POAP subgraph updated for The Graph Network #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ subgraph.yaml
.idea/

build
generated
generated
.git
.gitignore
.vscode
2 changes: 1 addition & 1 deletion config/xdai.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"network": "xdai",
"network": "gnosis",
"address": "0x22C1f6050E56d2876009903609a2cC3fEf83B415",
"startBlock": 12188423,
"file": "XPoap",
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
"deploy:xdai": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ poap-xyz/poap-xdai",
"deploy:chiado": "goldsky subgraph deploy poap-xyz/poap-chiado",
"deploy:goerli": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ poap-xyz/poap-goerli",
"deploy:studio:mainnet": "graph deploy --studio poap-ethereum-mainnet",
"deploy:studio:gnosis": "graph deploy --studio poap-gnosis-chain",


"create-local": "graph create --node http://localhost:8020/ poap-xyz/poap",
"remove-local": "graph remove --node http://localhost:8020/ poap-xyz/poap",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 poap-xyz/poap"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.18.0",
"@graphprotocol/graph-ts": "0.18.0"
"@graphprotocol/graph-cli": "0.51.0",
"@graphprotocol/graph-ts": "0.31.0"
},
"devDependencies": {
"mustache": "^4.0.1"
Expand Down
29 changes: 17 additions & 12 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function handleEventToken(ev: EventTokenEvent): void
{
let event = Event.load(ev.params.eventId.toString());
// This handler always run after the transfer handler
let token = Token.load(ev.params.tokenId.toString());
let token = Token.load(ev.params.tokenId.toString())!;
if (event == null) {
event = new Event(ev.params.eventId.toString());
event.tokenCount = BigInt.fromI32(0);
Expand All @@ -39,7 +39,7 @@ export function handleEventToken(ev: EventTokenEvent): void
event.tokenMints += BigInt.fromI32(1);
event.transferCount += BigInt.fromI32(1);
token.event = event.id;
token.mintOrder = event.tokenMints;
token.mintOrder = event.tokenMints;
event.save();
token.save();
}
Expand Down Expand Up @@ -78,21 +78,26 @@ export function handleTransfer(ev: TransferEvent): void {
token.transferCount += BigInt.fromI32(1);
token.save();

let event = Event.load(token.event);

if(event != null) {
// Add one transfer
event.transferCount += BigInt.fromI32(1);
if (token.event != null) {
let event = Event.load(token.event as string);

// Burning the token
if(to.id == ZERO_ADDRESS) {
event.tokenCount -= BigInt.fromI32(1);
// Subtract all the transfers from the burned token
event.transferCount -= token.transferCount;
if(event != null) {
// Add one transfer
event.transferCount += BigInt.fromI32(1);

// Burning the token
if(to.id == ZERO_ADDRESS) {
event.tokenCount -= BigInt.fromI32(1);
// Subtract all the transfers from the burned token
event.transferCount -= token.transferCount;
}
event.save();
}
event.save();
}



transfer.token = token.id;
transfer.from = from.id;
transfer.to = to.id;
Expand Down
4 changes: 2 additions & 2 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dataSources:
startBlock: {{ startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.4
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- EventToken
Expand All @@ -26,4 +26,4 @@ dataSources:
handler: handleEventToken
- event: Transfer(indexed address,indexed address,indexed uint256)
handler: handleTransfer
file: ./src/mapping.ts
file: ./src/mapping.ts
Loading