feature: deploy core can distinguish between dev/prod/staging (#569)

* feature: deploy core can distinguish between dev/prod/staging

* feature: default to dev env if not set
buddies-main-deployment
James Prestwich 3 years ago committed by GitHub
parent 7d65515a5f
commit ee17c5fe6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      typescript/optics-deploy/config/alfajores.ts
  2. 12
      typescript/optics-deploy/config/kovan.ts
  3. 12
      typescript/optics-deploy/scripts/alfajoresKovan.ts
  4. 14
      typescript/optics-deploy/src/chain.ts
  5. 10
      typescript/optics-deploy/src/core/CoreDeploy.ts
  6. 1
      typescript/optics-tests/test/testChain.ts

@ -13,7 +13,8 @@ export const chainJson: ChainJson = {
export const chain = toChain(chainJson);
export const config: CoreConfig = {
export const devConfig: CoreConfig = {
environment: 'dev',
updater: '0x4177372FD9581ceb2367e0Ce84adC5DAD9DF8D55',
watchers: ['0x20aC2FD664bA5406A7262967C34107e708dCb18E'],
recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036',
@ -21,4 +22,13 @@ export const config: CoreConfig = {
recoveryTimelock: 180,
};
export const stagingConfig: CoreConfig = {
environment: 'staging',
updater: '0x201dd86063Dc251cA5a576d1b7365C38e5fB4CD5',
watchers: ['0x22B2855635154Baa41C306BcA979C8c9a077A180'],
recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036',
optimisticSeconds: 10,
recoveryTimelock: 180,
};
export const bridgeConfig: BridgeConfig = {};

@ -17,7 +17,8 @@ const chainJson: ChainJson = {
export const chain = toChain(chainJson);
export const config: CoreConfig = {
export const devConfig: CoreConfig = {
environment: 'dev',
updater: '0x4177372FD9581ceb2367e0Ce84adC5DAD9DF8D55',
optimisticSeconds: 10,
watchers: ['0x20aC2FD664bA5406A7262967C34107e708dCb18E'],
@ -25,6 +26,15 @@ export const config: CoreConfig = {
recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036',
};
export const stagingConfig: CoreConfig = {
environment: 'staging',
updater: '0x201dd86063Dc251cA5a576d1b7365C38e5fB4CD5',
watchers: ['0x22B2855635154Baa41C306BcA979C8c9a077A180'],
recoveryManager: '0x24F6c874F56533d9a1422e85e5C7A806ED11c036',
optimisticSeconds: 10,
recoveryTimelock: 180,
};
export const bridgeConfig: BridgeConfig = {
weth: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
};

@ -2,8 +2,16 @@ 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';
const alfaDeploy = new CoreDeploy(alfajores.chain, alfajores.config);
const kovanDeploy = new CoreDeploy(kovan.chain, kovan.config);
let environment = deployEnvironment();
let alfaConfig =
environment === 'staging' ? alfajores.stagingConfig : alfajores.devConfig;
let kovanConfig =
environment === 'staging' ? kovan.stagingConfig : kovan.devConfig;
const alfaDeploy = new CoreDeploy(alfajores.chain, alfaConfig);
const kovanDeploy = new CoreDeploy(kovan.chain, kovanConfig);
deployTwoChains(alfaDeploy, kovanDeploy);

@ -3,6 +3,8 @@ import { BigNumber } from 'ethers';
import { NonceManager } from '@ethersproject/experimental';
import { ProxyAddresses } from './proxyUtils';
export type DeployEnvironment = 'dev' | 'staging' | 'prod';
export type CoreContractDeployOutput = {
upgradeBeaconController: string;
xAppConnectionManager: string;
@ -31,6 +33,18 @@ export type Chain = {
domain: number;
};
export function deployEnvironment(): DeployEnvironment {
const e = process.env.OPTICS_DEPLOY_ENVIRONMENT;
if (e === 'staging') {
return 'staging';
} else if (e === 'prod') {
return 'prod';
}
return 'dev';
}
export function toChain(config: ChainJson): Chain {
const provider = new ethers.providers.JsonRpcProvider(config.rpc);
const signer = new ethers.Wallet(config.deployerKey!, provider);

@ -1,8 +1,15 @@
import { Chain, ChainJson, RustConfig, toChain } from '../chain';
import {
Chain,
ChainJson,
DeployEnvironment,
RustConfig,
toChain,
} from '../chain';
import { CoreContracts } from './CoreContracts';
import { Deploy } from '../deploy';
export type CoreConfig = {
environment: DeployEnvironment;
updater: string;
recoveryTimelock: number;
recoveryManager: string;
@ -27,6 +34,7 @@ export class CoreDeploy extends Deploy<CoreContracts> {
return [
chain,
{
environment: config.environment,
updater: config.updater,
watchers: config.watchers ?? [],
recoveryManager: config.recoveryManager,

@ -29,6 +29,7 @@ export async function getTestChain(
},
},
{
environment: 'dev',
recoveryTimelock: 1,
recoveryManager: recoveryManager || ethers.constants.AddressZero,
updater,

Loading…
Cancel
Save