Skip to content

Commit b819e25

Browse files
authored
🌊 Setup contracts-watr deployment (#1251)
1 parent 3fa4b4e commit b819e25

16 files changed

+266
-43
lines changed

packages/contracts-watr/contracts/TokenControllerV3.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {IRegistry} from "./interface/IRegistry.sol";
77
import {IOwnedUpgradeabilityProxy} from "./interface/IOwnedUpgradeabilityProxy.sol";
88
import {ITrueCurrency} from "./interface/ITrueCurrency.sol";
99
import {IProofOfReserveToken} from "./interface/IProofOfReserveToken.sol";
10+
import {IClaimableOwnable} from "./interface/IClaimableOwnable.sol";
1011

1112
/** @title TokenController
1213
* @dev This contract allows us to split ownership of the TrueCurrency contract
@@ -183,6 +184,12 @@ contract TokenControllerV3 {
183184
_;
184185
}
185186

187+
function initialize() external {
188+
require(!initialized, "already initialized");
189+
owner = msg.sender;
190+
initialized = true;
191+
}
192+
186193
/**
187194
* @dev Modifier throws if called by any account other than proofOfReserveEnabler or owner.
188195
*/
@@ -209,6 +216,19 @@ contract TokenControllerV3 {
209216
pendingOwner = address(0);
210217
}
211218

219+
/*
220+
========================================
221+
token ownership
222+
========================================
223+
*/
224+
function transferTrueCurrencyOwnership(address _newOwner) external onlyOwner {
225+
IClaimableOwnable(address(token)).transferOwnership(_newOwner);
226+
}
227+
228+
function claimTrueCurrencyOwnership() public onlyOwner {
229+
IClaimableOwnable(address(token)).claimOwnership();
230+
}
231+
212232
/*
213233
========================================
214234
proxy functions

packages/contracts-watr/contracts/TrueCurrency.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ abstract contract TrueCurrency is BurnableTokenWithBounds {
5454
*/
5555
event Mint(address indexed to, uint256 value);
5656

57+
function initialize() external {
58+
require(!initialized, "already initialized");
59+
owner = msg.sender;
60+
initialized = true;
61+
}
62+
5763
/**
5864
* @dev Creates `amount` tokens and assigns them to `account`, increasing
5965
* the total supply.

packages/contracts-watr/contracts/common/ClaimableOwnable.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
pragma solidity 0.6.10;
33

44
import {ProxyStorage} from "./ProxyStorage.sol";
5+
import {IClaimableOwnable} from "../interface/IClaimableOwnable.sol";
56

67
/**
78
* @title ClamableOwnable
89
* @dev The ClamableOwnable contract is a copy of Claimable Contract by Zeppelin.
910
* and provides basic authorization control functions. Inherits storage layout of
1011
* ProxyStorage.
1112
*/
12-
contract ClaimableOwnable is ProxyStorage {
13+
contract ClaimableOwnable is ProxyStorage, IClaimableOwnable {
1314
/**
1415
* @dev emitted when ownership is transferred
1516
* @param previousOwner previous owner of this contract
@@ -46,14 +47,14 @@ contract ClaimableOwnable is ProxyStorage {
4647
* @dev Allows the current owner to set the pendingOwner address.
4748
* @param newOwner The address to transfer ownership to.
4849
*/
49-
function transferOwnership(address newOwner) external onlyOwner {
50+
function transferOwnership(address newOwner) external override onlyOwner {
5051
pendingOwner = newOwner;
5152
}
5253

5354
/**
5455
* @dev Allows the pendingOwner address to finalize the transfer.
5556
*/
56-
function claimOwnership() external onlyPendingOwner {
57+
function claimOwnership() external override onlyPendingOwner {
5758
emit OwnershipTransferred(owner, pendingOwner);
5859
owner = pendingOwner;
5960
pendingOwner = address(0);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.6.10;
3+
4+
interface IClaimableOwnable {
5+
function claimOwnership() external;
6+
7+
function transferOwnership(address newOwner) external;
8+
}

packages/contracts-watr/contracts/mocks/MockTrueCurrency.sol

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ contract MockTrueCurrency is TrueCurrencyWithProofOfReserve {
77
uint8 constant DECIMALS = 18;
88
uint8 constant ROUNDING = 2;
99

10-
function initialize() external {
11-
require(!initialized);
12-
owner = msg.sender;
13-
initialized = true;
14-
}
15-
1610
function decimals() public pure override returns (uint8) {
1711
return DECIMALS;
1812
}

packages/contracts-watr/contracts/mocks/RegistryMock.sol

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,4 @@ contract RegistryMock is Registry {
1212
owner = msg.sender;
1313
emit OwnershipTransferred(address(0), owner);
1414
}
15-
16-
function initialize() public {
17-
require(!initialized, "already initialized");
18-
owner = msg.sender;
19-
initialized = true;
20-
}
2115
}

packages/contracts-watr/contracts/mocks/TokenControllerMock.sol

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ interface HasOwner {
2020
contract TokenControllerMock is TokenControllerV3 {
2121
event TransferChild(address indexed child, address indexed newOwner);
2222

23-
// initalize controller. useful for tests
24-
function initialize() external {
25-
require(!initialized, "already initialized");
26-
owner = msg.sender;
27-
initialized = true;
28-
}
29-
3023
// initialize with paramaters. useful for tests
3124
// sets initial paramaters on testnet
3225
function initializeWithParams(TrueCurrency _token, Registry _registry) external {

packages/contracts-watr/contracts/test/Registry.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ contract Registry {
3636
event StartSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber);
3737
event StopSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber);
3838

39+
function initialize() external {
40+
require(!initialized, "already initialized");
41+
owner = msg.sender;
42+
initialized = true;
43+
}
44+
3945
// Allows a write if either a) the writer is that Registry's owner, or
4046
// b) the writer is writing to attribute foo and that writer already has
4147
// the canWriteTo-foo attribute set (in that same Registry)

packages/contracts-watr/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"prebuild": "yarn clean",
1414
"build:hardhat": "hardhat compile",
1515
"build:typechain": "typechain --target ethers-v5 --out-dir build/types 'build/*.json'",
16-
"build": "yarn build:hardhat && yarn build:typechain && mars",
16+
"build:canary": "git log --pretty=format:'%H' -n 1 > ./build/canary.hash",
17+
"build": "yarn build:hardhat && yarn build:typechain && mars && yarn build:canary",
1718
"preflatten": "rm -rf custom_flatten",
1819
"flatten": "waffle flatten .waffle.json",
1920
"test": "mocha 'test/**/*.test.ts'",
2021
"checks": "yarn lint && yarn test",
21-
"deploy": "./utils/bash/marsDeploy.sh"
22+
"deploy": "./utils/bash/marsDeploy.sh scripts/deployment/deploy.ts"
2223
},
2324
"dependencies": {
2425
"ethereum-mars": "^0.2.6-dev.eb75a27",
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1-
import {contract, createProxy, ExecuteOptions} from "ethereum-mars";
2-
import {OwnedUpgradeabilityProxy, TokenControllerV3} from "../../build/artifacts";
1+
import { TrueUSD } from '../../build/artifacts'
2+
import { deployToken } from './deployToken'
3+
import { deployTokenController, setupTokenController } from './deployTokenController'
4+
import { deployRegistry } from './deployRegistry'
35

4-
export function baseDeployment(deployer: string, options: ExecuteOptions) {
5-
const proxy = createProxy(OwnedUpgradeabilityProxy)
6+
export function baseDeployment() {
7+
const {
8+
implementation: tokenControllerImplementation,
9+
proxy: tokenControllerProxy,
10+
} = deployTokenController()
611

7-
const tokenControllerImplementation = contract(TokenControllerV3)
8-
const tokenControllerProxy = proxy(tokenControllerImplementation)
12+
const { implementation: trueUSDImplementation, proxy: trueUSDProxy } = deployToken(TrueUSD, tokenControllerProxy)
13+
14+
const {
15+
implementation: registryImplementation,
16+
proxy: registryProxy,
17+
} = deployRegistry()
18+
19+
setupTokenController(tokenControllerProxy, trueUSDProxy, registryProxy)
920

1021
return {
22+
trueUSDImplementation,
23+
trueUSDProxy,
1124
tokenControllerImplementation,
1225
tokenControllerProxy,
26+
registryImplementation,
27+
registryProxy,
1328
}
1429
}

0 commit comments

Comments
 (0)