fn mint(&mut self, initial_balance: U512) -> Result<URef, Error> {
        let caller = self.get_caller();
        let is_empty_purse = initial_balance.is_zero();
        if !is_empty_purse && caller != PublicKey::System.to_account_hash() {
            return Err(Error::InvalidNonEmptyPurseCreation);
        }

        let purse_uref: URef = self.new_uref(())?;
        self.write_balance(purse_uref, initial_balance)?;

        if !is_empty_purse {
            // get total supply uref if exists, otherwise error
            let total_supply_uref = match self.get_key(TOTAL_SUPPLY_KEY) {
                None => {
                    // total supply URef should exist due to genesis
                    return Err(Error::TotalSupplyNotFound);
                }
                Some(Key::URef(uref)) => uref,
                Some(_) => return Err(Error::MissingKey),
            };
            // increase total supply
            self.add(total_supply_uref, initial_balance)?;
        }

        Ok(purse_uref)
    }
/// Mint new token with given `initial_balance` balance. Returns new purse on success, otherwise
/// an error.
Mint new token with given `initial_balance` balance. Returns new purse on success, otherwise
an error.
Mint new token with given ` initial_balance ` balance . Returns new purse on success otherwise an error .
fn mint(&mut self, initial_balance: U512) -> Result<URef, Error> {
        let caller = self.get_caller();
        let is_empty_purse = initial_balance.is_zero();
        if !is_empty_purse && caller != PublicKey::System.to_account_hash() {
            return Err(Error::InvalidNonEmptyPurseCreation);
        }
        let purse_uref: URef = self.new_uref(())?;
        self.write_balance(purse_uref, initial_balance)?;
        if !is_empty_purse {
            // get total supply uref if exists, otherwise error
            let total_supply_uref = match self.get_key(TOTAL_SUPPLY_KEY) {
                None => {
                    // total supply URef should exist due to genesis
                    return Err(Error::TotalSupplyNotFound);
                }
                Some(Key::URef(uref)) => uref,
                Some(_) => return Err(Error::MissingKey),
            };
            // increase total supply
            self.add(total_supply_uref, initial_balance)?;
        }
        Ok(purse_uref)
    }
fn mint ( & mut self , initial_balance : U512 ) -> Result < URef , Error > { let caller = self . get_caller ( ) ; let is_empty_purse = initial_balance . is_zero ( ) ; if ! is_empty_purse && caller != PublicKey :: System . to_account_hash ( ) { return Err ( Error :: InvalidNonEmptyPurseCreation ) ; } let purse_uref : URef = self . new_uref ( ( ) ) ? ; self . write_balance ( purse_uref , initial_balance ) ? ; if ! is_empty_purse { // get total supply uref if exists, otherwise error let total_supply_uref = match self . get_key ( TOTAL_SUPPLY_KEY ) { None => { // total supply URef should exist due to genesis return Err ( Error :: TotalSupplyNotFound ) ; } Some ( Key :: URef ( uref ) ) => uref , Some ( _ ) => return Err ( Error :: MissingKey ) , } ; // increase total supply self . add ( total_supply_uref , initial_balance ) ? ; } Ok ( purse_uref ) }
Mint new token with given `initial_balance` balance.
Mint new token with given ` initial_balance ` balance .
&mut self
initial_balance
U512
&mut self
initial_balance
U512