diff --git a/src/erc165/mod.rs b/src/erc165/mod.rs index c825394..12c15e5 100644 --- a/src/erc165/mod.rs +++ b/src/erc165/mod.rs @@ -1,3 +1,4 @@ +use thiserror::Error; use alloy_primitives::Address; use alloy_sol_types::{sol, SolCall, SolInterface}; use alloy_ethers_typecast::transaction::{ReadContractParameters, ReadableClientHttp}; @@ -5,6 +6,12 @@ use alloy_ethers_typecast::transaction::{ReadContractParameters, ReadableClientH // IERC165 contract alloy bindings sol!("lib/forge-std/src/interfaces/IERC165.sol"); +#[derive(Error, Debug)] +pub enum XorSelectorsError { + #[error("no selectors")] + NoSelectors, +} + /// Calculates XOR of the selectors of a type that implements SolInterface pub trait XorSelectors { /// get xor of all the selectors. @@ -16,10 +23,10 @@ pub trait XorSelectors { /// /// related info can be found here: /// https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified - fn xor_selectors() -> anyhow::Result<[u8; 4]> { + fn xor_selectors() -> Result<[u8; 4], XorSelectorsError> { let selectors = T::selectors().collect::>(); if selectors.is_empty() { - return Err(anyhow::anyhow!("no selectors")); + return Err(XorSelectorsError::NoSelectors); } let mut result = u32::from_be_bytes(selectors[0]); for selector in &selectors[1..] {