This repository was archived by the owner on Dec 26, 2024. It is now read-only.
File tree 2 files changed +35
-4
lines changed
2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,7 @@ module.exports = function(getRequest, apiKey) {
6
6
* @param {string } address - Contract address
7
7
* @example
8
8
* api.contract
9
- * .getabi('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
10
- * .at('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
11
- * .memberId('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
9
+ * .getabi('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413')
12
10
* .then(console.log)
13
11
* @returns {Promise.<object> }
14
12
*/
@@ -21,6 +19,28 @@ module.exports = function(getRequest, apiKey) {
21
19
} ) ;
22
20
23
21
return getRequest ( query ) ;
24
- }
22
+ } ,
23
+ /**
24
+ * Returns the Sourcecode of a given verified contract
25
+ * @param {string } address - Contract address
26
+ * @example
27
+ * api.contract
28
+ * .getsourcecode('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413')
29
+ * .then(console.log)
30
+ * @returns {Promise.<object> }
31
+ */
32
+ getsourcecode ( address ) {
33
+ const module = 'contract' ;
34
+ const action = 'getsourcecode' ;
35
+
36
+ var query = querystring . stringify ( {
37
+ module, action, address, apiKey
38
+ } ) ;
39
+
40
+ return getRequest ( query ) ;
41
+ } ,
42
+
43
+
44
+
25
45
} ;
26
46
} ;
Original file line number Diff line number Diff line change @@ -169,6 +169,17 @@ describe('api', function() {
169
169
} ) ;
170
170
} ) ;
171
171
172
+ it ( 'contract.getsourcecode' , function ( done ) {
173
+ var api = init ( process . env . API_KEY ) ;
174
+ var abi = api . contract . getsourcecode ( '0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413' ) ;
175
+ abi . then ( function ( ) {
176
+ assert . ok ( true ) ;
177
+ done ( ) ;
178
+ } ) . catch ( err => {
179
+ assert . equal ( err , 'Contract source code not verified' ) ;
180
+ done ( ) ;
181
+ } ) ;
182
+ } ) . timeout ( 100000 ) ;
172
183
173
184
174
185
describe ( 'proxy' , function ( ) {
You can’t perform that action at this time.
0 commit comments