fn resolve_transfer_target_mode<R>(
        &mut self,
        correlation_id: CorrelationId,
        tracking_copy: Rc<RefCell<TrackingCopy<R>>>,
    ) -> Result<TransferTargetMode, Error>
    where
        R: StateReader<Key, StoredValue>,
        R::Error: Into<ExecError>,
    {
        let imputed_runtime_args = &self.inner;
        let arg_name = mint::ARG_TARGET;

        let account_hash = match imputed_runtime_args.get(arg_name) {
            Some(cl_value) if *cl_value.cl_type() == CLType::URef => {
                let uref: URef = cl_value.clone().into_t().map_err(Error::reverter)?;

                if !self.purse_exists(uref, correlation_id, tracking_copy) {
                    return Err(Error::reverter(ApiError::InvalidPurse));
                }

                return Ok(TransferTargetMode::PurseExists(uref));
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::ByteArray(32) => {
                let account_hash: AccountHash =
                    cl_value.clone().into_t().map_err(Error::reverter)?;
                account_hash
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::Key => {
                let account_key: Key = cl_value.clone().into_t().map_err(Error::reverter)?;

                let account_hash: AccountHash = account_key
                    .into_account()
                    .ok_or_else(|| Error::reverter(ApiError::Transfer))?;
                account_hash
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::PublicKey => {
                let public_key: PublicKey = cl_value.clone().into_t().map_err(Error::reverter)?;

                AccountHash::from(&public_key)
            }
            Some(_) => return Err(Error::reverter(ApiError::InvalidArgument)),
            None => return Err(Error::reverter(ApiError::MissingArgument)),
        };

        self.to = Some(account_hash);
        match tracking_copy
            .borrow_mut()
            .read_account(correlation_id, account_hash)
        {
            Ok(account) => Ok(TransferTargetMode::PurseExists(
                account.main_purse().with_access_rights(AccessRights::ADD),
            )),
            Err(_) => Ok(TransferTargetMode::CreateAccount(account_hash)),
        }
    }
/// Resolves a transfer target mode.
///
/// User has to specify a "target" argument which must be one of the following types:
///   * an existing purse [`URef`]
///   * a 32-byte array, interpreted as an account hash
///   * a [`Key::Account`], from which the account hash is extracted
///   * a [`PublicKey`], which is converted to an account hash
///
/// If the "target" account hash is not existing, then a special variant is returned that
/// indicates that the system has to create new account first.
///
/// Returns [`TransferTargetMode`] with a resolved variant.
Resolves a transfer target mode.

If the "target" account hash is not existing, then a special variant is returned that
indicates that the system has to create new account first.

Returns [`TransferTargetMode`] with a resolved variant.
Resolves a transfer target mode . If the " target " account hash is not existing then a special variant is returned that indicates that the system has to create new account first . Returns [ ` TransferTargetMode ` ] with a resolved variant .
fn resolve_transfer_target_mode<R>(
        &mut self,
        correlation_id: CorrelationId,
        tracking_copy: Rc<RefCell<TrackingCopy<R>>>,
    ) -> Result<TransferTargetMode, Error>
    where
        R: StateReader<Key, StoredValue>,
        R::Error: Into<ExecError>,
    {
        let imputed_runtime_args = &self.inner;
        let arg_name = mint::ARG_TARGET;
        let account_hash = match imputed_runtime_args.get(arg_name) {
            Some(cl_value) if *cl_value.cl_type() == CLType::URef => {
                let uref: URef = cl_value.clone().into_t().map_err(Error::reverter)?;
                if !self.purse_exists(uref, correlation_id, tracking_copy) {
                    return Err(Error::reverter(ApiError::InvalidPurse));
                }
                return Ok(TransferTargetMode::PurseExists(uref));
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::ByteArray(32) => {
                let account_hash: AccountHash =
                    cl_value.clone().into_t().map_err(Error::reverter)?;
                account_hash
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::Key => {
                let account_key: Key = cl_value.clone().into_t().map_err(Error::reverter)?;
                let account_hash: AccountHash = account_key
                    .into_account()
                    .ok_or_else(|| Error::reverter(ApiError::Transfer))?;
                account_hash
            }
            Some(cl_value) if *cl_value.cl_type() == CLType::PublicKey => {
                let public_key: PublicKey = cl_value.clone().into_t().map_err(Error::reverter)?;
                AccountHash::from(&public_key)
            }
            Some(_) => return Err(Error::reverter(ApiError::InvalidArgument)),
            None => return Err(Error::reverter(ApiError::MissingArgument)),
        };
        self.to = Some(account_hash);
        match tracking_copy
            .borrow_mut()
            .read_account(correlation_id, account_hash)
        {
            Ok(account) => Ok(TransferTargetMode::PurseExists(
                account.main_purse().with_access_rights(AccessRights::ADD),
            )),
            Err(_) => Ok(TransferTargetMode::CreateAccount(account_hash)),
        }
    }
fn resolve_transfer_target_mode < R > ( & mut self , correlation_id : CorrelationId , tracking_copy : Rc < RefCell < TrackingCopy < R > > > , ) -> Result < TransferTargetMode , Error > where R : StateReader < Key , StoredValue > , R :: Error : Into < ExecError > , { let imputed_runtime_args = & self . inner ; let arg_name = mint :: ARG_TARGET ; let account_hash = match imputed_runtime_args . get ( arg_name ) { Some ( cl_value ) if * cl_value . cl_type ( ) == CLType :: URef => { let uref : URef = cl_value . clone ( ) . into_t ( ) . map_err ( Error :: reverter ) ? ; if ! self . purse_exists ( uref , correlation_id , tracking_copy ) { return Err ( Error :: reverter ( ApiError :: InvalidPurse ) ) ; } return Ok ( TransferTargetMode :: PurseExists ( uref ) ) ; } Some ( cl_value ) if * cl_value . cl_type ( ) == CLType :: ByteArray ( 32 ) => { let account_hash : AccountHash = cl_value . clone ( ) . into_t ( ) . map_err ( Error :: reverter ) ? ; account_hash } Some ( cl_value ) if * cl_value . cl_type ( ) == CLType :: Key => { let account_key : Key = cl_value . clone ( ) . into_t ( ) . map_err ( Error :: reverter ) ? ; let account_hash : AccountHash = account_key . into_account ( ) . ok_or_else ( | | Error :: reverter ( ApiError :: Transfer ) ) ? ; account_hash } Some ( cl_value ) if * cl_value . cl_type ( ) == CLType :: PublicKey => { let public_key : PublicKey = cl_value . clone ( ) . into_t ( ) . map_err ( Error :: reverter ) ? ; AccountHash :: from ( & public_key ) } Some ( _ ) => return Err ( Error :: reverter ( ApiError :: InvalidArgument ) ) , None => return Err ( Error :: reverter ( ApiError :: MissingArgument ) ) , } ; self . to = Some ( account_hash ) ; match tracking_copy . borrow_mut ( ) . read_account ( correlation_id , account_hash ) { Ok ( account ) => Ok ( TransferTargetMode :: PurseExists ( account . main_purse ( ) . with_access_rights ( AccessRights :: ADD ) , ) ) , Err ( _ ) => Ok ( TransferTargetMode :: CreateAccount ( account_hash ) ) , } }
Resolves a transfer target mode.
Resolves a transfer target mode .
&mut self
correlation_id
CorrelationId
tracking_copy
Rc<RefCell<TrackingCopy<R>>>
&mut self
correlation_id
CorrelationId
tracking_copy
Rc<RefCell<TrackingCopy<R>>>