/// Burn the funds for canister creation or top up to prevent
/// accumulating a lot of dead accounts on the ledger.
Burn the funds for canister creation or top up to prevent
accumulating a lot of dead accounts on the ledger.
Burn the funds for canister creation or top up to prevent accumulating a lot of dead accounts on the ledger .
async fn burn(
    tn: &TransactionNotification,
    amount: Tokens,
    ledger_canister_id: &CanisterId,
) -> Result<(), String> {
    let minting_account_id = STATE.read().unwrap().minting_account_id;
    if let Some(minting_account_id) = minting_account_id {
        let send_args = SendArgs {
            memo: Memo::default(),
            amount,
            fee: Tokens::ZERO,
            from_subaccount: tn.to_subaccount,
            to: minting_account_id,
            created_at_time: None,
        };
        let res: Result<BlockHeight, (Option<i32>, String)> = dfn_core::api::call_with_cleanup(
            *ledger_canister_id,
            "send_pb",
            protobuf,
            send_args.clone(),
        )
        .await;
        let block = res.map_err(|(code, msg)| {
            format!(
                "Burning of {} ICPTs from {} failed with code {}: {:?}",
                send_args.amount,
                tn.from,
                code.unwrap_or_default(),
                msg
            )
        })?;
        print(format!(
            "Burning of {} ICPTs from {} done in block {}.",
            send_args.amount, tn.from, block
        ));
    }
    Ok(())
}
async fn burn ( tn : & TransactionNotification , amount : Tokens , ledger_canister_id : & CanisterId , ) -> Result < ( ) , String > { let minting_account_id = STATE . read ( ) . unwrap ( ) . minting_account_id ; if let Some ( minting_account_id ) = minting_account_id { let send_args = SendArgs { memo : Memo :: default ( ) , amount , fee : Tokens :: ZERO , from_subaccount : tn . to_subaccount , to : minting_account_id , created_at_time : None , } ; let res : Result < BlockHeight , ( Option < i32 > , String ) > = dfn_core :: api :: call_with_cleanup ( * ledger_canister_id , " " , protobuf , send_args . clone ( ) , ) . await ; let block = res . map_err ( | ( code , msg ) | { format ! ( " " send_args amount tn from code unwrap_or_default ( ) msg ) } ) ? ; print ( format ! ( " " send_args amount tn from block ) ) ; } Ok ( ( ) ) }
Burn the funds for canister creation or top up to prevent
accumulating a lot of dead accounts on the ledger.
Burn the funds for canister creation or top up to prevent accumulating a lot of dead accounts on the ledger .
tn
&TransactionNotification
amount
Tokens
ledger_canister_id
&CanisterId