Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat(abigen): descriptive deserialization errors #1633

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -103,6 +103,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

Expand Down
7 changes: 5 additions & 2 deletions ethers-contract/ethers-contract-abigen/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this better @mattsse


(contract.into_abi(), false, abi_parser)
};
Expand Down