def main(operation: int) -> Any:

    # create an array
    stuff = ['a', 3, ['j', 3, 5], 'jk', 'lmnopqr']

    # serialize it
    to_save = serialize(stuff)
    put('serialized', to_save)

    if operation == 1:
        return to_save

    elif operation == 2:
        to_retrieve = get('serialized')
        return to_retrieve

    elif operation == 3:

        to_retrieve = get('serialized')
        deserialized = deserialize(to_retrieve)
        return deserialized

    elif operation == 4:

        to_retrieve = get('serialized')
        deserialized = deserialize(to_retrieve)
        return cast(list, deserialized)[2]

    return False
def owner_of(token_id: ByteString) -> UInt160:
    """
    Get the owner of the specified token.

    The parameter token_id SHOULD be a valid NFT ID (64 bytes maximum).

    :param token_id: the id of a token
    :type token_id: str
    """
    assert len(token_id) <= 64

    owner = UInt160()

    token_bytes = storage.get(account_prefix_key + token_id)
    if len(token_bytes) != 0:
        token = cast(NFT, deserialize(token_bytes))
        owner = token.owner

    return owner
Example #3
0
def deserialize_arg() -> Any:
    return deserialize(1)
Example #4
0
def deserialize_arg(arg: bytes) -> Any:
    return deserialize(arg)
def deserialize_user_class(arg: bytes) -> Example:
    user_class = cast(Example, deserialize(arg))
    return user_class
def get_account(account: UInt160) -> Optional[Account]:
    account_bytes = storage.get(PREFIX_ACCOUNT + account)
    if len(account_bytes) == 0:
        return None
    return cast(Account, deserialize(account_bytes))