1use candid::Principal;
2pub use ic_cycles_ledger_client::Account;
3use ic_ledger_types::Subaccount;
4use serde_bytes::ByteBuf;
5
6pub mod caller;
7pub mod cycles;
8pub mod error;
9pub mod vendor;
10pub use caller::PaymentType;
11pub use error::PaymentError;
12pub use vendor::Icrc2Payer;
13
14const SUB_ACCOUNT_ZERO: Subaccount = Subaccount([0; 32]);
15#[must_use]
16pub fn principal2account(principal: &Principal) -> ByteBuf {
17 let hex_str = ic_ledger_types::AccountIdentifier::new(principal, &SUB_ACCOUNT_ZERO).to_hex();
21 hex::decode(&hex_str)
22 .unwrap_or_else(|_| {
23 unreachable!(
24 "Failed to decode hex account identifier we just created: {}",
25 hex_str
26 )
27 })
28 .into()
29}