Convert JAM-related types between different formats.
@typeberry/convert [options] <bin-hex-or-json-input-file> <type> [process] [output-format]
Attempts to read provided input file as 'type' and output in requested 'output-format'.
For some 'type's it's additionally possible to process the data before outputting it.
The input type is detected from file extension (.bin, .hex or .json).
--flavor - Chain spec flavor, either full or tiny (default: tiny)to-print - Print the object to the console (default)to-json - JSON format (when supported)to-hex - JAM-codec hex-encoded string (when supported)to-repl - Start a JavaScript REPL with the data loaded into a variableblockheaderwork-reportwork-packagework-itemspitest-vector-pvmstate-dumpstate-transition-vectorSome input types support additional processing before output:
as-root-hash, as-entries, as-truncated-entriesas-pre-state, as-post-state# Convert header from JSON to hex
@typeberry/convert ./genesis-header.json header to-hex
# Convert state dump and process it to entries, output as JSON
@typeberry/convert ./state-snapshot.json state-dump as-entries to-json
# Start a REPL with header data loaded
@typeberry/convert ./genesis-header.json header to-repl
# Convert with specific chain spec flavor
@typeberry/convert --flavor=full ./genesis-header.json header to-json
# Process state dump to root hash and print (default output)
@typeberry/convert ./state-dump.json state-dump as-root-hash
When using to-repl, the tool starts an interactive JavaScript REPL with:
data variableinspect(obj) - Pretty-print objectstoJson(obj) - Dump the object into JSONtype - Shows the data type name.help, .exit, etc.)Example REPL session:
header> data.timeSlotIndex
42
header> Object.keys(data)
['parentHeaderHash', 'priorStateRoot', 'extrinsicHash', ...]
header> inspect(data)
Header { ... }
header> .exit