Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants