fix(abi): change abiarraytype trait bounds for tuple (#1079)

This commit is contained in:
Matthias Seitz 2022-03-25 01:40:34 +01:00 committed by GitHub
parent 3c0d8c36dd
commit a43a9b8806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -572,3 +572,14 @@ fn can_derive_ethcall_for_bytes() {
assert_ethcall::<BatchCall>(); 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,
}
}

View File

@ -252,4 +252,12 @@ mod tests {
let v = vec![bytes]; let v = vec![bytes];
assert_codec(v); 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);
}
} }

View File

@ -164,7 +164,7 @@ macro_rules! impl_abi_type_tuple {
impl<$($ty, )+> AbiArrayType for ($($ty,)+) where impl<$($ty, )+> AbiArrayType for ($($ty,)+) where
$( $(
$ty: AbiArrayType, $ty: AbiType,
)+ {} )+ {}
} }
} }