// metamorphic-on-fn.huff: A proxy that delegatecalls into the deployer
// address if the migrate() function is called, forwarding all calldata,
// including the selector. Otherwise, it delegatecalls into its
// implementation slot. Make sure to call the migrate function the moment
// this was created. Be careful to enforce access control!
#define constant SLOT_IMPL = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
#define function migrate() nonpayable returns ()
#define constant ADDR_DEPLOYER = 0x1000000000000000000000000000000000000001
#define macro MAIN() = takes(0) returns(0) {
calldatasize 0x0 0x0 calldatacopy
0x0 calldataload 0xe0 shr __FUNC_SIG(migrate) eq MIGRATE jumpi
ALL jump
MIGRATE:
[ADDR_DEPLOYER] CONT jump
ALL:
[SLOT_IMPL] sload
CONT:
0x0 calldatasize 0x0 0x0 swap4 gas delegatecall
returndatasize 0x0 0x0 returndatacopy
returndatasize 0x0 dup3 RETURN jumpi revert
RETURN:
return
}
#define macro CONSTRUCTOR() = takes(0) returns(0) {
codesize 0x20 sub calldataload [SLOT_IMPL] sstore
}