Skip to content

Instantly share code, notes, and snippets.

@androolloyd
Created February 1, 2020 14:05
Show Gist options
  • Save androolloyd/65e921216419e2f71aa2093c8b5cecf4 to your computer and use it in GitHub Desktop.
Save androolloyd/65e921216419e2f71aa2093c8b5cecf4 to your computer and use it in GitHub Desktop.
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