def storage_put(self, key: Union[str, bytes], value: Any, contract_path: str): if isinstance(key, str): key = String(key).to_bytes() if contract_path.endswith('.py'): contract_path = contract_path.replace('.py', '.nef') if contract_path in self.contracts: contract_id = self._get_contract_id(contract_path) storage_key = Storage.build_key(key, contract_id) self._storage[storage_key] = value
def storage_delete(self, key: Union[str, bytes], contract_path: str): if isinstance(key, str): key = String(key).to_bytes() if contract_path.endswith('.py'): contract_path = contract_path.replace('.py', '.nef') if contract_path not in self._contract_paths: return None index = self._contract_paths.index(contract_path) storage_key = Storage.build_key(key, index) if storage_key in self._storage: self._storage.pop(key)
def storage_get(self, key: Union[str, bytes], contract_path: str) -> Any: if isinstance(key, str): key = String(key).to_bytes() if contract_path.endswith('.py'): contract_path = contract_path.replace('.py', '.nef') if contract_path not in self.contracts: return None contract_id = self._get_contract_id(contract_path) storage_key = Storage.build_key(key, contract_id) if storage_key in self._storage: return self._storage[storage_key] else: return None