def big_map_diff_decode(self, data): schema, key_path, val_path = self._get_big_map_schema() return { decode_data(item['key'], schema, root=key_path): decode_data(item['value'], schema, root=val_path) for item in data }
def test_parameter_parsing(self, code_name, parameters_name): code = json.loads(get_data(code_name)) parameters = json.loads(get_data(parameters_name)) schema = build_schema(code) data = decode_data(parameters, schema) res = encode_data(data, schema) self.assertDictEqual(parameters, res)
def test_storage_parsing(self, source_name): script = json.loads(get_data(source_name)) storage = next(s for s in script['code'] if s['prim'] == 'storage') schema = build_schema(storage) data = decode_data(script['storage'], schema) res = encode_data(data, schema) self.assertDictEqual(script['storage'], res)
def decode_storage(self, data=None, annotations=True, literals=True): if data is None: data = self.get('script')['storage'] return decode_data(data=data, schema=self._get_schema('storage'), annotations=annotations, literals=literals)
def big_map_get(self, key): schema, key_path, val_path = self._get_big_map_schema() query = dict(key=encode_data(key, schema, root=key_path), type=schema.type_map[key_path]) value = self._node.post(f'{self._path}/big_map_get', json=query) return decode_data(value, schema, root=val_path)
def decode_parameters(self, data, annotations=True, literals=True): return decode_data(data=data, schema=self._get_schema('parameter'), annotations=annotations, literals=literals)