2019-02-14 02:18:08 -02:00
|
|
|
pragma solidity >=0.5.0 <0.6.0;
|
2018-03-11 22:12:50 +07:00
|
|
|
|
2019-02-14 02:18:08 -02:00
|
|
|
import "./InstanceAbstract.sol";
|
2018-03-11 22:12:50 +07:00
|
|
|
import "./DelegatedCall.sol";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @title Instance
|
|
|
|
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
2019-02-14 02:18:08 -02:00
|
|
|
* @dev Contract that forward everything through delegatecall to defined base
|
2018-03-11 22:12:50 +07:00
|
|
|
*/
|
2019-02-14 02:18:08 -02:00
|
|
|
contract Instance is InstanceAbstract, DelegatedCall {
|
2018-03-11 22:12:50 +07:00
|
|
|
|
|
|
|
/**
|
2019-02-14 02:18:08 -02:00
|
|
|
* @notice delegatecall `_init` with `_initMsg` and set base as `_base`
|
|
|
|
* @param _base base for delegatecall
|
|
|
|
* @param _init constructor contract
|
|
|
|
* @param _initMsg arguments to be passed for the single delegatecall on `_init`
|
2018-03-11 22:12:50 +07:00
|
|
|
*/
|
2019-02-14 02:18:08 -02:00
|
|
|
constructor(
|
|
|
|
InstanceAbstract _base,
|
|
|
|
InstanceAbstract _init,
|
|
|
|
bytes memory _initMsg
|
|
|
|
)
|
|
|
|
public
|
|
|
|
payable
|
|
|
|
DelegatedCall(address(_init), _initMsg)
|
|
|
|
{
|
|
|
|
base = _base;
|
2018-03-11 22:12:50 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-02-14 02:18:08 -02:00
|
|
|
* @dev delegatecall everything (but declared functions) to `_target()`
|
|
|
|
* @notice Verify `base()` code to predict behavior
|
2018-03-11 22:12:50 +07:00
|
|
|
*/
|
2019-02-14 02:18:08 -02:00
|
|
|
function ()
|
|
|
|
external
|
|
|
|
payable
|
|
|
|
delegateAndReturn(address(base))
|
|
|
|
{ }
|
2018-03-11 22:12:50 +07:00
|
|
|
|
|
|
|
}
|