forked from AcalaNetwork/chopsticks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* try runtime * fixed review comments * testing * require wasm
- Loading branch information
1 parent
fc5a7e9
commit b1ca9cd
Showing
2 changed files
with
59 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
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,37 @@ | ||
import { writeFileSync } from 'node:fs' | ||
|
||
import { Config } from './schema' | ||
import { generateHtmlDiffPreviewFile } from './utils/generate-html-diff' | ||
import { openHtml } from './utils/open-html' | ||
import { setup } from './setup' | ||
|
||
export const tryRuntime = async (argv: Config) => { | ||
if (argv['wasm-override'] === undefined) throw Error('`wasm-override` with `try-runtime` feature must be defined') | ||
const context = await setup(argv) | ||
const block = context.chain.head | ||
const registry = await block.registry | ||
registry.register({ | ||
UpgradeCheckSelect: { | ||
_enum: { | ||
None: null, | ||
}, | ||
}, | ||
}) | ||
|
||
const select_none = registry.createType('UpgradeCheckSelect', 'None') | ||
const result = await block.call('TryRuntime_on_runtime_upgrade', [select_none.toHex()], []) | ||
|
||
if (argv['html']) { | ||
const filePath = await generateHtmlDiffPreviewFile(block, result.storageDiff, block.hash) | ||
console.log(`Generated preview ${filePath}`) | ||
if (argv['open']) { | ||
openHtml(filePath) | ||
} | ||
} else if (argv['output-path']) { | ||
writeFileSync(argv['output-path'], JSON.stringify(result, null, 2)) | ||
} else { | ||
console.dir(result, { depth: null, colors: false }) | ||
} | ||
|
||
process.exit(0) | ||
} |