Exemple #1
0
 def from_micheline_value(cls, val_expr) -> 'ChainIdType':
     value = parse_micheline_literal(
         val_expr, {
             'bytes': lambda x: unforge_chain_id(bytes.fromhex(x)),
             'string': lambda x: x
         })
     return cls.from_value(value)
Exemple #2
0
def blind_unpack(data: bytes):
    try:
        return unforge_chain_id(data)
    except ValueError:
        pass
    try:
        return unforge_address(data)
    except (ValueError, KeyError):
        pass
    try:
        return unforge_public_key(data)
    except (ValueError, KeyError):
        pass
    try:
        return unforge_signature(data)
    except ValueError:
        pass

    if len(data) > 0 and data.startswith(b'\x05'):
        try:
            res = unforge_micheline(data[1:])
            return micheline_value_to_python_object(res)
        except (ValueError, AssertionError):
            pass

    try:
        return data.decode()
    except ValueError:
        pass

    return data