aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/migrations/2_deploy_independent_contracts.ts
blob: 10947655b97d11f057c526dd5c2eb597531217d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {Artifacts} from '../util/artifacts';
import {ContractInstance, MultiSigConfigByNetwork} from '../util/types';
const {
  MultiSigWalletWithTimeLock,
  TokenTransferProxy,
  EtherToken,
  TokenRegistry,
} = new Artifacts(artifacts);

let multiSigConfigByNetwork: MultiSigConfigByNetwork;
try {
  /* tslint:disable */
  const multiSigConfig = require('./config/multisig');
  multiSigConfigByNetwork = multiSigConfig.multiSig;
  /* tslint:enable */
} catch (e) {
  multiSigConfigByNetwork = {};
}

module.exports = (deployer: any, network: string, accounts: string[]) => {
  const defaultConfig = {
    owners: [accounts[0], accounts[1]],
    confirmationsRequired: 2,
    secondsRequired: 0,
  };
  const config = multiSigConfigByNetwork[network] || defaultConfig;
  if (network !== 'live') {
      deployer.deploy(MultiSigWalletWithTimeLock, config.owners, config.confirmationsRequired, config.secondsRequired)
      .then(() => {
          return deployer.deploy(TokenTransferProxy);
      }).then(() => {
          return deployer.deploy(TokenRegistry);
      }).then(() => {
          return deployer.deploy(EtherToken);
      });
  } else {
    deployer.deploy([
      [MultiSigWalletWithTimeLock, config.owners, config.confirmationsRequired, config.secondsRequired],
      TokenTransferProxy,
      TokenRegistry,
    ]);
  }
};