1use hex::FromHexError;
2use thiserror::Error;
3
4use cosmwasm_std::StdError;
5
6#[derive(Error, Debug, PartialEq)]
7pub enum StakingApiError {
8 #[error("{0}")]
9 Std(#[from] StdError),
10 #[error("Invalid address string: {0}")]
11 InvalidAddressString(String),
12 #[error("{0}")]
13 HexError(#[from] FromHexError),
14 #[error("Staking tx hash hex string is not {0} chars long")]
15 InvalidStakingTxHash(usize),
16 #[error("Invalid Btc tx: {0}")]
17 InvalidBtcTx(String),
18 #[error("Empty Btc public key")]
19 EmptyBtcPk,
20 #[error("Empty Btc private key")]
21 EmptyBtcSk,
22 #[error("Empty proof of possession")]
23 MissingPop,
24 #[error("Empty chain id")]
25 EmptyChainId,
26 #[error("No Finality Providers Btc public keys")]
27 EmptyBtcPkList,
28 #[error("Duplicate Finality Provider Btc public key: {0}")]
29 DuplicatedBtcPk(String),
30 #[error("Empty Staking tx")]
31 EmptyStakingTx,
32 #[error("Empty Slashing tx")]
33 EmptySlashingTx,
34 #[error("Empty unbonding tx")]
35 EmptyUnbondingTx,
36 #[error("Invalid unbonding time blocks: {0}, max: {1}")]
37 ErrInvalidUnbondingTime(u32, u32),
38 #[error("Empty signature from the delegator")]
39 EmptySignature,
40 #[error("Description error: {0}")]
41 DescriptionErr(String),
42}
43
44impl StakingApiError {
45 pub fn description_err(msg: impl Into<String>) -> Self {
46 StakingApiError::DescriptionErr(msg.into())
47 }
48}