OpenZeppelin / cairo-contracts

OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup
https://docs.openzeppelin.com/contracts-cairo
MIT License
797 stars 320 forks source link

Consider moving "private" functions to a `PrivateImpl` #994

Open andrew-fleming opened 1 month ago

andrew-fleming commented 1 month ago

For functions meant to be private, it might make sense to move them out of a component's InternalImpl and into a PrivateImpl. I think this will better communicate that the moved functions are meant to be private. Here's an example of this idea: https://github.com/andrew-fleming/cairo-contracts/blob/ffe01ad9949e4e10ed21df69041bbeb673c404ba/src/token/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo#L128-L136

Furthermore, this separation makes it more difficult to accidentally misuse sensitive functions. Most contracts bring a component's InternalImpl into scope to call the initializer which means that private functions are also immediately accessible