From 9d38d1a412cf8ef974bcceee280870d36193933a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 2 Aug 2021 18:24:22 +0200 Subject: [PATCH] fix: convert tuple arguments to tuples (#363) --- .../ethers-contract-abigen/src/contract/methods.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ethers-contract/ethers-contract-abigen/src/contract/methods.rs b/ethers-contract/ethers-contract-abigen/src/contract/methods.rs index a33329cd..ec8100a3 100644 --- a/ethers-contract/ethers-contract-abigen/src/contract/methods.rs +++ b/ethers-contract/ethers-contract-abigen/src/contract/methods.rs @@ -1,5 +1,6 @@ use super::{types, util, Context}; use anyhow::{anyhow, Context as _, Result}; +use ethers_core::abi::ParamType; use ethers_core::{ abi::{Function, FunctionExt, Param, StateMutability}, types::Selector, @@ -76,7 +77,16 @@ pub(crate) fn expand_inputs_call_arg(inputs: &[Param]) -> TokenStream { let names = inputs .iter() .enumerate() - .map(|(i, param)| util::expand_input_name(i, ¶m.name)) + .map(|(i, param)| { + let name = util::expand_input_name(i, ¶m.name); + match param.kind { + ParamType::Tuple(_) => { + // make sure the tuple gets converted to `Token::Tuple` + quote! {(#name,)} + } + _ => name, + } + }) .collect::>(); match names.len() { 0 => quote! { () },