From 4cc842a648be89ba9e5828e0fba06ee1c2a99219 Mon Sep 17 00:00:00 2001 From: Pacman Date: Mon, 19 Jun 2023 20:11:53 +0200 Subject: [PATCH] feat(deployment): read mnemonic from env var --- README.md | 2 +- scripts/deploy/base/setupDeployer.ts | 8 +++++++- scripts/deploy/neutron/config.ts | 2 -- scripts/deploy/osmosis/config.ts | 7 ------- scripts/types/config.ts | 1 - 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 854c0bd4..55a7d43a 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ This compiles and optimizes all contracts, storing them in `/artifacts` director ## Deployment -When the deployment scripts run for the first time, it will upload code IDs for each contract, instantiate each contract, initialize assets, and set oracles. If you want to redeploy, you must locally delete the `osmo-test-4.json` file in the artifacts directory. +When the deployment scripts run for the first time, it will upload code IDs for each contract, instantiate each contract, initialize assets, and set oracles. If you want to redeploy, you must locally delete the `osmo-test-4.json` file in the artifacts directory. The contracts will be uploaded and instantiated using a wallet created from a 24-word BIP-39 seed phrase in the environment variable `MNEMONIC`. This variable must be set. Everything related to deployment must be ran from the `scripts` directory. diff --git a/scripts/deploy/base/setupDeployer.ts b/scripts/deploy/base/setupDeployer.ts index e15745e1..99c365e6 100644 --- a/scripts/deploy/base/setupDeployer.ts +++ b/scripts/deploy/base/setupDeployer.ts @@ -6,7 +6,13 @@ import { Deployer } from './deployer' import { Storage } from './storage' const getWallet = async (config: DeploymentConfig) => { - return await DirectSecp256k1HdWallet.fromMnemonic(config.deployerMnemonic, { + const mnemonic = process.env.MNEMONIC + + if (!mnemonic) { + throw new Error('The environment variable MNEMONIC is not set.') + } + + return await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: config.chainPrefix, }) } diff --git a/scripts/deploy/neutron/config.ts b/scripts/deploy/neutron/config.ts index 064bbd82..78552c16 100644 --- a/scripts/deploy/neutron/config.ts +++ b/scripts/deploy/neutron/config.ts @@ -110,8 +110,6 @@ export const neutronTestnetConfig: DeploymentConfig = { rewardCollectorTimeoutSeconds: 600, rpcEndpoint: 'https://rpc-palvus.pion-1.ntrn.tech:443', safetyFundFeeShare: '0.5', - deployerMnemonic: - 'bundle bundle orchard jeans office umbrella bird around taxi arrive infant discover elder they joy misery photo crunch gift fancy pledge attend adult eight', // TODO: Set mnemonic before deploying slippage_tolerance: '0.01', base_asset_symbol: 'NTRN', second_asset_symbol: 'ATOM', diff --git a/scripts/deploy/osmosis/config.ts b/scripts/deploy/osmosis/config.ts index 2bcea51f..52338b18 100644 --- a/scripts/deploy/osmosis/config.ts +++ b/scripts/deploy/osmosis/config.ts @@ -200,8 +200,6 @@ export const osmosisTestnetConfig: DeploymentConfig = { rewardCollectorTimeoutSeconds: 600, rpcEndpoint: 'https://rpc-test.osmosis.zone', safetyFundFeeShare: '0.5', - deployerMnemonic: - 'elevator august inherit simple buddy giggle zone despair marine rich swim danger blur people hundred faint ladder wet toe strong blade utility trial process', slippage_tolerance: '0.01', base_asset_symbol: 'OSMO', second_asset_symbol: 'ATOM', @@ -236,8 +234,6 @@ export const osmosisTestMultisig: DeploymentConfig = { rewardCollectorTimeoutSeconds: 600, rpcEndpoint: 'https://rpc-test.osmosis.zone', safetyFundFeeShare: '0.5', - deployerMnemonic: - 'elevator august inherit simple buddy giggle zone despair marine rich swim danger blur people hundred faint ladder wet toe strong blade utility trial process', slippage_tolerance: '0.01', base_asset_symbol: 'OSMO', second_asset_symbol: 'ATOM', @@ -272,7 +268,6 @@ export const osmosisMainnet: DeploymentConfig = { rewardCollectorTimeoutSeconds: 600, rpcEndpoint: 'https://rpc.osmosis.zone', safetyFundFeeShare: '0.5', - deployerMnemonic: 'TO BE INSERTED AT TIME OF DEPLOYMENT', slippage_tolerance: '0.01', base_asset_symbol: 'OSMO', second_asset_symbol: 'ATOM', @@ -336,8 +331,6 @@ export const osmosisLocalConfig: DeploymentConfig = { rewardCollectorTimeoutSeconds: 600, rpcEndpoint: 'http://localhost:26657', safetyFundFeeShare: '0.2', - deployerMnemonic: - 'notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius', slippage_tolerance: '0.05', base_asset_symbol: 'OSMO', second_asset_symbol: 'ATOM', diff --git a/scripts/types/config.ts b/scripts/types/config.ts index 73149cd4..83ecebfd 100644 --- a/scripts/types/config.ts +++ b/scripts/types/config.ts @@ -38,7 +38,6 @@ export interface DeploymentConfig { safetyFundDenom: string chainId: string rpcEndpoint: string - deployerMnemonic: string slippage_tolerance: string base_asset_symbol: string second_asset_symbol: string