MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / extend_errors

Function extend_errors

contract-bindings/src/error_parser.rs:39–50  ·  view source on GitHub ↗

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>>,
)

Source from the content-addressed store, hash-verified

37///
38/// If a selector already exists in the map, a warning is logged.
39pub 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)]
53pub enum ParseContractError {

Callers

nothing calls this directly

Calls 3

signatureMethod · 0.80
iterMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected