Last active
October 15, 2022 22:11
-
-
Save Philogy/beaaa6cd2c5532088159d530cb173721 to your computer and use it in GitHub Desktop.
Minimal EIP1967 UUPS Proxy
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
/** | |
=================================================== | |
POTENTIALLY OUT-OF-DATE (last update: 2022-10-15). | |
PLEASE REFER TO THE FOLLOWING REPO: https://github.com/Philogy/concise-erc1967-proxies | |
=================================================== | |
*/ | |
#define constant IMPL_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc | |
#define macro CONSTRUCTOR() = takes (0) returns (0) { | |
0x20 0x6d returndatasize codecopy | |
returndatasize mload [IMPL_SLOT] sstore | |
} | |
#define macro _MAIN(zero) = takes(0) returns(0) { | |
<zero> <zero> // [0, 0] | |
calldatasize <zero> <zero> calldatacopy // [0, 0] | |
<zero> <zero> calldatasize <zero> // [...call_args, 0, 0] | |
[IMPL_SLOT] sload // [...call_args, 0, 0] | |
gas // [...call_args, 0, 0] | |
delegatecall // [success, 0, 0] | |
returndatasize returndatasize // [ret_size, ret_size, success, 0, 0] | |
swap4 // [0, ret_size, success, 0, ret_size] | |
dup1 returndatacopy // [success, 0, ret_size] | |
is_success jumpi // [0, ret_size] | |
revert | |
is_success: | |
return | |
} | |
#define macro MAIN() = takes(0) returns(0) { | |
_MAIN(returndatasize) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment