@human-protocol/sdk 3.0.1 → 3.0.2
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 +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/escrow.d.ts +0 -6
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +0 -6
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +0 -3
- package/dist/graphql/queries/kvstore.d.ts +1 -0
- package/dist/graphql/queries/kvstore.d.ts.map +1 -1
- package/dist/graphql/queries/kvstore.js +12 -1
- package/dist/graphql/queries/operator.js +1 -1
- package/dist/graphql/queries/statistics.d.ts +2 -2
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +11 -7
- package/dist/graphql/types.d.ts +0 -5
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interfaces.d.ts +3 -5
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +69 -106
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +123 -159
- package/dist/statistics.d.ts +72 -66
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +121 -89
- package/package.json +1 -1
- package/src/constants.ts +1 -0
- package/src/escrow.ts +0 -6
- package/src/graphql/queries/escrow.ts +0 -3
- package/src/graphql/queries/kvstore.ts +11 -0
- package/src/graphql/queries/operator.ts +1 -1
- package/src/graphql/queries/statistics.ts +13 -9
- package/src/graphql/types.ts +0 -5
- package/src/index.ts +2 -1
- package/src/interfaces.ts +3 -5
- package/src/kvstore.ts +145 -158
- package/src/statistics.ts +138 -100
package/dist/statistics.js
CHANGED
|
@@ -9,6 +9,7 @@ const ethers_1 = require("ethers");
|
|
|
9
9
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
10
10
|
const graphql_1 = require("./graphql");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const enums_1 = require("./enums");
|
|
12
13
|
/**
|
|
13
14
|
* ## Introduction
|
|
14
15
|
*
|
|
@@ -63,10 +64,12 @@ class StatisticsClient {
|
|
|
63
64
|
* **Input parameters**
|
|
64
65
|
*
|
|
65
66
|
* ```ts
|
|
66
|
-
* interface
|
|
67
|
+
* interface IStatisticsFilter {
|
|
67
68
|
* from?: Date;
|
|
68
69
|
* to?: Date;
|
|
69
|
-
*
|
|
70
|
+
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
71
|
+
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
72
|
+
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
|
|
70
73
|
* }
|
|
71
74
|
* ```
|
|
72
75
|
*
|
|
@@ -87,7 +90,7 @@ class StatisticsClient {
|
|
|
87
90
|
* ```
|
|
88
91
|
*
|
|
89
92
|
*
|
|
90
|
-
* @param {
|
|
93
|
+
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
91
94
|
* @returns {EscrowStatistics} Escrow statistics data.
|
|
92
95
|
*
|
|
93
96
|
*
|
|
@@ -105,12 +108,18 @@ class StatisticsClient {
|
|
|
105
108
|
* });
|
|
106
109
|
* ```
|
|
107
110
|
*/
|
|
108
|
-
async getEscrowStatistics(
|
|
111
|
+
async getEscrowStatistics(filter = {}) {
|
|
109
112
|
try {
|
|
113
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
114
|
+
const skip = filter.skip || 0;
|
|
115
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
110
116
|
const { escrowStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY);
|
|
111
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(
|
|
112
|
-
from:
|
|
113
|
-
to:
|
|
117
|
+
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.getTime() / 1000 : undefined,
|
|
119
|
+
to: filter.to ? filter.to.getTime() / 1000 : undefined,
|
|
120
|
+
orderDirection: orderDirection,
|
|
121
|
+
first: first,
|
|
122
|
+
skip: skip,
|
|
114
123
|
});
|
|
115
124
|
return {
|
|
116
125
|
totalEscrows: +escrowStatistics.totalEscrowCount,
|
|
@@ -135,10 +144,12 @@ class StatisticsClient {
|
|
|
135
144
|
* **Input parameters**
|
|
136
145
|
*
|
|
137
146
|
* ```ts
|
|
138
|
-
* interface
|
|
147
|
+
* interface IStatisticsFilter {
|
|
139
148
|
* from?: Date;
|
|
140
149
|
* to?: Date;
|
|
141
|
-
*
|
|
150
|
+
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
151
|
+
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
152
|
+
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
|
|
142
153
|
* }
|
|
143
154
|
* ```
|
|
144
155
|
*
|
|
@@ -154,7 +165,7 @@ class StatisticsClient {
|
|
|
154
165
|
* ```
|
|
155
166
|
*
|
|
156
167
|
*
|
|
157
|
-
* @param {
|
|
168
|
+
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
158
169
|
* @returns {WorkerStatistics} Worker statistics data.
|
|
159
170
|
*
|
|
160
171
|
*
|
|
@@ -172,11 +183,17 @@ class StatisticsClient {
|
|
|
172
183
|
* });
|
|
173
184
|
* ```
|
|
174
185
|
*/
|
|
175
|
-
async getWorkerStatistics(
|
|
186
|
+
async getWorkerStatistics(filter = {}) {
|
|
176
187
|
try {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
188
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
189
|
+
const skip = filter.skip || 0;
|
|
190
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
191
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
192
|
+
from: filter.from ? filter.from.getTime() / 1000 : undefined,
|
|
193
|
+
to: filter.to ? filter.to.getTime() / 1000 : undefined,
|
|
194
|
+
orderDirection: orderDirection,
|
|
195
|
+
first: first,
|
|
196
|
+
skip: skip,
|
|
180
197
|
});
|
|
181
198
|
return {
|
|
182
199
|
dailyWorkersData: eventDayDatas.map((eventDayData) => ({
|
|
@@ -196,10 +213,12 @@ class StatisticsClient {
|
|
|
196
213
|
* **Input parameters**
|
|
197
214
|
*
|
|
198
215
|
* ```ts
|
|
199
|
-
* interface
|
|
216
|
+
* interface IStatisticsFilter {
|
|
200
217
|
* from?: Date;
|
|
201
218
|
* to?: Date;
|
|
202
|
-
*
|
|
219
|
+
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
220
|
+
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
221
|
+
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
|
|
203
222
|
* }
|
|
204
223
|
* ```
|
|
205
224
|
*
|
|
@@ -217,7 +236,7 @@ class StatisticsClient {
|
|
|
217
236
|
* ```
|
|
218
237
|
*
|
|
219
238
|
*
|
|
220
|
-
* @param {
|
|
239
|
+
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
221
240
|
* @returns {PaymentStatistics} Payment statistics data.
|
|
222
241
|
*
|
|
223
242
|
*
|
|
@@ -256,11 +275,17 @@ class StatisticsClient {
|
|
|
256
275
|
* );
|
|
257
276
|
* ```
|
|
258
277
|
*/
|
|
259
|
-
async getPaymentStatistics(
|
|
278
|
+
async getPaymentStatistics(filter = {}) {
|
|
260
279
|
try {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
280
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
281
|
+
const skip = filter.skip || 0;
|
|
282
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
283
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
284
|
+
from: filter.from ? filter.from.getTime() / 1000 : undefined,
|
|
285
|
+
to: filter.to ? filter.to.getTime() / 1000 : undefined,
|
|
286
|
+
orderDirection: orderDirection,
|
|
287
|
+
first: first,
|
|
288
|
+
skip: skip,
|
|
264
289
|
});
|
|
265
290
|
return {
|
|
266
291
|
dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
|
|
@@ -282,39 +307,14 @@ class StatisticsClient {
|
|
|
282
307
|
* This function returns the statistical data of HMToken.
|
|
283
308
|
*
|
|
284
309
|
*
|
|
285
|
-
* **Input parameters**
|
|
286
|
-
*
|
|
287
|
-
* ```ts
|
|
288
|
-
* interface IStatisticsParams {
|
|
289
|
-
* from?: Date;
|
|
290
|
-
* to?: Date;
|
|
291
|
-
* limit?: number;
|
|
292
|
-
* }
|
|
293
|
-
* ```
|
|
294
|
-
*
|
|
295
|
-
* ```ts
|
|
296
|
-
* type HMTHolder = {
|
|
297
|
-
* address: string;
|
|
298
|
-
* balance: BigNumber;
|
|
299
|
-
* }
|
|
300
|
-
*
|
|
301
|
-
* type DailyHMTData = {
|
|
302
|
-
* timestamp: Date;
|
|
303
|
-
* totalTransactionAmount: BigNumber;
|
|
304
|
-
* totalTransactionCount: number;
|
|
305
|
-
* };
|
|
306
|
-
*
|
|
307
310
|
* type HMTStatistics = {
|
|
308
311
|
* totalTransferAmount: BigNumber;
|
|
309
312
|
* totalTransferCount: BigNumber;
|
|
310
313
|
* totalHolders: number;
|
|
311
|
-
* holders: HMTHolder[];
|
|
312
|
-
* dailyHMTData: DailyHMTData[];
|
|
313
314
|
* };
|
|
314
315
|
* ```
|
|
315
316
|
*
|
|
316
317
|
*
|
|
317
|
-
* @param {IStatisticsParams} params Statistics params with duration data
|
|
318
318
|
* @returns {HMTStatistics} HMToken statistics data.
|
|
319
319
|
*
|
|
320
320
|
*
|
|
@@ -330,58 +330,16 @@ class StatisticsClient {
|
|
|
330
330
|
* console.log('HMT statistics:', {
|
|
331
331
|
* ...hmtStatistics,
|
|
332
332
|
* totalTransferAmount: hmtStatistics.totalTransferAmount.toString(),
|
|
333
|
-
* holders: hmtStatistics.holders.map((h) => ({
|
|
334
|
-
* ...h,
|
|
335
|
-
* balance: h.balance.toString(),
|
|
336
|
-
* })),
|
|
337
|
-
* dailyHMTData: hmtStatistics.dailyHMTData.map((d) => ({
|
|
338
|
-
* ...d,
|
|
339
|
-
* totalTransactionAmount: d.totalTransactionAmount.toString(),
|
|
340
|
-
* })),
|
|
341
|
-
* });
|
|
342
|
-
*
|
|
343
|
-
* const hmtStatisticsRange = await statisticsClient.getHMTStatistics({
|
|
344
|
-
* from: new Date(2023, 4, 8),
|
|
345
|
-
* to: new Date(2023, 5, 8),
|
|
346
|
-
* });
|
|
347
|
-
*
|
|
348
|
-
* console.log('HMT statistics from 5/8 - 6/8:', {
|
|
349
|
-
* ...hmtStatisticsRange,
|
|
350
|
-
* totalTransferAmount: hmtStatisticsRange.totalTransferAmount.toString(),
|
|
351
|
-
* holders: hmtStatisticsRange.holders.map((h) => ({
|
|
352
|
-
* ...h,
|
|
353
|
-
* balance: h.balance.toString(),
|
|
354
|
-
* })),
|
|
355
|
-
* dailyHMTData: hmtStatisticsRange.dailyHMTData.map((d) => ({
|
|
356
|
-
* ...d,
|
|
357
|
-
* totalTransactionAmount: d.totalTransactionAmount.toString(),
|
|
358
|
-
* })),
|
|
359
333
|
* });
|
|
360
334
|
* ```
|
|
361
335
|
*/
|
|
362
|
-
async getHMTStatistics(
|
|
336
|
+
async getHMTStatistics() {
|
|
363
337
|
try {
|
|
364
338
|
const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
|
|
365
|
-
const { holders } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_HOLDERS_QUERY)());
|
|
366
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
367
|
-
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
368
|
-
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
369
|
-
});
|
|
370
339
|
return {
|
|
371
340
|
totalTransferAmount: ethers_1.ethers.toBigInt(hmtokenStatistics.totalValueTransfered),
|
|
372
341
|
totalTransferCount: Number(hmtokenStatistics.totalTransferEventCount),
|
|
373
342
|
totalHolders: +hmtokenStatistics.holders,
|
|
374
|
-
holders: holders.map((holder) => ({
|
|
375
|
-
address: holder.address,
|
|
376
|
-
balance: ethers_1.ethers.toBigInt(holder.balance),
|
|
377
|
-
})),
|
|
378
|
-
dailyHMTData: eventDayDatas.map((eventDayData) => ({
|
|
379
|
-
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
380
|
-
totalTransactionAmount: ethers_1.ethers.toBigInt(eventDayData.dailyHMTTransferAmount),
|
|
381
|
-
totalTransactionCount: +eventDayData.dailyHMTTransferCount,
|
|
382
|
-
dailyUniqueSenders: +eventDayData.dailyUniqueSenders,
|
|
383
|
-
dailyUniqueReceivers: +eventDayData.dailyUniqueReceivers,
|
|
384
|
-
})),
|
|
385
343
|
};
|
|
386
344
|
}
|
|
387
345
|
catch (e) {
|
|
@@ -431,5 +389,79 @@ class StatisticsClient {
|
|
|
431
389
|
return (0, utils_1.throwError)(e);
|
|
432
390
|
}
|
|
433
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* This function returns the statistical data of HMToken day by day.
|
|
394
|
+
*
|
|
395
|
+
*
|
|
396
|
+
* **Input parameters**
|
|
397
|
+
*
|
|
398
|
+
* ```ts
|
|
399
|
+
* interface IStatisticsFilter {
|
|
400
|
+
* from?: Date;
|
|
401
|
+
* to?: Date;
|
|
402
|
+
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
403
|
+
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
404
|
+
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is ASC.
|
|
405
|
+
* }
|
|
406
|
+
* ```
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* type DailyHMTData = {
|
|
410
|
+
* timestamp: Date;
|
|
411
|
+
* totalTransactionAmount: bigint;
|
|
412
|
+
* totalTransactionCount: number;
|
|
413
|
+
* dailyUniqueSenders: number;
|
|
414
|
+
* dailyUniqueReceivers: number;
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
*
|
|
419
|
+
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
420
|
+
* @returns {DailyHMTData[]} Daily HMToken statistics data.
|
|
421
|
+
*
|
|
422
|
+
*
|
|
423
|
+
* **Code example**
|
|
424
|
+
*
|
|
425
|
+
* ```ts
|
|
426
|
+
* import { StatisticsClient, ChainId, NETWORKS } from '@human-protocol/sdk';
|
|
427
|
+
*
|
|
428
|
+
* const statisticsClient = new StatisticsClient(NETWORKS[ChainId.POLYGON_AMOY]);
|
|
429
|
+
*
|
|
430
|
+
* const dailyHMTStats = await statisticsClient.getHMTStatistics();
|
|
431
|
+
*
|
|
432
|
+
* console.log('Daily HMT statistics:', dailyHMTStats);
|
|
433
|
+
*
|
|
434
|
+
* const hmtStatisticsRange = await statisticsClient.getHMTStatistics({
|
|
435
|
+
* from: new Date(2023, 4, 8),
|
|
436
|
+
* to: new Date(2023, 5, 8),
|
|
437
|
+
* });
|
|
438
|
+
*
|
|
439
|
+
* console.log('HMT statistics from 5/8 - 6/8:', hmtStatisticsRange);
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
async getHMTDailyData(filter = {}) {
|
|
443
|
+
try {
|
|
444
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
445
|
+
const skip = filter.skip || 0;
|
|
446
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
447
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
448
|
+
from: filter.from ? filter.from.getTime() / 1000 : undefined,
|
|
449
|
+
to: filter.to ? filter.to.getTime() / 1000 : undefined,
|
|
450
|
+
orderDirection: orderDirection,
|
|
451
|
+
first: first,
|
|
452
|
+
skip: skip,
|
|
453
|
+
});
|
|
454
|
+
return eventDayDatas.map((eventDayData) => ({
|
|
455
|
+
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
456
|
+
totalTransactionAmount: ethers_1.ethers.toBigInt(eventDayData.dailyHMTTransferAmount),
|
|
457
|
+
totalTransactionCount: +eventDayData.dailyHMTTransferCount,
|
|
458
|
+
dailyUniqueSenders: +eventDayData.dailyUniqueSenders,
|
|
459
|
+
dailyUniqueReceivers: +eventDayData.dailyUniqueReceivers,
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
catch (e) {
|
|
463
|
+
return (0, utils_1.throwError)(e);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
434
466
|
}
|
|
435
467
|
exports.StatisticsClient = StatisticsClient;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/escrow.ts
CHANGED
|
@@ -1484,11 +1484,8 @@ export class EscrowUtils {
|
|
|
1484
1484
|
* manifestHash?: string;
|
|
1485
1485
|
* manifestUrl?: string;
|
|
1486
1486
|
* recordingOracle?: string;
|
|
1487
|
-
* recordingOracleFee?: string;
|
|
1488
1487
|
* reputationOracle?: string;
|
|
1489
|
-
* reputationOracleFee?: string;
|
|
1490
1488
|
* exchangeOracle?: string;
|
|
1491
|
-
* exchangeOracleFee?: string;
|
|
1492
1489
|
* status: EscrowStatus;
|
|
1493
1490
|
* token: string;
|
|
1494
1491
|
* totalFundedAmount: string;
|
|
@@ -1618,11 +1615,8 @@ export class EscrowUtils {
|
|
|
1618
1615
|
* manifestHash?: string;
|
|
1619
1616
|
* manifestUrl?: string;
|
|
1620
1617
|
* recordingOracle?: string;
|
|
1621
|
-
* recordingOracleFee?: string;
|
|
1622
1618
|
* reputationOracle?: string;
|
|
1623
|
-
* reputationOracleFee?: string;
|
|
1624
1619
|
* exchangeOracle?: string;
|
|
1625
|
-
* exchangeOracleFee?: string;
|
|
1626
1620
|
* status: EscrowStatus;
|
|
1627
1621
|
* token: string;
|
|
1628
1622
|
* totalFundedAmount: string;
|
|
@@ -21,3 +21,14 @@ export const GET_KVSTORE_BY_ADDRESS_QUERY = () => {
|
|
|
21
21
|
${KVSTORE_FRAGMENT}
|
|
22
22
|
`;
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
export const GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY = () => {
|
|
26
|
+
return gql`
|
|
27
|
+
query getKVStoreDataByKey($address: String!, $key: String!) {
|
|
28
|
+
kvstores(where: { address: $address, key: $key }) {
|
|
29
|
+
...KVStoreFields
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
${KVSTORE_FRAGMENT}
|
|
33
|
+
`;
|
|
34
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { IStatisticsFilter } from '../../interfaces';
|
|
3
3
|
|
|
4
4
|
const HMTOKEN_STATISTICS_FRAGMENT = gql`
|
|
5
5
|
fragment HMTokenStatisticsFields on HMTokenStatistics {
|
|
@@ -70,25 +70,29 @@ export const GET_ESCROW_STATISTICS_QUERY = gql`
|
|
|
70
70
|
${ESCROW_STATISTICS_FRAGMENT}
|
|
71
71
|
`;
|
|
72
72
|
|
|
73
|
-
export const GET_EVENT_DAY_DATA_QUERY = (params:
|
|
74
|
-
const { from, to
|
|
73
|
+
export const GET_EVENT_DAY_DATA_QUERY = (params: IStatisticsFilter) => {
|
|
74
|
+
const { from, to } = params;
|
|
75
75
|
const WHERE_CLAUSE = `
|
|
76
76
|
where: {
|
|
77
77
|
${from !== undefined ? `timestamp_gte: $from` : ''}
|
|
78
78
|
${to !== undefined ? `timestamp_lte: $to` : ''}
|
|
79
79
|
}
|
|
80
80
|
`;
|
|
81
|
-
const LIMIT_CLAUSE = `
|
|
82
|
-
first: ${limit ? `$limit` : `1000`}
|
|
83
|
-
`;
|
|
84
81
|
|
|
85
82
|
return gql`
|
|
86
|
-
query GetEscrowDayData(
|
|
83
|
+
query GetEscrowDayData(
|
|
84
|
+
$from: Int,
|
|
85
|
+
$to: Int,
|
|
86
|
+
$orderDirection: String
|
|
87
|
+
$first: Int
|
|
88
|
+
$skip: Int
|
|
89
|
+
) {
|
|
87
90
|
eventDayDatas(
|
|
88
91
|
${WHERE_CLAUSE},
|
|
89
92
|
orderBy: timestamp,
|
|
90
|
-
orderDirection:
|
|
91
|
-
$
|
|
93
|
+
orderDirection: $orderDirection,
|
|
94
|
+
first: $first,
|
|
95
|
+
skip: $skip
|
|
92
96
|
) {
|
|
93
97
|
...EventDayDataFields
|
|
94
98
|
}
|
package/src/graphql/types.ts
CHANGED
|
@@ -13,11 +13,8 @@ export type EscrowData = {
|
|
|
13
13
|
manifestHash?: string;
|
|
14
14
|
manifestUrl?: string;
|
|
15
15
|
recordingOracle?: string;
|
|
16
|
-
recordingOracleFee?: string;
|
|
17
16
|
reputationOracle?: string;
|
|
18
|
-
reputationOracleFee?: string;
|
|
19
17
|
exchangeOracle?: string;
|
|
20
|
-
exchangeOracleFee?: string;
|
|
21
18
|
status: string;
|
|
22
19
|
token: string;
|
|
23
20
|
totalFundedAmount: string;
|
|
@@ -141,8 +138,6 @@ export type HMTStatistics = {
|
|
|
141
138
|
totalTransferAmount: bigint;
|
|
142
139
|
totalTransferCount: number;
|
|
143
140
|
totalHolders: number;
|
|
144
|
-
holders: HMTHolder[];
|
|
145
|
-
dailyHMTData: DailyHMTData[];
|
|
146
141
|
};
|
|
147
142
|
|
|
148
143
|
export type IMDataEntity = {
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StakingClient } from './staking';
|
|
2
2
|
import { StorageClient } from './storage';
|
|
3
|
-
import { KVStoreClient } from './kvstore';
|
|
3
|
+
import { KVStoreClient, KVStoreUtils } from './kvstore';
|
|
4
4
|
import { EscrowClient, EscrowUtils } from './escrow';
|
|
5
5
|
import { StatisticsClient } from './statistics';
|
|
6
6
|
import { Encryption, EncryptionUtils } from './encryption';
|
|
@@ -16,6 +16,7 @@ export {
|
|
|
16
16
|
StakingClient,
|
|
17
17
|
StorageClient,
|
|
18
18
|
KVStoreClient,
|
|
19
|
+
KVStoreUtils,
|
|
19
20
|
EscrowClient,
|
|
20
21
|
EscrowUtils,
|
|
21
22
|
StatisticsClient,
|
package/src/interfaces.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface ILeader {
|
|
|
26
26
|
amountSlashed: bigint;
|
|
27
27
|
reputation: bigint;
|
|
28
28
|
reward: bigint;
|
|
29
|
-
|
|
29
|
+
amountJobsProcessed: bigint;
|
|
30
30
|
role?: string;
|
|
31
31
|
fee?: bigint;
|
|
32
32
|
publicKey?: string;
|
|
@@ -96,15 +96,13 @@ export interface IKeyPair {
|
|
|
96
96
|
revocationCertificate?: string;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
export interface
|
|
99
|
+
export interface IStatisticsFilter extends IPagination {
|
|
100
100
|
from?: Date;
|
|
101
101
|
to?: Date;
|
|
102
|
-
limit?: number;
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
export interface IHMTHoldersParams {
|
|
104
|
+
export interface IHMTHoldersParams extends IPagination {
|
|
106
105
|
address?: string;
|
|
107
|
-
orderDirection?: 'asc' | 'desc';
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
export interface IPayoutFilter {
|