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

feat(ethers-core/abi): impl AbiArrayType for u8 #1140

Closed
Closed
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
8 changes: 1 addition & 7 deletions ethers-core/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ impl<T: AbiArrayType, const N: usize> AbiType for [T; N] {

impl<T: AbiArrayType, const N: usize> AbiArrayType for [T; N] {}

impl<const N: usize> AbiType for [u8; N] {
fn param_type() -> ParamType {
ParamType::FixedBytes(N)
}
}
impl<const N: usize> AbiArrayType for [u8; N] {}
impl AbiArrayType for u8 {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this defeats the whole purpose of this trait.

Copy link
Contributor Author

@meetmangukiya meetmangukiya Apr 13, 2022

Choose a reason for hiding this comment

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

The currently pushed code is certainly wrong. Can you check the comment #1140 (comment) regarding the manual impls for u8 tuples? Also, I don't think we need to implement AbiArrayType for tuples for fixing this error, tuples already have AbiArrayType implemented IIUC

impl<$($ty, )+> AbiArrayType for ($($ty,)+) where
$(
$ty: AbiType,
)+ {}

For the broader issue and source of error #1140 (comment)


macro_rules! impl_abi_type {
($($name:ty => $var:ident $(($value:expr))? ),*) => {
Expand All @@ -123,7 +118,6 @@ macro_rules! impl_abi_type {

impl_abi_type!(
Bytes => Bytes,
Vec<u8> => Array(Box::new(ParamType::Uint(8))),
Address => Address,
bool => Bool,
String => String,
Expand Down