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

Method try_parse

fendermint/eth/api/src/error.rs:130–157  ·  view source on GitHub ↗

Check if the error indicates an out-of-order submission with the nonce expectation in the message.

(code: ExitCode, msg: &str)

Source from the content-addressed store, hash-verified

128
129 /// Check if the error indicates an out-of-order submission with the nonce expectation in the message.
130 pub fn try_parse(code: ExitCode, msg: &str) -> Option<Self> {
131 if code != ExitCode::SYS_SENDER_STATE_INVALID {
132 return None;
133 }
134
135 lazy_static! {
136 static ref OOS_RE: Regex =
137 Regex::new(r"expected sequence (\d+), got (\d+)").expect("regex parses");
138 }
139
140 if let Some((e, g)) = OOS_RE
141 .captures_iter(msg)
142 .map(|c| c.extract())
143 .map(|(_, [e, g])| (e, g))
144 .filter_map(|(e, g)| {
145 let e = e.parse().ok()?;
146 let g = g.parse().ok()?;
147 Some((e, g))
148 })
149 .next()
150 {
151 return Some(Self {
152 expected: e,
153 got: g,
154 });
155 }
156 None
157 }
158}
159
160#[cfg(test)]

Callers

nothing calls this directly

Calls 3

okMethod · 0.80
nextMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected