snt-gas-relay/contracts/deploy/DelegatedCall.sol

36 lines
1.1 KiB
Solidity
Raw Normal View History

pragma solidity ^0.4.21;
2017-11-28 03:33:25 +00:00
/**
* @title DelegatedCall
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
2018-03-11 15:11:42 +00:00
* @dev Abstract contract that delegates calls by `delegated` modifier to result of `targetDelegatedCall()`
* Important to avoid overwriting wrong storage pointers is that never define storage to this contract
2017-11-28 03:33:25 +00:00
*/
contract DelegatedCall {
/**
* @dev delegates the call of this function
*/
modifier delegated {
2017-12-01 06:45:26 +00:00
//require successfull delegate call to remote `_target()`
2018-03-11 15:11:42 +00:00
require(targetDelegatedCall().delegatecall(msg.data));
2017-11-28 03:33:25 +00:00
assembly {
let outSize := returndatasize
let outDataPtr := mload(0x40) //load memory
returndatacopy(outDataPtr, 0, outSize) //copy last return into pointer
return(outDataPtr, outSize)
}
2018-03-11 15:11:42 +00:00
assert(false); //should never reach here
2017-11-28 03:33:25 +00:00
_; //never will execute local logic
}
/**
* @dev defines the address for delegation of calls
*/
2018-03-11 15:11:42 +00:00
function targetDelegatedCall()
2017-11-28 03:33:25 +00:00
internal
view
2017-11-28 03:33:25 +00:00
returns(address);
}