File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,19 @@ const TESTNET_API_URL_MAP = {
9
9
rinkeby : 'https://rinkeby.etherscan.io'
10
10
} ;
11
11
12
+ /**
13
+ * @param {string } chain
14
+ * @returns {string }
15
+ */
16
+ function pickChainUrl ( chain ) {
17
+ if ( ! chain || ! TESTNET_API_URL_MAP [ chain ] ) {
18
+ return MAIN_API_URL ;
19
+ }
20
+
21
+ return TESTNET_API_URL_MAP [ chain ] ;
22
+ }
23
+
24
+
12
25
/**
13
26
* @module etherscan/api
14
27
*/
@@ -23,18 +36,6 @@ module.exports = function (apiKey, chain) {
23
36
apiKey = 'YourApiKeyToken' ;
24
37
}
25
38
26
- /**
27
- * @param {string } chain
28
- * @returns {string }
29
- */
30
- function pickChainUrl ( chain ) {
31
- if ( ! chain || ! TESTNET_API_URL_MAP [ chain ] ) {
32
- return MAIN_API_URL ;
33
- }
34
-
35
- return TESTNET_API_URL_MAP [ chain ] ;
36
- }
37
-
38
39
var client = axios . create ( {
39
40
baseURL : pickChainUrl ( chain ) ,
40
41
timeout : 3000
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ describe('api', function () {
92
92
} ) ;
93
93
} ) ;
94
94
} ) ;
95
+
95
96
describe ( 'stats' , function ( ) {
96
97
it ( 'ethsupply' , function ( done ) {
97
98
var api = init ( ) ;
@@ -110,6 +111,7 @@ describe('api', function () {
110
111
done ( ) ;
111
112
} ) ;
112
113
} ) ;
114
+
113
115
it ( 'tokensupply by address' , function ( done ) {
114
116
var api = init ( ) ;
115
117
var supply = api . stats . tokensupply ( null , '0x57d90b64a1a57749b0f932f1a3395792e12e7055' ) ;
@@ -125,11 +127,10 @@ describe('api', function () {
125
127
price . then ( function ( res ) {
126
128
assert . ok ( res ) ;
127
129
done ( ) ;
128
- } ) ;
130
+ } ) . catch ( done ) ;
129
131
} ) ;
130
132
} ) ;
131
133
132
-
133
134
it ( 'block.getblockreward' , function ( done ) {
134
135
var api = init ( ) ;
135
136
var blockreward = api . block . getblockreward ( ) ;
You can’t perform that action at this time.
0 commit comments