Closed antazoey closed 2 years ago
Would it make sense to also reicate the namespacing? E.g.
project.accounts.Bar
?
I thought about that. That would be a little more work. This PR makes it so you can do project.accounts_Bar
.
Let me see if we can
See https://github.com/ApeWorX/ape/pull/698 for supporting .
access. It will require the next ape release!
However, good news is that users can call the project.get_contract()
method and pass in contract names like "accounts.library"
and get the ContractContainer
So this PR is not dependency necessarily on the next ape release, but need to know if we like the approach in the inked Ape PR before moving forward.
What I did
fixes: #5
How I did it
Use namespace in contract type name. E.g. if your project looks like this:
You will get the following contract type names:
Otherwise, you would get an error
Contract collision across names
and that is becauseBar.cairo
is a file in there twice.This is actually a really common design pattern in Cairo because of their namespacing capabilities. Noticeably, in the OZ Cairo contracts project: https://github.com/OpenZeppelin/cairo-contracts, you will see many files named
library.cairo
in different namespaces. This is totally a valid Cairo project structure.How to verify it
You can now compile this repo: https://github.com/OpenZeppelin/cairo-contracts NOTE: First, you have to create an
ape-config.yaml
that looks like this:This is step 1 to getting #4 to work properly
Checklist