fn resolve_source_uref<R>(
        &self,
        account: &Account,
        correlation_id: CorrelationId,
        tracking_copy: Rc<RefCell<TrackingCopy<R>>>,
    ) -> Result<URef, Error>
    where
        R: StateReader<Key, StoredValue>,
        R::Error: Into<ExecError>,
    {
        let imputed_runtime_args = &self.inner;
        let arg_name = mint::ARG_SOURCE;
        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 account.main_purse().addr() == uref.addr() {
                    return Ok(uref);
                }

                let normalized_uref = Key::URef(uref).normalize();
                let maybe_named_key = account
                    .named_keys()
                    .values()
                    .find(|&named_key| named_key.normalize() == normalized_uref);

                match maybe_named_key {
                    Some(Key::URef(found_uref)) => {
                        if found_uref.is_writeable() {
                            // it is a URef and caller has access but is it a purse URef?
                            if !self.purse_exists(
                                found_uref.to_owned(),
                                correlation_id,
                                tracking_copy,
                            ) {
                                return Err(Error::reverter(ApiError::InvalidPurse));
                            }

                            Ok(uref)
                        } else {
                            Err(Error::Exec(ExecError::InvalidAccess {
                                required: AccessRights::WRITE,
                            }))
                        }
                    }
                    Some(key) => Err(Error::Exec(ExecError::TypeMismatch(
                        casper_types::StoredValueTypeMismatch::new(
                            "Key::URef".to_string(),
                            key.type_string(),
                        ),
                    ))),
                    None => Err(Error::Exec(ExecError::ForgedReference(uref))),
                }
            }
            Some(_) => Err(Error::reverter(ApiError::InvalidArgument)),
            None => Ok(account.main_purse()), // if no source purse passed use account main purse
        }
    }
/// Resolves the source purse of the transfer.
///
/// User can optionally pass a "source" argument which should refer to an [`URef`] existing in
/// user's named keys. When the "source" argument is missing then user's main purse is assumed.
///
/// Returns resolved [`URef`].
Resolves the source purse of the transfer.
User can optionally pass a "source" argument which should refer to an [`URef`] existing in
user's named keys. When the "source" argument is missing then user's main purse is assumed.


Resolves the source purse of the transfer . User can optionally pass a " source " argument which should refer to an [ ` URef ` ] existing in user ' s named keys . When the " source " argument is missing then user ' s main purse is assumed .
fn resolve_source_uref<R>(
        &self,
        account: &Account,
        correlation_id: CorrelationId,
        tracking_copy: Rc<RefCell<TrackingCopy<R>>>,
    ) -> Result<URef, Error>
    where
        R: StateReader<Key, StoredValue>,
        R::Error: Into<ExecError>,
    {
        let imputed_runtime_args = &self.inner;
        let arg_name = mint::ARG_SOURCE;
        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 account.main_purse().addr() == uref.addr() {
                    return Ok(uref);
                }
                let normalized_uref = Key::URef(uref).normalize();
                let maybe_named_key = account
                    .named_keys()
                    .values()
                    .find(|&named_key| named_key.normalize() == normalized_uref);
                match maybe_named_key {
                    Some(Key::URef(found_uref)) => {
                        if found_uref.is_writeable() {
                            // it is a URef and caller has access but is it a purse URef?
                            if !self.purse_exists(
                                found_uref.to_owned(),
                                correlation_id,
                                tracking_copy,
                            ) {
                                return Err(Error::reverter(ApiError::InvalidPurse));
                            }
                            Ok(uref)
                        } else {
                            Err(Error::Exec(ExecError::InvalidAccess {
                                required: AccessRights::WRITE,
                            }))
                        }
                    }
                    Some(key) => Err(Error::Exec(ExecError::TypeMismatch(
                        casper_types::StoredValueTypeMismatch::new(
                            "Key::URef".to_string(),
                            key.type_string(),
                        ),
                    ))),
                    None => Err(Error::Exec(ExecError::ForgedReference(uref))),
                }
            }
            Some(_) => Err(Error::reverter(ApiError::InvalidArgument)),
            None => Ok(account.main_purse()), // if no source purse passed use account main purse
        }
    }
fn resolve_source_uref < R > ( & self , account : & Account , correlation_id : CorrelationId , tracking_copy : Rc < RefCell < TrackingCopy < R > > > , ) -> Result < URef , Error > where R : StateReader < Key , StoredValue > , R :: Error : Into < ExecError > , { let imputed_runtime_args = & self . inner ; let arg_name = mint :: ARG_SOURCE ; 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 account . main_purse ( ) . addr ( ) == uref . addr ( ) { return Ok ( uref ) ; } let normalized_uref = Key :: URef ( uref ) . normalize ( ) ; let maybe_named_key = account . named_keys ( ) . values ( ) . find ( | & named_key | named_key . normalize ( ) == normalized_uref ) ; match maybe_named_key { Some ( Key :: URef ( found_uref ) ) => { if found_uref . is_writeable ( ) { // it is a URef and caller has access but is it a purse URef? if ! self . purse_exists ( found_uref . to_owned ( ) , correlation_id , tracking_copy , ) { return Err ( Error :: reverter ( ApiError :: InvalidPurse ) ) ; } Ok ( uref ) } else { Err ( Error :: Exec ( ExecError :: InvalidAccess { required : AccessRights :: WRITE , } ) ) } } Some ( key ) => Err ( Error :: Exec ( ExecError :: TypeMismatch ( casper_types :: StoredValueTypeMismatch :: new ( " " . to_string ( ) , key . type_string ( ) , ) , ) ) ) , None => Err ( Error :: Exec ( ExecError :: ForgedReference ( uref ) ) ) , } } Some ( _ ) => Err ( Error :: reverter ( ApiError :: InvalidArgument ) ) , None => Ok ( account . main_purse ( ) ) , // if no source purse passed use account main purse } }
Resolves the source purse of the transfer.
Resolves the source purse of the transfer .
&self
account
&Account
correlation_id
CorrelationId
tracking_copy
Rc<RefCell<TrackingCopy<R>>>
&self
account
&Account
correlation_id
CorrelationId
tracking_copy
Rc<RefCell<TrackingCopy<R>>>