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 serialize_bool() -> bytes: return serialize(True)
def serialize_user_class() -> bytes: user_class = Example() return serialize(user_class)
def set_account(self): storage.put(PREFIX_ACCOUNT + self.address, serialize(self))
def set_nft(token_id: bytes, token: NFT): storage.put(PREFIX_TOKEN + token_id, serialize(token))
def set_value(token_id: bytes, example_class: Example): storage.put(b'00' + token_id, serialize(example_class))
def serialize_dict() -> bytes: return serialize({1: 1, 2: 1, 3: 2})
def serialize_str() -> bytes: return serialize('42')
def serialize_sequence() -> bytes: return serialize([2, 3, 5, 7])
def serialize_int() -> bytes: return serialize(42)