예제 #1
0
파일: big_map.py 프로젝트: multisme/pytezos
 def make_update(key: MichelsonType,
                 val: Optional[MichelsonType]) -> dict:
     update = {
         'key': key.to_micheline_value(mode=mode),
         'key_hash': forge_script_expr(key.pack(legacy=True))
     }
     if val is not None:
         update['value'] = val.to_micheline_value(mode=mode)
     return update
예제 #2
0
 def get(self, key: MichelsonType, dup=True) -> Optional[MichelsonType]:
     self.args[0].assert_type_equal(type(key))
     val = next((v for k, v in self if k == key),
                Undefined)  # search in diff
     if val is Undefined:
         assert self.context, f'context is not attached'
         key_hash = forge_script_expr(key.pack(legacy=True))
         val_expr = self.context.get_big_map_value(self.ptr, key_hash)
         if val_expr is None:
             return None
         else:
             return self.args[1].from_micheline_value(val_expr)
     else:
         return val
예제 #3
0
파일: big_map.py 프로젝트: multisme/pytezos
 def get_key_hash(self, key_obj):
     key = self.args[0].from_python_object(key_obj)
     return forge_script_expr(key.pack(legacy=True))
예제 #4
0
 def test_get_key_hash(self, val_expr, type_expr, expected):
     ty = MichelsonType.match(type_expr)
     key = ty.from_micheline_value(val_expr).pack(legacy=True)
     self.assertEqual(expected, forge_script_expr(key))