solady icon indicating copy to clipboard operation
solady copied to clipboard

💡Idea: Don't Kill Me

Open RogerPodacter opened this issue 2 years ago • 1 comments

BUT, what about: Solady-style implementation of Diamond Storage. You've ADMITTED Diamond Storage is good, you basically use it across all these libraries (and the A contract), and in ERC721 you've really made it "lean and mean" with the whole _ERC721_MASTER_SLOT_SEED thing ChatGPT is explaining to me!

I'm not sure exactly what the interface would be for the person using the lib, but there must be an option. I'm also not sure how you would give users the ability to "add new members to existing structs," but I think that's a bad idea anyway so all the better if users can't do it!

Again, don't kill me, just calling it how I see it!

RogerPodacter avatar Apr 07 '23 13:04 RogerPodacter

In Simple Terms: Diamond Storage is a pattern used in smart contract development to reduce gas costs and improve contract upgradability. It allows for data to be stored in a single contract and accessed by multiple contracts. This pattern is commonly used in ERC721 and other token standards.

In a Solady-style implementation of Diamond Storage, the focus would be on minimizing the code size and gas costs while maintaining the benefits of Diamond Storage. Solady is a framework for developing efficient and secure smart contracts on Solana.

One approach to implementing Diamond Storage in a Solady-style could be to use a single state struct to store all the data related to the contract. This state struct can be defined in a separate file and imported into the contract. The contract can then access the state struct using a global variable.

To allow for adding new members to the state struct, the contract can include a function that modifies the state struct. However, this should be done with caution as it can potentially introduce security vulnerabilities and impact the contract upgradability.

Overall, implementing Diamond Storage in a Solady-style requires careful consideration of the trade-offs between code size, gas costs, and contract upgradability. The interface for the library would depend on the specific use case and requirements.

gauravjaincr7 avatar Apr 27 '23 07:04 gauravjaincr7