diff --git a/README.md b/README.md index 9736a673..d58ac6dc 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Make sure you have setup Rust environment (>= 1.64). - `yarn start run-block --endpoint=wss://acala-rpc-2.aca-api.network/ws` - This will replay the last block and print out the changed storages + - Use option `--output-path=` to print out JSON file - Run a test node - `yarn start dev --endpoint=wss://acala-rpc-2.aca-api.network/ws` diff --git a/src/index.ts b/src/index.ts index a73fb345..eb40baef 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { TaskManager } from './task' import { createServer } from './server' import { defaultLogger } from './logger' import { handler } from './rpc' +import { writeFileSync } from 'fs' const setup = async (argv: any) => { const port = argv.port || process.env.PORT || 8000 @@ -67,7 +68,13 @@ const runBlock = async (argv: any) => { wasm, calls, }, - console.log + (output) => { + if (argv['output-path']) { + writeFileSync(argv['output-path'], JSON.stringify(output, null, 2)) + } else { + console.dir(output, { depth: null, colors: false }) + } + } ) setTimeout(() => process.exit(0), 50) @@ -96,6 +103,10 @@ yargs(hideBin(process.argv)) desc: 'Command to execute the executor', string: true, }, + 'output-path': { + desc: 'File path to print output', + string: true, + }, }), (argv) => { runBlock(argv).catch((err) => {