@human-protocol/sdk 3.0.8 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +4 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -151
- package/dist/decorators.js +1 -1
- package/dist/encryption.d.ts +21 -29
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +17 -29
- package/dist/enums.d.ts +5 -12
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +6 -12
- package/dist/error.d.ts +31 -28
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +36 -33
- package/dist/escrow.d.ts +104 -88
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +192 -131
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +15 -5
- package/dist/interfaces.d.ts +12 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +15 -15
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +11 -10
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +23 -11
- package/dist/staking.d.ts +38 -21
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +62 -21
- package/dist/statistics.d.ts +10 -29
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +18 -37
- package/dist/storage.d.ts +13 -18
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +13 -18
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +3 -5
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +7 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +11 -2
- package/package.json +1 -1
- package/src/constants.ts +11 -174
- package/src/decorators.ts +1 -1
- package/src/encryption.ts +21 -29
- package/src/enums.ts +5 -11
- package/src/error.ts +39 -37
- package/src/escrow.ts +257 -151
- package/src/graphql/queries/operator.ts +15 -5
- package/src/interfaces.ts +13 -2
- package/src/kvstore.ts +16 -16
- package/src/operator.ts +26 -12
- package/src/staking.ts +71 -22
- package/src/statistics.ts +19 -38
- package/src/storage.ts +13 -18
- package/src/transaction.ts +5 -7
- package/src/types.ts +6 -2
- package/src/utils.ts +10 -1
package/dist/statistics.js
CHANGED
|
@@ -13,20 +13,15 @@ const enums_1 = require("./enums");
|
|
|
13
13
|
/**
|
|
14
14
|
* ## Introduction
|
|
15
15
|
*
|
|
16
|
-
* This client enables
|
|
16
|
+
* This client enables obtaining statistical information from the subgraph.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* We just need to create client object using relevant network data.
|
|
18
|
+
* Unlike other SDK clients, `StatisticsClient` does not require `signer` or `provider` to be provided.
|
|
19
|
+
* We just need to create a client object using relevant network data.
|
|
20
20
|
*
|
|
21
21
|
* ```ts
|
|
22
22
|
* constructor(network: NetworkData)
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
-
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
26
|
-
*
|
|
27
|
-
* - **Signer**: when the user wants to use this model in order to send transactions caling the contract functions.
|
|
28
|
-
* - **Provider**: when the user wants to use this model in order to get information from the contracts or subgraph.
|
|
29
|
-
*
|
|
30
25
|
* ## Installation
|
|
31
26
|
*
|
|
32
27
|
* ### npm
|
|
@@ -60,7 +55,6 @@ class StatisticsClient {
|
|
|
60
55
|
/**
|
|
61
56
|
* This function returns the statistical data of escrows.
|
|
62
57
|
*
|
|
63
|
-
*
|
|
64
58
|
* **Input parameters**
|
|
65
59
|
*
|
|
66
60
|
* ```ts
|
|
@@ -89,10 +83,8 @@ class StatisticsClient {
|
|
|
89
83
|
* };
|
|
90
84
|
* ```
|
|
91
85
|
*
|
|
92
|
-
*
|
|
93
86
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
94
|
-
* @returns {EscrowStatistics} Escrow statistics data.
|
|
95
|
-
*
|
|
87
|
+
* @returns {Promise<EscrowStatistics>} Escrow statistics data.
|
|
96
88
|
*
|
|
97
89
|
* **Code example**
|
|
98
90
|
*
|
|
@@ -115,8 +107,8 @@ class StatisticsClient {
|
|
|
115
107
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
116
108
|
const { escrowStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY);
|
|
117
109
|
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
118
|
-
from: filter.from ? filter.from
|
|
119
|
-
to: filter.to ? filter.to
|
|
110
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
111
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
120
112
|
orderDirection: orderDirection,
|
|
121
113
|
first: first,
|
|
122
114
|
skip: skip,
|
|
@@ -142,7 +134,6 @@ class StatisticsClient {
|
|
|
142
134
|
/**
|
|
143
135
|
* This function returns the statistical data of workers.
|
|
144
136
|
*
|
|
145
|
-
*
|
|
146
137
|
* **Input parameters**
|
|
147
138
|
*
|
|
148
139
|
* ```ts
|
|
@@ -166,10 +157,8 @@ class StatisticsClient {
|
|
|
166
157
|
* };
|
|
167
158
|
* ```
|
|
168
159
|
*
|
|
169
|
-
*
|
|
170
160
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
171
|
-
* @returns {WorkerStatistics} Worker statistics data.
|
|
172
|
-
*
|
|
161
|
+
* @returns {Promise<WorkerStatistics>} Worker statistics data.
|
|
173
162
|
*
|
|
174
163
|
* **Code example**
|
|
175
164
|
*
|
|
@@ -191,8 +180,8 @@ class StatisticsClient {
|
|
|
191
180
|
const skip = filter.skip || 0;
|
|
192
181
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
193
182
|
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
194
|
-
from: filter.from ? filter.from
|
|
195
|
-
to: filter.to ? filter.to
|
|
183
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
184
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
196
185
|
orderDirection: orderDirection,
|
|
197
186
|
first: first,
|
|
198
187
|
skip: skip,
|
|
@@ -211,7 +200,6 @@ class StatisticsClient {
|
|
|
211
200
|
/**
|
|
212
201
|
* This function returns the statistical data of payments.
|
|
213
202
|
*
|
|
214
|
-
*
|
|
215
203
|
* **Input parameters**
|
|
216
204
|
*
|
|
217
205
|
* ```ts
|
|
@@ -237,10 +225,8 @@ class StatisticsClient {
|
|
|
237
225
|
* };
|
|
238
226
|
* ```
|
|
239
227
|
*
|
|
240
|
-
*
|
|
241
228
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
242
|
-
* @returns {PaymentStatistics} Payment statistics data.
|
|
243
|
-
*
|
|
229
|
+
* @returns {Promise<PaymentStatistics>} Payment statistics data.
|
|
244
230
|
*
|
|
245
231
|
* **Code example**
|
|
246
232
|
*
|
|
@@ -283,8 +269,8 @@ class StatisticsClient {
|
|
|
283
269
|
const skip = filter.skip || 0;
|
|
284
270
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
285
271
|
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
286
|
-
from: filter.from ? filter.from
|
|
287
|
-
to: filter.to ? filter.to
|
|
272
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
273
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
288
274
|
orderDirection: orderDirection,
|
|
289
275
|
first: first,
|
|
290
276
|
skip: skip,
|
|
@@ -308,7 +294,7 @@ class StatisticsClient {
|
|
|
308
294
|
/**
|
|
309
295
|
* This function returns the statistical data of HMToken.
|
|
310
296
|
*
|
|
311
|
-
*
|
|
297
|
+
* ```ts
|
|
312
298
|
* type HMTStatistics = {
|
|
313
299
|
* totalTransferAmount: BigNumber;
|
|
314
300
|
* totalTransferCount: BigNumber;
|
|
@@ -316,9 +302,7 @@ class StatisticsClient {
|
|
|
316
302
|
* };
|
|
317
303
|
* ```
|
|
318
304
|
*
|
|
319
|
-
*
|
|
320
|
-
* @returns {HMTStatistics} HMToken statistics data.
|
|
321
|
-
*
|
|
305
|
+
* @returns {Promise<HMTStatistics>} HMToken statistics data.
|
|
322
306
|
*
|
|
323
307
|
* **Code example**
|
|
324
308
|
*
|
|
@@ -354,7 +338,7 @@ class StatisticsClient {
|
|
|
354
338
|
* **Input parameters**
|
|
355
339
|
*
|
|
356
340
|
* @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
|
|
357
|
-
* @returns {HMTHolder[]} List of HMToken holders.
|
|
341
|
+
* @returns {Promise<HMTHolder[]>} List of HMToken holders.
|
|
358
342
|
*
|
|
359
343
|
* **Code example**
|
|
360
344
|
*
|
|
@@ -394,7 +378,6 @@ class StatisticsClient {
|
|
|
394
378
|
/**
|
|
395
379
|
* This function returns the statistical data of HMToken day by day.
|
|
396
380
|
*
|
|
397
|
-
*
|
|
398
381
|
* **Input parameters**
|
|
399
382
|
*
|
|
400
383
|
* ```ts
|
|
@@ -417,10 +400,8 @@ class StatisticsClient {
|
|
|
417
400
|
* }
|
|
418
401
|
* ```
|
|
419
402
|
*
|
|
420
|
-
*
|
|
421
403
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
422
|
-
* @returns {DailyHMTData[]} Daily HMToken statistics data.
|
|
423
|
-
*
|
|
404
|
+
* @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
|
|
424
405
|
*
|
|
425
406
|
* **Code example**
|
|
426
407
|
*
|
|
@@ -447,8 +428,8 @@ class StatisticsClient {
|
|
|
447
428
|
const skip = filter.skip || 0;
|
|
448
429
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
449
430
|
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
450
|
-
from: filter.from ? filter.from
|
|
451
|
-
to: filter.to ? filter.to
|
|
431
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
432
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
452
433
|
orderDirection: orderDirection,
|
|
453
434
|
first: first,
|
|
454
435
|
skip: skip,
|
package/dist/storage.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { UploadFile, StorageCredentials, StorageParams } from './types';
|
|
|
5
5
|
*
|
|
6
6
|
* ## Introduction
|
|
7
7
|
*
|
|
8
|
-
* This client enables
|
|
8
|
+
* This client enables interacting with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage, and others.
|
|
9
9
|
*
|
|
10
10
|
* The instance creation of `StorageClient` should be made using its constructor:
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ import { UploadFile, StorageCredentials, StorageParams } from './types';
|
|
|
13
13
|
* constructor(params: StorageParams, credentials?: StorageCredentials)
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* > If credentials
|
|
16
|
+
* > If credentials are not provided, it uses anonymous access to the bucket for downloading files.
|
|
17
17
|
*
|
|
18
18
|
* ## Installation
|
|
19
19
|
*
|
|
@@ -53,7 +53,7 @@ export declare class StorageClient {
|
|
|
53
53
|
* **Storage client constructor**
|
|
54
54
|
*
|
|
55
55
|
* @param {StorageParams} params - Cloud storage params
|
|
56
|
-
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials
|
|
56
|
+
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
|
|
57
57
|
*/
|
|
58
58
|
constructor(params: StorageParams, credentials?: StorageCredentials);
|
|
59
59
|
/**
|
|
@@ -61,8 +61,7 @@ export declare class StorageClient {
|
|
|
61
61
|
*
|
|
62
62
|
* @param {string[]} keys Array of filenames to download.
|
|
63
63
|
* @param {string} bucket Bucket name.
|
|
64
|
-
* @returns {any[]} Returns an array of
|
|
65
|
-
*
|
|
64
|
+
* @returns {Promise<any[]>} Returns an array of JSON files downloaded and parsed into objects.
|
|
66
65
|
*
|
|
67
66
|
* **Code example**
|
|
68
67
|
*
|
|
@@ -84,28 +83,26 @@ export declare class StorageClient {
|
|
|
84
83
|
*/
|
|
85
84
|
downloadFiles(keys: string[], bucket: string): Promise<any[]>;
|
|
86
85
|
/**
|
|
87
|
-
* This function downloads files from a
|
|
88
|
-
*
|
|
89
|
-
* @param {string} url Url of the file to download.
|
|
90
|
-
* @returns {any} Returns the JSON file downloaded and parsed into object.
|
|
86
|
+
* This function downloads files from a URL.
|
|
91
87
|
*
|
|
88
|
+
* @param {string} url URL of the file to download.
|
|
89
|
+
* @returns {Promise<any>} Returns the JSON file downloaded and parsed into an object.
|
|
92
90
|
*
|
|
93
91
|
* **Code example**
|
|
94
92
|
*
|
|
95
93
|
* ```ts
|
|
96
94
|
* import { StorageClient } from '@human-protocol/sdk';
|
|
97
95
|
*
|
|
98
|
-
* const file = await
|
|
96
|
+
* const file = await StorageClient.downloadFileFromUrl('http://localhost/file.json');
|
|
99
97
|
* ```
|
|
100
98
|
*/
|
|
101
99
|
static downloadFileFromUrl(url: string): Promise<any>;
|
|
102
100
|
/**
|
|
103
101
|
* This function uploads files to a bucket.
|
|
104
102
|
*
|
|
105
|
-
* @param {any[]} files Array of objects to upload serialized into
|
|
103
|
+
* @param {any[]} files Array of objects to upload serialized into JSON.
|
|
106
104
|
* @param {string} bucket Bucket name.
|
|
107
|
-
* @returns {UploadFile[]} Returns an array of
|
|
108
|
-
*
|
|
105
|
+
* @returns {Promise<UploadFile[]>} Returns an array of uploaded file metadata.
|
|
109
106
|
*
|
|
110
107
|
* **Code example**
|
|
111
108
|
*
|
|
@@ -135,8 +132,7 @@ export declare class StorageClient {
|
|
|
135
132
|
* This function checks if a bucket exists.
|
|
136
133
|
*
|
|
137
134
|
* @param {string} bucket Bucket name.
|
|
138
|
-
* @returns {boolean} Returns `true` if exists, `false` if it doesn't.
|
|
139
|
-
*
|
|
135
|
+
* @returns {Promise<boolean>} Returns `true` if exists, `false` if it doesn't.
|
|
140
136
|
*
|
|
141
137
|
* **Code example**
|
|
142
138
|
*
|
|
@@ -160,11 +156,10 @@ export declare class StorageClient {
|
|
|
160
156
|
*/
|
|
161
157
|
bucketExists(bucket: string): Promise<boolean>;
|
|
162
158
|
/**
|
|
163
|
-
* This function
|
|
159
|
+
* This function lists all file names contained in the bucket.
|
|
164
160
|
*
|
|
165
161
|
* @param {string} bucket Bucket name.
|
|
166
|
-
* @returns {
|
|
167
|
-
*
|
|
162
|
+
* @returns {Promise<string[]>} Returns the list of file names contained in the bucket.
|
|
168
163
|
*
|
|
169
164
|
* **Code example**
|
|
170
165
|
*
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;;;;;;;;;OAaG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IAmCxB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
|
package/dist/storage.js
CHANGED
|
@@ -50,7 +50,7 @@ const constants_1 = require("./constants");
|
|
|
50
50
|
*
|
|
51
51
|
* ## Introduction
|
|
52
52
|
*
|
|
53
|
-
* This client enables
|
|
53
|
+
* This client enables interacting with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage, and others.
|
|
54
54
|
*
|
|
55
55
|
* The instance creation of `StorageClient` should be made using its constructor:
|
|
56
56
|
*
|
|
@@ -58,7 +58,7 @@ const constants_1 = require("./constants");
|
|
|
58
58
|
* constructor(params: StorageParams, credentials?: StorageCredentials)
|
|
59
59
|
* ```
|
|
60
60
|
*
|
|
61
|
-
* > If credentials
|
|
61
|
+
* > If credentials are not provided, it uses anonymous access to the bucket for downloading files.
|
|
62
62
|
*
|
|
63
63
|
* ## Installation
|
|
64
64
|
*
|
|
@@ -96,7 +96,7 @@ class StorageClient {
|
|
|
96
96
|
* **Storage client constructor**
|
|
97
97
|
*
|
|
98
98
|
* @param {StorageParams} params - Cloud storage params
|
|
99
|
-
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials
|
|
99
|
+
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
|
|
100
100
|
*/
|
|
101
101
|
constructor(params, credentials) {
|
|
102
102
|
try {
|
|
@@ -116,8 +116,7 @@ class StorageClient {
|
|
|
116
116
|
*
|
|
117
117
|
* @param {string[]} keys Array of filenames to download.
|
|
118
118
|
* @param {string} bucket Bucket name.
|
|
119
|
-
* @returns {any[]} Returns an array of
|
|
120
|
-
*
|
|
119
|
+
* @returns {Promise<any[]>} Returns an array of JSON files downloaded and parsed into objects.
|
|
121
120
|
*
|
|
122
121
|
* **Code example**
|
|
123
122
|
*
|
|
@@ -154,18 +153,17 @@ class StorageClient {
|
|
|
154
153
|
}));
|
|
155
154
|
}
|
|
156
155
|
/**
|
|
157
|
-
* This function downloads files from a
|
|
158
|
-
*
|
|
159
|
-
* @param {string} url Url of the file to download.
|
|
160
|
-
* @returns {any} Returns the JSON file downloaded and parsed into object.
|
|
156
|
+
* This function downloads files from a URL.
|
|
161
157
|
*
|
|
158
|
+
* @param {string} url URL of the file to download.
|
|
159
|
+
* @returns {Promise<any>} Returns the JSON file downloaded and parsed into an object.
|
|
162
160
|
*
|
|
163
161
|
* **Code example**
|
|
164
162
|
*
|
|
165
163
|
* ```ts
|
|
166
164
|
* import { StorageClient } from '@human-protocol/sdk';
|
|
167
165
|
*
|
|
168
|
-
* const file = await
|
|
166
|
+
* const file = await StorageClient.downloadFileFromUrl('http://localhost/file.json');
|
|
169
167
|
* ```
|
|
170
168
|
*/
|
|
171
169
|
static async downloadFileFromUrl(url) {
|
|
@@ -190,10 +188,9 @@ class StorageClient {
|
|
|
190
188
|
/**
|
|
191
189
|
* This function uploads files to a bucket.
|
|
192
190
|
*
|
|
193
|
-
* @param {any[]} files Array of objects to upload serialized into
|
|
191
|
+
* @param {any[]} files Array of objects to upload serialized into JSON.
|
|
194
192
|
* @param {string} bucket Bucket name.
|
|
195
|
-
* @returns {UploadFile[]} Returns an array of
|
|
196
|
-
*
|
|
193
|
+
* @returns {Promise<UploadFile[]>} Returns an array of uploaded file metadata.
|
|
197
194
|
*
|
|
198
195
|
* **Code example**
|
|
199
196
|
*
|
|
@@ -247,8 +244,7 @@ class StorageClient {
|
|
|
247
244
|
* This function checks if a bucket exists.
|
|
248
245
|
*
|
|
249
246
|
* @param {string} bucket Bucket name.
|
|
250
|
-
* @returns {boolean} Returns `true` if exists, `false` if it doesn't.
|
|
251
|
-
*
|
|
247
|
+
* @returns {Promise<boolean>} Returns `true` if exists, `false` if it doesn't.
|
|
252
248
|
*
|
|
253
249
|
* **Code example**
|
|
254
250
|
*
|
|
@@ -274,11 +270,10 @@ class StorageClient {
|
|
|
274
270
|
return this.client.bucketExists(bucket);
|
|
275
271
|
}
|
|
276
272
|
/**
|
|
277
|
-
* This function
|
|
273
|
+
* This function lists all file names contained in the bucket.
|
|
278
274
|
*
|
|
279
275
|
* @param {string} bucket Bucket name.
|
|
280
|
-
* @returns {
|
|
281
|
-
*
|
|
276
|
+
* @returns {Promise<string[]>} Returns the list of file names contained in the bucket.
|
|
282
277
|
*
|
|
283
278
|
* **Code example**
|
|
284
279
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CAwC3B"}
|
package/dist/transaction.js
CHANGED
|
@@ -30,7 +30,7 @@ class TransactionUtils {
|
|
|
30
30
|
*/
|
|
31
31
|
static async getTransaction(chainId, hash) {
|
|
32
32
|
if (!ethers_1.ethers.isHexString(hash)) {
|
|
33
|
-
throw error_1.
|
|
33
|
+
throw error_1.ErrorInvalidHashProvided;
|
|
34
34
|
}
|
|
35
35
|
const networkData = constants_1.NETWORKS[chainId];
|
|
36
36
|
if (!networkData) {
|
|
@@ -110,11 +110,9 @@ class TransactionUtils {
|
|
|
110
110
|
fromAddress: filter?.fromAddress,
|
|
111
111
|
toAddress: filter?.toAddress,
|
|
112
112
|
startDate: filter?.startDate
|
|
113
|
-
?
|
|
114
|
-
: undefined,
|
|
115
|
-
endDate: filter.endDate
|
|
116
|
-
? Math.floor(filter.endDate.getTime() / 1000)
|
|
113
|
+
? (0, utils_1.getUnixTimestamp)(filter?.startDate)
|
|
117
114
|
: undefined,
|
|
115
|
+
endDate: filter.endDate ? (0, utils_1.getUnixTimestamp)(filter.endDate) : undefined,
|
|
118
116
|
startBlock: filter.startBlock ? filter.startBlock : undefined,
|
|
119
117
|
endBlock: filter.endBlock ? filter.endBlock : undefined,
|
|
120
118
|
orderDirection: orderDirection,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionLike } from 'ethers';
|
|
1
2
|
/**
|
|
2
3
|
* Enum for escrow statuses.
|
|
3
4
|
* @readonly
|
|
@@ -21,7 +22,7 @@ export declare enum EscrowStatus {
|
|
|
21
22
|
*/
|
|
22
23
|
Paid = 3,
|
|
23
24
|
/**
|
|
24
|
-
* Escrow is finished
|
|
25
|
+
* Escrow is finished.
|
|
25
26
|
*/
|
|
26
27
|
Complete = 4,
|
|
27
28
|
/**
|
|
@@ -120,7 +121,7 @@ export type NetworkData = {
|
|
|
120
121
|
*/
|
|
121
122
|
subgraphUrl: string;
|
|
122
123
|
/**
|
|
123
|
-
* Subgraph URL
|
|
124
|
+
* Subgraph URL API key
|
|
124
125
|
*/
|
|
125
126
|
subgraphUrlApiKey: string;
|
|
126
127
|
/**
|
|
@@ -162,4 +163,7 @@ export type EscrowWithdraw = {
|
|
|
162
163
|
*/
|
|
163
164
|
amountWithdrawn: bigint;
|
|
164
165
|
};
|
|
166
|
+
export type TransactionLikeWithNonce = TransactionLike & {
|
|
167
|
+
nonce: number;
|
|
168
|
+
};
|
|
165
169
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,I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;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -17,8 +17,14 @@ export declare const isValidUrl: (url: string) => boolean;
|
|
|
17
17
|
* **Get the subgraph URL.*
|
|
18
18
|
*
|
|
19
19
|
* @param {NetworkData} networkData
|
|
20
|
-
* @param {string} apiKey
|
|
21
20
|
* @returns
|
|
22
21
|
*/
|
|
23
22
|
export declare const getSubgraphUrl: (networkData: NetworkData) => string;
|
|
23
|
+
/**
|
|
24
|
+
* **Convert a date to Unix timestamp (seconds since epoch).*
|
|
25
|
+
*
|
|
26
|
+
* @param {Date} date
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
export declare const getUnixTimestamp: (date: Date) => number;
|
|
24
30
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,MAAO,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,YAOrC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,MAAO,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,YAOrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,WAatD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,SAAU,IAAI,KAAG,MAE7C,CAAC"}
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSubgraphUrl = exports.isValidUrl = exports.throwError = void 0;
|
|
3
|
+
exports.getUnixTimestamp = exports.getSubgraphUrl = exports.isValidUrl = exports.throwError = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
6
|
const error_1 = require("./error");
|
|
@@ -55,7 +55,6 @@ exports.isValidUrl = isValidUrl;
|
|
|
55
55
|
* **Get the subgraph URL.*
|
|
56
56
|
*
|
|
57
57
|
* @param {NetworkData} networkData
|
|
58
|
-
* @param {string} apiKey
|
|
59
58
|
* @returns
|
|
60
59
|
*/
|
|
61
60
|
const getSubgraphUrl = (networkData) => {
|
|
@@ -70,3 +69,13 @@ const getSubgraphUrl = (networkData) => {
|
|
|
70
69
|
return subgraphUrl;
|
|
71
70
|
};
|
|
72
71
|
exports.getSubgraphUrl = getSubgraphUrl;
|
|
72
|
+
/**
|
|
73
|
+
* **Convert a date to Unix timestamp (seconds since epoch).*
|
|
74
|
+
*
|
|
75
|
+
* @param {Date} date
|
|
76
|
+
* @returns {number}
|
|
77
|
+
*/
|
|
78
|
+
const getUnixTimestamp = (date) => {
|
|
79
|
+
return Math.floor(date.getTime() / 1000);
|
|
80
|
+
};
|
|
81
|
+
exports.getUnixTimestamp = getUnixTimestamp;
|