diff --git a/typescript/optics-deploy/.env.example b/typescript/optics-deploy/.env.example index fb5faf8f0..10f725c06 100644 --- a/typescript/optics-deploy/.env.example +++ b/typescript/optics-deploy/.env.example @@ -1,2 +1,8 @@ ALFAJORES_DEPLOYER_KEY= -KOVAN_DEPLOYER_KEY= \ No newline at end of file +ALFAJORES_RPC= + +KOVAN_DEPLOYER_KEY= +KOVAN_RPC= + +RINKEBY_DEPLOYER_KEY= +RINKEBY_RPC= \ No newline at end of file diff --git a/typescript/optics-deploy/config/mainnets/.gitkeep b/typescript/optics-deploy/config/mainnets/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/typescript/optics-deploy/config/alfajores.ts b/typescript/optics-deploy/config/testnets/alfajores.ts similarity index 76% rename from typescript/optics-deploy/config/alfajores.ts rename to typescript/optics-deploy/config/testnets/alfajores.ts index 1a9795eb9..fdecae36c 100644 --- a/typescript/optics-deploy/config/alfajores.ts +++ b/typescript/optics-deploy/config/testnets/alfajores.ts @@ -1,12 +1,18 @@ -import { ChainJson, toChain } from '../src/chain'; +import { ChainJson, toChain } from '../../src/chain'; import * as dotenv from 'dotenv'; -import { CoreConfig } from '../src/core/CoreDeploy'; -import { BridgeConfig } from '../src/bridge/BridgeDeploy'; +import { CoreConfig } from '../../src/core/CoreDeploy'; +import { BridgeConfig } from '../../src/bridge/BridgeDeploy'; + dotenv.config(); +const rpc = process.env.ALFAJORES_RPC; +if (!rpc) { + throw new Error('Missing RPC URI'); +} + export const chainJson: ChainJson = { name: 'alfajores', - rpc: 'https://alfajores-forno.celo-testnet.org', + rpc, deployerKey: process.env.ALFAJORES_DEPLOYER_KEY, domain: 1000, }; diff --git a/typescript/optics-deploy/config/kovan.ts b/typescript/optics-deploy/config/testnets/kovan.ts similarity index 78% rename from typescript/optics-deploy/config/kovan.ts rename to typescript/optics-deploy/config/testnets/kovan.ts index 5881f7f55..16e802020 100644 --- a/typescript/optics-deploy/config/kovan.ts +++ b/typescript/optics-deploy/config/testnets/kovan.ts @@ -1,15 +1,20 @@ import * as dotenv from 'dotenv'; -import { ChainJson, toChain } from '../src/chain'; -import { CoreConfig } from '../src/core/CoreDeploy'; -import { BridgeConfig } from '../src/bridge/BridgeDeploy'; +import { ChainJson, toChain } from '../../src/chain'; +import { CoreConfig } from '../../src/core/CoreDeploy'; +import { BridgeConfig } from '../../src/bridge/BridgeDeploy'; import { BigNumber } from 'ethers'; dotenv.config(); +const rpc = process.env.KOVAN_RPC; +if (!rpc) { + throw new Error('Missing RPC URI'); +} + const chainJson: ChainJson = { name: 'kovan', - rpc: 'https://kovan.infura.io/v3/5c456d7844fa40a683e934df60534c60', + rpc, deployerKey: process.env.KOVAN_DEPLOYER_KEY, domain: 3000, gasPrice: BigNumber.from(10_000_000_000), diff --git a/typescript/optics-deploy/config/testnets/rinkeby.ts b/typescript/optics-deploy/config/testnets/rinkeby.ts new file mode 100644 index 000000000..b6d312133 --- /dev/null +++ b/typescript/optics-deploy/config/testnets/rinkeby.ts @@ -0,0 +1,44 @@ +import * as dotenv from 'dotenv'; + +import { ChainJson, toChain } from '../../src/chain'; +import { CoreConfig } from '../../src/core/CoreDeploy'; +import { BridgeConfig } from '../../src/bridge/BridgeDeploy'; +import { BigNumber } from 'ethers'; + +dotenv.config(); + +const rpc = process.env.RINKEBY_RPC; +if (!rpc) { + throw new Error('Missing RPC URI'); +} + +const chainJson: ChainJson = { + name: 'rinkeby', + rpc, + deployerKey: process.env.RINKEBY_DEPLOYER_KEY, + domain: 2000, +}; + +export const chain = toChain(chainJson); + +export const devConfig: CoreConfig = { + environment: 'dev', + updater: '0x4177372FD9581ceb2367e0Ce84adC5DAD9DF8D55', + optimisticSeconds: 10, + watchers: ['0x20aC2FD664bA5406A7262967C34107e708dCb18E'], + recoveryTimelock: 180, + recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036', +}; + +export const stagingConfig: CoreConfig = { + environment: 'staging', + updater: '0x201dd86063Dc251cA5a576d1b7365C38e5fB4CD5', + watchers: ['0x22B2855635154Baa41C306BcA979C8c9a077A180'], + recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036', + optimisticSeconds: 10, + recoveryTimelock: 180, +}; + +export const bridgeConfig: BridgeConfig = { + weth: '0xc778417E063141139Fce010982780140Aa0cD5Ab', +}; diff --git a/typescript/optics-deploy/package.json b/typescript/optics-deploy/package.json index e134a961e..367426dab 100644 --- a/typescript/optics-deploy/package.json +++ b/typescript/optics-deploy/package.json @@ -13,8 +13,8 @@ "scripts": { "prettier": "prettier --write ./src ./config ./scripts", "test": "echo \"Error: no test specified\" && exit 1", - "deploy-core": "npx ts-node ./scripts/alfajoresKovan.ts", - "deploy-bridge": "npx ts-node ./scripts/bridgeAlfajoresKovan.ts" + "deploy-core": "npx ts-node ./scripts/alfajoresKovan/core.ts", + "deploy-bridge": "npx ts-node ./scripts/alfajoresKovan/bridge.ts" }, "author": "Celo Labs Inc.", "license": "MIT OR Apache-2.0", diff --git a/typescript/optics-deploy/scripts/bridgeAlfajoresKovan.ts b/typescript/optics-deploy/scripts/alfajoresKovan/bridge.ts similarity index 50% rename from typescript/optics-deploy/scripts/bridgeAlfajoresKovan.ts rename to typescript/optics-deploy/scripts/alfajoresKovan/bridge.ts index 4f32debdb..5e4f3b143 100644 --- a/typescript/optics-deploy/scripts/bridgeAlfajoresKovan.ts +++ b/typescript/optics-deploy/scripts/alfajoresKovan/bridge.ts @@ -1,8 +1,8 @@ -import { getPathToLatestDeploy } from '../src/verification/readDeployOutput'; -import { deployBridges } from '../src/bridge'; -import * as alfajores from '../config/alfajores'; -import * as kovan from '../config/kovan'; -import { BridgeDeploy } from '../src/bridge/BridgeDeploy'; +import { getPathToLatestDeploy } from '../../src/verification/readDeployOutput'; +import { deployBridges } from '../../src/bridge'; +import * as alfajores from '../../config/testnets/alfajores'; +import * as kovan from '../../config/testnets/kovan'; +import { BridgeDeploy } from '../../src/bridge/BridgeDeploy'; // get the path to the latest core system deploy const path = getPathToLatestDeploy(); diff --git a/typescript/optics-deploy/scripts/alfajoresKovan.ts b/typescript/optics-deploy/scripts/alfajoresKovan/core.ts similarity index 58% rename from typescript/optics-deploy/scripts/alfajoresKovan.ts rename to typescript/optics-deploy/scripts/alfajoresKovan/core.ts index 28e9ed6cc..ecd7f3458 100644 --- a/typescript/optics-deploy/scripts/alfajoresKovan.ts +++ b/typescript/optics-deploy/scripts/alfajoresKovan/core.ts @@ -1,8 +1,8 @@ -import { deployTwoChains } from '../src/core'; -import * as alfajores from '../config/alfajores'; -import * as kovan from '../config/kovan'; -import { CoreDeploy } from '../src/core/CoreDeploy'; -import { deployEnvironment } from '../src/chain'; +import { deployTwoChains } from '../../src/core'; +import * as alfajores from '../../config/testnets/alfajores'; +import * as kovan from '../../config/testnets/kovan'; +import { CoreDeploy } from '../../src/core/CoreDeploy'; +import { deployEnvironment } from '../../src/chain'; let environment = deployEnvironment(); diff --git a/typescript/optics-deploy/scripts/threeTestnets/bridge.ts b/typescript/optics-deploy/scripts/threeTestnets/bridge.ts new file mode 100644 index 000000000..4302a0aa0 --- /dev/null +++ b/typescript/optics-deploy/scripts/threeTestnets/bridge.ts @@ -0,0 +1,23 @@ +import { getPathToLatestDeploy } from '../../src/verification/readDeployOutput'; +import { deployBridges } from '../../src/bridge'; +import * as alfajores from '../../config/testnets/alfajores'; +import * as kovan from '../../config/testnets/kovan'; +import * as rinkeby from '../../config/testnets/rinkeby'; +import { BridgeDeploy } from '../../src/bridge/BridgeDeploy'; + +// get the path to the latest core system deploy +const path = getPathToLatestDeploy(); + +const alfajoresDeploy = new BridgeDeploy( + alfajores.chain, + alfajores.bridgeConfig, + path, +); +const kovanDeploy = new BridgeDeploy(kovan.chain, kovan.bridgeConfig, path); +const rinkebyDeploy = new BridgeDeploy( + rinkeby.chain, + rinkeby.bridgeConfig, + path, +); + +deployBridges([alfajoresDeploy, kovanDeploy, rinkebyDeploy]); diff --git a/typescript/optics-deploy/scripts/threeTestnets/core.ts b/typescript/optics-deploy/scripts/threeTestnets/core.ts new file mode 100644 index 000000000..5c37357ec --- /dev/null +++ b/typescript/optics-deploy/scripts/threeTestnets/core.ts @@ -0,0 +1,21 @@ +import { deployNChains } from '../../src/core'; +import * as alfajores from '../../config/testnets/alfajores'; +import * as kovan from '../../config/testnets/kovan'; +import * as rinkeby from '../../config/testnets/rinkeby'; +import { CoreDeploy } from '../../src/core/CoreDeploy'; +import { deployEnvironment } from '../../src/chain'; + +let environment = deployEnvironment(); + +let alfaConfig = + environment === 'staging' ? alfajores.stagingConfig : alfajores.devConfig; +let kovanConfig = + environment === 'staging' ? kovan.stagingConfig : kovan.devConfig; +let rinkebyConfig = + environment === 'staging' ? rinkeby.stagingConfig : rinkeby.devConfig; + +const alfaDeploy = new CoreDeploy(alfajores.chain, alfaConfig); +const kovanDeploy = new CoreDeploy(kovan.chain, kovanConfig); +const rinkebyDeploy = new CoreDeploy(rinkeby.chain, rinkebyConfig); + +deployNChains([alfaDeploy, kovanDeploy, rinkebyDeploy]);