junobuild_shared/ledger/icrc.rs
1use crate::ledger::types::icrc::IcrcTransferResult;
2use candid::Principal;
3use ic_cdk::api::call::CallResult;
4use ic_cdk::call;
5use icrc_ledger_types::icrc1::transfer::TransferArg;
6
7/// Initiates a transfer of tokens on a specified ledger using the provided ICRC-1 arguments.
8///
9/// This function performs a transfer using the `icrc1_transfer` method on the specified ledger
10/// and returns the result of the transfer operation.
11///
12/// # Arguments
13/// * `ledger_id` - A `Principal` representing the ID of the ledger where the transfer will be executed.
14/// * `args` - A `TransferArg` struct containing the details of the ICRC-1 transfer.
15///
16/// # Returns
17/// A `CallResult<IcrcTransferResult>` indicating either the success or failure of the ICRC-1 token transfer.
18pub async fn icrc_transfer_token(
19 ledger_id: Principal,
20 args: TransferArg,
21) -> CallResult<IcrcTransferResult> {
22 let (result,) = call(ledger_id, "icrc1_transfer", (args,)).await?;
23 Ok(result)
24}