1#![allow(missing_docs)]
2
3use cosmwasm_std::{Coin, Instantiate2AddressError};
4use cw_orch_core::CwEnvError;
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8pub enum DaemonError {
9 #[error(transparent)]
10 CosmwasmStd(#[from] cosmwasm_std::StdError),
11 #[error("Reqwest HTTP(s) Error")]
12 ReqwestError(#[from] ::reqwest::Error),
13 #[error("JSON Conversion Error")]
14 SerdeJson(#[from] ::serde_json::Error),
15 #[error(transparent)]
16 ParseIntError(#[from] std::num::ParseIntError),
17 #[error(transparent)]
18 ParseFloatError(#[from] std::num::ParseFloatError),
19 #[error(transparent)]
20 IOErr(#[from] ::std::io::Error),
21 #[error(transparent)]
22 Secp256k1(#[from] bitcoin::secp256k1::Error),
23 #[error(transparent)]
24 VarError(#[from] ::std::env::VarError),
25 #[error(transparent)]
26 AnyError(#[from] ::anyhow::Error),
27 #[error(transparent)]
28 Status(#[from] ::tonic::Status),
29 #[error(transparent)]
30 TransportError(#[from] ::tonic::transport::Error),
31 #[error(transparent)]
32 TendermintError(#[from] ::cosmrs::tendermint::Error),
33 #[error(transparent)]
34 CwEnvError(#[from] ::cw_orch_core::CwEnvError),
35 #[error(transparent)]
36 StripPrefixPath(#[from] std::path::StripPrefixError),
37 #[error("Bech32 Decode Error")]
38 Bech32DecodeErr,
39 #[error("Bech32 Decode Error: Key Failed prefix {0} or length {1} Wanted:{2}/{3}")]
40 Bech32DecodeExpanded(String, usize, String, usize),
41 #[error("Mnemonic - Wrong length, it should be 24 words")]
42 WrongLength,
43 #[error("Mnemonic - Bad Phrase")]
44 Phrasing,
45 #[error("Mnemonic - Missing Phrase")]
46 MissingPhrase,
47 #[error("Bad Implementation. Missing Component")]
48 Implementation,
49 #[error("Unable to convert into public key `{key}`: {source}")]
50 Conversion {
51 key: String,
52 source: bech32::DecodeError,
53 },
54 #[error("Can not augment daemon deployment after usage in more than one contract.")]
55 SharedDaemonState,
56 #[error(transparent)]
57 ErrReport(#[from] ::eyre::ErrReport),
58 #[error(transparent)]
59 GRpcDecodeError(#[from] ::prost::DecodeError),
60 #[error(transparent)]
61 ED25519(#[from] ::ed25519_dalek::ed25519::Error),
62 #[error(transparent)]
63 DecodeError(#[from] ::base64::DecodeError),
64 #[error(transparent)]
65 HexError(#[from] ::hex::FromHexError),
66 #[error(transparent)]
67 BitCoinBip32(#[from] ::bitcoin::bip32::Error),
68 #[error("83 length-missing SECP256K1 prefix")]
69 ConversionSECP256k1,
70 #[error("82 length-missing ED25519 prefix")]
71 ConversionED25519,
72 #[error("Expected Key length of 82 or 83 length was {0}")]
73 ConversionLength(usize),
74 #[error("Expected Key length of 40 length was {0}")]
75 ConversionLengthED25519Hex(usize),
76 #[error("Expected ED25519 key of length 32 with a BECH32 ED25519 prefix of 5 chars - Len {0} - Hex {1}")]
77 ConversionPrefixED25519(usize, String),
78 #[error("Can't call Transactions without some gas rules")]
79 NoGasOpts,
80 #[error("Can't parse `{parse}` into a coin")]
81 CoinParseErrV { parse: String },
82 #[error("Can't parse `{0}` into a coin")]
83 CoinParseErr(String),
84 #[error("TX submit returned `{0}` - {1} '{2}'")]
85 TxResultError(usize, String, String),
86 #[error("No price found for Gas using denom {0}")]
87 GasPriceError(String),
88 #[error("Attempting to fetch validator set in parts, and failed Height mismatch {0} {1}")]
89 TendermintValidatorSet(u64, u64),
90 #[error("Transaction {0} not found after {1} attempts")]
91 TXNotFound(String, usize),
92 #[error("unknown API error")]
93 Unknown,
94 #[error("Generic Error {0}")]
95 StdErr(String),
96 #[error("calling contract with unimplemented action")]
97 NotImplemented,
98 #[error("new chain detected, fill out the scaffold at {0}")]
99 NewChain(String),
100 #[error("new network detected, fill out the scaffold at {0}")]
101 NewNetwork(String),
102 #[error("Can not connect to any grpc endpoint that was provided.")]
103 CannotConnectGRPC,
104 #[error("tx failed: {reason} with code {code}")]
105 TxFailed { code: usize, reason: String },
106 #[error("The list of grpc endpoints is empty")]
107 GRPCListIsEmpty,
108 #[error("no wasm path provided for contract.")]
109 MissingWasmPath,
110 #[error("daemon builder missing {0}")]
111 BuilderMissing(String),
112 #[error("ibc error: {0}")]
113 IbcError(String),
114 #[error("insufficient fee, check gas price: {0}")]
115 InsufficientFee(String),
116 #[error("Not enough balance, expected {expected}, found {current}")]
117 NotEnoughBalance { expected: Coin, current: Coin },
118 #[error("Can't set the daemon state, it's read-only {0}")]
119 StateReadOnly(String),
120 #[error("You need to pass a runtime to the querier object to do synchronous queries. Use daemon.querier instead")]
121 QuerierNeedRuntime,
122 #[error(transparent)]
123 Instantiate2Error(#[from] Instantiate2AddressError),
124 #[error(transparent)]
125 CheckSum(#[from] cosmwasm_std::ChecksumError),
126 #[error("Error opening file {0},err: ({1})")]
127 OpenFile(String, String),
128 #[error("State file {0} already locked, use another state file, clone daemon which holds the lock, or use `state` method of Builder")]
129 StateAlreadyLocked(String),
130}
131
132impl DaemonError {
133 pub fn ibc_err(msg: impl ToString) -> Self {
134 Self::IbcError(msg.to_string())
135 }
136}
137
138impl From<DaemonError> for CwEnvError {
139 fn from(val: DaemonError) -> Self {
140 CwEnvError::AnyError(val.into())
141 }
142}