Skip to content

Commit 242d85a

Browse files
committed
fix(account): Update error message when asking for a contract that is not verified by etherscan
* BC break, major release * error is not 'NOTOK' anymore, ubt a conrete error message * still ways to improve
1 parent 61a95c7 commit 242d85a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

lib/get-request.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ module.exports = function(chain, timeout) {
3737
var data = response.data;
3838

3939
if (data.status && data.status != 1) {
40-
return reject(data.message);
40+
let returnMessage = 'NOTOK';
41+
if (data.result && typeof data.result === 'string') {
42+
returnMessage = data.result;
43+
}
44+
return reject(returnMessage);
4145
}
4246

4347
if (data.error) {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
},
3434
"homepage": "https://github.com/sebs/etherscan-api#readme",
3535
"devDependencies": {
36-
"browserify": "^16.2.2",
37-
"chai": "^4.0.2",
36+
"browserify": "^16.2.3",
37+
"chai": "^4.2.0",
3838
"changelog": "^1.4.2",
3939
"ink-docstrap": "^1.3.2",
4040
"jsdoc": "^3.5.5",
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"axios": "^0.18.0",
47-
"gh-pages": "^2.0.0",
47+
"gh-pages": "^2.0.1",
4848
"querystring": "^0.2.0"
4949
}
5050
}

test/methods-test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ describe('api', function() {
144144
done();
145145
});
146146
});
147-
148-
xit('contract.getabi', function(done){
149-
var api = init();
147+
// test for bug #31
148+
// see https://github.com/sebs/etherscan-api/issues/31
149+
it('contract.getabi for a contract that is not verified by etherscan: error', function(done){
150+
var api = init('test', 'ropsten', 10000);
150151
var abi = api.contract.getabi('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413');
151-
abi.then(function(res){
152-
assert.ok(res);
152+
abi.then(function(){
153+
assert.false(true, 'should not be a success');
154+
}).catch(err=> {
155+
assert.equal(err, 'Contract source code not verified');
153156
done();
154157
});
155158
});

0 commit comments

Comments
 (0)