on df0c310 help sign in
bridge/migrations/1_migration.js
183 lines 6.3 kB history raw
1var Azimuth = artifacts.require('azimuth-solidity/Azimuth');
2var Polls = artifacts.require('azimuth-solidity/Polls');
3var Claims = artifacts.require('azimuth-solidity/Claims');
4var Censures = artifacts.require('azimuth-solidity/Censures');
5var Ecliptic = artifacts.require('azimuth-solidity/Ecliptic');
6var DelegatedSending = artifacts.require('azimuth-solidity/DelegatedSending');
7var LSR = artifacts.require('azimuth-solidity/LinearStarRelease');
8var CSR = artifacts.require('azimuth-solidity/ConditionalStarRelease');
9// TODO: replace when https://github.com/urbit/azimuth/pull/43 is merged
10var Naive = artifacts.require('Naive');
12const user1 = '0xD53208cf45fC9bd7938B200BFf8814A26146688f';
13const rateUnit = 50;
15const conditions = [
16 '0x00000000000000000000000000000000000000000000000000000000000000a0',
17 '0x00000000000000000000000000000000000000000000000000000000000001e0',
18 '0x0000000000000000000000000000000000000000000000000000000000000260',
19 '0x00000000000000000000000000000000000000000000000000000000621f23c4',
20 '0x0000000000000000000000000000000000000000000000000000000000000003',
21 '0x0000000000000000000000000000000000000000000000000000000000000060',
22 '0x00000000000000000000000000000000000000000000000000000000000000a0',
23];
24const minute = 60;
25const getLivelines = start => [
26 start - 5 * minute,
27 start + 10 * minute,
28 start + 15 * minute,
29 start + 20 * minute,
30 start + 25 * minute,
31 start + 30 * minute,
32 start + 35 * minute,
33];
35const getDeadlines = start => [
36 start + 10 * minute,
37 start + 15 * minute,
38 start + 20 * minute,
39 start + 25 * minute,
40 start + 30 * minute,
41 start + 35 * minute,
42 start + 40 * minute,
43];
45async function getChainTime() {
46 const block = await web3.eth.getBlock('latest');
48 return web3.utils.toDecimal(block.timestamp);
51module.exports = async function(deployer) {
52 await deployer;
54 // setup contracts
55 const azimuth = await deployer.deploy(Azimuth);
56 const polls = await deployer.deploy(Polls, 1209600, 604800);
57 const claims = await deployer.deploy(Claims, azimuth.address);
58 const censures = await deployer.deploy(Censures, azimuth.address);
60 //NOTE for real deployment, use a real ENS registry
61 const ecliptic = await deployer.deploy(
62 Ecliptic,
63 '0x0000000000000000000000000000000000000000',
64 azimuth.address,
65 polls.address,
66 claims.address
67 );
69 // configure contract ownership
70 await azimuth.transferOwnership(ecliptic.address);
71 await polls.transferOwnership(ecliptic.address);
73 // deploy secondary contracts
74 const sending = await deployer.deploy(DelegatedSending, azimuth.address);
75 const time = await getChainTime();
76 const livelines = getLivelines(time);
77 const deadlines = getDeadlines(time);
79 const escapeHatchDate = time + 200 * minute;
81 const csr = await deployer.deploy(
82 CSR,
83 azimuth.address,
84 conditions,
85 livelines,
86 deadlines,
87 escapeHatchDate
88 );
90 const lsr = await deployer.deploy(LSR, azimuth.address);
92 // deploy naive contract
93 const naive = await deployer.deploy(Naive);
95 const own = await ecliptic.owner();
96 switch (process.env.WITH_TEST_STATE) {
97 case 'STAR_RELEASE':
98 await ecliptic.createGalaxy(0, own);
99 await ecliptic.createGalaxy(1, own);
101 await ecliptic.configureKeys(0, '0x123', '0x456', 1, false);
102 await ecliptic.configureKeys(1, '0x123', '0x456', 1, false);
103 await ecliptic.spawn(256, own);
105 lsr.startReleasing();
106 await ecliptic.setSpawnProxy(0, lsr.address);
107 await ecliptic.setSpawnProxy(1, csr.address);
108 await ecliptic.setTransferProxy(256, lsr.address);
109 // Release 2 stars every 5 minutes, starting 2 minutes from now
110 // for a maximum of 8 stars
111 await lsr.register(user1, 2 * minute, 21, 2, 5 * minute);
112 // Release 1 star per minute for each completed batch
113 // 3 in each batch
114 await csr.register(user1, [3, 3, 3, 3, 3, 3, 3], 1, rateUnit);
116 for (let i = 2; i < 23; i++) {
117 const offset = 256 * i;
118 await lsr.deposit(user1, offset);
119 await csr.deposit(user1, offset + 1);
120 }
121 break;
122 case 'INVITES':
123 await ecliptic.createGalaxy(0, own);
124 await ecliptic.configureKeys(0, '0x123', '0x456', 1, false);
125 await ecliptic.spawn(256, own);
126 await ecliptic.configureKeys(256, '0x456', '0x789', 1, false);
127 // set transfer proxy to delegated sending, very brittle
128 await ecliptic.setSpawnProxy(256, sending.address);
129 await ecliptic.spawn(65792, own);
130 await ecliptic.spawn(131328, own);
131 await ecliptic.spawn(512, own);
132 await sending.setPoolSize(256, 65792, 1000);
133 break;
134 case 'RESIDENTS':
135 await ecliptic.createGalaxy(0, own);
136 await ecliptic.configureKeys(0, '0x123', '0x456', 1, false);
137 await ecliptic.spawn(256, own);
138 await ecliptic.configureKeys(256, '0x456', '0x789', 1, false);
139 for (let i = 2; i < 30; i++) {
140 // await ecliptic.spawn(256 * i, user1);
141 const offset = 65536 * i;
142 await ecliptic.spawn(offset + 256, own);
143 await ecliptic.transferPoint(offset + 256, user1, false);
144 }
145 break;
146 case 'L2':
147 // all ships will have as owner:
148 // 0x6deffb0cafdb11d175f123f6891aa64f01c24f7d
149 //
150 // ~zod -> L1
151 await ecliptic.createGalaxy(0, own);
152 await ecliptic.configureKeys(0, '0xffff', '0xffff', 1, false);
153 // ~marzod -> L1
154 await ecliptic.spawn(256, own);
155 await ecliptic.configureKeys(256, '0xffff', '0xffff', 1, false);
156 // ~wanzod -> L1
157 await ecliptic.spawn(768, own);
158 await ecliptic.configureKeys(768, '0xffff', '0xffff', 1, false);
159 // ~wanzod sets spawn-proxy to L2
160 await ecliptic.setSpawnProxy(
161 768,
162 '0x1111111111111111111111111111111111111111'
163 );
164 // ~wicdev-wisryt -> L1
165 await ecliptic.spawn(65792, own);
166 // ~panret-tocsel -> L1
167 await ecliptic.spawn(131328, own);
168 // ~binzod -> L1
169 await ecliptic.spawn(512, own);
170 // ~norsyr-torryn -> L1
171 await ecliptic.spawn(99549440, own);
172 // ~norsyr-torryn -> L2
173 await ecliptic.transferPoint(
174 99549440,
175 '0x1111111111111111111111111111111111111111',
176 true
177 );
178 break;
180 default:
181 return;
182 }
183};