Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .Rhistory
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ for extra security.
### Delegation process

To delegate calls to new contract, first deploy a contract that implements DelegateBurnable. Configure fees, burn bounds etc.
Also must implement setBalanceSheet(address) and SetAllowanceSheet(address) functions that can claim storage contracts.

Reclaim Balancesheets and Allowancesheets from TrueUSD, then transfer their ownership to the new contract. With the new contract call setBalanceSheet and setAllowanceSheet.

Transfer ownership of the new contract to TimeLockedController. Claim ownership of new contract with TimeLockedController.

If the new contract has function setDelegatedFrom, call the function with TrueUSD contract address as the parameter.

call delegateToNewContract to delegate to new contract.
call delegateToNewContract(_newContractAddress, _balanceSheetAddress, _allowanceSheetAddress) to delegate to new contract.


## Testing
Expand Down
22 changes: 21 additions & 1 deletion contracts/TimeLockedController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,28 @@ contract TimeLockedController is HasNoEther, HasNoTokens, Claimable {
}

// Future BurnableToken calls to trueUSD will be delegated to _delegate
function delegateToNewContract(DelegateBurnable _delegate) public onlyOwner {
function delegateToNewContract(DelegateBurnable _delegate,
Ownable _balanceSheet,
Ownable _alowanceSheet)public onlyOwner{
//initiate transfer ownership of storage contracts from trueUSD contract
requestReclaimContract(_balanceSheet);
requestReclaimContract(_alowanceSheet);

//claim ownership of storage contract
issueClaimOwnership(_balanceSheet);
issueClaimOwnership(_alowanceSheet);

//initiate transfer ownership of storage contracts to new delegate contract
transferChild(_balanceSheet,_delegate);
transferChild(_alowanceSheet,_delegate);

//call to claim the storage contract with the new delegate contract
require(address(_delegate).call(bytes4(keccak256("setBalanceSheet(address)")), _balanceSheet));
require(address(_delegate).call(bytes4(keccak256("setAllowanceSheet(address)")), _alowanceSheet));


trueUSD.delegateToNewContract(_delegate);

}

// Incoming delegate* calls from _source will be accepted by trueUSD
Expand Down
8 changes: 4 additions & 4 deletions contracts/TrueUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ contract TrueUSD is ModularPausableToken, NoOwner, BurnableTokenWithBounds, Comp
function mint(address _to, uint256 _value) onlyWhenNoDelegate public returns (bool) {
super.mint(_to, _value);
}
function setBalanceSheet(address _sheet) onlyWhenNoDelegate public {
super.setBalanceSheet(_sheet);
function setBalanceSheet(address _sheet) onlyWhenNoDelegate public returns (bool) {
return super.setBalanceSheet(_sheet);
}
function setAllowanceSheet(address _sheet) onlyWhenNoDelegate public {
super.setAllowanceSheet(_sheet);
function setAllowanceSheet(address _sheet) onlyWhenNoDelegate public returns (bool) {
return super.setAllowanceSheet(_sheet);
}
function setBurnBounds(uint256 _min, uint256 _max) onlyWhenNoDelegate public {
super.setBurnBounds(_min, _max);
Expand Down
46 changes: 46 additions & 0 deletions contracts/mocks/DelegateBurnableMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pragma solidity ^0.4.23;

import "../DelegateBurnable.sol";
import "openzeppelin-solidity/contracts/ownership/Claimable.sol";

contract DelegateBurnableMock is DelegateBurnable{

function setBalanceSheet(address _balanceSheet) public returns(bool){
Claimable balanceSheet = Claimable(_balanceSheet);
balanceSheet.claimOwnership();
return true;
}

function setAllowanceSheet(address _allowanceSheet) public returns(bool){
Claimable allowanceSheet = Claimable(_allowanceSheet);
allowanceSheet.claimOwnership();
return true;
}

function delegateTotalSupply() public view returns (uint256){
return 0;
}
function delegateBalanceOf(address who) public view returns (uint256){
return 0;
}
function delegateTransfer(address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateAllowance(address owner, address spender) public view returns (uint256){
return 0;
}
function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateApprove(address spender, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool){
return true;
}
function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool){
return true;
}
function delegateBurn(address _origSender, uint256 _value) public{
}
}
46 changes: 46 additions & 0 deletions contracts/mocks/FaultyDelegateBurnableMock1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pragma solidity ^0.4.23;

import "../DelegateBurnable.sol";
import "openzeppelin-solidity/contracts/ownership/Claimable.sol";

contract FaultyDelegateBurnableMock1 is DelegateBurnable{

function faultySetBalanceSheet(address _balanceSheet) public returns(bool){
Claimable balanceSheet = Claimable(_balanceSheet);
balanceSheet.claimOwnership();
return true;
}

function setAllowanceSheet(address _allowanceSheet) public returns(bool){
Claimable allowanceSheet = Claimable(_allowanceSheet);
allowanceSheet.claimOwnership();
return true;
}

function delegateTotalSupply() public view returns (uint256){
return 0;
}
function delegateBalanceOf(address who) public view returns (uint256){
return 0;
}
function delegateTransfer(address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateAllowance(address owner, address spender) public view returns (uint256){
return 0;
}
function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateApprove(address spender, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool){
return true;
}
function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool){
return true;
}
function delegateBurn(address _origSender, uint256 _value) public{
}
}
46 changes: 46 additions & 0 deletions contracts/mocks/FaultyDelegateBurnableMock2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pragma solidity ^0.4.23;

import "../DelegateBurnable.sol";
import "openzeppelin-solidity/contracts/ownership/Claimable.sol";

contract FaultyDelegateBurnableMock2 is DelegateBurnable{

function setBalanceSheet(address _balanceSheet) public returns(bool){
Claimable balanceSheet = Claimable(_balanceSheet);
balanceSheet.claimOwnership();
return true;
}

function faultySetAllowanceSheet(address _allowanceSheet) public returns(bool){
Claimable allowanceSheet = Claimable(_allowanceSheet);
allowanceSheet.claimOwnership();
return true;
}

function delegateTotalSupply() public view returns (uint256){
return 0;
}
function delegateBalanceOf(address who) public view returns (uint256){
return 0;
}
function delegateTransfer(address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateAllowance(address owner, address spender) public view returns (uint256){
return 0;
}
function delegateTransferFrom(address from, address to, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateApprove(address spender, uint256 value, address origSender) public returns (bool){
return true;
}
function delegateIncreaseApproval(address spender, uint addedValue, address origSender) public returns (bool){
return true;
}
function delegateDecreaseApproval(address spender, uint subtractedValue, address origSender) public returns (bool){
return true;
}
function delegateBurn(address _origSender, uint256 _value) public{
}
}
5 changes: 3 additions & 2 deletions contracts/modularERC20/ModularBasicToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ contract ModularBasicToken is ERC20Basic, Claimable {
* @dev claim ownership of the balancesheet contract
* @param _sheet The address to of the balancesheet to claim.
*/
function setBalanceSheet(address _sheet) public onlyOwner {
function setBalanceSheet(address _sheet) public onlyOwner returns (bool){
balances = BalanceSheet(_sheet);
balances.claimOwnership();
emit BalanceSheetSet(_sheet);
return true;
}

/**
Expand All @@ -47,7 +48,7 @@ contract ModularBasicToken is ERC20Basic, Claimable {
transferAllArgs(msg.sender, _to, _value);
return true;
}


function transferAllArgs(address _from, address _to, uint256 _value) internal {
require(_to != address(0),"to address cannot be 0x0");
Expand Down
3 changes: 2 additions & 1 deletion contracts/modularERC20/ModularStandardToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ contract ModularStandardToken is ERC20, ModularBasicToken {
* @dev claim ownership of the AllowanceSheet contract
* @param _sheet The address to of the AllowanceSheet to claim.
*/
function setAllowanceSheet(address _sheet) public onlyOwner {
function setAllowanceSheet(address _sheet) public onlyOwner returns(bool){
allowances = AllowanceSheet(_sheet);
allowances.claimOwnership();
emit AllowanceSheetSet(_sheet);
return true;
}

/**
Expand Down
Loading