-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌊 Setup contracts-watr
deployment
#1251
Merged
Merged
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3bbb11f
Create `contracts-watr` package
abam-iksde e40c0b5
Add initialize method to contracts
abam-iksde 6e30c4f
Deployment script
abam-iksde 3935f93
Make test showOwner script
abam-iksde c28994b
Add network parameter and prompt for PRIVATE_KEY in script
abam-iksde c35a211
Add canary generation to build
abam-iksde 21d9030
Change `pnpm` to `yarn`
abam-iksde 2749876
Don't pass `args`
abam-iksde 736abf8
Add `Registry` to deployment
abam-iksde c7e674d
Create `IClaimableOwnable` interface
abam-iksde cb8fc57
Remove constructor from interface
abam-iksde 12f66a0
Implement `IClaimableOwnable` interface
abam-iksde f6500f9
Lint
abam-iksde c1a0894
Verify ownership with tests
abam-iksde d20ba3d
Verify registry with test
abam-iksde 1cd84e2
Use `transferProxyOwnership`
abam-iksde 720db28
Handle proxy ownership
abam-iksde 80953f0
Add `upgradeTo`
abam-iksde 4c12812
Use deployed implementation address
abam-iksde 7dc8927
Add ownership transfer
abam-iksde c620a98
Refactor deployment
abam-iksde e80ab8c
Verify proxy ownership with test
abam-iksde b56a3b1
Match `TrueCurrencyWithProofOfReserve` to contracts-por
abam-iksde c48ce32
Match `TrueUSD.test.ts` to contracts-por
abam-iksde dc65658
Merge branch 'watr-package' into watr-deployment
abam-iksde b8e695d
Merge branch 'main' into watr-deployment
abam-iksde ea45bec
Extract `ClaimableOwnable` interface
abam-iksde ebf48c5
Merge branch 'main' into watr-deployment
tt-krzysztof File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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) | ||
}) | ||
}) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is handled better in #1245 : extracting the interface from ClaimableOwnable.