-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌊 Setup
contracts-watr
deployment (#1251)
- Loading branch information
1 parent
3fa4b4e
commit b819e25
Showing
16 changed files
with
266 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/contracts-watr/contracts/interface/IClaimableOwnable.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.6.10; | ||
|
||
interface IClaimableOwnable { | ||
function claimOwnership() external; | ||
|
||
function transferOwnership(address newOwner) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 21 additions & 6 deletions
27
packages/contracts-watr/scripts/deployment/baseDeployment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import {contract, createProxy, ExecuteOptions} from "ethereum-mars"; | ||
import {OwnedUpgradeabilityProxy, TokenControllerV3} from "../../build/artifacts"; | ||
import { TrueUSD } from '../../build/artifacts' | ||
import { deployToken } from './deployToken' | ||
import { deployTokenController, setupTokenController } from './deployTokenController' | ||
import { deployRegistry } from './deployRegistry' | ||
|
||
export function baseDeployment(deployer: string, options: ExecuteOptions) { | ||
const proxy = createProxy(OwnedUpgradeabilityProxy) | ||
export function baseDeployment() { | ||
const { | ||
implementation: tokenControllerImplementation, | ||
proxy: tokenControllerProxy, | ||
} = deployTokenController() | ||
|
||
const tokenControllerImplementation = contract(TokenControllerV3) | ||
const tokenControllerProxy = proxy(tokenControllerImplementation) | ||
const { implementation: trueUSDImplementation, proxy: trueUSDProxy } = deployToken(TrueUSD, tokenControllerProxy) | ||
|
||
const { | ||
implementation: registryImplementation, | ||
proxy: registryProxy, | ||
} = deployRegistry() | ||
|
||
setupTokenController(tokenControllerProxy, trueUSDProxy, registryProxy) | ||
|
||
return { | ||
trueUSDImplementation, | ||
trueUSDProxy, | ||
tokenControllerImplementation, | ||
tokenControllerProxy, | ||
registryImplementation, | ||
registryProxy, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {deploy} from "ethereum-mars"; | ||
import {baseDeployment} from "./baseDeployment"; | ||
import { deploy } from 'ethereum-mars' | ||
import { baseDeployment } from './baseDeployment' | ||
|
||
deploy({ verify: true }, baseDeployment) | ||
deploy({ verify: false }, baseDeployment) |
16 changes: 16 additions & 0 deletions
16
packages/contracts-watr/scripts/deployment/deployRegistry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { contract, createProxy } from 'ethereum-mars' | ||
import { OwnedUpgradeabilityProxy, Registry } from '../../build/artifacts' | ||
|
||
export function deployRegistry() { | ||
const ownedUpgradabilityProxy = createProxy(OwnedUpgradeabilityProxy) | ||
|
||
const implementation = contract(Registry) | ||
const proxy = ownedUpgradabilityProxy(implementation, (registry) => { | ||
registry.initialize() | ||
}) | ||
|
||
return { | ||
implementation, | ||
proxy, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { AddressLike, ArtifactFrom, contract, createProxy, Transaction, TransactionOverrides } from 'ethereum-mars' | ||
import { OwnedUpgradeabilityProxy } from '../../build/artifacts' | ||
import { NoParams } from 'ethereum-mars/build/src/syntax/contract' | ||
|
||
type Token = NoParams & { | ||
initialize(options?: TransactionOverrides): Transaction, | ||
transferOwnership(newOwner: AddressLike, options?: TransactionOverrides): Transaction, | ||
} | ||
|
||
export function deployToken<T extends Token>(tokenArtifact: ArtifactFrom<T>, controller: AddressLike) { | ||
const implementation = contract(tokenArtifact) | ||
const tokenProxy = createProxy(OwnedUpgradeabilityProxy, (proxy) => { | ||
proxy.upgradeTo(implementation) | ||
proxy.transferProxyOwnership(controller) | ||
}) | ||
const proxy = tokenProxy(implementation, (token) => { | ||
token.initialize() | ||
token.transferOwnership(controller) | ||
}) | ||
|
||
return { | ||
implementation, | ||
proxy, | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/contracts-watr/scripts/deployment/deployTokenController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AddressLike, contract, createProxy } from 'ethereum-mars' | ||
import { OwnedUpgradeabilityProxy, TokenControllerV3 } from '../../build/artifacts' | ||
|
||
export function deployTokenController() { | ||
const ownedUpgradabilityProxy = createProxy(OwnedUpgradeabilityProxy) | ||
|
||
const implementation = contract(TokenControllerV3) | ||
const proxy = ownedUpgradabilityProxy(implementation, (controller) => { | ||
controller.initialize() | ||
}) | ||
|
||
return { | ||
implementation, | ||
proxy, | ||
} | ||
} | ||
|
||
export function setupTokenController(controller: ReturnType<typeof deployTokenController>['proxy'], token: AddressLike, registry: AddressLike) { | ||
controller.setRegistry(registry) | ||
controller.setToken(token) | ||
controller.claimTrueCurrencyProxyOwnership() | ||
controller.claimTrueCurrencyOwnership() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Contract } from 'ethers' | ||
import { JsonRpcProvider } from '@ethersproject/providers' | ||
import { expect } from 'chai' | ||
import { unknown as deployments } from '../deployments-watr_local.json' | ||
|
||
describe('verify deployment', () => { | ||
const provider = new JsonRpcProvider('http://127.0.0.1:8822', 688) | ||
const ownableInterface = [ | ||
'function owner() view returns (address)', | ||
'function proxyOwner() view returns (address)', | ||
] | ||
const controllerInterface = [ | ||
...ownableInterface, | ||
'function token() view returns (address)', | ||
'function registry() view returns (address)', | ||
] | ||
|
||
const ownableContract = (address: string) => new Contract( | ||
address, | ||
controllerInterface, | ||
provider, | ||
) | ||
|
||
const controllerContract = (address: string) => new Contract( | ||
address, | ||
controllerInterface, | ||
provider, | ||
) | ||
|
||
it('controller owns currency', async () => { | ||
const contract = ownableContract(deployments.trueUSD_proxy.address) | ||
|
||
const owner = await contract.owner() | ||
const proxyOwner = await contract.proxyOwner() | ||
|
||
expect(owner).to.eq(deployments.tokenControllerV3_proxy.address) | ||
expect(proxyOwner).to.eq(deployments.tokenControllerV3_proxy.address) | ||
}) | ||
|
||
it('controller has currency set as token', async () => { | ||
const contract = controllerContract(deployments.tokenControllerV3_proxy.address) | ||
|
||
const token = await contract.token() | ||
|
||
expect(token).to.eq(deployments.trueUSD_proxy.address) | ||
}) | ||
|
||
it('controller has registry set correctly', async () => { | ||
const contract = controllerContract(deployments.tokenControllerV3_proxy.address) | ||
|
||
const token = await contract.registry() | ||
|
||
expect(token).to.eq(deployments.registry_proxy.address) | ||
}) | ||
}) |
Oops, something went wrong.