Skip to content

Commit 79326da

Browse files
committed
Improve failure message of contract import unhandled array types
1 parent 4063fc9 commit 79326da

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

codegenerator/cli/src/config_parsing/entity_parsing.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,14 +1157,27 @@ impl UserDefinedFieldType {
11571157
Ok(Self::NonNullType(Box::new(Self::Single(GqlScalar::String))))
11581158
}
11591159
EthAbiParamType::Array(abi_type) | EthAbiParamType::FixedArray(abi_type, _) => {
1160-
let inner_type = Self::from_ethabi_type(abi_type)?;
1160+
//Validate no nested arrays or
1161+
match abi_type.as_ref() {
1162+
EthAbiParamType::Tuple(_) => {
1163+
Err(anyhow!("Unhandled contract import type 'array of tuple'"))?
1164+
}
1165+
EthAbiParamType::Array(_) => {
1166+
Err(anyhow!("Unhandled contract import type 'array of array'"))?
1167+
}
1168+
_ => (),
1169+
}
1170+
let inner_type = Self::from_ethabi_type(abi_type)
1171+
.context("Unhandled contract import nested type in array")?;
11611172
Ok(Self::NonNullType(Box::new(Self::ListType(Box::new(
11621173
inner_type,
11631174
)))))
11641175
}
1165-
EthAbiParamType::Tuple(_abi_types) => Err(anyhow!(
1166-
"Tuples are not handled currently using contract import."
1167-
)),
1176+
EthAbiParamType::Tuple(_abi_types) =>
1177+
//This case should be flattened out unless it is nested inside an array
1178+
{
1179+
Err(anyhow!("Unhandled contract import type 'tuple'"))
1180+
}
11681181
}
11691182
}
11701183
}

codegenerator/cli/src/hbs_templating/contract_import_templates.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,10 @@ impl Param {
402402
event_key: flattened_event_param.get_event_param_key(),
403403
tuple_param_accessor_indexes: flattened_event_param.accessor_indexes,
404404
graphql_type: FieldType::from_ethabi_type(&flattened_event_param.event_param.kind)
405-
.context("converting eth event param to gql scalar")?,
405+
.context(format!(
406+
"Converting eth event param '{}' to gql scalar",
407+
flattened_event_param.event_param.name
408+
))?,
406409
is_eth_address: flattened_event_param.event_param.kind == ParamType::Address,
407410
})
408411
}

0 commit comments

Comments
 (0)