fn transfer_to_new_account(
        &mut self,
        source: URef,
        target: AccountHash,
        amount: U512,
        id: Option<u64>,
    ) -> Result<TransferResult, Error> {
        let mint_contract_hash = self.get_mint_contract()?;

        let target_key = Key::Account(target);

        // A precondition check that verifies that the transfer can be done
        // as the source purse has enough funds to cover the transfer.
        if amount > self.get_balance(source)?.unwrap_or_default() {
            return Ok(Err(mint::Error::InsufficientFunds.into()));
        }

        let target_purse = self.mint_create(mint_contract_hash)?;

        if source == target_purse {
            return Ok(Err(mint::Error::EqualSourceAndTarget.into()));
        }

        match self.mint_transfer(
            mint_contract_hash,
            Some(target),
            source,
            target_purse.with_access_rights(AccessRights::ADD),
            amount,
            id,
        )? {
            Ok(()) => {
                let account = Account::create(target, Default::default(), target_purse);
                self.context.write_account(target_key, account)?;
                Ok(Ok(TransferredTo::NewAccount))
            }
            Err(mint_error) => Ok(Err(mint_error.into())),
        }
    }
/// Creates a new account at a given public key, transferring a given amount
/// of motes from the given source purse to the new account's purse.
Creates a new account at a given public key, transferring a given amount
of motes from the given source purse to the new account's purse.
Creates a new account at a given public key transferring a given amount of motes from the given source purse to the new account ' s purse .
fn transfer_to_new_account(
        &mut self,
        source: URef,
        target: AccountHash,
        amount: U512,
        id: Option<u64>,
    ) -> Result<TransferResult, Error> {
        let mint_contract_hash = self.get_mint_contract()?;
        let target_key = Key::Account(target);
        // A precondition check that verifies that the transfer can be done
        // as the source purse has enough funds to cover the transfer.
        if amount > self.get_balance(source)?.unwrap_or_default() {
            return Ok(Err(mint::Error::InsufficientFunds.into()));
        }
        let target_purse = self.mint_create(mint_contract_hash)?;
        if source == target_purse {
            return Ok(Err(mint::Error::EqualSourceAndTarget.into()));
        }
        match self.mint_transfer(
            mint_contract_hash,
            Some(target),
            source,
            target_purse.with_access_rights(AccessRights::ADD),
            amount,
            id,
        )? {
            Ok(()) => {
                let account = Account::create(target, Default::default(), target_purse);
                self.context.write_account(target_key, account)?;
                Ok(Ok(TransferredTo::NewAccount))
            }
            Err(mint_error) => Ok(Err(mint_error.into())),
        }
    }
fn transfer_to_new_account ( & mut self , source : URef , target : AccountHash , amount : U512 , id : Option < u64 > , ) -> Result < TransferResult , Error > { let mint_contract_hash = self . get_mint_contract ( ) ? ; let target_key = Key :: Account ( target ) ; // A precondition check that verifies that the transfer can be done // as the source purse has enough funds to cover the transfer. if amount > self . get_balance ( source ) ? . unwrap_or_default ( ) { return Ok ( Err ( mint :: Error :: InsufficientFunds . into ( ) ) ) ; } let target_purse = self . mint_create ( mint_contract_hash ) ? ; if source == target_purse { return Ok ( Err ( mint :: Error :: EqualSourceAndTarget . into ( ) ) ) ; } match self . mint_transfer ( mint_contract_hash , Some ( target ) , source , target_purse . with_access_rights ( AccessRights :: ADD ) , amount , id , ) ? { Ok ( ( ) ) => { let account = Account :: create ( target , Default :: default ( ) , target_purse ) ; self . context . write_account ( target_key , account ) ? ; Ok ( Ok ( TransferredTo :: NewAccount ) ) } Err ( mint_error ) => Ok ( Err ( mint_error . into ( ) ) ) , } }
Creates a new account at a given public key, transferring a given amount
of motes from the given source purse to the new account's purse.
Creates a new account at a given public key transferring a given amount of motes from the given source purse to the new account ' s purse .
&mut self
source
URef
target
AccountHash
amount
U512
id
Option<u64>
&mut self
source
URef
target
AccountHash
amount
U512
id
Option<u64>