def remove_existing_transaction_type(transaction_type: str) -> None: """ Deletes a registered transaction type """ _log.info(f"Deleting existing transaction type {transaction_type}") redisearch.delete_index(transaction_type) storage.delete(f"{FOLDER}/{transaction_type}")
def delete_interchain_client(blockchain: str, name: str) -> None: """Delete an interchain client from this chain Args: blockchain: the blockchain of the desired client (i.e. bitcoin, ethereum, etc) name: the name (id) of the network to delete (user defined on the creation of the interchain) """ storage.delete(f"{FOLDER}/{blockchain}/{name}")
def remove_existing_transaction_type(transaction_type: str) -> None: """ Deletes a registered transaction type if not contract """ _log.info(f"Deleting existing transaction type {transaction_type}") redis.srem_sync(TYPE_LIST_KEY, transaction_type) storage.delete(f"{FOLDER}/TYPES/{transaction_type}")
def delete_api_key(key_id: str, interchain: bool) -> None: """Delete an api key from this chain Args: key_id: The key id to delete (public chain id if interchain) interchain: Whether or not this is an interchain key """ if not interchain and key_id.startswith("INTERCHAIN"): raise RuntimeError( "Attempt to remove interchain key when not intended") storage.delete(f"{INTERCHAIN_FOLDER if interchain else FOLDER}/{key_id}")
def delete_contract_data(self) -> None: """Remove all stored information on this smart contract""" try: _log.info(f"Deleting contract data for contract {self.model.id}") storage.delete_directory(f"SMARTCONTRACT/{self.model.id}") _log.info("Removing index") smart_contract_dao.remove_smart_contract_index(self.model.id) _log.info(f"Deleting txn type {self.model.txn_type}") transaction_type_dao.remove_existing_transaction_type(self.model.txn_type) key = f"KEYS/{self.model.auth_key_id}" _log.info(f"Deleting HMAC key {key}") storage.delete(key) except Exception: _log.exception("Error deleting contract data") self.model.set_state(state=self.end_error_state, msg="Error deleting contract data")
def remove_auth_key(auth_key_id: str, interchain: bool = False) -> bool: """Remove a registered auth key from this chain Args: auth_key_id: The key id string associated with the auth_key to delete Note: in case of interchain, this is the interchain dcid interchain: boolean whether this key to remove is an interchain key Returns: False if failed to delete, True otherwise """ path = None if interchain: path = f"KEYS/INTERCHAIN/{auth_key_id}" else: path = f"KEYS/{auth_key_id}" try: storage.delete(path) return True except Exception: return False
def delete_contract_data(self) -> None: """Remove all stored information on this smart contract Returns: None """ _log.info("Deleting contract data") try: storage.delete_directory(f"SMARTCONTRACT/{self.model.id}") _log.info("Removing index") elasticsearch.remove_index(doc_id=self.model.id, folder="SMARTCONTRACT") _log.info("Deleting txn type") transaction_type_dao.remove_existing_transaction_type( self.model.txn_type) key = f"KEYS/{self.model.auth_key_id}" _log.info(f"Deleting HMAC key {key}") storage.delete(key) except Exception: _log.exception("Error deleting contract data") self.model.set_state(state=self.end_error_state, msg="Error deleting contract data")
def test_delete_calls_cache_with_correct_params(self): storage.delete("thing") storage.redis.cache_delete.assert_called_once_with("thing")
def test_delete_calls_storage_delete_with_params(self): storage.delete("thing") storage.storage.delete.assert_called_once_with("test", "thing")