pub fn add_currency(&mut self, space_delim_strings: &[&str], is_blocking: bool) -> Result<()> {
        ensure!(
            space_delim_strings.len() >= 3 && space_delim_strings.len() <= 6,
            "Invalid number of arguments for adding currency"
        );

        let (sender_address, _) =
            self.get_account_address_from_parameter(space_delim_strings[1])?;
        let sender_ref_id = self.get_account_ref_id(&sender_address)?;
        let sender = self.accounts.get(sender_ref_id).unwrap();
        let sequence_number = sender.sequence_number;

        let currency_to_add = space_delim_strings[2];
        let currency_code = from_currency_code_string(currency_to_add).map_err(|_| {
            format_err!(
                "Invalid currency code {} provided to add currency",
                currency_to_add
            )
        })?;

        let gas_unit_price = if space_delim_strings.len() > 3 {
            Some(space_delim_strings[3].parse::<u64>().map_err(|error| {
                format_parse_data_error(
                    "gas_unit_price",
                    InputType::UnsignedInt,
                    space_delim_strings[3],
                    error,
                )
            })?)
        } else {
            None
        };

        let max_gas_amount = if space_delim_strings.len() > 4 {
            Some(space_delim_strings[4].parse::<u64>().map_err(|error| {
                format_parse_data_error(
                    "max_gas_amount",
                    InputType::UnsignedInt,
                    space_delim_strings[4],
                    error,
                )
            })?)
        } else {
            None
        };

        let gas_currency_code = if space_delim_strings.len() > 5 {
            Some(space_delim_strings[5].to_owned())
        } else {
            None
        };

        let program = transaction_builder::encode_add_currency_to_account_script(
            type_tag_for_currency_code(currency_code),
        );

        let txn = self.create_txn_to_submit(
            TransactionPayload::Script(program),
            &sender,
            max_gas_amount,    /* max_gas_amount */
            gas_unit_price,    /* gas_unit_price */
            gas_currency_code, /* gas_currency_code */
        )?;

        self.client
            .submit_transaction(self.accounts.get_mut(sender_ref_id), txn)?;
        if is_blocking {
            self.wait_for_transaction(sender_address, sequence_number)?;
        }
        Ok(())
    }
/// Adds a currency to the sending account. Fails if that currency already exists.
Adds a currency to the sending account. Fails if that currency already exists.
Adds a currency to the sending account . Fails if that currency already exists .
pub fn add_currency(&mut self, space_delim_strings: &[&str], is_blocking: bool) -> Result<()> {
        ensure!(
            space_delim_strings.len() >= 3 && space_delim_strings.len() <= 6,
            "Invalid number of arguments for adding currency"
        );
        let (sender_address, _) =
            self.get_account_address_from_parameter(space_delim_strings[1])?;
        let sender_ref_id = self.get_account_ref_id(&sender_address)?;
        let sender = self.accounts.get(sender_ref_id).unwrap();
        let sequence_number = sender.sequence_number;
        let currency_to_add = space_delim_strings[2];
        let currency_code = from_currency_code_string(currency_to_add).map_err(|_| {
            format_err!(
                "Invalid currency code {} provided to add currency",
                currency_to_add
            )
        })?;
        let gas_unit_price = if space_delim_strings.len() > 3 {
            Some(space_delim_strings[3].parse::<u64>().map_err(|error| {
                format_parse_data_error(
                    "gas_unit_price",
                    InputType::UnsignedInt,
                    space_delim_strings[3],
                    error,
                )
            })?)
        } else {
            None
        };
        let max_gas_amount = if space_delim_strings.len() > 4 {
            Some(space_delim_strings[4].parse::<u64>().map_err(|error| {
                format_parse_data_error(
                    "max_gas_amount",
                    InputType::UnsignedInt,
                    space_delim_strings[4],
                    error,
                )
            })?)
        } else {
            None
        };
        let gas_currency_code = if space_delim_strings.len() > 5 {
            Some(space_delim_strings[5].to_owned())
        } else {
            None
        };
        let program = transaction_builder::encode_add_currency_to_account_script(
            type_tag_for_currency_code(currency_code),
        );
        let txn = self.create_txn_to_submit(
            TransactionPayload::Script(program),
            &sender,
            max_gas_amount,    /* max_gas_amount */
            gas_unit_price,    /* gas_unit_price */
            gas_currency_code, /* gas_currency_code */
        )?;
        self.client
            .submit_transaction(self.accounts.get_mut(sender_ref_id), txn)?;
        if is_blocking {
            self.wait_for_transaction(sender_address, sequence_number)?;
        }
        Ok(())
    }
pub fn add_currency ( & mut self , space_delim_strings : & [ & str ] , is_blocking : bool ) -> Result < ( ) > { ensure ! ( space_delim_strings len ( ) 3 space_delim_strings len ( ) 6 " " ) ; let ( sender_address , _ ) = self . get_account_address_from_parameter ( space_delim_strings [ 1 ] ) ? ; let sender_ref_id = self . get_account_ref_id ( & sender_address ) ? ; let sender = self . accounts . get ( sender_ref_id ) . unwrap ( ) ; let sequence_number = sender . sequence_number ; let currency_to_add = space_delim_strings [ 2 ] ; let currency_code = from_currency_code_string ( currency_to_add ) . map_err ( | _ | { format_err ! ( " " currency_to_add ) } ) ? ; let gas_unit_price = if space_delim_strings . len ( ) > 3 { Some ( space_delim_strings [ 3 ] . parse :: < u64 > ( ) . map_err ( | error | { format_parse_data_error ( " " , InputType :: UnsignedInt , space_delim_strings [ 3 ] , error , ) } ) ? ) } else { None } ; let max_gas_amount = if space_delim_strings . len ( ) > 4 { Some ( space_delim_strings [ 4 ] . parse :: < u64 > ( ) . map_err ( | error | { format_parse_data_error ( " " , InputType :: UnsignedInt , space_delim_strings [ 4 ] , error , ) } ) ? ) } else { None } ; let gas_currency_code = if space_delim_strings . len ( ) > 5 { Some ( space_delim_strings [ 5 ] . to_owned ( ) ) } else { None } ; let program = transaction_builder :: encode_add_currency_to_account_script ( type_tag_for_currency_code ( currency_code ) , ) ; let txn = self . create_txn_to_submit ( TransactionPayload :: Script ( program ) , & sender , max_gas_amount , /* max_gas_amount */ gas_unit_price , /* gas_unit_price */ gas_currency_code , /* gas_currency_code */ ) ? ; self . client . submit_transaction ( self . accounts . get_mut ( sender_ref_id ) , txn ) ? ; if is_blocking { self . wait_for_transaction ( sender_address , sequence_number ) ? ; } Ok ( ( ) ) }
Adds a currency to the sending account.
Adds a currency to the sending account .
&mut self
space_delim_strings
&[&str]
is_blocking
bool
&mut self
space_delim_strings
&[&str]
is_blocking
bool