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

Commit

Permalink
fix(abi): change abiarraytype trait bounds for tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Mar 24, 2022
1 parent 3c0d8c3 commit 2d734b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ethers-contract/tests/common/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,14 @@ fn can_derive_ethcall_for_bytes() {

assert_ethcall::<BatchCall>();
}

#[test]
fn can_derive_array_tuples() {
#[derive(Clone, Debug, Default, Eq, PartialEq, EthEvent, EthDisplay)]
#[ethevent(name = "DiamondCut", abi = "DiamondCut((address,uint8,bytes4[])[],address,bytes)")]
pub struct DiamondCutFilter {
pub diamond_cut: Vec<(Address, u8, Vec<[u8; 4]>)>,
pub init: Address,
pub calldata: Bytes,
}
}
8 changes: 8 additions & 0 deletions ethers-core/src/abi/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,12 @@ mod tests {
let v = vec![bytes];
assert_codec(v);
}

#[test]
fn tuple_array() {
let nested: Vec<[u8; 4]> = vec![[0, 0, 0, 1]];
assert_codec(nested.clone());
let tuple: Vec<(Address, u8, Vec<[u8; 4]>)> = vec![(Address::random(), 0, nested)];
assert_codec(tuple);
}
}
2 changes: 1 addition & 1 deletion ethers-core/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ macro_rules! impl_abi_type_tuple {

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

0 comments on commit 2d734b2

Please sign in to comment.