-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsendRewards.js
More file actions
158 lines (145 loc) · 5.02 KB
/
sendRewards.js
File metadata and controls
158 lines (145 loc) · 5.02 KB
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
const fs = require('fs');
const path = require('path');
const ethers = require('ethers');
console.log('\nPlease wait reading csv file and converting information into JavaScript Object');
const filePath = path.join(__dirname, 'Book6.1mac.csv');
const contents = fs.readFileSync(filePath, {encoding: 'utf-8'});
const addressObj = {};
//console.log('con', contents.length);
// for(const content of contents.split('\n')) {
const contentArray = contents.split('\n');
for(let i = 0;
// i < 100;
i < contentArray.length;
i++) {
const content = contentArray[i];
(async ()=>{const addressAndAmount = content.split(',');
//if(addressAndAmount.length === 2) {
// console.log(addressAndAmount);
try{
addressObj[addressAndAmount[0].split(' ').join('').split('"').join('')] = ethers.utils.parseEther(addressAndAmount[1].split(' ').join('').split('"').join(''));
}
catch (e) {
console.log(e.message);
console.log('error', addressAndAmount[1]);
}
try{
const provider = ethers.getDefaultProvider();
provider.getBalance(addressAndAmount[0].split(' ').join('').split('"').join(''));
}catch (e){
console.log(e, addressAndAmount[0].split(' ').join('').split('"').join(''))
}})()
//}
}
// console.log('done');
// // console.log('\nAddress vs ES tokens');
console.log(addressObj);
//
// const { esContract, timeally } = require('./src/env');
//
//
// // const { network } from './src/env';
// const network = 'kovan';
// const provider = ethers.getDefaultProvider(network);
//
// //24C4FE6063E62710EAD956611B71825B778B041B18ED53118CE5DA5F02E494BA
// // if(!process.argv[2]) {
// // throw '\nNOTE: Please pass your private key as comand line argument.\neg => node deploy.js 0x24C4FE063E...\n'
// // }
// //
// // console.log('\nPlease wait loading wallet...');
// // const wallet = new ethers.Wallet(process.argv[2], provider);
// // console.log(`Loaded wallet @ ${wallet.address}`);
// //
// // const esInstance = new ethers.Contract(esContract.address, esContract.abi, wallet);
// // const timeallyInstance = new ethers.Contract(timeally.address, timeally.abi, wallet);
//
// //console.log(esInstance, timeallyInstance);
//
// // const addressObj = {
// // '0xb2d0ff1108086063e6E4FF0171D7Bfa279FeCa25': ethers.utils.parseEther('100'),
// // '0xC8e1F3B9a0CdFceF9fFd2343B943989A22517b26': ethers.utils.parseEther('100'),
// // '0xC9082b2B3c4b099aDCE27afa079699D3e65d7527': ethers.utils.parseEther('100'),
// // // '0x1031a1C7Cc8edc64Cae561DcEA4285f8ab97e02F': ethers.utils.parseEther('40'),
// // // '0x3D2bB9D34D96307942b7cCe133bBF1aAd361C529': ethers.utils.parseEther('50')
// // }
//
// //console.log(Object.keys(addressObj), Object.values(addressObj));
//
let sum = ethers.utils.bigNumberify(0);
//console.log(ethers.utils.formatEther(sum));
for(const key in addressObj) {
sum = sum.add(addressObj[key]);
//console.log(ethers.utils.formatEther(sum));
}
//
// console.log('total ES to send as rewards', ethers.utils.formatEther(sum));
//
// // console.log(
// // Object.keys(addressObj),
// // Object.values(addressObj)
// // );
//
console.log('[');
// for(const address of Object.keys(addressObj)) {
// console.log(`"${address}",`);
// }
let start = 0;//100;
let end = 0;
//Object.keys(addressObj).length;
//220;
start--;
end--;
for(
let i = start;
i <= end;
i++
) {
const address = Object.keys(addressObj)[i];
console.log(`"${address}"${i !== Object.keys(addressObj).length - 1 ? ',' : ''}`);
}
console.log(']');
console.log('[');
// for(const address of Object.values(addressObj)) {
// console.log(`"${address}",`);
// }
let sumOfValue = ethers.utils.bigNumberify(0);
for(
let i = start;
i <= end;
i++
) {
const value = Object.values(addressObj)[i];
console.log(`"${value}"${i !== Object.values(addressObj).length - 1 ? ',' : ''}`);
sumOfValue = sumOfValue.add(value);
}
console.log(']');
//
// console.log('total being sent', ethers.utils.formatEther(sumOfValue));
// // let tx;
// // (async()=>{
// //
// // console.log('\nWallet Balance Currently:', ethers.utils.formatEther(await esInstance.functions.balanceOf(wallet.address)), 'ES');
// //
// // console.log(`\nPlease wait giving allowance of ${ethers.utils.formatEther(sum)} ES by owner to timeally`);
// // tx = await esInstance.functions.approve( timeallyInstance.address, sum );
// // await tx.wait();
// // console.log('done');
// //
// // console.log('\nPlease wait transferring this amount from owner to timeally');
// // tx = await timeallyInstance.functions.topupRewardBucket( sum );
// // await tx.wait();
// // console.log('done');
// //
// // console.log('\nPlease wait alloting rewards for users');
// // const args = [
// // Object.keys(addressObj),
// // Object.values(addressObj)
// // ];
// // console.log(args);
// // tx = await timeallyInstance.functions.giveLaunchReward( ...args );
// // await tx.wait();
// // console.log('done');
// //
// // console.log('\nWallet Balance Currently:', ethers.utils.formatEther(await esInstance.functions.balanceOf(wallet.address)), 'ES');
// // })();