-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathpolymath.js
29 lines (25 loc) · 957 Bytes
/
polymath.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
/**
* @title Polymath
* @symbol POLY
* @ethContractAddr 0x9992ec3cf6a55b00978cddf2b27bc6882d88d1ec
* @implementation Dynamic
* @cmcId polymath-network
*/
module.exports = (callback, request) => {
request('http://api.ethplorer.io/getTokenInfo/0x9992ec3cf6a55b00978cddf2b27bc6882d88d1ec?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);
} else {
resp.c = 300056960;
}
callback(resp);
} else {
callback(new Error('Request error ' + typeof response !== 'undefined' ? response.statusCode : error));
}
});
};