Last active
June 17, 2019 07:51
-
-
Save 0xdewy/557253586ed3f109c94f3593b4ad43c9 to your computer and use it in GitHub Desktop.
Fallback function of Proxy contraact
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
function () | |
payable | |
external { | |
address implementation = Resolver(resolver()).getUserVersion(msg.sender); | |
require(implementation != address(0), "INVALID IMPLEMENTATION"); | |
assembly { | |
let ptr := mload(0x40) | |
calldatacopy(ptr, 0, calldatasize) // Copy incoming calldata | |
let result := delegatecall(gas, implementation, ptr, calldatasize, 0, 0) | |
let size := returndatasize | |
returndatacopy(ptr, 0, size) | |
switch result | |
case 0 { revert(ptr, size) } | |
default { return(ptr, size) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment