Created
July 23, 2021 20:50
-
-
Save mudgen/ec79627eda4b3f77d047697cb565796c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//LibAppStorage.sol | |
struct AppStorage { | |
uint256 secondVar; | |
uint256 firstVar; | |
uint256 lastVar; | |
... | |
} | |
library LibAppStorage { | |
function diamondStorage() | |
internal | |
pure | |
returns (AppStorage storage ds) { | |
assembly { | |
ds.slot := 0 | |
} | |
} | |
function myLibraryFunction() internal { | |
AppStorage storage s = LibAppStorage.diamondStorage(); | |
s.lastVar = s.firstVar + s.secondVar; | |
} | |
function myLibraryFunction2(AppStorage storage s) internal { | |
s.lastVar = s.firstVar + s.secondVar; | |
} | |
} | |
contract Test { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment