-
Notifications
You must be signed in to change notification settings - Fork 29
/
eos.js
73 lines (65 loc) · 2.48 KB
/
eos.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
/**
* @title EOS
* @symbol EOS
* @implementation Dynamic
* @cmcId eos
*/
module.exports = (callback, request) => {
Promise.all([
request({
'uri': 'https://eospark.com/interface_main?n=get_base_info',
headers: {
'referer': 'https://eospark.com/',
'content-type': 'application/x-www-form-urlencoded'
},
'method': 'POST',
'body': '{"interface_name":"get_target_token_details","page":1,"size":1,"sort_field":"holder_num","sort_order":"descend","token_name":""}',
promise: true,
json: true
}),
request({
uri: 'https://eos.greymass.com/v1/chain/get_currency_balance',
headers: {
'Origin': 'https://bloks.io',
'Referer': 'https://bloks.io/account/eosio.ramfee',
'content-type': 'text/plain;charset=UTF-8'
},
method: 'POST',
body: '{"code":"eosio.token","account":"eosio.ramfee","symbol":"EOS"}',
promise: true
})
])
.then(results => {
if (typeof results[0].errmsg !== 'undefined'
&& results[0].errmsg == 'Success'
&& results[0].data.token_details_list[0].symbol == 'EOS'
) {
results[0] = results[0].data.token_details_list[0]
results[1] = Number(JSON.parse(results[1])[0].replace(' EOS', ''))
var resp = {
c: Number(results[0].supply - results[1]),
m: Number(results[0].max_supply)
}
callback(resp)
} else {
callback(new Error('Response malformed'));
}
})
.catch(error => {
callback(new Error('Request error ' + error.message));
});
// request('http://api.ethplorer.io/getTokenInfo/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0?apiKey=freekey', (error, response, body) => {
// if (!error && response.statusCode == 200) {
// body = JSON.parse(body);
// var resp = {
// t: Number(body.totalSupply) * Math.pow(10, -18)
// };
// if (typeof body.price !== 'undefined' && typeof body.price.availableSupply !== 'undefined') {
// resp.c = Number(body.price.availableSupply);
// }
// callback(resp);
// } else {
// callback(new Error('Request error ' + typeof response !== 'undefined' ? response.statusCode : error));
// }
// });
};