Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Naming Collisions with Struct Imports #98

Open
sentilesdal opened this issue Jan 26, 2024 · 1 comment
Open

Fix Naming Collisions with Struct Imports #98

sentilesdal opened this issue Jan 26, 2024 · 1 comment

Comments

@sentilesdal
Copy link
Contributor

If two solidity files define structs with the same names, we can get naming collisions. To avoid problems from this, we should update the names of the structs to include the contract name, i.e.

ContactA_SimpleStruct
ContractB_SimpleStruct
IContract_SimpleStruct

This is a bit cumbersome but will fix the issue. We could get smarter in the generated code and allow just importing the module and subscript the structs, i.e.

from pypechain_types import IContract, ContractA

foo = IContract.SimpleStruct({...})
bar = ContractA.SimpleStruct({...})

This will cause some problems though for the templating machine though so the first fix of including the contract name in the struct name should be used first.

@wakamex
Copy link
Contributor

wakamex commented Jan 26, 2024

won't this re-create the problem of not sharing the same struct, like Fees?

slundqui added a commit that referenced this issue Oct 8, 2024
Fixes an issue where struct references don't get matched up correctly.
See new `struct_references` test that highlights this issue.

- When finding what type files to import when building type files (for
struct references in other files), we look at the contract name of
structs instead of looking for structs in abis.
- Always reference a fully qualified name for nested structs. This
solves issues around creating the return type data structure when doing
`function.call()`.
- Define the python type as the fully qualified name. This solves an
issue with structures in different file references and functions
returning a vector of the struct.
- Handle the case when a struct doesn't get referenced with a contract
name in the abi.
- Fix to handling of struct arrays as input/output to functions with
fully qualified names for structs.

This might solve #98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants