aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/migrations/2_deploy_independent_contracts.ts
blob: db9fc370d67e88f0eddec283b15abc3ec9b7b14b (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
44
45
46
47
import {Artifacts} from '../util/artifacts';
import {ContractInstance, MultiSigConfigByNetwork} from '../util/types';
const {
    MultiSigWalletWithTimeLock,
    TokenTransferProxy,
    EtherToken,
    EtherTokenV2,
    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);
            }).then(() => {
                return deployer.deploy(EtherTokenV2);
            });
    } else {
        deployer.deploy([
            [MultiSigWalletWithTimeLock, config.owners, config.confirmationsRequired, config.secondsRequired],
            TokenTransferProxy,
            TokenRegistry,
        ]);
    }
};