Skip to content

Commit eb5a5a6

Browse files
committed
Fixed some whitespaces
1 parent efe7f6c commit eb5a5a6

File tree

5 files changed

+28
-85
lines changed

5 files changed

+28
-85
lines changed

lib/init.js

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function pickChainUrl(chain) {
3030
* @param {string} apiKey - (optional) Your Etherscan APIkey
3131
* @param {string} chain - (optional) Testnet chain keys [ropsten, rinkeby, kovan]
3232
*/
33-
module.exports = function (apiKey, chain) {
33+
module.exports = function(apiKey, chain) {
3434

3535
if (!apiKey) {
3636
apiKey = 'YourApiKeyToken';
@@ -46,24 +46,22 @@ module.exports = function (apiKey, chain) {
4646
* @returns {Promise<any>}
4747
*/
4848
function getRequest(query) {
49-
return new Promise(function (resolve, reject) {
50-
client.get('/api?' + query)
51-
.then(function (response) {
52-
var data = response.data;
53-
54-
if (data.status && data.status != 1) {
55-
return reject(data.message);
56-
}
57-
58-
if (data.error) {
59-
return reject(data.error.message);
60-
}
61-
62-
resolve(data);
63-
})
64-
.catch(function (error) {
65-
return reject(error);
66-
});
49+
return new Promise(function(resolve, reject) {
50+
client.get('/api?' + query).then(function(response) {
51+
var data = response.data;
52+
53+
if (data.status && data.status != 1) {
54+
return reject(data.message);
55+
}
56+
57+
if (data.error) {
58+
return reject(data.error.message);
59+
}
60+
61+
resolve(data);
62+
}).catch(function(error) {
63+
return reject(error);
64+
});
6765
});
6866
}
6967

@@ -531,7 +529,6 @@ module.exports = function (apiKey, chain) {
531529
}
532530

533531
var query = querystring.stringify(queryObject);
534-
535532
return getRequest(query);
536533
},
537534
/**
@@ -571,7 +568,7 @@ module.exports = function (apiKey, chain) {
571568
const module = 'account';
572569
const action = 'txlistinternal';
573570

574-
var queryParams = {
571+
var queryObject = {
575572
module,
576573
action,
577574
apiKey
@@ -590,14 +587,14 @@ module.exports = function (apiKey, chain) {
590587
}
591588

592589
if (txhash) {
593-
queryParams.txhash = txhash;
590+
queryObject.txhash = txhash;
594591
} else {
595-
queryParams.address = address;
592+
queryObject.address = address;
596593
}
597594

598-
queryParams.txhash = txhash;
595+
queryObject.txhash = txhash;
599596

600-
return getRequest(querystring.stringify(queryParams));
597+
return getRequest(querystring.stringify(queryObject));
601598
},
602599
/**
603600
* Get a list of transactions for a specfic address

test/index-test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
'use strict';
22
const assert = require('chai').assert;
33
describe('index.js', function () {
4-
54
it('can be required', function () {
65
require('../.');
76
});
8-
97
it('has init', function () {
108
var res = require('../.');
119
assert.ok(res.init);
1210
});
13-
1411
it('init on mainnet', function () {
1512
var client = require('../.');
1613
assert.ok(client.init(null, 'mainnet'));
1714
});
18-
1915
});

test/methods-test.js

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ describe('api', function () {
1212
done();
1313
});
1414
});
15-
1615
/**
1716
* @deprecated by Etherscan
1817
* https://etherscan.io/apis#tokens
@@ -29,20 +28,14 @@ describe('api', function () {
2928
// done();
3029
// });
3130
// });
32-
3331
it('tokenbalance by address', function (done) {
3432
var api = init();
35-
var supply = api.account.tokenbalance(
36-
'0xe04f27eb70e025b78871a2ad7eabe85e61212761',
37-
false,
38-
'0x57d90b64a1a57749b0f932f1a3395792e12e7055'
39-
);
33+
var supply = api.account.tokenbalance('0xe04f27eb70e025b78871a2ad7eabe85e61212761', false, '0x57d90b64a1a57749b0f932f1a3395792e12e7055');
4034
supply.then(function (res) {
4135
assert.ok(res);
4236
done();
4337
});
4438
});
45-
4639
it('txlist', function (done) {
4740
var api = init();
4841
var txlist = api.account.txlist('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
@@ -51,7 +44,6 @@ describe('api', function () {
5144
done();
5245
});
5346
});
54-
5547
it('txlistinternal by hash', function (done) {
5648
var api = init();
5749
var txlist = api.account.txlistinternal('0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170');
@@ -60,12 +52,8 @@ describe('api', function () {
6052
assert.ok(res);
6153
done();
6254
})
63-
.catch(function (error) {
64-
console.log('REALY ERROR!!!!!????');
65-
done(error);
66-
});
55+
.catch(done);
6756
});
68-
6957
it('txlistinternal by address', function (done) {
7058
var api = init();
7159
var txlist = api.account.txlistinternal(null, '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
@@ -74,7 +62,6 @@ describe('api', function () {
7462
done();
7563
});
7664
});
77-
7865
it('balance', function (done) {
7966
var api = init();
8067
var balance = api.account.balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
@@ -92,7 +79,6 @@ describe('api', function () {
9279
});
9380
});
9481
});
95-
9682
describe('stats', function () {
9783
it('ethsupply', function (done) {
9884
var api = init();
@@ -102,7 +88,6 @@ describe('api', function () {
10288
done();
10389
});
10490
});
105-
10691
it('tokensupply by tokenname', function (done) {
10792
var api = init();
10893
var supply = api.stats.tokensupply('MKR');
@@ -111,7 +96,6 @@ describe('api', function () {
11196
done();
11297
});
11398
});
114-
11599
it('tokensupply by address', function (done) {
116100
var api = init();
117101
var supply = api.stats.tokensupply(null, '0x57d90b64a1a57749b0f932f1a3395792e12e7055');
@@ -120,7 +104,6 @@ describe('api', function () {
120104
done();
121105
}).catch(done);
122106
});
123-
124107
it('ethprice', function (done) {
125108
var api = init();
126109
var price = api.stats.ethprice();
@@ -130,7 +113,6 @@ describe('api', function () {
130113
}).catch(done);
131114
});
132115
});
133-
134116
it('block.getblockreward', function (done) {
135117
var api = init();
136118
var blockreward = api.block.getblockreward();
@@ -139,7 +121,6 @@ describe('api', function () {
139121
done();
140122
});
141123
});
142-
143124
it('transaction.getstatus', function (done) {
144125
var api = init();
145126
var status = api.transaction.getstatus('0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a');
@@ -148,7 +129,6 @@ describe('api', function () {
148129
done();
149130
});
150131
});
151-
152132
xit('contract.getabi', function (done) {
153133
var api = init();
154134
var abi = api.contract.getabi('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413');
@@ -157,8 +137,6 @@ describe('api', function () {
157137
done();
158138
});
159139
});
160-
161-
162140
describe('proxy', function () {
163141
it('proxy.eth_blockNumber', function (done) {
164142
var api = init();
@@ -168,8 +146,6 @@ describe('api', function () {
168146
done();
169147
});
170148
});
171-
172-
173149
it('proxy.eth_getBlockByNumber', function (done) {
174150
var api = init();
175151
var res = api.proxy.eth_getBlockByNumber('0x10d4f');
@@ -178,8 +154,6 @@ describe('api', function () {
178154
done();
179155
});
180156
});
181-
182-
183157
it('proxy.eth_getUncleByBlockNumberAndIndex', function (done) {
184158
var api = init();
185159
var res = api.proxy.eth_getUncleByBlockNumberAndIndex('0x210A9B', '0x0');
@@ -188,7 +162,6 @@ describe('api', function () {
188162
done();
189163
});
190164
});
191-
192165
it('proxy.eth_getBlockTransactionCountByNumber', function (done) {
193166
var api = init();
194167
var res = api.proxy.eth_getBlockTransactionCountByNumber('0x10FB78');
@@ -197,19 +170,14 @@ describe('api', function () {
197170
done();
198171
});
199172
});
200-
201173
it('proxy.eth_getTransactionByHash', function (done) {
202174
var api = init();
203-
var res = api.proxy.eth_getTransactionByHash(
204-
'0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1'
205-
);
175+
var res = api.proxy.eth_getTransactionByHash('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');
206176
res.then(function (res) {
207177
assert.ok(res);
208178
done();
209179
});
210180
});
211-
212-
213181
it('proxy.eth_getTransactionByBlockNumberAndIndex', function (done) {
214182
var api = init();
215183
var res = api.proxy.eth_getTransactionByBlockNumberAndIndex('0x10d4f', '0x0');
@@ -218,7 +186,6 @@ describe('api', function () {
218186
done();
219187
});
220188
});
221-
222189
it('proxy.eth_getTransactionCount', function (done) {
223190
var api = init();
224191
var res = api.proxy.eth_getTransactionCount('0x2910543af39aba0cd09dbb2d50200b3e800a63d2');
@@ -227,7 +194,6 @@ describe('api', function () {
227194
done();
228195
});
229196
});
230-
231197
xit('proxy.eth_sendRawTransaction', function (done) {
232198
var api = init();
233199
var res = api.proxy.eth_sendRawTransaction('0xf904808000831cfde080');
@@ -236,18 +202,14 @@ describe('api', function () {
236202
done();
237203
});
238204
});
239-
240205
it('proxy.eth_getTransactionReceipt', function (done) {
241206
var api = init();
242-
var res = api.proxy.eth_getTransactionReceipt(
243-
'0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1'
244-
);
207+
var res = api.proxy.eth_getTransactionReceipt('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');
245208
res.then(function (res) {
246209
assert.ok(res);
247210
done();
248211
});
249212
});
250-
251213
it('proxy.eth_call', function (done) {
252214
var api = init();
253215
var res = api.proxy.eth_call(
@@ -260,7 +222,6 @@ describe('api', function () {
260222
done();
261223
});
262224
});
263-
264225
it('proxy.eth_getCode', function (done) {
265226
var api = init();
266227
var res = api.proxy.eth_getCode('0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c', 'latest');
@@ -269,7 +230,6 @@ describe('api', function () {
269230
done();
270231
});
271232
});
272-
273233
it('proxy.eth_getStorageAt', function (done) {
274234
var api = init();
275235
var res = api.proxy.eth_getStorageAt('0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd', '0x0', 'latest');
@@ -278,7 +238,6 @@ describe('api', function () {
278238
done();
279239
});
280240
});
281-
282241
it('proxy.eth_gasPrice', function (done) {
283242
var api = init();
284243
var res = api.proxy.eth_gasPrice();
@@ -287,7 +246,6 @@ describe('api', function () {
287246
done();
288247
});
289248
});
290-
291249
xit('proxy.eth_estimateGas', function (done) {
292250
var api = init();
293251
var res = api.proxy.eth_estimateGas(

test/testnet-balance-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ describe('testnet balance', function () {
77
var balance = api.account.balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
88
assert.ok(balance.then);
99
});
10-
1110
it('executes the promise', function (done) {
1211
var api = init('YourApiKeyToken', 'ropsten');
1312
var balance = api.account.balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
1413
balance.then(function () {
1514
done();
1615
});
1716
});
18-
1917
it('has data', function (done) {
2018
var api = init('YourApiKeyToken', 'ropsten');
2119
var balance = api.account.balance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');

test/testnet-methods-test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('testnet methods', function () {
1919
})
2020
.catch(done);
2121
});
22-
2322
/**
2423
* @deprecated by Etherscan
2524
* https://etherscan.io/apis#tokens
@@ -67,7 +66,6 @@ describe('testnet methods', function () {
6766
done();
6867
}).catch(done);
6968
});
70-
7169
xit('txlistinternal by address', function (done) {
7270

7371
var txlist = api.account.txlistinternal(null, '0x3FAcfa472e86E3EDaEaa837f6BA038ac01F7F539');
@@ -216,9 +214,7 @@ describe('testnet methods', function () {
216214

217215
it('proxy.eth_getTransactionByHash', function (done) {
218216

219-
var res = api.proxy.eth_getTransactionByHash(
220-
'0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1'
221-
);
217+
var res = api.proxy.eth_getTransactionByHash('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');
222218
res.then(function (res) {
223219
assert.ok(res);
224220
done();
@@ -255,9 +251,7 @@ describe('testnet methods', function () {
255251

256252
it('proxy.eth_getTransactionReceipt', function (done) {
257253

258-
var res = api.proxy.eth_getTransactionReceipt(
259-
'0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1'
260-
);
254+
var res = api.proxy.eth_getTransactionReceipt('0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1');
261255
res.then(function (res) {
262256
assert.ok(res);
263257
done();

0 commit comments

Comments
 (0)