scilla-data-parser
v0.1.1
Published
Scilla data types can be very verbose, making it hard for developers to use the state directly. The parser will help developers can make references and manipulation to state more easily.
Downloads
144
Readme
Install
npm install --save scilla-data-parser
Usage
const ScillaDataParser = require('scilla-data-parser').ScillaDataParser
var scillaJson = JSON.parse(`
{
"vname": "map2",
"type": "Map (String) (Pair (String) (Uint32))",
"value": [
{
"key": "m",
"val": {
"constructor": "Pair",
"argtypes": [ "String", "Uint32" ],
"arguments": [ "k", "1" ]
}
}
]
}
`);
var simpleJson = ScillaDataParser.convertToSimpleJson(scillaJson, false);
//{ map2: { m: { x: 'k', y: 1 } } }
var straightJson = ScillaDataParser.convertToSimpleJson(scillaJson, true);
//{ vname: 'map2',
// type: 'Map (String) (Pair (String) (Uint32))',
// value: { m: { x: 'k', y: 1 } } }
var revertScillaJson = ScillaDataParser.convertToScillaData(straightJson);
//Same as scillaJson