cairo-contracts icon indicating copy to clipboard operation
cairo-contracts copied to clipboard

Suggestion: use Scarb workspaces

Open milancermak opened this issue 2 years ago • 3 comments

Use Scarb workspaces to split the lib into packages.

🧐 Motivation The library is already pretty broad (in terms of functionality) and sure to grow. There are times were a project does not need all of the features it offers. For example, say I want to use only access control and reentrancy guard. With the current structure, I'd have to pull in the whole cairo-contracts package (thought the unused parts would not be compiled).

With the use of workspaces, I could declare only the dependencies I need inside Scarb.toml, e.g.

[dependencies]
access = { git = "https://github.com/OpenZeppelin/cairo-contracts.git" }
security = { git = "https://github.com/OpenZeppelin/cairo-contracts.git" }

Note this is just a suggestion. I can see arguments for doing it both ways, just wanted to open a discussion.

milancermak avatar Sep 14 '23 10:09 milancermak

thanks! we'll reconsider after releasing

martriay avatar Sep 20 '23 21:09 martriay

For example, say I want to use only access control and reentrancy guard

When OZ modules depend on each other, would this require the user to add "OZ dependencies" manually or does it work out of the box? e.g. Account requires Introspection, does the user need to install Introspection before using Account?

martriay avatar Dec 10 '23 18:12 martriay

Works out of the box.

As an example, consider alexandria_math package. If in Scarb.toml, we have alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git" } as dependency, Scarb will resolve and install alexandria_math's dependencies as well.

milancermak avatar Dec 11 '23 14:12 milancermak