pub fn remove_key(&mut self, name: &str) -> Result<(), Error> {
        match self.base_key() {
            account_hash @ Key::Account(_) => {
                let account: Account = {
                    let mut account: Account = self.read_gs_typed(&account_hash)?;
                    account.named_keys_mut().remove(name);
                    account
                };
                self.named_keys.remove(name);
                let account_value = self.account_to_validated_value(account)?;
                self.metered_write_gs_unsafe(account_hash, account_value)?;
                Ok(())
            }
            contract_uref @ Key::URef(_) => {
                let contract: Contract = {
                    let value: StoredValue = self
                        .tracking_copy
                        .borrow_mut()
                        .read(self.correlation_id, &contract_uref)
                        .map_err(Into::into)?
                        .ok_or(Error::KeyNotFound(contract_uref))?;

                    value.try_into().map_err(Error::TypeMismatch)?
                };

                self.named_keys.remove(name);
                self.remove_key_from_contract(contract_uref, contract, name)
            }
            contract_hash @ Key::Hash(_) => {
                let contract: Contract = self.read_gs_typed(&contract_hash)?;
                self.named_keys.remove(name);
                self.remove_key_from_contract(contract_hash, contract, name)
            }
            transfer_addr @ Key::Transfer(_) => {
                let _transfer: Transfer = self.read_gs_typed(&transfer_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove transfers from global state
                Ok(())
            }
            deploy_info_addr @ Key::DeployInfo(_) => {
                let _deploy_info: DeployInfo = self.read_gs_typed(&deploy_info_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove deploy infos from global state
                Ok(())
            }
            era_info_addr @ Key::EraInfo(_) => {
                let _era_info: EraInfo = self.read_gs_typed(&era_info_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove era infos from global state
                Ok(())
            }
            Key::Balance(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Bid(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Withdraw(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Dictionary(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::SystemContractRegistry => {
                error!("should not remove the system contract registry key");
                Err(Error::RemoveKeyFailure(RemoveKeyFailure::PermissionDenied))
            }
        }
    }
/// Remove Key from the `named_keys` map of the current context.
/// It removes both from the ephemeral map (RuntimeContext::named_keys) but
/// also persistable map (one that is found in the
/// TrackingCopy/GlobalState).
Remove Key from the `named_keys` map of the current context.
It removes both from the ephemeral map (RuntimeContext::named_keys) but
also persistable map (one that is found in the
TrackingCopy/GlobalState).
Remove Key from the ` named_keys ` map of the current context . It removes both from the ephemeral map ( RuntimeContext :: named_keys ) but also persistable map ( one that is found in the TrackingCopy / GlobalState ) .
pub fn remove_key(&mut self, name: &str) -> Result<(), Error> {
        match self.base_key() {
            account_hash @ Key::Account(_) => {
                let account: Account = {
                    let mut account: Account = self.read_gs_typed(&account_hash)?;
                    account.named_keys_mut().remove(name);
                    account
                };
                self.named_keys.remove(name);
                let account_value = self.account_to_validated_value(account)?;
                self.metered_write_gs_unsafe(account_hash, account_value)?;
                Ok(())
            }
            contract_uref @ Key::URef(_) => {
                let contract: Contract = {
                    let value: StoredValue = self
                        .tracking_copy
                        .borrow_mut()
                        .read(self.correlation_id, &contract_uref)
                        .map_err(Into::into)?
                        .ok_or(Error::KeyNotFound(contract_uref))?;
                    value.try_into().map_err(Error::TypeMismatch)?
                };
                self.named_keys.remove(name);
                self.remove_key_from_contract(contract_uref, contract, name)
            }
            contract_hash @ Key::Hash(_) => {
                let contract: Contract = self.read_gs_typed(&contract_hash)?;
                self.named_keys.remove(name);
                self.remove_key_from_contract(contract_hash, contract, name)
            }
            transfer_addr @ Key::Transfer(_) => {
                let _transfer: Transfer = self.read_gs_typed(&transfer_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove transfers from global state
                Ok(())
            }
            deploy_info_addr @ Key::DeployInfo(_) => {
                let _deploy_info: DeployInfo = self.read_gs_typed(&deploy_info_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove deploy infos from global state
                Ok(())
            }
            era_info_addr @ Key::EraInfo(_) => {
                let _era_info: EraInfo = self.read_gs_typed(&era_info_addr)?;
                self.named_keys.remove(name);
                // Users cannot remove era infos from global state
                Ok(())
            }
            Key::Balance(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Bid(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Withdraw(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::Dictionary(_) => {
                self.named_keys.remove(name);
                Ok(())
            }
            Key::SystemContractRegistry => {
                error!("should not remove the system contract registry key");
                Err(Error::RemoveKeyFailure(RemoveKeyFailure::PermissionDenied))
            }
        }
    }
pub fn remove_key ( & mut self , name : & str ) -> Result < ( ) , Error > { match self . base_key ( ) { account_hash @ Key :: Account ( _ ) => { let account : Account = { let mut account : Account = self . read_gs_typed ( & account_hash ) ? ; account . named_keys_mut ( ) . remove ( name ) ; account } ; self . named_keys . remove ( name ) ; let account_value = self . account_to_validated_value ( account ) ? ; self . metered_write_gs_unsafe ( account_hash , account_value ) ? ; Ok ( ( ) ) } contract_uref @ Key :: URef ( _ ) => { let contract : Contract = { let value : StoredValue = self . tracking_copy . borrow_mut ( ) . read ( self . correlation_id , & contract_uref ) . map_err ( Into :: into ) ? . ok_or ( Error :: KeyNotFound ( contract_uref ) ) ? ; value . try_into ( ) . map_err ( Error :: TypeMismatch ) ? } ; self . named_keys . remove ( name ) ; self . remove_key_from_contract ( contract_uref , contract , name ) } contract_hash @ Key :: Hash ( _ ) => { let contract : Contract = self . read_gs_typed ( & contract_hash ) ? ; self . named_keys . remove ( name ) ; self . remove_key_from_contract ( contract_hash , contract , name ) } transfer_addr @ Key :: Transfer ( _ ) => { let _transfer : Transfer = self . read_gs_typed ( & transfer_addr ) ? ; self . named_keys . remove ( name ) ; // Users cannot remove transfers from global state Ok ( ( ) ) } deploy_info_addr @ Key :: DeployInfo ( _ ) => { let _deploy_info : DeployInfo = self . read_gs_typed ( & deploy_info_addr ) ? ; self . named_keys . remove ( name ) ; // Users cannot remove deploy infos from global state Ok ( ( ) ) } era_info_addr @ Key :: EraInfo ( _ ) => { let _era_info : EraInfo = self . read_gs_typed ( & era_info_addr ) ? ; self . named_keys . remove ( name ) ; // Users cannot remove era infos from global state Ok ( ( ) ) } Key :: Balance ( _ ) => { self . named_keys . remove ( name ) ; Ok ( ( ) ) } Key :: Bid ( _ ) => { self . named_keys . remove ( name ) ; Ok ( ( ) ) } Key :: Withdraw ( _ ) => { self . named_keys . remove ( name ) ; Ok ( ( ) ) } Key :: Dictionary ( _ ) => { self . named_keys . remove ( name ) ; Ok ( ( ) ) } Key :: SystemContractRegistry => { error ! ( " " ) ; Err ( Error :: RemoveKeyFailure ( RemoveKeyFailure :: PermissionDenied ) ) } } }
Remove Key from the `named_keys` map of the current context.
Remove Key from the ` named_keys ` map of the current context .
&mut self
name
&str
&mut self
name
&str