Add demo for graph-watcher IPLD statediff and checkpointing

This commit is contained in:
2022-05-06 15:43:45 +05:30
committed by Ashwin Phatak
parent ba6b996e65
commit ce6568aad2
9 changed files with 343 additions and 64 deletions
+1
View File
@@ -5,6 +5,7 @@
import '@nomiclabs/hardhat-waffle';
import './test/tasks/example-deploy';
import './test/tasks/example-test';
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
+2 -1
View File
@@ -42,7 +42,8 @@
"build:example": "cd test/subgraph/example1 && yarn && yarn codegen && yarn build",
"watch": "DEBUG=vulcanize:* nodemon --watch src src/watcher.ts",
"compare-entity": "node bin/compare-entity",
"example:deploy": "hardhat --network localhost example-deploy"
"example:deploy": "hardhat --network localhost example-deploy",
"example:test": "hardhat --network localhost example-test"
},
"dependencies": {
"@apollo/client": "^3.3.19",
@@ -0,0 +1,31 @@
//
// Copyright 2022 Vulcanize, Inc.
//
import { task, types } from 'hardhat/config';
import '@nomiclabs/hardhat-ethers';
import { ContractTransaction } from 'ethers';
task('example-test', 'Trigger Test event')
.addParam('address', 'Contract address', undefined, types.string)
.setAction(async (args, hre) => {
const { address } = args;
await hre.run('compile');
const Example = await hre.ethers.getContractFactory('Example');
const example = Example.attach(address);
const transaction: ContractTransaction = await example.emitEvent();
const receipt = await transaction.wait();
if (receipt.events) {
const TestEvent = receipt.events.find(el => el.event === 'Test');
if (TestEvent && TestEvent.args) {
console.log('Test Event');
console.log('param1:', TestEvent.args.param1.toString());
console.log('param2:', TestEvent.args.param2.toString());
console.log('param3:', TestEvent.args.param3.toString());
}
}
});