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

Handle contracts with duplicated names #2626

Open
cptartur opened this issue Oct 30, 2024 · 0 comments
Open

Handle contracts with duplicated names #2626

cptartur opened this issue Oct 30, 2024 · 0 comments
Labels
bug Something isn't working snforge

Comments

@cptartur
Copy link
Member

cptartur commented Oct 30, 2024

It is possible to have a compiling Scarb package containing contracts with duplicated names e.g.

src/
  lib.rs <- Contract named MyContract
tests/
  contracts.rs <- Contract named MyContract

In starknet_artifacts.json file they are correctly distinguished by their full paths and two .contract_class files are generated. However we have no logic to handle duplicated names and since we handle contract by names using a hashmap, which contract will be collected is undefined. This may result in different contracts being used between different tests runs.

We should introduce a logic to handle these duplicated entries and update the syntax of declare cheatcode:
If there is only one implementation under given <ContractName> allow declaring with declare(<ContractName>).
If there are duplicated names, require declaring with full path (declare(full::path::<ContractName>)) and fail otherwise (consider panic since it's a code error).

@cptartur cptartur converted this from a draft issue Oct 30, 2024
@github-actions github-actions bot added the new label Oct 30, 2024
@cptartur cptartur added bug Something isn't working snforge and removed new labels Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snforge
Projects
Status: Triage
Development

No branches or pull requests

1 participant