fn mint_transfer_direct(
        &mut self,
        to: Option<AccountHash>,
        source: URef,
        target: URef,
        amount: U512,
        id: Option<u64>,
    ) -> Result<Result<(), mint::Error>, Error> {
        // if caller is system proceed
        // else if caller has access to uref proceed
        if self.context.get_caller() != PublicKey::System.to_account_hash()
            && self.context.validate_uref(&source).is_err()
        {
            return Err(Error::InvalidCaller);
        }

        let args_values = RuntimeArgs::try_new(|args| {
            args.insert(mint::ARG_TO, to)?;
            args.insert(mint::ARG_SOURCE, source)?;
            args.insert(mint::ARG_TARGET, target)?;
            args.insert(mint::ARG_AMOUNT, amount)?;
            args.insert(mint::ARG_ID, id)?;
            Ok(())
        })
        .map_err(|_| Error::CLValue)?;

        let gas_counter = self.gas_counter();
        let mut stack = self.stack().clone();
        stack
            .push(
                self.get_system_contract_stack_frame(MINT)
                    .map_err(|_| Error::Storage)?,
            )
            .map_err(|_| Error::RuntimeStackOverflow)?;
        let cl_value = self
            .call_host_mint(
                self.context.protocol_version(),
                mint::METHOD_TRANSFER,
                &mut NamedKeys::default(),
                &args_values,
                &[],
                stack,
            )
            .map_err(|exec_error| <Option<Error>>::from(exec_error).unwrap_or(Error::Transfer))?;
        self.set_gas_counter(gas_counter);
        cl_value.into_t().map_err(|_| Error::CLValue)
    }
/// Allows optimized auction and mint interaction.
/// Intended to be used only by system contracts to manage staked purses.
/// NOTE: Never expose this through FFI.
Allows optimized auction and mint interaction.
Intended to be used only by system contracts to manage staked purses.
NOTE: Never expose this through FFI.
Allows optimized auction and mint interaction . Intended to be used only by system contracts to manage staked purses . NOTE : Never expose this through FFI .
fn mint_transfer_direct(
        &mut self,
        to: Option<AccountHash>,
        source: URef,
        target: URef,
        amount: U512,
        id: Option<u64>,
    ) -> Result<Result<(), mint::Error>, Error> {
        // if caller is system proceed
        // else if caller has access to uref proceed
        if self.context.get_caller() != PublicKey::System.to_account_hash()
            && self.context.validate_uref(&source).is_err()
        {
            return Err(Error::InvalidCaller);
        }
        let args_values = RuntimeArgs::try_new(|args| {
            args.insert(mint::ARG_TO, to)?;
            args.insert(mint::ARG_SOURCE, source)?;
            args.insert(mint::ARG_TARGET, target)?;
            args.insert(mint::ARG_AMOUNT, amount)?;
            args.insert(mint::ARG_ID, id)?;
            Ok(())
        })
        .map_err(|_| Error::CLValue)?;
        let gas_counter = self.gas_counter();
        let mut stack = self.stack().clone();
        stack
            .push(
                self.get_system_contract_stack_frame(MINT)
                    .map_err(|_| Error::Storage)?,
            )
            .map_err(|_| Error::RuntimeStackOverflow)?;
        let cl_value = self
            .call_host_mint(
                self.context.protocol_version(),
                mint::METHOD_TRANSFER,
                &mut NamedKeys::default(),
                &args_values,
                &[],
                stack,
            )
            .map_err(|exec_error| <Option<Error>>::from(exec_error).unwrap_or(Error::Transfer))?;
        self.set_gas_counter(gas_counter);
        cl_value.into_t().map_err(|_| Error::CLValue)
    }
fn mint_transfer_direct ( & mut self , to : Option < AccountHash > , source : URef , target : URef , amount : U512 , id : Option < u64 > , ) -> Result < Result < ( ) , mint :: Error > , Error > { // if caller is system proceed // else if caller has access to uref proceed if self . context . get_caller ( ) != PublicKey :: System . to_account_hash ( ) && self . context . validate_uref ( & source ) . is_err ( ) { return Err ( Error :: InvalidCaller ) ; } let args_values = RuntimeArgs :: try_new ( | args | { args . insert ( mint :: ARG_TO , to ) ? ; args . insert ( mint :: ARG_SOURCE , source ) ? ; args . insert ( mint :: ARG_TARGET , target ) ? ; args . insert ( mint :: ARG_AMOUNT , amount ) ? ; args . insert ( mint :: ARG_ID , id ) ? ; Ok ( ( ) ) } ) . map_err ( | _ | Error :: CLValue ) ? ; let gas_counter = self . gas_counter ( ) ; let mut stack = self . stack ( ) . clone ( ) ; stack . push ( self . get_system_contract_stack_frame ( MINT ) . map_err ( | _ | Error :: Storage ) ? , ) . map_err ( | _ | Error :: RuntimeStackOverflow ) ? ; let cl_value = self . call_host_mint ( self . context . protocol_version ( ) , mint :: METHOD_TRANSFER , & mut NamedKeys :: default ( ) , & args_values , & [ ] , stack , ) . map_err ( | exec_error | < Option < Error > > :: from ( exec_error ) . unwrap_or ( Error :: Transfer ) ) ? ; self . set_gas_counter ( gas_counter ) ; cl_value . into_t ( ) . map_err ( | _ | Error :: CLValue ) }
Allows optimized auction and mint interaction.
Allows optimized auction and mint interaction .
&mut self
to
Option<AccountHash>
source
URef
target
URef
amount
U512
id
Option<u64>
&mut self
to
Option<AccountHash>
source
URef
target
URef
amount
U512
id
Option<u64>