Right now, assuming I have a contract Foo with a function bar, if it has an error, I have to do a lot of parsing / handling to get the abi error. I would like to have a more convenient function to handle this.
Example of how I'm doing it right now:
sol!(
#[allow(missing_docs)]
#[sol(rpc)]
Foo,
"abis/Foo.json"
);
let foo_contract = Foo::new(FOO_ADDRESS, &provider);
let tx_receipt = match foo_contract
.bar()
.from(signer)
.send()
.await
{
Ok(result) => result.get_receipt().await?,
Err(error) => match error {
Error::TransportError(TransportError::ErrorResp(err)) => {
let data = err.data.unwrap_or_default();
let data = data.get().trim_matches('"');
let data = Bytes::from_str(data)?;
let decoded_error = Foo::FooErrors::abi_decode(&data, true)?;
}
_ => {
return Err(eyre::eyre!(
"Received TransportError with data: {:?}",
eyre::eyre!(error)
))
}
},
};
Component
contract
Describe the feature you would like
Right now, assuming I have a contract Foo with a function bar, if it has an error, I have to do a lot of parsing / handling to get the abi error. I would like to have a more convenient function to handle this.
Example of how I'm doing it right now:
Additional context
No response