Skip to content

Commit a34cbe2

Browse files
committed
new migrations
1 parent 7c4cf61 commit a34cbe2

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
const AddressHashMap = artifacts.require('./AddressHashMap.sol');
2+
const Multisig = artifacts.require('./MultiSigWallet.sol');
3+
const SNM = artifacts.require('./SNM.sol');
4+
const Blacklist = artifacts.require('./Blacklist.sol');
5+
const ProfileRegistry = artifacts.require('./ProfileRegistry');
6+
const Oracle = artifacts.require('./OracleUSD.sol');
7+
8+
let Orders = artifacts.require('./Orders.sol');
9+
let Deals = artifacts.require('./Deals.sol');
10+
let AdministratumCrud = artifacts.require('./AdministratumCrud.sol');
11+
let Administratum = artifacts.require('Administratum.sol');
12+
let ChangeRequests = artifacts.require('./ChangeRequests.sol');
13+
let Market = artifacts.require('./Market.sol');
14+
15+
const TruffleConfig = require('../truffle');
16+
const ContractRegistry = require('../migration_utils/address_hashmap');
17+
18+
const benchmarksNum = 13;
19+
const netflagsNum = 3;
20+
21+
22+
async function deploySidechain (deployer, network, accounts) {
23+
let registry = new ContractRegistry(AddressHashMap, network, Multisig);
24+
console.log('registry created');
25+
await registry.init();
26+
console.log('registry initialized');
27+
28+
let pr = await registry.resolve(ProfileRegistry, 'profileRegistryAddress');
29+
console.log('profile registry initialized');
30+
31+
let bl = await registry.resolve(Blacklist, 'blacklistAddress');
32+
console.log('blacklist initialized')
33+
34+
let snm = await registry.resolve(SNM, 'sidechainSNMAddress');
35+
console.log('snm initialized');
36+
37+
let oracle = await registry.resolve(Oracle, 'oracleAddress');
38+
console.log('oracle initialized');
39+
40+
41+
// deploy crud
42+
await deployer.deploy(Orders, { gasPrice: 0 });
43+
let orders = await Orders.deployed();
44+
console.log('orders crud deployed');
45+
46+
47+
await deployer.deploy(Deals, { gasPrice: 0 });
48+
console.log('deals crud deployed');
49+
let deals = await Deals.deployed();
50+
console.log('deployed object fetched');
51+
52+
await deployer.deploy(AdministratumCrud, { gasPrice: 0 });
53+
console.log('administratum crud deployed');
54+
let ac = await AdministratumCrud.deployed();
55+
console.log('deployed object fetched');
56+
57+
await deployer.deploy(Administratum, ac.address, { gasPrice: 0 });
58+
console.log('administratum deployed');
59+
let adm = await Administratum.deployed();
60+
console.log('deployed object fetched');
61+
62+
await deployer.deploy(ChangeRequests, { gasPrice: 0 });
63+
console.log('change requests crud deployed');
64+
let cr = await ChangeRequests.deployed();
65+
console.log('deployed object fetched');
66+
67+
// deploy market
68+
await deployer.deploy(Market, snm.address, bl.address, oracle.address, pr.address, adm.address, orders.address, deals.address, cr.address, benchmarksNum, netflagsNum )
69+
console.log('market deployed');
70+
let market = await Market.deployed();
71+
console.log('deployed object fetched');
72+
73+
// link market to administratum
74+
await adm.SetMarketAddress(market.address, { gasPrice:0 });
75+
let ms = await registry.resolve(Multisig, 'migrationMultSigAddress');
76+
console.log('ms resolved');
77+
78+
// link administratum crud to its contract
79+
await ac.tranferOwnership(adm.address, { gasPrice: 0 });
80+
81+
//transfer crud ownerships
82+
await orders.tranferOwnership(market.address, { gasPrice: 0 });
83+
await deals.tranferOwnership(market.address, { gasPrice: 0 });
84+
await cr.tranferOwnership(market.address, { gasPrice: 0 });
85+
await orders.transferAdministratorship(market.address, { gasPrice: 0 });
86+
await deals.transferAdministratorship(market.address, { gasPrice: 0 });
87+
await cr.transferAdministratorship(market.address, { gasPrice: 0 });
88+
89+
// transfer main contracts ownership
90+
await adm.transferOwnership(ms.address, { gasPrice: 0 });
91+
await market.transferOwnership(ms.address, { gasPrice: 0 });
92+
console.log('ownerships transferred');
93+
94+
95+
console.log('and submitted all theese addresses to registry');
96+
97+
await registry.write('migrationMultiSigAddress', ms.address);
98+
await registry.write('administratumAddress', adm.address);
99+
await registry.write('ordersCrudAddress', orders.address);
100+
await registry.write('dealsCrudAddress', deals.address);
101+
await registry.write('administratumCrudAddress', ac.address);
102+
await registry.write('administratumAddress', adm.address);
103+
await registry.write('marketAddress', market.address);
104+
}
105+
106+
module.exports = function (deployer, network, accounts) {
107+
deployer.then(async () => { // eslint-disable-line promise/catch-or-return
108+
if (TruffleConfig.isSidechain(network)) {
109+
await deploySidechain(deployer, network, accounts);
110+
}
111+
});
112+
};

0 commit comments

Comments
 (0)