From a43a9b8806a13035db5c657406b3542dd0bfc749 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 25 Mar 2022 01:40:34 +0100 Subject: [PATCH] fix(abi): change abiarraytype trait bounds for tuple (#1079) --- ethers-contract/tests/common/derive.rs | 11 +++++++++++ ethers-core/src/abi/codec.rs | 8 ++++++++ ethers-core/src/abi/mod.rs | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ethers-contract/tests/common/derive.rs b/ethers-contract/tests/common/derive.rs index a18879d3..65f07ca7 100644 --- a/ethers-contract/tests/common/derive.rs +++ b/ethers-contract/tests/common/derive.rs @@ -572,3 +572,14 @@ fn can_derive_ethcall_for_bytes() { assert_ethcall::(); } + +#[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, + } +} diff --git a/ethers-core/src/abi/codec.rs b/ethers-core/src/abi/codec.rs index 39cf4031..283bd076 100644 --- a/ethers-core/src/abi/codec.rs +++ b/ethers-core/src/abi/codec.rs @@ -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); + } } diff --git a/ethers-core/src/abi/mod.rs b/ethers-core/src/abi/mod.rs index 925880b8..b2d50839 100644 --- a/ethers-core/src/abi/mod.rs +++ b/ethers-core/src/abi/mod.rs @@ -164,7 +164,7 @@ macro_rules! impl_abi_type_tuple { impl<$($ty, )+> AbiArrayType for ($($ty,)+) where $( - $ty: AbiArrayType, + $ty: AbiType, )+ {} } }