Example #1
0
 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
     }
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
    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)
Example #5
0
 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)
Example #6
0
 def decode_parameters(self, data, annotations=True, literals=True):
     return decode_data(data=data,
                        schema=self._get_schema('parameter'),
                        annotations=annotations,
                        literals=literals)