From 3be93904e143da6fed6a7426c3e1a463e90a39fb Mon Sep 17 00:00:00 2001 From: Ino Murko Date: Fri, 18 Jun 2021 13:46:01 +0200 Subject: [PATCH] remove watchers from wallet deployment scripts, init pools --- .github/workflows/omgx-publish-develop.yml | 2 +- packages/omgx/wallet/bin/deploy.ts | 43 +++++-------------- .../deploy/000-LiquidityPools.deploy.ts | 24 ++++++++++- .../wallet/deploy/001-ERC20Test.deploy.ts | 4 +- .../wallet/deploy/003-AtomicSwap.deploy.ts | 4 +- .../omgx/wallet/scripts/wait-for-l1-and-l2.sh | 2 +- packages/omgx/wallet/tsconfig.json | 2 +- 7 files changed, 40 insertions(+), 41 deletions(-) diff --git a/.github/workflows/omgx-publish-develop.yml b/.github/workflows/omgx-publish-develop.yml index a760e412c44d..2ad7dcde7a9b 100644 --- a/.github/workflows/omgx-publish-develop.yml +++ b/.github/workflows/omgx-publish-develop.yml @@ -79,4 +79,4 @@ jobs: for i in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep omgx); do echo "$1" docker push "$i" - done \ No newline at end of file + done diff --git a/packages/omgx/wallet/bin/deploy.ts b/packages/omgx/wallet/bin/deploy.ts index 90cae853693c..2d1f9078a65a 100644 --- a/packages/omgx/wallet/bin/deploy.ts +++ b/packages/omgx/wallet/bin/deploy.ts @@ -1,8 +1,5 @@ import { Wallet, providers } from 'ethers' -import {JsonRpcProvider} from '@ethersproject/providers' -import { Contract } from 'ethers' import { getContractFactory } from '@eth-optimism/contracts' -import { Watcher } from '@eth-optimism/core-utils' process.env.CONTRACTS_DEPLOYER_KEY = process.env.DEPLOYER_PRIVATE_KEY process.env.CONTRACTS_RPC_URL = @@ -24,42 +21,24 @@ const main = async () => { .attach(addressManagerAddress) as any } - const initWatcher = async ( - l1Provider: JsonRpcProvider, - l2Provider: JsonRpcProvider, - AddressManager: Contract - ) => { - const l1MessengerAddress = await AddressManager.getAddress( - 'Proxy__OVM_L1CrossDomainMessenger' - ) - const l2MessengerAddress = await AddressManager.getAddress( - 'OVM_L2CrossDomainMessenger' - ) - return new Watcher({ - l1: { - provider: l1Provider, - messengerAddress: l1MessengerAddress, - }, - l2: { - provider: l2Provider, - messengerAddress: l2MessengerAddress, - }, - }) - } + console.log(`ADDRESS_MANAGER_ADDRESS was set to ${process.env.ADDRESS_MANAGER_ADDRESS}`) + const addressManager = getAddressManager(deployer_1, process.env.ADDRESS_MANAGER_ADDRESS); + + const l1MessengerAddress = await addressManager.getAddress( + 'Proxy__OVM_L1CrossDomainMessenger' + ) + const l2MessengerAddress = await addressManager.getAddress( + 'OVM_L2CrossDomainMessenger' + ) - let addressManager = process.env.ADDRESS_MANAGER_ADDRESS; - console.log(`ADDRESS_MANAGER_ADDRESS was set to ${addressManager}`) - const watcher = await initWatcher(l1Provider, l2Provider, getAddressManager(deployer_1, addressManager)) await hre.run('deploy', { - watcher: watcher, + l1MessengerAddress: l1MessengerAddress, + l2MessengerAddress: l2MessengerAddress, l1provider: l1Provider, l2provider: l2Provider, deployer_l1: deployer_1, deployer_l2: deployer_2, - emOvmChainId: config.emOvmChainId, noCompile: process.env.NO_COMPILE ? true : false, - addressManager: getAddressManager(deployer_1, addressManager), - getAddressManager: getAddressManager, }) } diff --git a/packages/omgx/wallet/deploy/000-LiquidityPools.deploy.ts b/packages/omgx/wallet/deploy/000-LiquidityPools.deploy.ts index c2dd32d4341f..0401929c8dc4 100644 --- a/packages/omgx/wallet/deploy/000-LiquidityPools.deploy.ts +++ b/packages/omgx/wallet/deploy/000-LiquidityPools.deploy.ts @@ -27,7 +27,7 @@ const deployFn: DeployFunction = async (hre) => { ) // Deploy L2 liquidity pool L2LiquidityPool = await Factory__L2LiquidityPool.deploy( - (hre as any).deployConfig.watcher.l2.messengerAddress, + (hre as any).deployConfig.l2MessengerAddress, {gasLimit: 800000, gasPrice: 0} ) await L2LiquidityPool.deployTransaction.wait() @@ -42,7 +42,7 @@ const deployFn: DeployFunction = async (hre) => { // Deploy L1 liquidity pool L1LiquidityPool = await Factory__L1LiquidityPool.deploy( - (hre as any).deployConfig.watcher.l1.messengerAddress + (hre as any).deployConfig.l1MessengerAddress ) await L1LiquidityPool.deployTransaction.wait() const L1LiquidityPoolDeploymentSubmission: DeploymentSubmission = { @@ -54,6 +54,26 @@ const deployFn: DeployFunction = async (hre) => { await hre.deployments.save('L1LiquidityPool', L1LiquidityPoolDeploymentSubmission) console.log(`🌕 ${chalk.red('L1LiquidityPool deployed to:')} ${chalk.green(L1LiquidityPool.address)}`) + + // Initialize L1 liquidity pool + const L1LiquidityPoolTX = await L1LiquidityPool.init( + /* userRewardFeeRate 3.5% */ 35, + /* ownerRewardFeeRate 1.5% */ 15, + L2LiquidityPool.address, + {gasLimit: 800000, gasPrice: 0} + ) + await L1LiquidityPoolTX.wait() + console.log(`⭐️ ${chalk.blue('L1 LP initialized:')} ${chalk.green(L1LiquidityPoolTX.hash)}`) + + // Initialize L2 liquidity pool + const L2LiquidityPoolTX = await L2LiquidityPool.init( + /* userRewardFeeRate 3.5% */ 35, + /* ownerRewardFeeRate 1.5% */ 15, + L1LiquidityPool.address, + {gasLimit: 800000, gasPrice: 0} + ) + await L2LiquidityPoolTX.wait() + console.log(`⭐️ ${chalk.blue('L2 LP initialized:')} ${chalk.green(L2LiquidityPoolTX.hash)}`) } deployFn.tags = ['L1LiquidityPool', 'L2LiquidityPool', 'required'] diff --git a/packages/omgx/wallet/deploy/001-ERC20Test.deploy.ts b/packages/omgx/wallet/deploy/001-ERC20Test.deploy.ts index a94b9e7a5ca8..6dd102796d8a 100644 --- a/packages/omgx/wallet/deploy/001-ERC20Test.deploy.ts +++ b/packages/omgx/wallet/deploy/001-ERC20Test.deploy.ts @@ -63,7 +63,7 @@ const deployFn: DeployFunction = async (hre) => { //Set up things on L2 for this new token // [l2MessengerAddress, name, symbol] L2DepositedERC20 = await Factory__L2DepositedERC20.deploy( - (hre as any).deployConfig.watcher.l2.messengerAddress, + (hre as any).deployConfig.l2MessengerAddress, tokenName, tokenSymbol, {gasLimit: 800000, gasPrice: 0} @@ -83,7 +83,7 @@ const deployFn: DeployFunction = async (hre) => { L1ERC20Gateway = await Factory__L1ERC20Gateway.deploy( L1ERC20.address, L2DepositedERC20.address, - (hre as any).deployConfig.watcher.l1.messengerAddress + (hre as any).deployConfig.l1MessengerAddress ) await L1ERC20Gateway.deployTransaction.wait() const L1ERC20GatewayDeploymentSubmission: DeploymentSubmission = { diff --git a/packages/omgx/wallet/deploy/003-AtomicSwap.deploy.ts b/packages/omgx/wallet/deploy/003-AtomicSwap.deploy.ts index b561841e3e90..48ab2988e0cb 100644 --- a/packages/omgx/wallet/deploy/003-AtomicSwap.deploy.ts +++ b/packages/omgx/wallet/deploy/003-AtomicSwap.deploy.ts @@ -49,7 +49,7 @@ const deployFn: DeployFunction = async (hre) => { console.log(`🌕 ${chalk.red('AtomicSwap deployed to:')} ${chalk.green(AtomicSwap.address)}`) L1Message = await Factory__L1Message.deploy( - (hre as any).deployConfig.watcher.l1.messengerAddress, + (hre as any).deployConfig.l1MessengerAddress, ) await L1Message.deployTransaction.wait() const L1MessageDeploymentSubmission: DeploymentSubmission = { @@ -62,7 +62,7 @@ const deployFn: DeployFunction = async (hre) => { console.log(`🌕 ${chalk.red('L1 Message deployed to:')} ${chalk.green(L1Message.address)}`) L2Message = await Factory__L2Message.deploy( - (hre as any).deployConfig.watcher.l2.messengerAddress, + (hre as any).deployConfig.l2MessengerAddress, {gasLimit: 800000, gasPrice: 0} ) await L2Message.deployTransaction.wait() diff --git a/packages/omgx/wallet/scripts/wait-for-l1-and-l2.sh b/packages/omgx/wallet/scripts/wait-for-l1-and-l2.sh index 30063002e9f3..ab8f0c800179 100755 --- a/packages/omgx/wallet/scripts/wait-for-l1-and-l2.sh +++ b/packages/omgx/wallet/scripts/wait-for-l1-and-l2.sh @@ -57,4 +57,4 @@ if [ ! -z "$URL" ]; then $cmd else exec $cmd -fi \ No newline at end of file +fi diff --git a/packages/omgx/wallet/tsconfig.json b/packages/omgx/wallet/tsconfig.json index 65e768ceff14..583f8cf0a9a1 100644 --- a/packages/omgx/wallet/tsconfig.json +++ b/packages/omgx/wallet/tsconfig.json @@ -6,4 +6,4 @@ }, "include": ["./test", "./hardhat.config.ts", "./scripts", "./deploy"], "files": ["./hardhat.config.ts"] -} \ No newline at end of file +}