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

feat: add abi code trait impls #531

Merged
merged 5 commits into from
Oct 27, 2021
Merged

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Oct 25, 2021

Motivation

Implements Abiencode + AbiDecode to all core types including tuples

Solution

basically replicate the Abitype impls with macros

The reason this seems so redundant is because we can't add a default impl like

impl<T:AbiType +Tokenizable> AbiDeocde for T {
                fn decode(bytes: impl AsRef<[u8]>) -> Result<Self, AbiError> {
                    let tokens = ethers_core::abi::decode(
                        &[Self::param_type()], bytes.as_ref()
                    )?;
                    Ok(<Self as Detokenize>::from_tokens(tokens)?)
                }
}

because we also use AbiDcocde, Encode for EthCall for example which has the additional selector...

Still needs some tests

PR Checklist

  • Added Tests
  • Added Documentation
  • Updated the changelog

Copy link
Owner

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

so far lgtm - how about we move everything codec related to ethers-core/src/abi?

ethers-contract/src/codec.rs Outdated Show resolved Hide resolved
@mattsse mattsse requested a review from gakonst October 27, 2021 21:17
@gakonst gakonst merged commit eede86d into gakonst:master Oct 27, 2021
@gakonst
Copy link
Owner

gakonst commented Oct 27, 2021

Tests failed for unrelated reason

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants