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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use abstract_sdk::AbstractSdkError;
use abstract_std::{
    objects::{module::ModuleInfo, namespace::Namespace, validation::ValidationError, AccountId},
    AbstractError,
};
use cosmwasm_std::{Addr, Coin, StdError};
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum VCError {
    #[error("{0}")]
    Std(#[from] StdError),

    #[error("{0}")]
    Abstract(#[from] AbstractError),

    #[error("{0}")]
    AbstractSdk(#[from] AbstractSdkError),

    #[error("{0}")]
    Validation(#[from] ValidationError),

    #[error("{0}")]
    Ownership(#[from] cw_ownable::OwnershipError),

    #[error("Semver parsing error: {0}")]
    SemVer(String),

    #[error("Module {0} does not have a stored module reference")]
    ModuleNotFound(ModuleInfo),

    #[error("Module {0} is in both approve and reject")]
    InvalidApproveList(ModuleInfo),

    #[error("Module {0} cannot be updated")]
    NotUpdateableModule(ModuleInfo),

    #[error("Account ID {} is not in version control register", id)]
    UnknownAccountId { id: AccountId },

    #[error("Namespace {} is not in version control register", namespace)]
    UnknownNamespace { namespace: Namespace },

    #[error("Account owner mismatch sender: {}, owner: {}", sender, owner)]
    AccountOwnerMismatch { sender: Addr, owner: Addr },

    #[error("Account with ID {} has no owner", account_id)]
    NoAccountOwner { account_id: AccountId },

    #[error("Namespace {} is already occupied by account {}", namespace, id)]
    NamespaceOccupied { namespace: String, id: AccountId },

    #[error("Exceeds namespace limit: {}, current: {}", limit, current)]
    ExceedsNamespaceLimit { limit: usize, current: usize },

    #[error(
        "Decreasing namespace limit is not allowed: {}, current: {}",
        limit,
        current
    )]
    DecreaseNamespaceLimit { limit: u32, current: u32 },

    #[error("As namespace owner you can only yank a module, not remove it.")]
    OnlyYankAllowed,

    #[error("The admin of an adapter must be None")]
    AdminMustBeNone,

    #[error("No action specified")]
    NoAction,

    #[error("Account {0} already exists")]
    AccountAlreadyExists(AccountId),

    #[error("Invalid fee payment sent. Expected {}, sent {:?}", expected, sent)]
    InvalidFeePayment { expected: Coin, sent: Vec<Coin> },

    #[error("Initialization funds can only be specified for apps and standalone modules")]
    RedundantInitFunds {},

    #[error("Only account factory is allowed to add new accounts")]
    NotAccountFactory {},
}

impl From<cw_semver::Error> for VCError {
    fn from(err: cw_semver::Error) -> Self {
        Self::SemVer(err.to_string())
    }
}