feat(abigen): descriptive deserialization errors (#1633)

* feat(abigen): descriptive deserialization errors

* update changelog

* map_err -> wrap_err
This commit is contained in:
Clifton King 2022-08-23 19:54:56 -05:00 committed by GitHub
parent ff66008cbe
commit b1124441ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -4,7 +4,7 @@
### Unreleased
- Add `evm.deployedBytecode.immutableReferences` output selector [#1523](https://github.com/gakonst/ethers-rs/pull/1523)
- Add `evm.deployedBytecode.immutableReferences` output selector [#1523](https://github.com/gakonst/ethers-rs/pull/1523)
- Added `get_erc1155_token_transfer_events` function for etherscan client [#1503](https://github.com/gakonst/ethers-rs/pull/1503)
- Add support for Geth `debug_traceTransaction` [#1469](https://github.com/gakonst/ethers-rs/pull/1469)
- Use correct, new transaction type for `typool_content` RPC endpoint [#1501](https://github.com/gakonst/ethers-rs/pull/1501)
@ -104,6 +104,8 @@
`my_contract` rather than `mycontract_mod`.
- The `Cargo.toml` generated by bindings now includes the `abigen` feature on
ethers. [#1508](https://github.com/gakonst/ethers-rs/pull/1508)
- More descriptive contract deserialization errors.
[#1633](https://github.com/gakonst/ethers-rs/pull/1633)
### 0.6.0

View File

@ -191,7 +191,9 @@ impl Context {
// holds the bytecode parsed from the abi_str, if present
let mut contract_bytecode = None;
let (abi, human_readable, abi_parser) = parse_abi(&abi_str)?;
let (abi, human_readable, abi_parser) = parse_abi(&abi_str).wrap_err_with(|| {
eyre::eyre!("error parsing abi for contract: {}", args.contract_name)
})?;
// try to extract all the solidity structs from the normal JSON ABI
// we need to parse the json abi again because we need the internalType fields which are
@ -351,7 +353,8 @@ fn parse_abi(abi_str: &str) -> Result<(Abi, bool, AbiParser)> {
(abi, true, abi_parser)
} else {
// a best-effort coercion of an ABI or an artifact JSON into an artifact JSON.
let contract: JsonContract = serde_json::from_str(abi_str)?;
let contract: JsonContract = serde_json::from_str(abi_str)
.wrap_err_with(|| eyre::eyre!("failed deserializing abi:\n{}", abi_str))?;
(contract.into_abi(), false, abi_parser)
};