fn ensure_account_has_funds(api: &mut Api<sr25519::Pair>, accountid: &AccountId32) {
    let alice = AccountKeyring::Alice.pair();
    info!("encoding Alice's public 	= {:?}", alice.public().0.encode());
    let alice_acc = AccountId32::from(*alice.public().as_array_ref());
    info!("encoding Alice's AccountId = {:?}", alice_acc.encode());

    let free = get_balance(&api, &alice_acc);
    info!("    Alice's free balance = {:?}", free);
    let nonce = get_nonce(&api, &alice_acc);
    info!("    Alice's Account Nonce is {}", nonce);

    // check account balance
    let free = get_balance(&api, &accountid);
    info!("TEE's free balance = {:?}", free);

    if free < 1_000_000_000_000 {
        let signer_orig = api.signer.clone();
        api.signer = Some(alice);

        println!("[+] bootstrap funding Enclave form Alice's funds");
        let xt = api.balance_transfer(GenericAddress::Id(accountid.clone()), 1_000_000_000_000);
        let xt_hash = api
            .send_extrinsic(xt.hex_encode(), XtStatus::InBlock)
            .unwrap();
        info!("[<] Extrinsic got finalized. Hash: {:?}\n", xt_hash);

        //verify funds have arrived
        let free = get_balance(&api, &accountid);
        info!("TEE's NEW free balance = {:?}", free);

        api.signer = signer_orig;
    }
}
// Alice plays the faucet and sends some funds to the account if balance is low
Alice plays the faucet and sends some funds to the account if balance is low
Alice plays the faucet and sends some funds to the account if balance is low
fn ensure_account_has_funds(api: &mut Api<sr25519::Pair>, accountid: &AccountId32) {
    let alice = AccountKeyring::Alice.pair();
    info!("encoding Alice's public 	= {:?}", alice.public().0.encode());
    let alice_acc = AccountId32::from(*alice.public().as_array_ref());
    info!("encoding Alice's AccountId = {:?}", alice_acc.encode());
    let free = get_balance(&api, &alice_acc);
    info!("    Alice's free balance = {:?}", free);
    let nonce = get_nonce(&api, &alice_acc);
    info!("    Alice's Account Nonce is {}", nonce);
    // check account balance
    let free = get_balance(&api, &accountid);
    info!("TEE's free balance = {:?}", free);
    if free < 1_000_000_000_000 {
        let signer_orig = api.signer.clone();
        api.signer = Some(alice);
        println!("[+] bootstrap funding Enclave form Alice's funds");
        let xt = api.balance_transfer(GenericAddress::Id(accountid.clone()), 1_000_000_000_000);
        let xt_hash = api
            .send_extrinsic(xt.hex_encode(), XtStatus::InBlock)
            .unwrap();
        info!("[<] Extrinsic got finalized. Hash: {:?}\n", xt_hash);
        //verify funds have arrived
        let free = get_balance(&api, &accountid);
        info!("TEE's NEW free balance = {:?}", free);
        api.signer = signer_orig;
    }
}
fn ensure_account_has_funds ( api : & mut Api < sr25519 :: Pair > , accountid : & AccountId32 ) { let alice = AccountKeyring :: Alice . pair ( ) ; info ! ( " " alice public ( ) 0 encode ( ) ) ; let alice_acc = AccountId32 :: from ( * alice . public ( ) . as_array_ref ( ) ) ; info ! ( " " alice_acc encode ( ) ) ; let free = get_balance ( & api , & alice_acc ) ; info ! ( " " free ) ; let nonce = get_nonce ( & api , & alice_acc ) ; info ! ( " " nonce ) ; // check account balance let free = get_balance ( & api , & accountid ) ; info ! ( " " free ) ; if free < 1_000_000_000_000 { let signer_orig = api . signer . clone ( ) ; api . signer = Some ( alice ) ; println ! ( " " ) ; let xt = api . balance_transfer ( GenericAddress :: Id ( accountid . clone ( ) ) , 1_000_000_000_000 ) ; let xt_hash = api . send_extrinsic ( xt . hex_encode ( ) , XtStatus :: InBlock ) . unwrap ( ) ; info ! ( " \n " xt_hash ) ; //verify funds have arrived let free = get_balance ( & api , & accountid ) ; info ! ( " " free ) ; api . signer = signer_orig ; } }
Alice plays the faucet and sends some funds to the account if balance is low
Alice plays the faucet and sends some funds to the account if balance is low
api
&mut Api<sr25519::Pair>
accountid
&AccountId32
api
&mut Api<sr25519::Pair>
accountid
&AccountId32