Skip to content

Commit 492cd0e

Browse files
committed
INital framework with jason
1 parent 5d7041e commit 492cd0e

File tree

6 files changed

+22
-23
lines changed

6 files changed

+22
-23
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"codegen": "graph codegen",
66
"build": "graph build",
77
"deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ avolabs-io/async_art_v2",
8-
"create-local": "graph create --node http://localhost:8020/ avolabs-io/async-subgraph_v2",
9-
"remove-local": "graph remove --node http://localhost:8020/ avolabs-io/async-subgraph_v2",
10-
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 avolabs-io/async-subgraph_v2"
8+
"create-local": "graph create --node http://127.0.0.1:8020/ avolabs-io/async-subgraph_v2",
9+
"remove-local": "graph remove --node http://127.0.0.1:8020/ avolabs-io/async-subgraph_v2",
10+
"deploy-local": "graph deploy --node http://127.0.0.1:8020/ --ipfs http://127.0.0.1:5001 avolabs-io/async-subgraph_v2"
1111
},
1212
"dependencies": {
1313
"@graphprotocol/graph-cli": "0.17.1",

schema.graphql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
type ExampleEntity @entity {
22
id: ID!
3-
count: BigInt!
4-
owner: Bytes! # address
5-
approved: Bytes! # address
3+
blockNumber: BigInt!
64
}
75

86
type EventParam @entity {

src/mapping.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigInt } from "@graphprotocol/graph-ts"
1+
import { BigInt } from "@graphprotocol/graph-ts";
22
import {
33
Contract,
44
Approval,
@@ -13,23 +13,18 @@ import {
1313
PlatformAddressUpdated,
1414
PlatformSalePercentageUpdated,
1515
TokenSale,
16-
Transfer
17-
} from "../generated/Contract/Contract"
18-
import { ExampleEntity } from "../generated/schema"
19-
import {
20-
saveEventToStateChange,
21-
} from "./util";
16+
Transfer,
17+
} from "../generated/Contract/Contract";
18+
import { ExampleEntity } from "../generated/schema";
19+
import { saveEventToStateChange } from "./util";
2220

2321
export function handleApproval(event: Approval): void {
24-
2522
let owner = event.params.owner;
2623
let ownerString = owner.toHex();
2724
let txTimestamp = event.block.timestamp;
2825
let blockNumber = event.block.number;
2926

30-
let eventParamValues: Array<string> = [
31-
ownerString,
32-
];
27+
let eventParamValues: Array<string> = [ownerString];
3328
let eventParamNames: Array<string> = ["owner"];
3429
let eventParamTypes: Array<string> = ["address"];
3530

@@ -61,7 +56,13 @@ export function handleBuyPriceSet(event: BuyPriceSet): void {}
6156

6257
export function handleControlLeverUpdated(event: ControlLeverUpdated): void {}
6358

64-
export function handleCreatorWhitelisted(event: CreatorWhitelisted): void {}
59+
export function handleCreatorWhitelisted(event: CreatorWhitelisted): void {
60+
let txTimestamp = event.block.timestamp;
61+
let blockNumber = event.block.number;
62+
let user = new ExampleEntity(txTimestamp.toString());
63+
user.blockNumber = blockNumber;
64+
user.save();
65+
}
6566

6667
export function handlePermissionUpdated(event: PermissionUpdated): void {}
6768

start-graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function start {
8585
echo "ERROR: Could not deploy contracts successfully"
8686
# killAndExit
8787
fi
88-
cd ../graph
88+
cd ..
8989

9090
sleep 5 ## Sometimes it takes a bit longer for the graph to be ready.
9191
graphCreate

subgraph.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ schema:
44
dataSources:
55
- kind: ethereum/contract
66
name: Contract
7-
network: mainnet
7+
network: ganache
88
source:
9-
address: "0xb6dAe651468E9593E4581705a09c10A76AC1e0c8"
9+
address: "0x5Db1Dd1980E17050B38413B0561d95CF781CB8C5"
1010
abi: Contract
11-
startBlock: 8752679
11+
startBlock: 0
1212
mapping:
1313
kind: ethereum/events
1414
apiVersion: 0.0.3

0 commit comments

Comments
 (0)