Extends the provided error map with errors from a contract's error collection. For each error, it extracts the Solidity selector (first 4 bytes of the error signature), hex-encodes it, and maps that selector to a clone of the `AbiError`. If a selector already exists in the map, a warning is logged.
(
map: &mut BTreeMap<String, AbiError>,
contract_errors: BTreeMap<String, Vec<AbiError>>,
)
| 37 | /// |
| 38 | /// If a selector already exists in the map, a warning is logged. |
| 39 | pub fn extend_errors( |
| 40 | map: &mut BTreeMap<String, AbiError>, |
| 41 | contract_errors: BTreeMap<String, Vec<AbiError>>, |
| 42 | ) { |
| 43 | for (_, v) in contract_errors.iter() { |
| 44 | for e in v { |
| 45 | // solidity selector is only the first 4 bytes of the signature |
| 46 | let selector = const_hex::encode(&e.signature().0[0..SOLIDITY_SELECTOR_BYTE_SIZE]); |
| 47 | map.insert(selector, e.clone()); |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | #[derive(Debug, PartialEq, thiserror::Error)] |
| 53 | pub enum ParseContractError { |