Skip to content

Commit 3b71042

Browse files
Merge pull request #63 from web3data/fix/wrong-method
fix(wrong-method): Move method to contract.js
2 parents 994cdf3 + 11328b2 commit 3b71042

File tree

7 files changed

+85
-80
lines changed

7 files changed

+85
-80
lines changed

dist/web3data.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.5.18*
1+
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.6.18*
22

33
> A javascript wrapper for accessing amberdata's public API.
44
@@ -695,7 +695,7 @@ Retrieves all the detailed information for the specified contract (ABI, bytecode
695695

696696
| Name | Type | Description | |
697697
| ---- | ---- | ----------- | -------- |
698-
| hash | | The address. |   |
698+
| hash | `string` | The address. |   |
699699

700700

701701

@@ -710,7 +710,7 @@ const details = await web3data.contract.getDetails('0x06012c8cf97bead5deae237070
710710
##### Returns
711711

712712

713-
- The detailed information for the specified contract.
713+
- `Promise.<object>` The detailed information for the specified contract.
714714

715715

716716

@@ -728,7 +728,7 @@ Retrieves the functions of the specified contract (if available). If not availab
728728

729729
| Name | Type | Description | |
730730
| ---- | ---- | ----------- | -------- |
731-
| hash | | The contract address. | &nbsp; |
731+
| hash | `string` | The contract address. | &nbsp; |
732732

733733

734734

@@ -743,7 +743,40 @@ const functions = await web3data.contract.getFunctions('0x06012c8cf97bead5deae23
743743
##### Returns
744744

745745

746-
- The functions or decompiled functions of the specified contract.
746+
- `Promise.<object>` The functions or decompiled functions of the specified contract.
747+
748+
749+
750+
751+
752+
#### getAudit(hash)
753+
754+
755+
Alias for getSecurityAudit.
756+
757+
758+
759+
760+
##### Parameters
761+
762+
| Name | Type | Description | |
763+
| ---- | ---- | ----------- | -------- |
764+
| hash | `string` | The contract address. | &nbsp; |
765+
766+
767+
768+
769+
##### Examples
770+
771+
```javascript
772+
const signatureDetails = await web3data.signature.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
773+
```
774+
775+
776+
##### Returns
777+
778+
779+
- `Promise.<object>` The vulnerabilities audit for the specified contract.
747780

748781

749782

@@ -761,22 +794,22 @@ Retrieves the vulnerabilities audit for the specified contract (if available).
761794

762795
| Name | Type | Description | |
763796
| ---- | ---- | ----------- | -------- |
764-
| hash | | The contract address. | &nbsp; |
797+
| hash | `string` | The contract address. | &nbsp; |
765798

766799

767800

768801

769802
##### Examples
770803

771804
```javascript
772-
const audit = await web3data.contract.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
805+
const audit = await web3data.contract.getSecurityAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
773806
```
774807

775808

776809
##### Returns
777810

778811

779-
- The vulnerabilities audit for the specified contract.
812+
- `Promise.<object>` The vulnerabilities audit for the specified contract.
780813

781814

782815

@@ -794,7 +827,7 @@ Retrieves the contract's abi.
794827

795828
| Name | Type | Description | |
796829
| ---- | ---- | ----------- | -------- |
797-
| hash | | The contract address. | &nbsp; |
830+
| hash | `string` | The contract address. | &nbsp; |
798831

799832

800833

@@ -809,7 +842,7 @@ const abi = await web3data.contract.getAbi('0x06012c8cf97bead5deae237070f9587f8e
809842
##### Returns
810843

811844

812-
- The abi of the contract.
845+
- `Promise.<object>` The abi of the contract.
813846

814847

815848

@@ -827,7 +860,7 @@ Retrieves the contract's source code.
827860

828861
| Name | Type | Description | |
829862
| ---- | ---- | ----------- | -------- |
830-
| hash | | The contract address. | &nbsp; |
863+
| hash | `string` | The contract address. | &nbsp; |
831864

832865

833866

@@ -842,7 +875,7 @@ const source = await web3data.contract.getSourceCode('0x06012c8cf97bead5deae2370
842875
##### Returns
843876

844877

845-
- The source of the contract.
878+
- `Promise.<object>` The source of the contract.
846879

847880

848881

@@ -860,7 +893,7 @@ Returns the contract's bytecode.
860893

861894
| Name | Type | Description | |
862895
| ---- | ---- | ----------- | -------- |
863-
| hash | | The contract address. | &nbsp; |
896+
| hash | `string` | The contract address. | &nbsp; |
864897

865898

866899

@@ -875,7 +908,7 @@ const code = await web3data.contract.getCode('0x06012c8cf97bead5deae237070f9587f
875908
##### Returns
876909

877910

878-
- The contract's bytecode.
911+
- `Promise.<object>` The contract's bytecode.
879912

880913

881914

@@ -1380,39 +1413,6 @@ new Signature(new Web3Data('API_KEY'))
13801413

13811414

13821415

1383-
#### getAudit(hash)
1384-
1385-
1386-
Alias for getSignature.
1387-
1388-
1389-
1390-
1391-
##### Parameters
1392-
1393-
| Name | Type | Description | |
1394-
| ---- | ---- | ----------- | -------- |
1395-
| hash | `string` | The (keccak 256) of the signature. | &nbsp; |
1396-
1397-
1398-
1399-
1400-
##### Examples
1401-
1402-
```javascript
1403-
const signatureDetails = await web3data.signature.getAudit('0xe2f0a05a')
1404-
```
1405-
1406-
1407-
##### Returns
1408-
1409-
1410-
- `Promise.<Array>` Information pertaining to the specified signature hash.
1411-
1412-
1413-
1414-
1415-
14161416
#### getSignature(hash)
14171417

14181418

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web3data-js",
3-
"version": "0.5.18",
3+
"version": "0.6.18",
44
"description": "A javascript wrapper for accessing amberdata's public API.",
55
"main": "index.js",
66
"browser": "dist/web3data.min.js",

src/contract.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class Contract {
2121
/**
2222
* Retrieves all the detailed information for the specified contract (ABI, bytecode, sourcecode...).
2323
*
24-
* @param hash - The address.
25-
* @returns The detailed information for the specified contract.
24+
* @param {string} hash - The address.
25+
* @returns {Promise<object>} The detailed information for the specified contract.
2626
* @example const details = await web3data.contract.getDetails('0x06012c8cf97bead5deae237070f9587f8e7a266d')
2727
*/
2828
getDetails(hash) {
@@ -36,8 +36,8 @@ class Contract {
3636
/**
3737
* Retrieves the functions of the specified contract (if available). If not available on chain, the byte code is decompiled and a list of functions is extracted from it.
3838
*
39-
* @param hash - The contract address.
40-
* @returns The functions or decompiled functions of the specified contract.
39+
* @param {string} hash - The contract address.
40+
* @returns {Promise<object>} The functions or decompiled functions of the specified contract.
4141
* @example const functions = await web3data.contract.getFunctions('0x06012c8cf97bead5deae237070f9587f8e7a266d')
4242
*/
4343
getFunctions(hash) {
@@ -49,12 +49,23 @@ class Contract {
4949
}).then(onFulfilled, onError)
5050
}
5151

52+
/**
53+
* Alias for getSecurityAudit.
54+
*
55+
* @param {string} hash - The contract address.
56+
* @returns {Promise<object>} The vulnerabilities audit for the specified contract.
57+
* @example const signatureDetails = await web3data.signature.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
58+
*/
59+
getAudit(hash) {
60+
return this.getSecurityAudit(hash)
61+
}
62+
5263
/**
5364
* Retrieves the vulnerabilities audit for the specified contract (if available).
5465
*
55-
* @param hash - The contract address.
56-
* @returns The vulnerabilities audit for the specified contract.
57-
* @example const audit = await web3data.contract.getAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
66+
* @param {string} hash - The contract address.
67+
* @returns {Promise<object>} The vulnerabilities audit for the specified contract.
68+
* @example const audit = await web3data.contract.getSecurityAudit('0x06012c8cf97bead5deae237070f9587f8e7a266d')
5869
*/
5970
getSecurityAudit(hash) {
6071
if (is.notHash(hash)) return Promise.reject(new Error(NO_ADDRESS))
@@ -68,8 +79,8 @@ class Contract {
6879
/**
6980
* Retrieves the contract's abi.
7081
*
71-
* @param hash - The contract address.
72-
* @returns The abi of the contract.
82+
* @param {string} hash - The contract address.
83+
* @returns {Promise<object>} The abi of the contract.
7384
* @example const abi = await web3data.contract.getAbi('0x06012c8cf97bead5deae237070f9587f8e7a266d')
7485
*/
7586
getAbi(hash) {
@@ -80,8 +91,8 @@ class Contract {
8091
/**
8192
* Retrieves the contract's source code.
8293
*
83-
* @param hash - The contract address.
84-
* @returns The source of the contract.
94+
* @param {string} hash - The contract address.
95+
* @returns {Promise<object>} The source of the contract.
8596
* @example const source = await web3data.contract.getSourceCode('0x06012c8cf97bead5deae237070f9587f8e7a266d')
8697
*/
8798
getSourceCode(hash) {
@@ -96,8 +107,8 @@ class Contract {
96107
/**
97108
* Returns the contract's bytecode.
98109
*
99-
* @param hash - The contract address.
100-
* @returns The contract's bytecode.
110+
* @param {string} hash - The contract address.
111+
* @returns {Promise<object>} The contract's bytecode.
101112
* @example const code = await web3data.contract.getCode('0x06012c8cf97bead5deae237070f9587f8e7a266d')
102113
*/
103114
getCode(hash) {

src/signature.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ class Signature {
1818
this.web3data = web3data
1919
}
2020

21-
/**
22-
* Alias for getSignature.
23-
*
24-
* @param {string} hash - The (keccak 256) of the signature.
25-
* @returns {Promise<Array>} Information pertaining to the specified signature hash.
26-
* @example const signatureDetails = await web3data.signature.getAudit('0xe2f0a05a')
27-
*/
28-
getAudit(hash) {
29-
return this.getSignature(hash)
30-
}
31-
3221
/**
3322
* Retrieves detailed information about the specified signature hash.
3423
*

test/contract.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,23 @@ test('Successfully calls getSecurityAudit', async t => {
4747
const audit = await t.context.web3data.contract.getSecurityAudit(TOKEN_ADDRESS);
4848
t.true(audit.hasProp('issues'))
4949
});
50-
test('throws exception when calling getAudit without hash', async t => {
50+
test('throws exception when calling getSecurityAudit without hash', async t => {
5151
await t.throwsAsync(async () => {
5252
await t.context.web3data.contract.getSecurityAudit()
5353
}, { instanceOf: Error, message: 'No contract address supplied' });
5454
});
5555

56+
/*********** Test getAudit() ***********/
57+
test('Successfully calls getAudit', async t => {
58+
const audit = await t.context.web3data.contract.getAudit(TOKEN_ADDRESS);
59+
t.true(audit.hasProp('issues'))
60+
});
61+
test('throws exception when calling getAudit without hash', async t => {
62+
await t.throwsAsync(async () => {
63+
await t.context.web3data.contract.getAudit()
64+
}, { instanceOf: Error, message: 'No contract address supplied' });
65+
});
66+
5667
/*********** Test getAbi() ***********/
5768
test('Successfully calls getAbi()', async t => {
5869
const abi = await t.context.web3data.contract.getAbi(TOKEN_ADDRESS);

test/signature.test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,3 @@ test('Successfully calls getSignature', async t => {
3232
const [signature] = await t.context.web3data.signature.getSignature('0x3d7d3f5a')
3333
t.true(signature.hasProp('textSignature'))
3434
})
35-
36-
test([rejectsPromise], 'getAudit', NO_HASH)
37-
test('Successfully calls getAudit', async t => {
38-
const [signature] = await t.context.web3data.signature.getSignature('0x3d7d3f5a')
39-
t.true(signature.hasProp('textSignature'))
40-
})

0 commit comments

Comments
 (0)