Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
remove watchers from wallet deployment scripts, init pools
Browse files Browse the repository at this point in the history
  • Loading branch information
InoMurko committed Jun 18, 2021
1 parent b0c3cdd commit 3be9390
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/omgx-publish-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
for i in $(docker images --format "{{.Repository}}:{{.Tag}}" | grep omgx); do
echo "$1"
docker push "$i"
done
done
43 changes: 11 additions & 32 deletions packages/omgx/wallet/bin/deploy.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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,
})

}
Expand Down
24 changes: 22 additions & 2 deletions packages/omgx/wallet/deploy/000-LiquidityPools.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 = {
Expand All @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions packages/omgx/wallet/deploy/001-ERC20Test.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions packages/omgx/wallet/deploy/003-AtomicSwap.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/omgx/wallet/scripts/wait-for-l1-and-l2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ if [ ! -z "$URL" ]; then
$cmd
else
exec $cmd
fi
fi
2 changes: 1 addition & 1 deletion packages/omgx/wallet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
},
"include": ["./test", "./hardhat.config.ts", "./scripts", "./deploy"],
"files": ["./hardhat.config.ts"]
}
}

0 comments on commit 3be9390

Please sign in to comment.