ic_papi_api/caller.rs
1//! Types used primarily by the caller of the payment API.
2use candid::{CandidType, Deserialize, Principal};
3pub use ic_cycles_ledger_client::Account;
4
5/// How a caller states that they will pay.
6#[derive(Debug, CandidType, Deserialize, Clone, Eq, PartialEq)]
7#[non_exhaustive]
8pub enum PaymentType {
9 /// The caller is paying with cycles attached to the call.
10 ///
11 /// Note: This is available to inter-canister aclls only; not to ingress messages.
12 ///
13 /// Note: The API does not require additional arguments to support this payment type.
14 AttachedCycles,
15 /// The caller is paying with cycles from their main account on the cycles ledger.
16 CallerPaysIcrc2Cycles,
17 /// A patron is paying with cycles on behalf of the caller.
18 PatronPaysIcrc2Cycles(PatronPaysIcrc2Cycles),
19 /// The caller is paying with tokens from their main account on the specified ledger.
20 CallerPaysIcrc2Tokens(CallerPaysIcrc2Tokens),
21 /// A patron is paying, on behalf of the caller, from an account on the specified ledger.
22 PatronPaysIcrc2Tokens(PatronPaysIcrc2Tokens),
23}
24
25pub type PatronPaysIcrc2Cycles = Account;
26
27#[derive(Debug, CandidType, Deserialize, Copy, Clone, Eq, PartialEq)]
28pub struct CallerPaysIcrc2Tokens {
29 pub ledger: Principal,
30}
31
32#[derive(Debug, CandidType, Deserialize, Clone, Eq, PartialEq)]
33pub struct PatronPaysIcrc2Tokens {
34 pub ledger: Principal,
35 pub patron: Account,
36}
37
38pub type TokenAmount = u64;