Skip to main content

abstract_account/
error.rs

1use abstract_sdk::std::objects::module::ModuleInfo;
2use abstract_std::{
3    objects::{registry::RegistryError, validation::ValidationError},
4    AbstractError,
5};
6use cosmwasm_std::{Instantiate2AddressError, StdError};
7use thiserror::Error;
8
9#[derive(Error, Debug, PartialEq)]
10pub enum AccountError {
11    #[error(transparent)]
12    Std(#[from] StdError),
13
14    #[error(transparent)]
15    Abstract(#[from] AbstractError),
16
17    #[error(transparent)]
18    Validation(#[from] ValidationError),
19
20    #[error(transparent)]
21    Ownership(#[from] abstract_std::objects::ownership::GovOwnershipError),
22
23    #[error(transparent)]
24    Instantiate2AddressError(#[from] Instantiate2AddressError),
25
26    #[error(transparent)]
27    RegistryError(#[from] RegistryError),
28
29    #[error("Your account is currently suspended")]
30    AccountSuspended {},
31
32    // ** Modules Error ** //
33    #[error("Failed to query modules to install: {error}")]
34    QueryModulesFailed { error: RegistryError },
35
36    #[error("Module with id: {0} is already installed")]
37    ModuleAlreadyInstalled(String),
38
39    #[error("Reinstalls of same version of app or standalone are not allowed")]
40    ProhibitedReinstall {},
41
42    #[error("The provided module {0} can't be installed on an Abstract account")]
43    ModuleNotInstallable(String),
44
45    #[error("The module {0} needs an init msg to be installed but not was provided")]
46    InitMsgMissing(String),
47
48    #[error("The name of the proposed module can not have length 0.")]
49    InvalidModuleName {},
50
51    #[error("The provided module {0} was not found")]
52    ModuleNotFound(String),
53
54    #[error("Cannot migrate {} twice", module_id)]
55    DuplicateModuleMigration { module_id: String },
56
57    #[error("{0} not upgradeable")]
58    NotUpgradeable(ModuleInfo),
59
60    #[error("Cannot remove module because {0:?} depend(s) on it.")]
61    ModuleHasDependents(Vec<String>),
62
63    #[error("Module {module_id} with version {version} does not fit requirement {comp}, post_migration: {post_migration}")]
64    VersionRequirementNotMet {
65        module_id: String,
66        version: String,
67        comp: String,
68        post_migration: bool,
69    },
70
71    #[error("module {0} is a dependency of {1} and is not installed.")]
72    DependencyNotMet(String, String),
73
74    #[error("Max amount of modules registered")]
75    ModuleLimitReached {},
76
77    #[error("Module with address {0} is already whitelisted")]
78    AlreadyWhitelisted(String),
79
80    #[error("can't remove module that is not whitelisted")]
81    NotWhitelisted {},
82
83    // ** Sub Account ** //
84    #[error("Sub account doesn't exist")]
85    SubAccountDoesntExist {},
86
87    #[error("Sub account is expected to be the caller")]
88    SubAccountIsNotCaller {},
89
90    #[error("Register of sub account failed")]
91    SubAccountRegisterFailed {},
92
93    #[error("Can't renounce account, with active sub account")]
94    RenounceWithSubAccount {},
95
96    // ** Other Errors ** //
97    #[error("No updates were included")]
98    NoUpdates {},
99
100    #[error("invalid configuration action, {}", error)]
101    InvalidConfigAction { error: StdError },
102
103    #[error("The provided contract version {0} is lower than the current version {1}")]
104    OlderVersion(String, String),
105
106    #[error("Sender is not whitelisted and is not a valid owner")]
107    SenderNotWhitelistedOrOwner {},
108
109    #[error("Contract got an unexpected Reply")]
110    UnexpectedReply(),
111
112    #[error("The caller ({caller}) is not the owner account's account ({account}). Only account can create sub-accounts for itself.", )]
113    SubAccountCreatorNotAccount { caller: String, account: String },
114
115    #[error("You can't chain admin calls")]
116    CantChainAdminCalls {},
117
118    #[error("Abstract Account Address ({abstract_account}) doesn't match to the Contract address ({contract})   ")]
119    AbstractAccountInvalidAddress {
120        abstract_account: String,
121        contract: String,
122    },
123
124    #[error("No auth methods capabilities on this account (xion feature disabled)")]
125    NoAuthFeature {},
126
127    #[error("Abstract Account don't have Authentication")]
128    AbstractAccountNoAuth {},
129
130    #[error("The new_code_id field needs to be filled when migrating from a xion account")]
131    MissingCodeIdToMigrate {},
132
133    #[cfg(feature = "xion")]
134    #[error(transparent)]
135    AbstractXion(#[from] abstract_xion::error::ContractError),
136}