1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use candid::CandidType;
use serde::Deserialize;

use crate::icrc_7::ext_types::{AccountIdentifierHex, TokenIdentifier};

#[derive(CandidType, Deserialize, Clone, Debug)]
pub enum TransferError {
    NonExistingTokenId,
    InvalidRecipient,
    Unauthorized,
    TooOld,
    CreatedInFuture { ledger_time: u64 },
    Duplicate { duplicate_of: u128 },
    GenericError { error_code: u128, message: String },
    GenericBatchError { error_code: u128, message: String },
}

#[derive(CandidType, Clone)]
pub enum ApprovalError {
    Unauthorized { tokens_ids: Vec<u128> },
    TooOld,
    TemporaryUnavailable,
    NonExistingTokenId,
    InvalidSpender,
    GenericError { error_code: u128, message: String },
    GenericBatchError { error_code: u128, message: String },
}

#[derive(CandidType, Clone)]
pub enum BurnError {
    Unauthorized,
    NonExistingTokenId,
    GenericError { error_code: u128, message: String },
    GenericBatchError { error_code: u128, message: String },
}

#[derive(CandidType, Clone, Deserialize, Debug)]
pub enum MintError {
    SupplyCapReached,
    Unauthorized,
    TokenIdAlreadyExist,
    TokenIdMinimumLimit,
    GenericError { error_code: u128, message: String },
    GenericBatchError { error_code: u128, message: String },
}

#[derive(CandidType, Deserialize, Clone, Debug)]
pub enum ExtCommonError {
    InvalidToken(TokenIdentifier),
    Other(String),
}

#[derive(CandidType, Deserialize, Clone, Debug)]
pub enum ExtTransferError {
    Unauthorized(AccountIdentifierHex),
    InsufficientBalance,
    Rejected,
    InvalidToken(TokenIdentifier),
    CannotNotify(AccountIdentifierHex),
    Other(String),
}

#[derive(CandidType, Debug, PartialEq, Deserialize)]
pub enum InsertTransactionError {
    SyncPending,
    NotSetArchiveCanister,
    RemoteError,
    Unexpected(String),
    CantWrite,
    InvalidId,
}