-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "constructor" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ | ||
"indexed": false, | ||
"internalType": "uint16", | ||
"name": "x", | ||
"type": "uint16" | ||
} | ||
], | ||
"name": "Trigger", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "uint16", | ||
"name": "x", | ||
"type": "uint16" | ||
} | ||
], | ||
"name": "emitTrigger", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "load-save", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"build-contracts": "../../common/build-contracts.sh", | ||
"codegen": "graph codegen --skip-migrations", | ||
"test": "yarn build-contracts && truffle test --compile-none --network test", | ||
"create:test": "graph create test/load-save --node $GRAPH_NODE_ADMIN_URI", | ||
"deploy:test": "graph deploy test/load-save --version-label v0.0.1 --ipfs $IPFS_URI --node $GRAPH_NODE_ADMIN_URI" | ||
}, | ||
"devDependencies": { | ||
"@graphprotocol/graph-cli": "0.69.0", | ||
"@graphprotocol/graph-ts": "0.34.0", | ||
"solc": "^0.8.2" | ||
}, | ||
"dependencies": { | ||
"@truffle/contract": "^4.3", | ||
"@truffle/hdwallet-provider": "^1.2", | ||
"apollo-fetch": "^0.7.0", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-register": "^6.26.0", | ||
"gluegun": "^4.6.1", | ||
"truffle": "^5.2" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type LSData @entity { | ||
id: ID! | ||
data: String! | ||
blockNumber: BigInt! | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BigInt, ethereum } from '@graphprotocol/graph-ts' | ||
import { LSData } from '../generated/schema' | ||
|
||
export function handleBlock(block: ethereum.Block): void { | ||
let diff = 1 | ||
let entity = new LSData(block.number.toString()) | ||
entity.data = 'original entity' | ||
entity.blockNumber = block.number | ||
entity.save() | ||
let block_number = block.number | ||
if (block_number.gt(BigInt.fromI32(diff))) { | ||
let bn = block_number.minus(BigInt.fromI32(diff)).toString() | ||
let entity2 = LSData.load(bn)! | ||
entity2.data = 'modified entity' | ||
entity2.save() | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
specVersion: 1.2.0 | ||
description: Source Subgraph A | ||
repository: https://github.com/graphprotocol/graph-node | ||
schema: | ||
file: ./schema.graphql | ||
dataSources: | ||
- kind: ethereum/contract | ||
name: SimpleContract | ||
network: test | ||
source: | ||
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3" | ||
abi: SimpleContract | ||
startBlock: 0 | ||
mapping: | ||
kind: ethereum/events | ||
apiVersion: 0.0.6 | ||
language: wasm/assemblyscript | ||
entities: | ||
- LSData | ||
abis: | ||
- name: SimpleContract | ||
file: ./abis/Contract.abi | ||
blockHandlers: | ||
- handler: handleBlock | ||
file: ./src/mapping.ts |
This file contains 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