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

Commit

Permalink
FIX: Use the name 'constructor' if there is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 10, 2023
1 parent c184bc7 commit 2184e2d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ethers-contract/ethers-contract-abigen/src/contract/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ impl InternalStructs {
{
let is_event = item.type_field == "event";

if let Some(name) = item.name {
let name = match item.name {
None if item.type_field == "constructor" => Some("constructor".to_owned()),
other => other,
};

if let Some(name) = name {
for (idx, input) in item.inputs.into_iter().enumerate() {
if let Some(ty) = input
.internal_type
Expand All @@ -254,7 +259,7 @@ impl InternalStructs {

if is_event {
// no outputs in an event
continue
continue;
}

let mut output_structs = Vec::new();
Expand Down Expand Up @@ -424,7 +429,7 @@ fn resolve_struct_tuples(all_structs: &HashMap<String, SolStruct>) -> HashMap<St
let mut sequential_retries = 0;
'outer: while let Some((id, ty)) = structs.pop_front() {
if sequential_retries > structs.len() {
break
break;
}
if let Some(tuple) = ty.as_tuple() {
params.insert(id.to_string(), tuple);
Expand Down Expand Up @@ -454,7 +459,7 @@ fn resolve_struct_tuples(all_structs: &HashMap<String, SolStruct>) -> HashMap<St
// struct field needs to be resolved first
structs.push_back((id, ty));
sequential_retries += 1;
continue 'outer
continue 'outer;
}
}
_ => {
Expand All @@ -477,7 +482,7 @@ fn insert_structs(structs: &mut HashMap<String, SolStruct>, tuple: &Component) {
if let Some(internal_ty) = tuple.internal_type.as_ref() {
let ident = struct_type_identifier(internal_ty);
if structs.contains_key(ident) {
return
return;
}
if let Some(fields) = tuple
.components
Expand Down

0 comments on commit 2184e2d

Please sign in to comment.