-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
188 lines (158 loc) · 15.3 KB
/
script.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
let ctx = {};
let voting = '0x24d840dbaa0c0c72589c8f8860063024d1c064db';
let claimer = '0x5AEdBAacDf054738327CAc23C47017903684CAdf';
let claimContract = '0xc5D532D29600F47328121092ae6D74F65fe6A3D8'
let claimToken = '0x53c29055ddc8d02ef8ef01127939c5246965e7d1'
let BN = web3.utils.BN;
await (async function() { ctx.voting = await IVoting.at(voting) })()
await (async function() { ctx.votesLength = parseInt((await ctx.voting.votesLength()).toString()) })()
// await (async function() { ctx.claim = await FlamincomeClaim.new() })()
await (async function() { ctx.claim = await FlamincomeClaim.at(claimContract) })()
await (async function() { ctx.token = await IERC20.at(claimToken) })()
await (async function() { await ctx.claim.setTotalSupply(new web3.utils.BN('1000000000000000000000')) })()
await (async function() { return (await ctx.claim.totalSupply()).toString() })()
await (async function() { await ctx.claim.setVotingAddress(voting) })()
await (async function() { return (await ctx.claim.voting()) })()
await (async function() { await ctx.claim.setCreateDate(new web3.utils.BN(1602247965)) })()
await (async function() { return (await ctx.claim.createDate()).toString() })()
await (async function() { return (await ctx.token.balanceOf(claimContract)).toString() })()
await (async function() { return (await ctx.token.balanceOf(claimer)).toString() })()
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(19), claimer)) })()
await (async function() { return (await ctx.claim.claimSomeAvailable([new web3.utils.BN(19)], claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(19), claimer)) })()
await (async function() { return (await ctx.claim.claimAt(new web3.utils.BN(19), claimer)) })()
await (async function() { return (await ctx.voting.getVote(0))['2'].toString() })()
// this will get enum VoterState { Absent, Yea, Nay }, 0 => Absent, 1 => Yea, 2 => Nay
await (async function() { return (await ctx.voting.getVoterState(15, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(16, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(17, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(18, claimer)).toString() })() // 0
await (async function() { return (await ctx.voting.getVoterState(19, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(20, claimer)).toString() })() // 2
await (async function() { return (await ctx.voting.getVoterState(31, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(33, claimer)).toString() })() // 1
await (async function() { return (await ctx.voting.getVoterState(37, claimer)).toString() })() // 1
await (async function() { return (await ctx.claim.parseVote(15)) })() // (true, 1602338864, 7345481, 3000000000000000000, 0)
await (async function() { return (await ctx.claim.parseVote(16)) })() // (true, 1602339014, 7345491, 3000000000000000000, 0)
await (async function() { return (await ctx.claim.parseVote(17)) })() // (true, 1602339225, 7345505, 3000000000000000000, 0)
await (async function() { return (await ctx.claim.parseVote(18)) })() // (false, 1602339390, 7345516, 0, 0)
await (async function() { return (await ctx.claim.parseVote(19)) })() // (true, 1602339706, 7345537, 3000000000000000000, 0)
await (async function() { return (await ctx.claim.parseVote(20)) })() // (false, 1602339796, 7345543, 0, 3000000000000000000)
await (async function() { return (await ctx.claim.parseVote(31)) })() // (true, 1602668717, 7367450, 113000000000000000001, 0)
await (async function() { return (await ctx.claim.parseVote(33)) })() // (true, 1603073433, 7394415, 103000000000000000003, 0)
await (async function() { return (await ctx.claim.parseVote(37)) })() // (true, 1603264967, 7407181, 103000000000000000005, 0)
await (async function() { return (await ctx.claim.isVoteOpen(1602338864, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602339014, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602339225, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602339390, false)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602339706, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602339796, false)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1602668717, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1603073433, true)) })() // false
await (async function() { return (await ctx.claim.isVoteOpen(1603264967, true)) })() // false
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(15))).toString() })() // 150
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(16))).toString() })() // 150
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(17))).toString() })() // 211
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(18))).toString() })() // 165
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(19))).toString() })() // 316
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(20))).toString() })() // 90
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(31))).toString() })() // 176292
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(33))).toString() })() // 241349
await (async function() { return (await ctx.claim.getVoteGap(new web3.utils.BN(37))).toString() })() // 93584
await (async function() { return (await ctx.claim.getStake(claimer, 7345481)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7345491)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7345505)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7345516)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7345537)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7345543)).toString() })() // 3000000000000000000
await (async function() { return (await ctx.claim.getStake(claimer, 7367450)).toString() })() // 102999999999999999996
await (async function() { return (await ctx.claim.getStake(claimer, 7394415)).toString() })() // 102999999999999999996
await (async function() { return (await ctx.claim.getStake(claimer, 7407181)).toString() })() // 102999999999999999994
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(15), claimer)) })() // 4756468797564687
(new BN('3000000000000000000')).mul(new BN(150)).mul(new BN('1000000000000000000000')).div((new BN('3000000000000000000')).mul(new BN('31536000'))).toString() // 4756468797564687
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(16), claimer)) })() // 4756468797564687
(new BN('3000000000000000000')).mul(new BN(150)).mul(new BN('1000000000000000000000')).div((new BN('3000000000000000000')).mul(new BN('31536000'))).toString() // 4756468797564687
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(17), claimer)) })() // 6690766108574327
(new BN('3000000000000000000')).mul(new BN(211)).mul(new BN('1000000000000000000000')).div((new BN('3000000000000000000')).mul(new BN('31536000'))).toString() // 6690766108574327
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(18), claimer)) })() // 0 this vote is in absent state
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(19), claimer)) })() // 10020294266869609
(new BN('3000000000000000000')).mul(new BN(316)).mul(new BN('1000000000000000000000')).div((new BN('3000000000000000000')).mul(new BN('31536000'))).toString() // 10020294266869609
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(20), claimer)) })() // 2853881278538812
(new BN('3000000000000000000')).mul(new BN(90)).mul(new BN('1000000000000000000000')).div((new BN('3000000000000000000')).mul(new BN('31536000'))).toString() // 2853881278538812
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(31), claimer)) })() // 5095476219339717945
(new BN('102999999999999999996')).mul(new BN(176292)).mul(new BN('1000000000000000000000')).div((new BN('113000000000000000001')).mul(new BN('31536000'))).toString() // 5095476219339717945
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(33), claimer)) })() // 7653126585489599187
(new BN('102999999999999999996')).mul(new BN(241349)).mul(new BN('1000000000000000000000')).div((new BN('103000000000000000003')).mul(new BN('31536000'))).toString() // 7653126585489599187
await (async function() { return (await ctx.claim.claimAtAvailable(new web3.utils.BN(37), claimer)) })() // 2967529173008625063
(new BN('102999999999999999994')).mul(new BN(93584)).mul(new BN('1000000000000000000000')).div((new BN('103000000000000000005')).mul(new BN('31536000'))).toString() // 2967529173008625063
let voteIds = [new web3.utils.BN(15), new web3.utils.BN(16), new web3.utils.BN(17), new web3.utils.BN(18), new web3.utils.BN(19), new web3.utils.BN(20), new web3.utils.BN(31), new web3.utils.BN(33), new web3.utils.BN(37)]
await (async function() { return (await ctx.claim.claimSomeAvailable(voteIds, claimer)) })() // true,true,true,false,true,true,true,true,true | 15745209857087054317
(new BN('4756468797564687')).add(new BN('4756468797564687')).add(new BN('6690766108574327')).add(new BN('10020294266869609')).add(new BN('2853881278538812')).add(new BN('5095476219339717945')).add(new BN('7653126585489599187')).add(new BN('2967529173008625063')).toString() // 15745209857087054317
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(15), claimer)) })()
await (async function() { return (await ctx.claim.claimAt(new web3.utils.BN(15), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(16), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(17), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(18), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(19), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(20), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(31), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(33), claimer)) })()
await (async function() { return (await ctx.claim.claimed(new web3.utils.BN(37), claimer)) })()
await (async function() { return (await ctx.claim.claimSome(voteIds, claimer)) })()
/***************************************************************************************************************/
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
async function checkVote(elem, idx) {
let state = await (async function() { return (await ctx.voting.getVoterState(elem, claimer)).toString() })()
console.log(`vote${elem} => ${state}`)
}
let voteIds = []
for (var i=0; i<ctx.votesLength; i++) {
voteIds.append(i)
}
console.log(voteIds)
await (async function() { await asyncForEach(voteIds, checkVote) })()
for (var i = 0; i < 38; i++) {
console.log(`await (async function() { return (await ctx.voting.getVoterState(${i}, claimer)).toString() })()`)
}
await (async function() { return (await ctx.voting.getVoterState(0, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(1, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(2, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(3, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(4, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(5, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(6, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(7, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(8, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(new web.utils.BN(9), claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(10, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(11, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(12, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(13, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(14, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(15, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(16, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(17, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(18, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(19, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(20, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(21, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(22, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(23, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(24, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(25, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(26, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(27, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(28, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(29, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(30, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(31, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(32, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(33, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(34, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(35, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(36, claimer)).toString() })()
await (async function() { return (await ctx.voting.getVoterState(37, claimer)).toString() })()