pub fn mint_tokens_and_set_fees(number_of_addresses: Option<u32>, tokens_per_address: Option<u64>, fees: Option<String>, seed: Option<String>) -> VcxResult<()> {
    trace!("mint_tokens_and_set_fees >>> number_of_addresses: {:?}, tokens_per_address: {:?}, fees: {:?}, seed: {:?}",
           number_of_addresses, tokens_per_address, fees, seed);

    let did_1 = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();

    let fees = if fees.is_some() {
        fees.as_ref().map(String::as_str)
    } else {
        None
    };

    let (did_2, _) = add_new_did(Some("TRUSTEE"));
    let (did_3, _) = add_new_did(Some("TRUSTEE"));
    let (did_4, _) = add_new_did(Some("TRUSTEE"));

    let number_of_addresses = number_of_addresses.unwrap_or(1);

    if number_of_addresses > 0 {
        let tokens_per_address: u64 = tokens_per_address.unwrap_or(50_000_000_000);
        let mut addresses = Vec::new();

        for _n in 0..number_of_addresses {
            addresses.push(create_address(seed.clone()).unwrap())
        }

        let mint: Vec<Value> = addresses.clone().into_iter().enumerate().map(|(_i, payment_address)|
            json!( { "recipient": payment_address, "amount": tokens_per_address } )
        ).collect();
        let outputs = serde_json::to_string(&mint).unwrap();
        let (req, _) = payments::build_mint_req(get_wallet_handle(), Some(&did_1), &outputs, None).wait().unwrap();

        let sign1 = ::utils::libindy::ledger::multisign_request(&did_1, &req).unwrap();
        let sign2 = ::utils::libindy::ledger::multisign_request(&did_2, &sign1).unwrap();
        let sign3 = ::utils::libindy::ledger::multisign_request(&did_3, &sign2).unwrap();
        let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap();

        match ::utils::libindy::ledger::libindy_submit_request(&sign4) {
            Ok(_) => (),
            Err(x) => println!("failure minting tokens: {}", x),
        };
    }

    if let Some(fees_) = fees {
        let txn = payments::build_set_txn_fees_req(get_wallet_handle(), Some(&did_1), settings::get_payment_method()?.as_str(), fees_)
            .wait()?;

        let sign1 = ::utils::libindy::ledger::multisign_request(&did_1, &txn).unwrap();
        let sign2 = ::utils::libindy::ledger::multisign_request(&did_2, &sign1).unwrap();
        let sign3 = ::utils::libindy::ledger::multisign_request(&did_3, &sign2).unwrap();
        let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap();

        ::utils::libindy::ledger::libindy_submit_request(&sign4).unwrap();

        let txn_fees: HashMap<String, String> =
            ::serde_json::from_str::<HashMap<String, u64>>(fees_).unwrap()
                .iter_mut()
                .map(|(k, _v)| (k.to_string(), k.to_string()))
                .collect();

        auth_rule::set_actions_fee_aliases(&did_1, &json!(txn_fees).to_string()).unwrap();
    }

    Ok(())
}
// This is used for testing purposes only!!!
This is used for testing purposes only
This is used for testing purposes only
pub fn mint_tokens_and_set_fees(number_of_addresses: Option<u32>, tokens_per_address: Option<u64>, fees: Option<String>, seed: Option<String>) -> VcxResult<()> {
    trace!("mint_tokens_and_set_fees >>> number_of_addresses: {:?}, tokens_per_address: {:?}, fees: {:?}, seed: {:?}",
           number_of_addresses, tokens_per_address, fees, seed);
    let did_1 = settings::get_config_value(settings::CONFIG_INSTITUTION_DID).unwrap();
    let fees = if fees.is_some() {
        fees.as_ref().map(String::as_str)
    } else {
        None
    };
    let (did_2, _) = add_new_did(Some("TRUSTEE"));
    let (did_3, _) = add_new_did(Some("TRUSTEE"));
    let (did_4, _) = add_new_did(Some("TRUSTEE"));
    let number_of_addresses = number_of_addresses.unwrap_or(1);
    if number_of_addresses > 0 {
        let tokens_per_address: u64 = tokens_per_address.unwrap_or(50_000_000_000);
        let mut addresses = Vec::new();
        for _n in 0..number_of_addresses {
            addresses.push(create_address(seed.clone()).unwrap())
        }
        let mint: Vec<Value> = addresses.clone().into_iter().enumerate().map(|(_i, payment_address)|
            json!( { "recipient": payment_address, "amount": tokens_per_address } )
        ).collect();
        let outputs = serde_json::to_string(&mint).unwrap();
        let (req, _) = payments::build_mint_req(get_wallet_handle(), Some(&did_1), &outputs, None).wait().unwrap();
        let sign1 = ::utils::libindy::ledger::multisign_request(&did_1, &req).unwrap();
        let sign2 = ::utils::libindy::ledger::multisign_request(&did_2, &sign1).unwrap();
        let sign3 = ::utils::libindy::ledger::multisign_request(&did_3, &sign2).unwrap();
        let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap();
        match ::utils::libindy::ledger::libindy_submit_request(&sign4) {
            Ok(_) => (),
            Err(x) => println!("failure minting tokens: {}", x),
        };
    }
    if let Some(fees_) = fees {
        let txn = payments::build_set_txn_fees_req(get_wallet_handle(), Some(&did_1), settings::get_payment_method()?.as_str(), fees_)
            .wait()?;
        let sign1 = ::utils::libindy::ledger::multisign_request(&did_1, &txn).unwrap();
        let sign2 = ::utils::libindy::ledger::multisign_request(&did_2, &sign1).unwrap();
        let sign3 = ::utils::libindy::ledger::multisign_request(&did_3, &sign2).unwrap();
        let sign4 = ::utils::libindy::ledger::multisign_request(&did_4, &sign3).unwrap();
        ::utils::libindy::ledger::libindy_submit_request(&sign4).unwrap();
        let txn_fees: HashMap<String, String> =
            ::serde_json::from_str::<HashMap<String, u64>>(fees_).unwrap()
                .iter_mut()
                .map(|(k, _v)| (k.to_string(), k.to_string()))
                .collect();
        auth_rule::set_actions_fee_aliases(&did_1, &json!(txn_fees).to_string()).unwrap();
    }
    Ok(())
}
pub fn mint_tokens_and_set_fees ( number_of_addresses : Option < u32 > , tokens_per_address : Option < u64 > , fees : Option < String > , seed : Option < String > ) -> VcxResult < ( ) > { trace ! ( " " number_of_addresses tokens_per_address fees seed ) ; let did_1 = settings :: get_config_value ( settings :: CONFIG_INSTITUTION_DID ) . unwrap ( ) ; let fees = if fees . is_some ( ) { fees . as_ref ( ) . map ( String :: as_str ) } else { None } ; let ( did_2 , _ ) = add_new_did ( Some ( " " ) ) ; let ( did_3 , _ ) = add_new_did ( Some ( " " ) ) ; let ( did_4 , _ ) = add_new_did ( Some ( " " ) ) ; let number_of_addresses = number_of_addresses . unwrap_or ( 1 ) ; if number_of_addresses > 0 { let tokens_per_address : u64 = tokens_per_address . unwrap_or ( 50_000_000_000 ) ; let mut addresses = Vec :: new ( ) ; for _n in 0 .. number_of_addresses { addresses . push ( create_address ( seed . clone ( ) ) . unwrap ( ) ) } let mint : Vec < Value > = addresses . clone ( ) . into_iter ( ) . enumerate ( ) . map ( | ( _i , payment_address ) | json ! ( { " " payment_address " " tokens_per_address } ) ) . collect ( ) ; let outputs = serde_json :: to_string ( & mint ) . unwrap ( ) ; let ( req , _ ) = payments :: build_mint_req ( get_wallet_handle ( ) , Some ( & did_1 ) , & outputs , None ) . wait ( ) . unwrap ( ) ; let sign1 = :: utils :: libindy :: ledger :: multisign_request ( & did_1 , & req ) . unwrap ( ) ; let sign2 = :: utils :: libindy :: ledger :: multisign_request ( & did_2 , & sign1 ) . unwrap ( ) ; let sign3 = :: utils :: libindy :: ledger :: multisign_request ( & did_3 , & sign2 ) . unwrap ( ) ; let sign4 = :: utils :: libindy :: ledger :: multisign_request ( & did_4 , & sign3 ) . unwrap ( ) ; match :: utils :: libindy :: ledger :: libindy_submit_request ( & sign4 ) { Ok ( _ ) => ( ) , Err ( x ) => println ! ( " " x ) , } ; } if let Some ( fees_ ) = fees { let txn = payments :: build_set_txn_fees_req ( get_wallet_handle ( ) , Some ( & did_1 ) , settings :: get_payment_method ( ) ? . as_str ( ) , fees_ ) . wait ( ) ? ; let sign1 = :: utils :: libindy :: ledger :: multisign_request ( & did_1 , & txn ) . unwrap ( ) ; let sign2 = :: utils :: libindy :: ledger :: multisign_request ( & did_2 , & sign1 ) . unwrap ( ) ; let sign3 = :: utils :: libindy :: ledger :: multisign_request ( & did_3 , & sign2 ) . unwrap ( ) ; let sign4 = :: utils :: libindy :: ledger :: multisign_request ( & did_4 , & sign3 ) . unwrap ( ) ; :: utils :: libindy :: ledger :: libindy_submit_request ( & sign4 ) . unwrap ( ) ; let txn_fees : HashMap < String , String > = :: serde_json :: from_str :: < HashMap < String , u64 > > ( fees_ ) . unwrap ( ) . iter_mut ( ) . map ( | ( k , _v ) | ( k . to_string ( ) , k . to_string ( ) ) ) . collect ( ) ; auth_rule :: set_actions_fee_aliases ( & did_1 , & json ! ( txn_fees ) . to_string ( ) ) . unwrap ( ) ; } Ok ( ( ) ) }
This is used for testing purposes only!!
This is used for testing purposes only!!
number_of_addresses
Option<u32>
tokens_per_address
Option<u64>
fees
Option<String>
seed
Option<String>
number_of_addresses
Option<u32>
tokens_per_address
Option<u64>
fees
Option<String>
seed
Option<String>