wormhole/
error.rs

1use cosmwasm_std::StdError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ContractError {
6    /// Invalid VAA version
7    #[error("InvalidVersion")]
8    InvalidVersion,
9
10    /// Guardian set with this index does not exist
11    #[error("InvalidGuardianSetIndex")]
12    InvalidGuardianSetIndex,
13
14    /// Guardian set expiration date is zero or in the past
15    #[error("GuardianSetExpired")]
16    GuardianSetExpired,
17
18    /// Not enough signers on the VAA
19    #[error("NoQuorum")]
20    NoQuorum,
21
22    /// Wrong guardian index order, order must be ascending
23    #[error("WrongGuardianIndexOrder")]
24    WrongGuardianIndexOrder,
25
26    /// Some problem with signature decoding from bytes
27    #[error("CannotDecodeSignature")]
28    CannotDecodeSignature,
29
30    /// Some problem with public key recovery from the signature
31    #[error("CannotRecoverKey")]
32    CannotRecoverKey,
33
34    /// Recovered pubkey from signature does not match guardian address
35    #[error("GuardianSignatureError")]
36    GuardianSignatureError,
37
38    /// VAA action code not recognized
39    #[error("InvalidVAAAction")]
40    InvalidVAAAction,
41
42    /// VAA guardian set is not current
43    #[error("NotCurrentGuardianSet")]
44    NotCurrentGuardianSet,
45
46    /// Only 128-bit amounts are supported
47    #[error("AmountTooHigh")]
48    AmountTooHigh,
49
50    /// Amount should be higher than zero
51    #[error("AmountTooLow")]
52    AmountTooLow,
53
54    /// Source and target chain ids must be different
55    #[error("SameSourceAndTarget")]
56    SameSourceAndTarget,
57
58    /// Target chain id must be the same as the current CHAIN_ID
59    #[error("WrongTargetChain")]
60    WrongTargetChain,
61
62    /// Wrapped asset init hook sent twice for the same asset id
63    #[error("AssetAlreadyRegistered")]
64    AssetAlreadyRegistered,
65
66    /// Guardian set must increase in steps of 1
67    #[error("GuardianSetIndexIncreaseError")]
68    GuardianSetIndexIncreaseError,
69
70    /// VAA was already executed
71    #[error("VaaAlreadyExecuted")]
72    VaaAlreadyExecuted,
73
74    /// Message sender not permitted to execute this operation
75    #[error("PermissionDenied")]
76    PermissionDenied,
77
78    /// Could not decode target address from canonical to human-readable form
79    #[error("WrongTargetAddressFormat")]
80    WrongTargetAddressFormat,
81
82    /// More signatures than active guardians found
83    #[error("TooManySignatures")]
84    TooManySignatures,
85
86    /// Wrapped asset not found in the registry
87    #[error("AssetNotFound")]
88    AssetNotFound,
89
90    /// Generic error when there is a problem with VAA structure
91    #[error("InvalidVAA")]
92    InvalidVAA,
93
94    /// Thrown when fee is enabled for the action, but was not sent with the transaction
95    #[error("FeeTooLow")]
96    FeeTooLow,
97
98    /// Registering asset outside of the wormhole
99    #[error("RegistrationForbidden")]
100    RegistrationForbidden,
101}
102
103impl ContractError {
104    pub fn std(&self) -> StdError {
105        StdError::GenericErr {
106            msg: format!("{}", self),
107        }
108    }
109
110    pub fn std_err<T>(&self) -> Result<T, StdError> {
111        Err(self.std())
112    }
113}