pub trait ContractRevert:
AbiDecode
+ AbiEncode
+ Send
+ Sync {
// Required method
fn valid_selector(selector: [u8; 4]) -> bool;
// Provided method
fn decode_with_selector(data: &[u8]) -> Option<Self> { ... }
}Expand description
A trait for enums unifying EthError types. This trait is usually used
to represent the errors that a specific contract might throw. I.e. all
solidity custom errors + revert strings.
This trait should be accessed via
crate::ContractError::decode_contract_revert. It is generally
unnecessary to import this trait into your code.
§Implementor’s Note
We do not recommend manual implementations of this trait. Instead, use the
automatically generated implementation in the crate::abigen macro
However, sophisticated users may wish to represent the errors of multiple
contracts as a single unified enum. E.g. if your contract calls Uniswap,
you may wish to implement this on pub enum MyContractOrUniswapErrors.
In that case, it should be straightforward to delegate to the inner types.
Required Methods§
Sourcefn valid_selector(selector: [u8; 4]) -> bool
fn valid_selector(selector: [u8; 4]) -> bool
true if the selector corresponds to an error that this contract can
revert. False otherwise
Provided Methods§
Sourcefn decode_with_selector(data: &[u8]) -> Option<Self>
fn decode_with_selector(data: &[u8]) -> Option<Self>
Decode the error from EVM revert data including an Error selector
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.