Regarding the use of an AppStorage struct, I always achieved similar result by creating an abstract AppStorage contract, that all my module/facets inherit from (first inheritance).
Do you have any strong opinion/argument against storage through inheritance ?
What you describe is the inherited storage pattern. It is totally fine. AppStorage is similar and can also be placed in a storage contract that is inherited by all facets.
What I like about AppStorage is that it adds a "s." prefix to all state variables which separates them from arguments, return variables and local variables. For me this makes things more explicit, clear and prevents name shadowing with function names or other variable names.
The s. is pretty great. Hey have you run into any storage access issues? I cut a new facet and use a library get() function like someFunction() that returns the slot (hashed with keccak256). But it returns empty storage. It's definitely the same diamond contract but seems to get mixed up. Maybe I did something wrong?
Regarding the use of an
AppStorage
struct, I always achieved similar result by creating an abstract AppStorage contract, that all my module/facets inherit from (first inheritance).Do you have any strong opinion/argument against storage through inheritance ?
What you describe is the inherited storage pattern. It is totally fine. AppStorage is similar and can also be placed in a storage contract that is inherited by all facets.
What I like about AppStorage is that it adds a "s." prefix to all state variables which separates them from arguments, return variables and local variables. For me this makes things more explicit, clear and prevents name shadowing with function names or other variable names.
The s. is pretty great. Hey have you run into any storage access issues? I cut a new facet and use a library get() function like someFunction() that returns the slot (hashed with keccak256). But it returns empty storage. It's definitely the same diamond contract but seems to get mixed up. Maybe I did something wrong?
library ArcaneBarracksStorage {
bytes32 constant namespace = keccak256("game.arcane.storage.barracks");
}
You will run into trouble if you declare state variables outside AppStorage or DiamondStorage or inherit contracts that do that.