def parse_address(val_expr, type_expr, selector): val = dispatch_core_map( val_expr, { 'bytes': lambda x: encoding.parse_address(bytes.fromhex(x)), 'string': lambda x: x }) return selector(val_expr, type_expr, val)
def decode_literal(node, prim): core_type, value = next(iter(node.items())) if prim in ['int', 'nat']: return int(value) if prim == 'timestamp': if core_type == 'int': return int(value) else: return value if prim == 'mutez': return Decimal(value) / 10 ** 6 if prim == 'bool': return value == 'True' if core_type == 'bytes': if prim in ['address', 'key_hash', 'contract']: return parse_address(bytes.fromhex(value)) if prim == 'key': return parse_public_key(bytes.fromhex(value)) return value