use candid::{CandidType, Deserialize, Nat};
use icrc_ledger_types::icrc1::account::Account;
use serde::Serialize;
#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct TransferArgs {
pub from_subaccount: Option<Vec<u8>>,
pub to: Account,
pub token_id: Nat,
pub memo: Option<Vec<u8>>,
pub created_at_time: Option<u64>,
}
impl TransferArgs {
pub fn new(to: Account, token_id: Nat) -> Self {
Self {
from_subaccount: None,
to,
token_id,
memo: None,
created_at_time: None,
}
}
}
pub type TransferResult = Result<Nat, TransferError>;
#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum TransferError {
NonExistingTokenId,
InvalidRecipient,
Unauthorized,
TooOld,
CreatedInFuture { ledger_time: u64 },
Duplicate { duplicate_of: Nat },
GenericError { error_code: Nat, message: String },
GenericBatchError { error_code: Nat, message: String },
}