Skip to content

Commit 35e0669

Browse files
committed
feat(tokens): [Method] getSupplies - Add docs + tests.
1 parent def238b commit 35e0669

File tree

8 files changed

+767
-292
lines changed

8 files changed

+767
-292
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: 102 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,15 +1508,15 @@ Creates an instance of Token.
15081508

15091509
| Name | Type | Description | |
15101510
| ---- | ---- | ----------- | -------- |
1511-
| web3data | | The web3data instance. |   |
1511+
| web3data | `Web3Data` | The web3data instance. |   |
15121512

15131513

15141514

15151515

15161516
##### Examples
15171517

15181518
```javascript
1519-
1519+
const token = new Token(new Web3data('API_KEY'))
15201520
```
15211521

15221522

@@ -1529,7 +1529,7 @@ Creates an instance of Token.
15291529

15301530

15311531

1532-
#### getRankings(filterOptions)
1532+
#### getRankings([filterOptions])
15331533

15341534

15351535
Retrieves the top ranked tokens by a specific metric.
@@ -1541,7 +1541,7 @@ Retrieves the top ranked tokens by a specific metric.
15411541

15421542
| Name | Type | Description | |
15431543
| ---- | ---- | ----------- | -------- |
1544-
| filterOptions | | The filters associated with the request. See [docs](https://docs.amberdata.io/reference#gettokenrankings) for more details. |   |
1544+
| filterOptions | `object` | The filters associated with the request. See [docs](https://docs.amberdata.io/reference#gettokenrankings) for more details. | *Optional* |
15451545

15461546

15471547

@@ -1556,13 +1556,13 @@ const rankings = await web3data.token.getRankings()
15561556
##### Returns
15571557

15581558

1559-
- The token rankings.
1559+
- `Promise.<object>` The token rankings.
15601560

15611561

15621562

15631563

15641564

1565-
#### getVolume(hash, filterOptions)
1565+
#### getVolume(hash[, filterOptions])
15661566

15671567

15681568
Retrieves the historical volume of token transfers for the specified address.
@@ -1574,8 +1574,8 @@ Retrieves the historical volume of token transfers for the specified address.
15741574

15751575
| Name | Type | Description | |
15761576
| ---- | ---- | ----------- | -------- |
1577-
| hash | | The address of the token contract. | &nbsp; |
1578-
| filterOptions | | The filters associated with the request. See [docs](https://docs.amberdata.io/reference#gettokenvolume) for more details. | &nbsp; |
1577+
| hash | `string` | The address of the token contract. | &nbsp; |
1578+
| filterOptions | `object` | The filters associated with the request. See [docs](https://docs.amberdata.io/reference#gettokenvolume) for more details. | *Optional* |
15791579

15801580

15811581

@@ -1630,7 +1630,7 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
16301630

16311631

16321632

1633-
#### getHolders(hash, filterOptions)
1633+
#### getHolders(hash[, filterOptions])
16341634

16351635

16361636

@@ -1642,8 +1642,8 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
16421642

16431643
| Name | Type | Description | |
16441644
| ---- | ---- | ----------- | -------- |
1645-
| hash | | The address for which to retrieve token holders. | &nbsp; |
1646-
| filterOptions | | The filters associated with the request. | &nbsp; |
1645+
| hash | `string` | The address for which to retrieve token holders. | &nbsp; |
1646+
| filterOptions | `object` | The filters associated with the request. | *Optional* |
16471647

16481648

16491649

@@ -1658,7 +1658,7 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
16581658
##### Returns
16591659

16601660

1661-
-
1661+
- `Promise.<object>`
16621662

16631663

16641664

@@ -1692,13 +1692,52 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
16921692
##### Returns
16931693

16941694

1695-
-
1695+
- `Promise.<object>`
1696+
1697+
1698+
1699+
1700+
1701+
#### getSupplies(hash[, filterOptions])
1702+
1703+
1704+
Retrieves the latest or historical token supplies (and derivatives) for the specified address. Use the `startDate` or `endDate` filters to get historical data.
1705+
1706+
1707+
1708+
1709+
##### Parameters
1710+
1711+
| Name | Type | Description | |
1712+
| ---- | ---- | ----------- | -------- |
1713+
| hash | `string` | The address for which to retrieve token supplies. | &nbsp; |
1714+
| filterOptions | `object` | The filters associated with the request. See [docs](https://docs.amberdata.io/reference#gettokensupplylatest) for more details. | *Optional* |
1715+
| filterOptions.startDate | `number` | Filter by token prices after this date The interval can not exceed 6 months (d), or 30 days (h). | *Optional* |
1716+
| filterOptions.endDate | `number` | Filter by token prices before this date The interval can not exceed 6 months (d), or 30 days (h). | *Optional* |
16961717

16971718

16981719

16991720

1721+
##### Examples
1722+
1723+
```javascript
1724+
// Latest
1725+
const latestSupplies = await web3data.token.getSupplies('0x06012c8cf97bead5deae237070f9587f8e7a266d')
1726+
// Historical
1727+
const historicalSupplies = await t.context.web3data.token.getSupplies('0x06012c8cf97bead5deae237070f9587f8e7a266d', {startDate: 1571011200, endDate: 1571097600, timeFormat: 'iso'})
1728+
```
1729+
1730+
1731+
##### Returns
1732+
17001733

1701-
#### getSupplies(hash, filterOptions)
1734+
- `Promise.<object>` The latest or historical token supplies.
1735+
1736+
1737+
1738+
1739+
1740+
#### getTransfers(hash[, filterOptions])
17021741

17031742

17041743

@@ -1710,8 +1749,8 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
17101749

17111750
| Name | Type | Description | |
17121751
| ---- | ---- | ----------- | -------- |
1713-
| hash | | The address for which to retrieve token supplies. | &nbsp; |
1714-
| filterOptions | | The filters associated with the request. | &nbsp; |
1752+
| hash | `string` | The address for which to retrieve token holders. | &nbsp; |
1753+
| filterOptions | `object` | The filters associated with the request. | *Optional* |
17151754

17161755

17171756

@@ -1726,16 +1765,21 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
17261765
##### Returns
17271766

17281767

1729-
-
1768+
- `Promise.<object>`
17301769

17311770

17321771

17331772

17341773

1735-
#### getTransfers(hash, filterOptions)
1774+
### src/utils.js
17361775

17371776

17381777

1778+
#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions)
1779+
1780+
1781+
Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends
1782+
the appropriate parameter(s) where applicable.
17391783

17401784

17411785

@@ -1744,8 +1788,12 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
17441788

17451789
| Name | Type | Description | |
17461790
| ---- | ---- | ----------- | -------- |
1747-
| hash | | The address for which to retrieve token holders. | &nbsp; |
1748-
| filterOptions | | The filters associated with the request. | &nbsp; |
1791+
| web3data | | Instance on which to call .rawQuery(). | &nbsp; |
1792+
| subendpoint | | The subendpoint. | &nbsp; |
1793+
| endpoint | | The endpoint. | &nbsp; |
1794+
| hash | | The address hash. | &nbsp; |
1795+
| pathParam | | The path parameter. | &nbsp; |
1796+
| filterOptions | | The filters associated with a given endpoint. | &nbsp; |
17491797

17501798

17511799

@@ -1760,7 +1808,40 @@ const velocity = await web3data.token.getVelocity('0x06012c8cf97bead5deae237070f
17601808
##### Returns
17611809

17621810

1763-
-
1811+
- Returns a Promise of the rawQuery request from web3data.
1812+
1813+
1814+
1815+
1816+
1817+
#### uuid(data)
1818+
1819+
1820+
Generates a uuid see [this gist]() for more details.
1821+
1822+
1823+
1824+
1825+
##### Parameters
1826+
1827+
| Name | Type | Description | |
1828+
| ---- | ---- | ----------- | -------- |
1829+
| data | | | &nbsp; |
1830+
1831+
1832+
1833+
1834+
##### Examples
1835+
1836+
```javascript
1837+
1838+
```
1839+
1840+
1841+
##### Returns
1842+
1843+
1844+
- `Void`
17641845

17651846

17661847

@@ -2096,82 +2177,6 @@ const metrics = await web3data.transaction.getMetrics()
20962177

20972178

20982179

2099-
### src/utils.js
2100-
2101-
2102-
2103-
#### get(web3data, subendpoint, endpoint, hash, pathParam, filterOptions)
2104-
2105-
2106-
Builds the endpoint url to pass to .rawQuery(). Checks for non empties and appends
2107-
the appropriate parameter(s) where applicable.
2108-
2109-
2110-
2111-
2112-
##### Parameters
2113-
2114-
| Name | Type | Description | |
2115-
| ---- | ---- | ----------- | -------- |
2116-
| web3data | | Instance on which to call .rawQuery(). | &nbsp; |
2117-
| subendpoint | | The subendpoint. | &nbsp; |
2118-
| endpoint | | The endpoint. | &nbsp; |
2119-
| hash | | The address hash. | &nbsp; |
2120-
| pathParam | | The path parameter. | &nbsp; |
2121-
| filterOptions | | The filters associated with a given endpoint. | &nbsp; |
2122-
2123-
2124-
2125-
2126-
##### Examples
2127-
2128-
```javascript
2129-
2130-
```
2131-
2132-
2133-
##### Returns
2134-
2135-
2136-
- Returns a Promise of the rawQuery request from web3data.
2137-
2138-
2139-
2140-
2141-
2142-
#### uuid(data)
2143-
2144-
2145-
Generates a uuid see [this gist]() for more details.
2146-
2147-
2148-
2149-
2150-
##### Parameters
2151-
2152-
| Name | Type | Description | |
2153-
| ---- | ---- | ----------- | -------- |
2154-
| data | | | &nbsp; |
2155-
2156-
2157-
2158-
2159-
##### Examples
2160-
2161-
```javascript
2162-
2163-
```
2164-
2165-
2166-
##### Returns
2167-
2168-
2169-
- `Void`
2170-
2171-
2172-
2173-
2174-
21752180
### src/web3data.js
21762181

21772182

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
"jsdoc/implements-on-classes": 1,
102102
"jsdoc/match-description": 1,
103103
"jsdoc/newline-after-description": 1,
104-
"jsdoc/no-types": 1,
105104
"jsdoc/no-undefined-types": 1,
106105
"jsdoc/require-description": 1,
107106
"jsdoc/require-description-complete-sentence": 1,

0 commit comments

Comments
 (0)