use cosmwasm_std::{WasmMsg, WasmQuery};
macro_rules! std_error_bail {
($msg:literal $(,)?) => {
return Err(StdError::msg($msg))
};
($err:expr $(,)?) => {
return Err(StdError::msg($err))
};
($fmt:expr, $($arg:tt)*) => {
return Err(StdError::msg(format!($fmt, $($arg)*)))
};
}
pub(crate) use std_error_bail;
macro_rules! std_error {
($msg:literal $(,)?) => {
StdError::msg($msg)
};
($err:expr $(,)?) => {
StdError::msg($err)
};
($fmt:expr, $($arg:tt)*) => {
StdError::msg(format!($fmt, $($arg)*))
};
}
pub(crate) use std_error;
pub fn empty_attribute_key(value: impl Into<String>) -> String {
format!("Empty attribute key. Value: {0}", value.into())
}
pub fn reserved_attribute_key(key: impl Into<String>) -> String {
format!(
"Attribute key starts with reserved prefix _: {0}",
key.into()
)
}
pub fn event_type_too_short(ty: impl Into<String>) -> String {
format!("Event type too short: {0}", ty.into())
}
pub fn unsupported_wasm_query(query: WasmQuery) -> String {
format!("Unsupported wasm query: {query:?}")
}
pub fn unsupported_wasm_message(msg: WasmMsg) -> String {
format!("Unsupported wasm message: {msg:?}")
}
pub fn invalid_code_id() -> String {
"code id: invalid".to_string()
}
pub fn unregistered_code_id(code_id: u64) -> String {
format!("code id {code_id}: no such code")
}
pub fn duplicated_code_id(code_id: u64) -> String {
format!("duplicated code id {code_id}")
}
pub fn no_more_code_id_available() -> String {
"no more code identifiers available".to_string()
}
pub fn duplicated_contract_address(addr: impl Into<String>) -> String {
format!(
"Contract with this address already exists: {0}",
addr.into()
)
}