1use cosmwasm_std::{Addr, OverflowError, StdError, Uint128};
2use cw_utils::PaymentError;
3use thiserror::Error;
4
5#[derive(Error, Debug, PartialEq)]
6pub enum ContractError {
7 #[error("{0}")]
8 Std(#[from] StdError),
9
10 #[error("{0}")]
11 PaymentError(#[from] PaymentError),
12
13 #[error("{0}")]
14 OverflowError(#[from] OverflowError),
15
16 #[error("Unauthorized")]
17 Unauthorized {},
18
19 #[error("The total allocation for all recipients cannot exceed total ASTRO amount allocated to unlock (currently {0} ASTRO)")]
20 TotalAllocationExceedsAmount(Uint128),
21
22 #[error("Insufficient unallocated ASTRO to increase allocation. Contract has: {0} unallocated ASTRO")]
23 UnallocatedTokensExceedsTotalDeposited(Uint128),
24
25 #[error("Proposed receiver not set")]
26 ProposedReceiverNotSet {},
27
28 #[error("Only contract owner can transfer unallocated ASTRO")]
29 UnallocatedTransferUnauthorized {},
30
31 #[error("Insufficient unallocated ASTRO to transfer. Contract has: {0} unallocated ASTRO")]
32 InsufficientUnallocatedTokens(Uint128),
33
34 #[error("ASTRO deposit amount mismatch. Expected: {expected}, got: {got}")]
35 DepositAmountMismatch { expected: Uint128, got: Uint128 },
36
37 #[error("Allocation (params) already exists for {user}")]
38 AllocationExists { user: String },
39
40 #[error("You may not withdraw once you proposed new receiver!")]
41 WithdrawErrorWhenProposedReceiver {},
42
43 #[error("No unlocked ASTRO to be withdrawn")]
44 NoUnlockedAstro {},
45
46 #[error("Proposed receiver already set to {proposed_receiver}")]
47 ProposedReceiverAlreadySet { proposed_receiver: Addr },
48
49 #[error("Invalid new_receiver. Proposed receiver already has an ASTRO allocation")]
50 ProposedReceiverAlreadyHasAllocation {},
51
52 #[error("Only the contract owner can decrease allocations")]
53 UnauthorizedDecreaseAllocation {},
54
55 #[error(
56 "Insufficient amount of lock to decrease allocation, user has locked {locked_amount} ASTRO"
57 )]
58 InsufficientLockedAmount { locked_amount: Uint128 },
59
60 #[error("Proposed receiver is either not set or doesn't match the message sender")]
61 ProposedReceiverMismatch {},
62
63 #[error("{address} doesn't have allocation")]
64 NoAllocation { address: String },
65}