Skip to content

Commit c6bd03d

Browse files
committed
doc(transactions): Finishing adding all documention.
1 parent 49e4857 commit c6bd03d

File tree

4 files changed

+276
-9
lines changed

4 files changed

+276
-9
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.

dist/web3data.min.js.map

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: 214 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,21 +1047,233 @@ Retrieves all transactions matching the specified filters.
10471047
| ---- | ---- | ----------- | -------- |
10481048
| filterOptions | | The filter options associated with the request. |   |
10491049
| filterOptions.status | | Filter by the status of the transactions to retrieve (all, completed, failed, pending). |   |
1050+
| filterOptions.includePrice | | Indicates whether or not to include price data with the results. |   |
10501051

10511052

10521053

10531054

10541055
##### Examples
10551056

10561057
```javascript
1057-
const transactions = await web3data.transaction.getTransactions()
1058+
const transactions = await web3data.transaction.getTransactions()
1059+
// Include pricing data with transactions
1060+
const transactions = await web3data.transaction.getTransactions({
1061+
includePrice: true
1062+
})
1063+
```
1064+
1065+
1066+
##### Returns
1067+
1068+
1069+
- All transactions matched by the specified filters.
1070+
1071+
1072+
1073+
1074+
1075+
#### getTransaction(hash, filterOptions)
1076+
1077+
1078+
Retrieves the transaction data for the specified hash.
1079+
1080+
1081+
1082+
1083+
##### Parameters
1084+
1085+
| Name | Type | Description | |
1086+
| ---- | ---- | ----------- | -------- |
1087+
| hash | | The transaction hash. |   |
1088+
| filterOptions | | The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#gettransaction) for more details. |   |
1089+
| filterOptions.validationMethod=none | | The validation method to be added to the response: `none`, `basic`, `full`. |   |
1090+
| filterOptions.includePrice=true | | Indicates whether or not to include price data with the results. |   |
1091+
1092+
1093+
1094+
1095+
##### Examples
1096+
1097+
```javascript
1098+
const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf')
1099+
```
1100+
1101+
1102+
##### Returns
1103+
1104+
1105+
- The data for the specified transaction hash.
1106+
1107+
1108+
1109+
1110+
1111+
#### getPendingTransactions()
1112+
1113+
1114+
Retrieves all pending transaction.
1115+
1116+
1117+
1118+
1119+
1120+
1121+
##### Examples
1122+
1123+
```javascript
1124+
const pendingTransactions = await web3data.transaction.getPendingTransactions()
1125+
```
1126+
1127+
1128+
##### Returns
1129+
1130+
1131+
- The pending transactions.
1132+
1133+
1134+
1135+
1136+
1137+
#### getGasPrediction()
1138+
1139+
1140+
Retrieves the latest gas predictions for the transactions.
1141+
1142+
1143+
1144+
1145+
1146+
1147+
##### Examples
1148+
1149+
```javascript
1150+
1151+
```
1152+
1153+
1154+
##### Returns
1155+
1156+
1157+
- The latest gas predictions for the transactions.
1158+
1159+
1160+
1161+
1162+
1163+
#### getGasPercentiles(filterOptions)
1164+
1165+
1166+
Retrieves the latest gas price percentiles for the transactions.
1167+
1168+
1169+
1170+
1171+
##### Parameters
1172+
1173+
| Name | Type | Description | |
1174+
| ---- | ---- | ----------- | -------- |
1175+
| filterOptions | | The filter options associated with the request. |   |
1176+
| filterOptions.numBlocks | | Number of past blocks on which to base the percentiles. |   |
1177+
1178+
1179+
1180+
1181+
##### Examples
1182+
1183+
```javascript
1184+
1185+
```
1186+
1187+
1188+
##### Returns
1189+
1190+
1191+
- The latest gas price percentiles for the transactions.
1192+
1193+
1194+
1195+
1196+
1197+
#### getGasPrice()
1198+
1199+
1200+
Retrieves the latest average gas price. Uses `getGasPrediction` under the hood.
1201+
1202+
1203+
1204+
1205+
1206+
1207+
##### Examples
1208+
1209+
```javascript
1210+
1211+
```
1212+
1213+
1214+
##### Returns
1215+
1216+
1217+
- The latest gas price.
1218+
1219+
1220+
1221+
1222+
1223+
#### getVolume(filterOptions)
1224+
1225+
1226+
Retrieves the historical (time series) volume of transactions.
1227+
1228+
1229+
1230+
1231+
##### Parameters
1232+
1233+
| Name | Type | Description | |
1234+
| ---- | ---- | ----------- | -------- |
1235+
| filterOptions | | The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#gethistoricaltransactionvolume) for more details. |   |
1236+
1237+
1238+
1239+
1240+
##### Examples
1241+
1242+
```javascript
1243+
1244+
```
1245+
1246+
1247+
##### Returns
1248+
1249+
1250+
- The historical (time series) volume of transactions.
1251+
1252+
1253+
1254+
1255+
1256+
#### getMetrics()
1257+
1258+
1259+
Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period.
1260+
1261+
1262+
1263+
1264+
1265+
1266+
##### Examples
1267+
1268+
```javascript
1269+
10581270
```
10591271

10601272

10611273
##### Returns
10621274

10631275

1064-
- - All transactions matched by the specified filters.
1276+
- Metrics for recent confirmed transactions.
10651277

10661278

10671279

src/transaction.js

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ class Transaction {
2525
*
2626
* @param [filterOptions] - The filter options associated with the request.
2727
* @param [filterOptions.status] - Filter by the status of the transactions to retrieve (all, completed, failed, pending).
28-
* @returns - All transactions matched by the specified filters.
28+
* @param [filterOptions.includePrice] - Indicates whether or not to include price data with the results.
29+
* @returns All transactions matched by the specified filters.
2930
* @example const transactions = await web3data.transaction.getTransactions()
31+
*
32+
* // Include pricing data with transactions
33+
* const transactions = await web3data.transaction.getTransactions({
34+
* includePrice: true
35+
* })
3036
*/
3137
getTransactions(filterOptions = {}) {
3238
return get(this.web3data, {
@@ -35,7 +41,17 @@ class Transaction {
3541
}).then(onFulfilled, onError)
3642
}
3743

38-
getTransaction(hash, filterOptions) {
44+
/**
45+
* Retrieves the transaction data for the specified hash.
46+
*
47+
* @param hash - The transaction hash.
48+
* @param [filterOptions] - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-transaction) for more details.
49+
* @param [filterOptions.validationMethod=none] - The validation method to be added to the response: `none`, `basic`, `full`.
50+
* @param [filterOptions.includePrice=true] - Indicates whether or not to include price data with the results.
51+
* @returns The data for the specified transaction hash.
52+
* @example const transaction = await web3data.transaction.getTransaction('0xd0a5a0912fdf87993b3cebd696f1ee667a8fbbe8fc890a22dcbdf114f36de4cf')
53+
*/
54+
getTransaction(hash, filterOptions = {}) {
3955
throwIf(is.notHash(hash), NO_HASH)
4056
return get(this.web3data, {
4157
pathParam: hash,
@@ -44,6 +60,12 @@ class Transaction {
4460
}).then(onFulfilled, onError)
4561
}
4662

63+
/**
64+
* Retrieves all pending transaction.
65+
*
66+
* @returns The pending transactions.
67+
* @example const pendingTransactions = await web3data.transaction.getPendingTransactions()
68+
*/
4769
getPendingTransactions() {
4870
return this.getTransactions({status: 'pending'}).then(
4971
pendingTransactions => {
@@ -57,21 +79,41 @@ class Transaction {
5779
)
5880
}
5981

82+
/**
83+
* Retrieves the latest gas predictions for the transactions.
84+
*
85+
* @returns The latest gas predictions for the transactions.
86+
* @example
87+
*/
6088
getGasPrediction() {
6189
return get(this.web3data, {
6290
endpoint: ENDPOINT,
6391
subendpoint: 'gas/predictions'
6492
}).then(onFulfilled, onError)
6593
}
6694

67-
getGasPercentiles(filterOptions) {
95+
/**
96+
* Retrieves the latest gas price percentiles for the transactions.
97+
*
98+
* @param [filterOptions] - The filter options associated with the request.
99+
* @param [filterOptions.numBlocks] - Number of past blocks on which to base the percentiles.
100+
* @returns The latest gas price percentiles for the transactions.
101+
* @example
102+
*/
103+
getGasPercentiles(filterOptions = {}) {
68104
return get(this.web3data, {
69105
endpoint: ENDPOINT,
70106
subendpoint: 'gas/percentiles',
71107
filterOptions
72108
}).then(onFulfilled, onError)
73109
}
74110

111+
/**
112+
* Retrieves the latest average gas price. Uses `getGasPrediction` under the hood.
113+
*
114+
* @returns The latest gas price.
115+
* @example
116+
*/
75117
getGasPrice() {
76118
return this.getGasPrediction().then(gasPrediction => {
77119
throwIf(
@@ -82,15 +124,28 @@ class Transaction {
82124
})
83125
}
84126

85-
getVolume(filterOptions) {
127+
/**
128+
* Retrieves the historical (time series) volume of transactions.
129+
*
130+
* @param [filterOptions] - The filter options associated with the request. See [docs](https://docs.amberdata.io/reference#get-historical-transaction-volume) for more details.
131+
* @returns The historical (time series) volume of transactions.
132+
* @example
133+
*/
134+
getVolume(filterOptions = {}) {
86135
return get(this.web3data, {
87136
endpoint: ENDPOINT,
88137
subendpoint: 'volume',
89138
filterOptions
90139
}).then(onFulfilled, onError)
91140
}
92141

93-
getMetrics(filterOptions) {
142+
/**
143+
* Get metrics for recent confirmed transactions for a given blockchain. Default metrics are over a 24h period.
144+
*
145+
* @returns Metrics for recent confirmed transactions.
146+
* @example
147+
*/
148+
getMetrics(filterOptions = {}) {
94149
return get(this.web3data, {
95150
endpoint: ENDPOINT,
96151
subendpoint: 'metrics/latest',

0 commit comments

Comments
 (0)