watcher-ts/packages/test/src/get-storage-at.ts
prathamesh0 e30af92901
Add a CLI in eden-watcher to fill state for a given range (#176)
* Add a CLI to fill state for a given range

* Refactor code

* Add a CLI to reset IPLD state

* Replace ORDER BY clause in the query to get latest IPLD block

* Optimize delete query in CLI to reset IPLD state

* Add an option to decouple subgraph state creation from mapping code

* Use a raw SQL query to delete IPLD blocks in a block range

* Accomodate changes in codegen
2022-09-09 16:23:41 +05:30

52 lines
1.1 KiB
TypeScript

//
// Copyright 2022 Vulcanize, Inc.
//
import yargs from 'yargs';
import { providers } from 'ethers';
import debug from 'debug';
const log = debug('vulcanize:test');
const main = async (): Promise<void> => {
const argv = await yargs.parserConfiguration({
'parse-numbers': false
}).options({
endpoint: {
alias: 'e',
demandOption: true,
describe: 'Endpoint to perform getStorageAt against',
type: 'string'
},
contract: {
alias: 'c',
demandOption: true,
describe: 'Contract address',
type: 'string'
},
slot: {
alias: 's',
demandOption: true,
describe: 'Storge slot',
type: 'string'
},
blockTag: {
alias: 'b',
describe: 'Block tag to make eth-call with (block number (hex) / block hash)',
type: 'string'
},
}).argv;
const provider = new providers.JsonRpcProvider(argv.endpoint);
log(`Making a getStorageAt call for slot ${argv.slot} to endpoint ${argv.endpoint}`);
const result = await provider.getStorageAt(argv.contract, argv.slot, argv.blockTag);
log("Result:");
log(result);
}
main().catch(err => {
log(err);
});