@human-protocol/sdk 5.0.0-beta.2 → 5.0.0
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.js +6 -6
- package/dist/escrow.d.ts +114 -44
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +236 -78
- package/dist/graphql/types.d.ts +101 -74
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/interfaces.d.ts +119 -77
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +13 -7
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -2
- package/dist/statistics.d.ts +32 -33
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +38 -39
- package/dist/transaction.d.ts +26 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +54 -4
- package/dist/types.d.ts +0 -75
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +14 -4
- package/package.json +2 -2
- package/src/constants.ts +6 -6
- package/src/escrow.ts +307 -108
- package/src/graphql/types.ts +108 -87
- package/src/interfaces.ts +132 -78
- package/src/operator.ts +17 -13
- package/src/staking.ts +17 -4
- package/src/statistics.ts +58 -62
- package/src/transaction.ts +66 -8
- package/src/types.ts +0 -79
- package/src/worker.ts +18 -6
package/dist/statistics.js
CHANGED
|
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.StatisticsClient = void 0;
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const ethers_1 = require("ethers");
|
|
9
8
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
9
|
+
const enums_1 = require("./enums");
|
|
10
10
|
const graphql_1 = require("./graphql");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
-
const enums_1 = require("./enums");
|
|
13
12
|
/**
|
|
14
13
|
* ## Introduction
|
|
15
14
|
*
|
|
@@ -68,8 +67,8 @@ class StatisticsClient {
|
|
|
68
67
|
* ```
|
|
69
68
|
*
|
|
70
69
|
* ```ts
|
|
71
|
-
*
|
|
72
|
-
* timestamp:
|
|
70
|
+
* interface IDailyEscrow {
|
|
71
|
+
* timestamp: number;
|
|
73
72
|
* escrowsTotal: number;
|
|
74
73
|
* escrowsPending: number;
|
|
75
74
|
* escrowsSolved: number;
|
|
@@ -77,14 +76,14 @@ class StatisticsClient {
|
|
|
77
76
|
* escrowsCancelled: number;
|
|
78
77
|
* };
|
|
79
78
|
*
|
|
80
|
-
*
|
|
79
|
+
* interface IEscrowStatistics {
|
|
81
80
|
* totalEscrows: number;
|
|
82
|
-
* dailyEscrowsData:
|
|
81
|
+
* dailyEscrowsData: IDailyEscrow[];
|
|
83
82
|
* };
|
|
84
83
|
* ```
|
|
85
84
|
*
|
|
86
85
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
87
|
-
* @returns {Promise<
|
|
86
|
+
* @returns {Promise<IEscrowStatistics>} Escrow statistics data.
|
|
88
87
|
*
|
|
89
88
|
* **Code example**
|
|
90
89
|
*
|
|
@@ -118,7 +117,7 @@ class StatisticsClient {
|
|
|
118
117
|
? +escrowStatistics.totalEscrowCount
|
|
119
118
|
: 0,
|
|
120
119
|
dailyEscrowsData: eventDayDatas.map((eventDayData) => ({
|
|
121
|
-
timestamp:
|
|
120
|
+
timestamp: +eventDayData.timestamp * 1000,
|
|
122
121
|
escrowsTotal: +eventDayData.dailyEscrowCount,
|
|
123
122
|
escrowsPending: +eventDayData.dailyPendingStatusEventCount,
|
|
124
123
|
escrowsSolved: +eventDayData.dailyCompletedStatusEventCount,
|
|
@@ -147,18 +146,18 @@ class StatisticsClient {
|
|
|
147
146
|
* ```
|
|
148
147
|
*
|
|
149
148
|
* ```ts
|
|
150
|
-
*
|
|
151
|
-
* timestamp:
|
|
149
|
+
* interface IDailyWorker {
|
|
150
|
+
* timestamp: number;
|
|
152
151
|
* activeWorkers: number;
|
|
153
152
|
* };
|
|
154
153
|
*
|
|
155
|
-
*
|
|
156
|
-
* dailyWorkersData:
|
|
154
|
+
* interface IWorkerStatistics {
|
|
155
|
+
* dailyWorkersData: IDailyWorker[];
|
|
157
156
|
* };
|
|
158
157
|
* ```
|
|
159
158
|
*
|
|
160
159
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
161
|
-
* @returns {Promise<
|
|
160
|
+
* @returns {Promise<IWorkerStatistics>} Worker statistics data.
|
|
162
161
|
*
|
|
163
162
|
* **Code example**
|
|
164
163
|
*
|
|
@@ -188,7 +187,7 @@ class StatisticsClient {
|
|
|
188
187
|
});
|
|
189
188
|
return {
|
|
190
189
|
dailyWorkersData: eventDayDatas.map((eventDayData) => ({
|
|
191
|
-
timestamp:
|
|
190
|
+
timestamp: +eventDayData.timestamp * 1000,
|
|
192
191
|
activeWorkers: +eventDayData.dailyWorkerCount,
|
|
193
192
|
})),
|
|
194
193
|
};
|
|
@@ -213,20 +212,20 @@ class StatisticsClient {
|
|
|
213
212
|
* ```
|
|
214
213
|
*
|
|
215
214
|
* ```ts
|
|
216
|
-
*
|
|
217
|
-
* timestamp:
|
|
218
|
-
* totalAmountPaid:
|
|
215
|
+
* interface IDailyPayment {
|
|
216
|
+
* timestamp: number;
|
|
217
|
+
* totalAmountPaid: bigint;
|
|
219
218
|
* totalCount: number;
|
|
220
|
-
* averageAmountPerWorker:
|
|
219
|
+
* averageAmountPerWorker: bigint;
|
|
221
220
|
* };
|
|
222
221
|
*
|
|
223
|
-
*
|
|
224
|
-
* dailyPaymentsData:
|
|
222
|
+
* interface IPaymentStatistics {
|
|
223
|
+
* dailyPaymentsData: IDailyPayment[];
|
|
225
224
|
* };
|
|
226
225
|
* ```
|
|
227
226
|
*
|
|
228
227
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
229
|
-
* @returns {Promise<
|
|
228
|
+
* @returns {Promise<IPaymentStatistics>} Payment statistics data.
|
|
230
229
|
*
|
|
231
230
|
* **Code example**
|
|
232
231
|
*
|
|
@@ -277,13 +276,13 @@ class StatisticsClient {
|
|
|
277
276
|
});
|
|
278
277
|
return {
|
|
279
278
|
dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
|
|
280
|
-
timestamp:
|
|
281
|
-
totalAmountPaid:
|
|
279
|
+
timestamp: +eventDayData.timestamp * 1000,
|
|
280
|
+
totalAmountPaid: BigInt(eventDayData.dailyHMTPayoutAmount),
|
|
282
281
|
totalCount: +eventDayData.dailyPayoutCount,
|
|
283
282
|
averageAmountPerWorker: eventDayData.dailyWorkerCount === '0'
|
|
284
|
-
?
|
|
285
|
-
:
|
|
286
|
-
|
|
283
|
+
? BigInt(0)
|
|
284
|
+
: BigInt(eventDayData.dailyHMTPayoutAmount) /
|
|
285
|
+
BigInt(eventDayData.dailyWorkerCount),
|
|
287
286
|
})),
|
|
288
287
|
};
|
|
289
288
|
}
|
|
@@ -295,14 +294,14 @@ class StatisticsClient {
|
|
|
295
294
|
* This function returns the statistical data of HMToken.
|
|
296
295
|
*
|
|
297
296
|
* ```ts
|
|
298
|
-
*
|
|
299
|
-
* totalTransferAmount:
|
|
300
|
-
* totalTransferCount:
|
|
297
|
+
* interface IHMTStatistics {
|
|
298
|
+
* totalTransferAmount: bigint;
|
|
299
|
+
* totalTransferCount: number;
|
|
301
300
|
* totalHolders: number;
|
|
302
301
|
* };
|
|
303
302
|
* ```
|
|
304
303
|
*
|
|
305
|
-
* @returns {Promise<
|
|
304
|
+
* @returns {Promise<IHMTStatistics>} HMToken statistics data.
|
|
306
305
|
*
|
|
307
306
|
* **Code example**
|
|
308
307
|
*
|
|
@@ -323,8 +322,8 @@ class StatisticsClient {
|
|
|
323
322
|
try {
|
|
324
323
|
const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
|
|
325
324
|
return {
|
|
326
|
-
totalTransferAmount:
|
|
327
|
-
totalTransferCount:
|
|
325
|
+
totalTransferAmount: BigInt(hmtokenStatistics.totalValueTransfered),
|
|
326
|
+
totalTransferCount: +hmtokenStatistics.totalTransferEventCount,
|
|
328
327
|
totalHolders: +hmtokenStatistics.holders,
|
|
329
328
|
};
|
|
330
329
|
}
|
|
@@ -338,7 +337,7 @@ class StatisticsClient {
|
|
|
338
337
|
* **Input parameters**
|
|
339
338
|
*
|
|
340
339
|
* @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
|
|
341
|
-
* @returns {Promise<
|
|
340
|
+
* @returns {Promise<IHMTHolder[]>} List of HMToken holders.
|
|
342
341
|
*
|
|
343
342
|
* **Code example**
|
|
344
343
|
*
|
|
@@ -368,7 +367,7 @@ class StatisticsClient {
|
|
|
368
367
|
});
|
|
369
368
|
return holders.map((holder) => ({
|
|
370
369
|
address: holder.address,
|
|
371
|
-
balance:
|
|
370
|
+
balance: BigInt(holder.balance),
|
|
372
371
|
}));
|
|
373
372
|
}
|
|
374
373
|
catch (e) {
|
|
@@ -391,8 +390,8 @@ class StatisticsClient {
|
|
|
391
390
|
* ```
|
|
392
391
|
*
|
|
393
392
|
* ```ts
|
|
394
|
-
*
|
|
395
|
-
* timestamp:
|
|
393
|
+
* interface IDailyHMT {
|
|
394
|
+
* timestamp: number;
|
|
396
395
|
* totalTransactionAmount: bigint;
|
|
397
396
|
* totalTransactionCount: number;
|
|
398
397
|
* dailyUniqueSenders: number;
|
|
@@ -401,7 +400,7 @@ class StatisticsClient {
|
|
|
401
400
|
* ```
|
|
402
401
|
*
|
|
403
402
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
404
|
-
* @returns {Promise<
|
|
403
|
+
* @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
|
|
405
404
|
*
|
|
406
405
|
* **Code example**
|
|
407
406
|
*
|
|
@@ -435,8 +434,8 @@ class StatisticsClient {
|
|
|
435
434
|
skip: skip,
|
|
436
435
|
});
|
|
437
436
|
return eventDayDatas.map((eventDayData) => ({
|
|
438
|
-
timestamp:
|
|
439
|
-
totalTransactionAmount:
|
|
437
|
+
timestamp: +eventDayData.timestamp * 1000,
|
|
438
|
+
totalTransactionAmount: BigInt(eventDayData.dailyHMTTransferAmount),
|
|
440
439
|
totalTransactionCount: +eventDayData.dailyHMTTransferCount,
|
|
441
440
|
dailyUniqueSenders: +eventDayData.dailyUniqueSenders,
|
|
442
441
|
dailyUniqueReceivers: +eventDayData.dailyUniqueReceivers,
|
package/dist/transaction.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class TransactionUtils {
|
|
|
11
11
|
* from: string;
|
|
12
12
|
* to: string;
|
|
13
13
|
* timestamp: bigint;
|
|
14
|
-
* value:
|
|
14
|
+
* value: bigint;
|
|
15
15
|
* method: string;
|
|
16
16
|
* receiver?: string;
|
|
17
17
|
* escrow?: string;
|
|
@@ -20,6 +20,18 @@ export declare class TransactionUtils {
|
|
|
20
20
|
* };
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* type InternalTransaction = {
|
|
25
|
+
* from: string;
|
|
26
|
+
* to: string;
|
|
27
|
+
* value: bigint;
|
|
28
|
+
* method: string;
|
|
29
|
+
* receiver?: string;
|
|
30
|
+
* escrow?: string;
|
|
31
|
+
* token?: string;
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
23
35
|
* @param {ChainId} chainId The chain ID.
|
|
24
36
|
* @param {string} hash The transaction hash.
|
|
25
37
|
* @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
|
|
@@ -56,6 +68,18 @@ export declare class TransactionUtils {
|
|
|
56
68
|
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
57
69
|
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
|
|
58
70
|
* }
|
|
71
|
+
*
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* type InternalTransaction = {
|
|
75
|
+
* from: string;
|
|
76
|
+
* to: string;
|
|
77
|
+
* value: bigint;
|
|
78
|
+
* method: string;
|
|
79
|
+
* receiver?: string;
|
|
80
|
+
* escrow?: string;
|
|
81
|
+
* token?: string;
|
|
82
|
+
* };
|
|
59
83
|
* ```
|
|
60
84
|
*
|
|
61
85
|
* ```ts
|
|
@@ -65,7 +89,7 @@ export declare class TransactionUtils {
|
|
|
65
89
|
* from: string;
|
|
66
90
|
* to: string;
|
|
67
91
|
* timestamp: bigint;
|
|
68
|
-
* value:
|
|
92
|
+
* value: bigint;
|
|
69
93
|
* method: string;
|
|
70
94
|
* receiver?: string;
|
|
71
95
|
* escrow?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAWlD,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAoB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuEG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
|
package/dist/transaction.js
CHANGED
|
@@ -23,7 +23,7 @@ class TransactionUtils {
|
|
|
23
23
|
* from: string;
|
|
24
24
|
* to: string;
|
|
25
25
|
* timestamp: bigint;
|
|
26
|
-
* value:
|
|
26
|
+
* value: bigint;
|
|
27
27
|
* method: string;
|
|
28
28
|
* receiver?: string;
|
|
29
29
|
* escrow?: string;
|
|
@@ -32,6 +32,18 @@ class TransactionUtils {
|
|
|
32
32
|
* };
|
|
33
33
|
* ```
|
|
34
34
|
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* type InternalTransaction = {
|
|
37
|
+
* from: string;
|
|
38
|
+
* to: string;
|
|
39
|
+
* value: bigint;
|
|
40
|
+
* method: string;
|
|
41
|
+
* receiver?: string;
|
|
42
|
+
* escrow?: string;
|
|
43
|
+
* token?: string;
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
35
47
|
* @param {ChainId} chainId The chain ID.
|
|
36
48
|
* @param {string} hash The transaction hash.
|
|
37
49
|
* @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
|
|
@@ -55,7 +67,9 @@ class TransactionUtils {
|
|
|
55
67
|
const { transaction } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), transaction_1.GET_TRANSACTION_QUERY, {
|
|
56
68
|
hash: hash.toLowerCase(),
|
|
57
69
|
});
|
|
58
|
-
|
|
70
|
+
if (!transaction)
|
|
71
|
+
return null;
|
|
72
|
+
return mapTransaction(transaction);
|
|
59
73
|
}
|
|
60
74
|
/**
|
|
61
75
|
* This function returns all transaction details based on the provided filter.
|
|
@@ -80,6 +94,18 @@ class TransactionUtils {
|
|
|
80
94
|
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
81
95
|
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
|
|
82
96
|
* }
|
|
97
|
+
*
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* type InternalTransaction = {
|
|
101
|
+
* from: string;
|
|
102
|
+
* to: string;
|
|
103
|
+
* value: bigint;
|
|
104
|
+
* method: string;
|
|
105
|
+
* receiver?: string;
|
|
106
|
+
* escrow?: string;
|
|
107
|
+
* token?: string;
|
|
108
|
+
* };
|
|
83
109
|
* ```
|
|
84
110
|
*
|
|
85
111
|
* ```ts
|
|
@@ -89,7 +115,7 @@ class TransactionUtils {
|
|
|
89
115
|
* from: string;
|
|
90
116
|
* to: string;
|
|
91
117
|
* timestamp: bigint;
|
|
92
|
-
* value:
|
|
118
|
+
* value: bigint;
|
|
93
119
|
* method: string;
|
|
94
120
|
* receiver?: string;
|
|
95
121
|
* escrow?: string;
|
|
@@ -148,7 +174,31 @@ class TransactionUtils {
|
|
|
148
174
|
if (!transactions) {
|
|
149
175
|
return [];
|
|
150
176
|
}
|
|
151
|
-
return transactions;
|
|
177
|
+
return transactions.map((transaction) => mapTransaction(transaction));
|
|
152
178
|
}
|
|
153
179
|
}
|
|
154
180
|
exports.TransactionUtils = TransactionUtils;
|
|
181
|
+
function mapTransaction(t) {
|
|
182
|
+
const internalTransactions = (t.internalTransactions || []).map((itx) => ({
|
|
183
|
+
from: itx.from,
|
|
184
|
+
to: itx.to,
|
|
185
|
+
value: BigInt(itx.value),
|
|
186
|
+
method: itx.method,
|
|
187
|
+
receiver: itx.receiver,
|
|
188
|
+
escrow: itx.escrow,
|
|
189
|
+
token: itx.token,
|
|
190
|
+
}));
|
|
191
|
+
return {
|
|
192
|
+
block: BigInt(t.block),
|
|
193
|
+
txHash: t.txHash,
|
|
194
|
+
from: t.from,
|
|
195
|
+
to: t.to,
|
|
196
|
+
timestamp: Number(t.timestamp) * 1000,
|
|
197
|
+
value: BigInt(t.value),
|
|
198
|
+
method: t.method,
|
|
199
|
+
receiver: t.receiver,
|
|
200
|
+
escrow: t.escrow,
|
|
201
|
+
token: t.token,
|
|
202
|
+
internalTransactions,
|
|
203
|
+
};
|
|
204
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -137,81 +137,6 @@ export type NetworkData = {
|
|
|
137
137
|
*/
|
|
138
138
|
oldFactoryAddress: string;
|
|
139
139
|
};
|
|
140
|
-
/**
|
|
141
|
-
* Represents the response data for an escrow withdrawal.
|
|
142
|
-
*/
|
|
143
|
-
export type EscrowWithdraw = {
|
|
144
|
-
/**
|
|
145
|
-
* The hash of the transaction associated with the escrow withdrawal.
|
|
146
|
-
*/
|
|
147
|
-
txHash: string;
|
|
148
|
-
/**
|
|
149
|
-
* The address of the token used for the withdrawal.
|
|
150
|
-
*/
|
|
151
|
-
tokenAddress: string;
|
|
152
|
-
/**
|
|
153
|
-
* The amount withdrawn from the escrow.
|
|
154
|
-
*/
|
|
155
|
-
withdrawnAmount: bigint;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Represents a payout from an escrow.
|
|
159
|
-
*/
|
|
160
|
-
export type Payout = {
|
|
161
|
-
/**
|
|
162
|
-
* Unique identifier of the payout.
|
|
163
|
-
*/
|
|
164
|
-
id: string;
|
|
165
|
-
/**
|
|
166
|
-
* The address of the escrow associated with the payout.
|
|
167
|
-
*/
|
|
168
|
-
escrowAddress: string;
|
|
169
|
-
/**
|
|
170
|
-
* The address of the recipient who received the payout.
|
|
171
|
-
*/
|
|
172
|
-
recipient: string;
|
|
173
|
-
/**
|
|
174
|
-
* The amount paid to the recipient.
|
|
175
|
-
*/
|
|
176
|
-
amount: bigint;
|
|
177
|
-
/**
|
|
178
|
-
* The timestamp when the payout was created (in UNIX format).
|
|
179
|
-
*/
|
|
180
|
-
createdAt: number;
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Represents a cancellation refund event.
|
|
184
|
-
*/
|
|
185
|
-
export type CancellationRefund = {
|
|
186
|
-
/**
|
|
187
|
-
* Unique identifier of the cancellation refund event.
|
|
188
|
-
*/
|
|
189
|
-
id: string;
|
|
190
|
-
/**
|
|
191
|
-
* The address of the escrow associated with the cancellation refund.
|
|
192
|
-
*/
|
|
193
|
-
escrowAddress: string;
|
|
194
|
-
/**
|
|
195
|
-
* The address of the receiver who received the refund.
|
|
196
|
-
*/
|
|
197
|
-
receiver: string;
|
|
198
|
-
/**
|
|
199
|
-
* The amount refunded to the receiver.
|
|
200
|
-
*/
|
|
201
|
-
amount: bigint;
|
|
202
|
-
/**
|
|
203
|
-
* The block number in which the cancellation refund event occurred.
|
|
204
|
-
*/
|
|
205
|
-
block: number;
|
|
206
|
-
/**
|
|
207
|
-
* The timestamp when the cancellation refund event occurred (in UNIX format).
|
|
208
|
-
*/
|
|
209
|
-
timestamp: number;
|
|
210
|
-
/**
|
|
211
|
-
* The transaction hash of the cancellation refund event.
|
|
212
|
-
*/
|
|
213
|
-
txHash: string;
|
|
214
|
-
};
|
|
215
140
|
export type TransactionLikeWithNonce = TransactionLike & {
|
|
216
141
|
nonce: number;
|
|
217
142
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,IAAI,IAAA;IACJ;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;IACT;;OAEG;IACH,QAAQ,IAAA;CACT;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;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
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,IAAI,IAAA;IACJ;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;IACT;;OAEG;IACH,QAAQ,IAAA;CACT;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;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,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/worker.d.ts
CHANGED
package/dist/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAIlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGvD,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAqB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA+B3E"}
|
package/dist/worker.js
CHANGED
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WorkerUtils = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
7
8
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
8
9
|
const constants_1 = require("./constants");
|
|
9
10
|
const enums_1 = require("./enums");
|
|
10
11
|
const error_1 = require("./error");
|
|
11
12
|
const worker_1 = require("./graphql/queries/worker");
|
|
12
13
|
const utils_1 = require("./utils");
|
|
13
|
-
const ethers_1 = require("ethers");
|
|
14
14
|
class WorkerUtils {
|
|
15
15
|
/**
|
|
16
16
|
* This function returns the worker data for the given address.
|
|
@@ -38,7 +38,9 @@ class WorkerUtils {
|
|
|
38
38
|
const { worker } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), worker_1.GET_WORKER_QUERY, {
|
|
39
39
|
address: address.toLowerCase(),
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
if (!worker)
|
|
42
|
+
return null;
|
|
43
|
+
return mapWorker(worker);
|
|
42
44
|
}
|
|
43
45
|
/**
|
|
44
46
|
* This function returns all worker details based on the provided filter.
|
|
@@ -60,7 +62,7 @@ class WorkerUtils {
|
|
|
60
62
|
* type IWorker = {
|
|
61
63
|
* id: string;
|
|
62
64
|
* address: string;
|
|
63
|
-
* totalHMTAmountReceived:
|
|
65
|
+
* totalHMTAmountReceived: bigint;
|
|
64
66
|
* payoutCount: number;
|
|
65
67
|
* };
|
|
66
68
|
* ```
|
|
@@ -103,7 +105,15 @@ class WorkerUtils {
|
|
|
103
105
|
if (!workers) {
|
|
104
106
|
return [];
|
|
105
107
|
}
|
|
106
|
-
return workers;
|
|
108
|
+
return workers.map((w) => mapWorker(w));
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
exports.WorkerUtils = WorkerUtils;
|
|
112
|
+
function mapWorker(w) {
|
|
113
|
+
return {
|
|
114
|
+
id: w.id,
|
|
115
|
+
address: w.address,
|
|
116
|
+
totalHMTAmountReceived: BigInt(w.totalHMTAmountReceived || 0),
|
|
117
|
+
payoutCount: Number(w.payoutCount || 0),
|
|
118
|
+
};
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "5.0.0
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@human-protocol/core": "5.0.0
|
|
41
|
+
"@human-protocol/core": "5.0.0",
|
|
42
42
|
"axios": "^1.4.0",
|
|
43
43
|
"ethers": "~6.15.0",
|
|
44
44
|
"graphql": "^16.8.1",
|
package/src/constants.ts
CHANGED
|
@@ -39,7 +39,7 @@ export const NETWORKS: {
|
|
|
39
39
|
subgraphUrl:
|
|
40
40
|
'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
|
|
41
41
|
subgraphUrlApiKey:
|
|
42
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
42
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmXGmcjEtwwEgB83KE2ECjjYY38kLMqzaq4ip8GWY7A6zz',
|
|
43
43
|
oldSubgraphUrl: '',
|
|
44
44
|
oldFactoryAddress: '',
|
|
45
45
|
},
|
|
@@ -54,7 +54,7 @@ export const NETWORKS: {
|
|
|
54
54
|
subgraphUrl:
|
|
55
55
|
'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
|
|
56
56
|
subgraphUrlApiKey:
|
|
57
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
57
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmT4xNvZh8ymarrk1zdytjLhCW59iuTavsd4JgHS4LbCVB',
|
|
58
58
|
oldSubgraphUrl: '',
|
|
59
59
|
oldFactoryAddress: '',
|
|
60
60
|
},
|
|
@@ -69,7 +69,7 @@ export const NETWORKS: {
|
|
|
69
69
|
subgraphUrl:
|
|
70
70
|
'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
|
|
71
71
|
subgraphUrlApiKey:
|
|
72
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
72
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmdVdpm9NnFz5B8QyzhW1bW1nNfRWemTiFn2MrhYZGTSQD',
|
|
73
73
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
|
|
74
74
|
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
|
|
75
75
|
},
|
|
@@ -84,7 +84,7 @@ export const NETWORKS: {
|
|
|
84
84
|
subgraphUrl:
|
|
85
85
|
'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
|
|
86
86
|
subgraphUrlApiKey:
|
|
87
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
87
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZjYMktZe8RAz7W7qL33VZBV6AC57xsLyE1cEfv6NABdZ',
|
|
88
88
|
oldSubgraphUrl:
|
|
89
89
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
|
|
90
90
|
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
|
|
@@ -100,7 +100,7 @@ export const NETWORKS: {
|
|
|
100
100
|
subgraphUrl:
|
|
101
101
|
'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
|
|
102
102
|
subgraphUrlApiKey:
|
|
103
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
103
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmUt9mmfNjtC5ZnQNiWHRbFG3k5zfngMuoTyky9jhXYqG2',
|
|
104
104
|
oldSubgraphUrl:
|
|
105
105
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
|
|
106
106
|
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
|
|
@@ -116,7 +116,7 @@ export const NETWORKS: {
|
|
|
116
116
|
subgraphUrl:
|
|
117
117
|
'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
|
|
118
118
|
subgraphUrlApiKey:
|
|
119
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
119
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmWRUFWpWoRRUh7Ec1HUJEwxc84DkP4iFTfLLsoVngJAPa',
|
|
120
120
|
oldSubgraphUrl: '',
|
|
121
121
|
oldFactoryAddress: '',
|
|
122
122
|
},
|