Created
February 1, 2020 14:05
-
-
Save androolloyd/65e921216419e2f71aa2093c8b5cecf4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
modifier validateRelayRequest( | |
bytes4 sig, | |
bytes data, | |
uint8 v, | |
bytes32 r, | |
bytes32 s | |
) { | |
bytes32 digest = keccak256( | |
abi.encodePacked( | |
"\x19\x01", | |
DOMAIN_SEPARATOR, | |
keccak256( | |
abi.encode( | |
RELAY_TYPEHASH, | |
sig, | |
data | |
) | |
) | |
) | |
); | |
sender = address payable(ecrecover(digest, v, r, s)); | |
// require(sender == activeAccounts[sender], "invalid-account"); | |
_; | |
sender = address payable(0); | |
} | |
function relay ( | |
bytes4 sig, | |
bytes data, | |
uint8 v, | |
bytes32 r, | |
bytes32 s | |
) | |
validateRelayRequest(sig, data, v, r, s) | |
external | |
{ | |
//new call frame | |
address payable _target = this; | |
assembly { | |
let succeeded := call(gas, _target, add(data, 0x20), mload(data), 0, 32) | |
response := mload(0) // load delegatecall output | |
switch iszero(succeeded) | |
case 1 { | |
// throw if delegatecall failed | |
revert(0, 0) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment