include SOB proposal for republic

This commit is contained in:
Ricardo Guilherme Schmidt 2018-03-11 22:12:50 +07:00
parent 266b1c3056
commit 1424baafa9
3 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,38 @@
pragma solidity ^0.4.17;
import "./InstanceStorage.sol";
import "./DelegatedCall.sol";
/**
* @title Instance
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
* @dev Contract that forward everything through delegatecall to defined kernel
*/
contract Instance is InstanceStorage, DelegatedCall {
function Instance(address _kernel) public {
kernel = _kernel;
}
/**
* @dev delegatecall everything (but declared functions) to `_target()`
* @notice Verify `kernel()` code to predict behavior
*/
function () external delegated {
//all goes to kernel
}
/**
* @dev returns kernel if kernel that is configured
* @return kernel address
*/
function targetDelegatedCall()
internal
constant
returns(address)
{
return kernel;
}
}

View File

@ -0,0 +1,15 @@
pragma solidity ^0.4.17;
/**
* @title InstanceStorage
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
* @dev Defines kernel vars that Kernel contract share with Instance.
* Important to avoid overwriting wrong storage pointers is that
* InstanceStorage should be always the first contract at heritance.
*/
contract InstanceStorage {
// protected zone start (InstanceStorage vars)
address public kernel;
// protected zone end
}

View File

@ -0,0 +1,25 @@
pragma solidity ^0.4.17;
import "./Instance.sol";
/**
* @title UpdatableInstance
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
* @dev Contract that can be updated by a call from itself.
*/
contract UpdatableInstance is Instance {
function UpdatableInstance(address _kernel)
Instance(_kernel)
public
{
}
function updateUpdatableInstance(address _kernel) external {
require(msg.sender == address(this));
kernel = _kernel;
}
}