Skip to content

Commit adff31c

Browse files
Fixed endpoint move and tests
1 parent df86a78 commit adff31c

File tree

13 files changed

+1061
-1065
lines changed

13 files changed

+1061
-1065
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: 83 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.7.3*
1+
# [web3data-js](https://github.com/web3data/web3data-js#readme) *0.7.4*
22

33
> A javascript wrapper for accessing amberdata's public API.
44
@@ -1248,86 +1248,6 @@ Class for all Litecoin based methods.
12481248

12491249

12501250

1251-
### src/signature.js
1252-
1253-
1254-
#### new Signature()
1255-
1256-
Contains methods pertaining to the `/signatures` endpoint of Amberdata's API.
1257-
1258-
1259-
1260-
1261-
1262-
1263-
##### Returns
1264-
1265-
1266-
- `Void`
1267-
1268-
1269-
1270-
#### Signature.constructor(web3data)
1271-
1272-
Creates an instance of Signature.
1273-
1274-
1275-
1276-
1277-
##### Parameters
1278-
1279-
| Name | Type | Description | |
1280-
| ---- | ---- | ----------- | -------- |
1281-
| web3data | `object` | - The web3data instance. |   |
1282-
1283-
1284-
1285-
1286-
##### Examples
1287-
1288-
```javascript
1289-
new Signature(new Web3Data('API_KEY'))
1290-
```
1291-
1292-
1293-
##### Returns
1294-
1295-
1296-
- `Void`
1297-
1298-
1299-
1300-
#### Signature.getSignature(hash)
1301-
1302-
Retrieves detailed information about the specified signature hash.
1303-
1304-
1305-
1306-
1307-
##### Parameters
1308-
1309-
| Name | Type | Description | |
1310-
| ---- | ---- | ----------- | -------- |
1311-
| hash | `string` | - The (keccak 256) of the signature. |   |
1312-
1313-
1314-
1315-
1316-
##### Examples
1317-
1318-
```javascript
1319-
const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a')
1320-
```
1321-
1322-
1323-
##### Returns
1324-
1325-
1326-
- `Promise.<Array>` Information pertaining to the specified signature hash.
1327-
1328-
1329-
1330-
13311251
### src/market.js
13321252

13331253

@@ -1580,7 +1500,7 @@ const histBbos = await web3data.market.getBbos('eth_btc', {startDate: Math.round
15801500

15811501

15821502

1583-
#### getPrices(base, filterOptions)
1503+
#### getPrices(base, pair, filterOptions)
15841504

15851505
Retrieves the historical prices for the specified asset.
15861506

@@ -1592,6 +1512,7 @@ Retrieves the historical prices for the specified asset.
15921512
| Name | Type | Description | |
15931513
| ---- | ---- | ----------- | -------- |
15941514
| base | | - The base of a pair to retrieve the price. Example: If pair is "eth_usd", then base is "eth". |   |
1515+
| pair | | |   |
15951516
| filterOptions | | - The filter options. See [docs](https://docs.amberdata.io/reference#market-prices-latest) for more details. |   |
15961517

15971518

@@ -2021,6 +1942,86 @@ const transfers = await web3data.token.getTransfers('0x06012c8cf97bead5deae23707
20211942

20221943

20231944

1945+
### src/signature.js
1946+
1947+
1948+
#### new Signature()
1949+
1950+
Contains methods pertaining to the `/signatures` endpoint of Amberdata's API.
1951+
1952+
1953+
1954+
1955+
1956+
1957+
##### Returns
1958+
1959+
1960+
- `Void`
1961+
1962+
1963+
1964+
#### Signature.constructor(web3data)
1965+
1966+
Creates an instance of Signature.
1967+
1968+
1969+
1970+
1971+
##### Parameters
1972+
1973+
| Name | Type | Description | |
1974+
| ---- | ---- | ----------- | -------- |
1975+
| web3data | `object` | - The web3data instance. |   |
1976+
1977+
1978+
1979+
1980+
##### Examples
1981+
1982+
```javascript
1983+
new Signature(new Web3Data('API_KEY'))
1984+
```
1985+
1986+
1987+
##### Returns
1988+
1989+
1990+
- `Void`
1991+
1992+
1993+
1994+
#### Signature.getSignature(hash)
1995+
1996+
Retrieves detailed information about the specified signature hash.
1997+
1998+
1999+
2000+
2001+
##### Parameters
2002+
2003+
| Name | Type | Description | |
2004+
| ---- | ---- | ----------- | -------- |
2005+
| hash | `string` | - The (keccak 256) of the signature. |   |
2006+
2007+
2008+
2009+
2010+
##### Examples
2011+
2012+
```javascript
2013+
const signatureDetails = await web3data.signature.getSignature('0xe2f0a05a')
2014+
```
2015+
2016+
2017+
##### Returns
2018+
2019+
2020+
- `Promise.<Array>` Information pertaining to the specified signature hash.
2021+
2022+
2023+
2024+
20242025
### src/transaction.js
20252026

20262027

src/block.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Block {
6363
* @example
6464
*/
6565
getBlockNumber() {
66-
return this.web3data.block.getBlock('latest').then((block) => {
66+
return this.web3data.block.getBlock('latest').then(block => {
6767
throwIf(block | !block.number, 'Failed to retrieve block number.')
6868
return Number.parseInt(block.number, 10)
6969
})
@@ -78,7 +78,7 @@ class Block {
7878
* @example
7979
*/
8080
getBlockTransactionCount(id) {
81-
return this.web3data.block.getBlock(id).then((block) => {
81+
return this.web3data.block.getBlock(id).then(block => {
8282
throwIf(
8383
!block || (!block.predictions && !block.numTransactions),
8484
'Failed to retrieve block transaction count.'
@@ -119,7 +119,7 @@ class Block {
119119
*/
120120
getTransactionFromBlock(id, index) {
121121
throwIf(is.undefined(id), NO_BLOCK_ID)
122-
return this.web3data.block.getTransactions(id).then((txns) => {
122+
return this.web3data.block.getTransactions(id).then(txns => {
123123
throwIf(!txns, 'Failed to retrieve transaction.')
124124

125125
// Check that 'index' is within valid range
@@ -143,7 +143,7 @@ class Block {
143143
.getBlock(id, {
144144
validationMethod: 'full'
145145
})
146-
.then((block) => {
146+
.then(block => {
147147
throwIf(
148148
!block ||
149149
(!block.predictions && !block.numTransactions && !block.validation),

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports.ERROR_MESSAGE_CONTRACT_NO_ADDRESS =
4545
'No contract address supplied'
4646
module.exports.ERROR_MESSAGE_BLOCK_NO_ID = 'No block number or hash supplied'
4747
module.exports.ERROR_MESSAGE_MARKET_NO_PAIR = 'No market pair supplied'
48+
module.exports.ERROR_MESSAGE_MARKET_NO_BASE = 'No market base supplied'
4849
module.exports.ERROR_MESSAGE_MARKET_NO_FEATURE = `Missing or unknown. Features: '${module.exports.MARKET_FEATURES.join(
4950
"', '"
5051
)}'`

src/contract.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Contract {
8585
* @example const code = await web3data.contract.getCode('0x06012c8cf97bead5deae237070f9587f8e7a266d')
8686
*/
8787
getCode(hash) {
88-
return this.getDetails(hash).then((details) => details.bytecode || '0x')
88+
return this.getDetails(hash).then(details => details.bytecode || '0x')
8989
}
9090
}
9191

src/market.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class Market {
2929
*/
3030
async getEtherPrice() {
3131
return get(this.web3data, {
32-
endpoint: ENDPOINT + '/prices/eth/latest'
33-
}).then((response) => response.payload.eth_usd.price, onError)
32+
endpoint: ENDPOINT + '/spot/prices/pairs/eth_usd/latest'
33+
}).then(response => response.payload.price, onError)
3434
}
3535

3636
/**
@@ -71,7 +71,7 @@ class Market {
7171
features = Array.isArray(features) ? features : [features]
7272

7373
// Iterate through each feature and if all is valid return array of promises
74-
features = features.map((feature) => {
74+
features = features.map(feature => {
7575
// Check each feature that it is valid
7676
throwIf(is.undefined(feature) || !FEATURES.includes(feature), NO_FEATURE)
7777

@@ -98,12 +98,12 @@ class Market {
9898
.then(onFulfilled, onError)
9999
// Return an object with 'feature' as the key and response the value
100100
// .split('/')[0] removes the extra endpoint added above in switch
101-
.then((response) => ({[feature.split('/')[0]]: response}))
101+
.then(response => ({[feature.split('/')[0]]: response}))
102102
)
103103
})
104104

105105
// Returns array of promises that once resolved are merged into a single object
106-
return Promise.all([...features]).then((data) =>
106+
return Promise.all([...features]).then(data =>
107107
data.reduce((accumObject, curObject) => ({...accumObject, ...curObject}))
108108
)
109109
}
@@ -146,7 +146,7 @@ class Market {
146146
getOrders(pair, exchange, filterOptions = {}) {
147147
throwIf(is.undefined(pair), NO_MARKET_PAIR)
148148
exchange = Array.isArray(exchange) ? exchange : [exchange]
149-
exchange.forEach((exchange) =>
149+
exchange.forEach(exchange =>
150150
throwIf(is.undefined(exchange), 'No exchange specified')
151151
)
152152
filterOptions.exchange = exchange
@@ -210,6 +210,7 @@ class Market {
210210
* Retrieves the historical prices for the specified asset.
211211
*
212212
* @param base - The base of a pair to retrieve the price. Example: If pair is "eth_usd", then base is "eth".
213+
* @param pair
213214
* @param [filterOptions] - The filter options. See [docs](https://docs.amberdata.io/reference#market-prices-latest) for more details.
214215
* @returns The latest or historical market prices indexed by pair.
215216
* @example // Latest
@@ -218,13 +219,13 @@ class Market {
218219
* // Historical (1 day ago)
219220
* const histPrices = await web3data.market.getPrices('eth', {startDate: Math.round((Date.now() - 86400000) /1000)})
220221
*/
221-
getPrices(base, filterOptions = {}) {
222-
throwIf(is.undefined(base), NO_MARKET_PAIR)
222+
getPrices(pair, filterOptions = {}) {
223+
throwIf(is.undefined(pair), NO_MARKET_PAIR)
223224
const subendpoint =
224225
filterOptions.startDate || filterOptions.endDate ? 'historical' : 'latest'
225226
return get(this.web3data, {
226-
pathParam: base,
227-
endpoint: `${ENDPOINT}/prices`,
227+
pathParam: pair,
228+
endpoint: `${ENDPOINT}/spot/prices/pairs`,
228229
subendpoint,
229230
filterOptions
230231
}).then(onFulfilled, onError)

src/transaction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Transaction {
8585
*/
8686
getPendingTransactions() {
8787
return this.getTransactions({status: 'pending'}).then(
88-
(pendingTransactions) => {
88+
pendingTransactions => {
8989
throwIf(
9090
is.undefined(pendingTransactions) || is.null(pendingTransactions),
9191
'Failed to retrieve pending transactions.'
@@ -135,7 +135,7 @@ class Transaction {
135135
* const gasPrice = await web3data.transaction.getGasPrice()
136136
*/
137137
getGasPrice() {
138-
return this.getGasPrediction().then((gasPrediction) => {
138+
return this.getGasPrediction().then(gasPrediction => {
139139
throwIf(
140140
!gasPrediction.average || !gasPrediction.average.gasPrice,
141141
'Failed to retrieve gas price.'

0 commit comments

Comments
 (0)