@human-protocol/sdk 4.0.3 → 4.1.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.js +6 -6
- package/dist/escrow.d.ts +47 -27
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +73 -31
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/hmtoken.d.ts.map +1 -1
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/payout.d.ts +1 -1
- package/dist/graphql/queries/payout.d.ts.map +1 -1
- package/dist/graphql/queries/payout.js +6 -5
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +1 -1
- package/dist/graphql/queries/transaction.d.ts.map +1 -1
- package/dist/graphql/queries/transaction.js +7 -1
- package/dist/graphql/queries/worker.d.ts +4 -0
- package/dist/graphql/queries/worker.d.ts.map +1 -0
- package/dist/graphql/queries/worker.js +44 -0
- package/dist/graphql/types.d.ts +1 -8
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +44 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/statistics.js +2 -2
- package/dist/transaction.d.ts +25 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +28 -2
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/worker.d.ts +63 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +109 -0
- package/package.json +13 -9
- package/src/constants.ts +6 -6
- package/src/escrow.ts +103 -45
- package/src/graphql/queries/payout.ts +7 -6
- package/src/graphql/queries/statistics.ts +1 -1
- package/src/graphql/queries/transaction.ts +17 -2
- package/src/graphql/queries/worker.ts +41 -0
- package/src/graphql/types.ts +1 -9
- package/src/index.ts +2 -0
- package/src/interfaces.ts +48 -1
- package/src/statistics.ts +2 -2
- package/src/transaction.ts +28 -2
- package/src/types.ts +26 -0
- package/src/utils.ts +2 -1
- package/src/worker.ts +120 -0
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
17
|
+
exports.WorkerUtils = exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
18
18
|
const staking_1 = require("./staking");
|
|
19
19
|
Object.defineProperty(exports, "StakingClient", { enumerable: true, get: function () { return staking_1.StakingClient; } });
|
|
20
20
|
const storage_1 = require("./storage");
|
|
@@ -34,6 +34,8 @@ const operator_1 = require("./operator");
|
|
|
34
34
|
Object.defineProperty(exports, "OperatorUtils", { enumerable: true, get: function () { return operator_1.OperatorUtils; } });
|
|
35
35
|
const transaction_1 = require("./transaction");
|
|
36
36
|
Object.defineProperty(exports, "TransactionUtils", { enumerable: true, get: function () { return transaction_1.TransactionUtils; } });
|
|
37
|
+
const worker_1 = require("./worker");
|
|
38
|
+
Object.defineProperty(exports, "WorkerUtils", { enumerable: true, get: function () { return worker_1.WorkerUtils; } });
|
|
37
39
|
__exportStar(require("./constants"), exports);
|
|
38
40
|
__exportStar(require("./types"), exports);
|
|
39
41
|
__exportStar(require("./enums"), exports);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -56,6 +56,27 @@ export interface IOperator {
|
|
|
56
56
|
registrationNeeded?: boolean;
|
|
57
57
|
registrationInstructions?: string;
|
|
58
58
|
}
|
|
59
|
+
export interface IEscrow {
|
|
60
|
+
id: string;
|
|
61
|
+
address: string;
|
|
62
|
+
amountPaid: string;
|
|
63
|
+
balance: string;
|
|
64
|
+
count: string;
|
|
65
|
+
factoryAddress: string;
|
|
66
|
+
finalResultsUrl?: string;
|
|
67
|
+
intermediateResultsUrl?: string;
|
|
68
|
+
launcher: string;
|
|
69
|
+
manifestHash?: string;
|
|
70
|
+
manifestUrl?: string;
|
|
71
|
+
recordingOracle?: string;
|
|
72
|
+
reputationOracle?: string;
|
|
73
|
+
exchangeOracle?: string;
|
|
74
|
+
status: string;
|
|
75
|
+
token: string;
|
|
76
|
+
totalFundedAmount: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
chainId: number;
|
|
79
|
+
}
|
|
59
80
|
export interface IEscrowsFilter extends IPagination {
|
|
60
81
|
launcher?: string;
|
|
61
82
|
reputationOracle?: string;
|
|
@@ -90,7 +111,8 @@ export interface IStatisticsFilter extends IPagination {
|
|
|
90
111
|
export interface IHMTHoldersParams extends IPagination {
|
|
91
112
|
address?: string;
|
|
92
113
|
}
|
|
93
|
-
export interface IPayoutFilter {
|
|
114
|
+
export interface IPayoutFilter extends IPagination {
|
|
115
|
+
chainId: ChainId;
|
|
94
116
|
escrowAddress?: string;
|
|
95
117
|
recipient?: string;
|
|
96
118
|
from?: Date;
|
|
@@ -130,6 +152,9 @@ export interface ITransactionsFilter extends IPagination {
|
|
|
130
152
|
endDate?: Date;
|
|
131
153
|
fromAddress?: string;
|
|
132
154
|
toAddress?: string;
|
|
155
|
+
method?: string;
|
|
156
|
+
escrow?: string;
|
|
157
|
+
token?: string;
|
|
133
158
|
}
|
|
134
159
|
export interface IPagination {
|
|
135
160
|
first?: number;
|
|
@@ -142,4 +167,22 @@ export interface StakerInfo {
|
|
|
142
167
|
lockedUntil: bigint;
|
|
143
168
|
withdrawableAmount: bigint;
|
|
144
169
|
}
|
|
170
|
+
export interface IStatusEventFilter extends IPagination {
|
|
171
|
+
chainId: ChainId;
|
|
172
|
+
statuses?: EscrowStatus[];
|
|
173
|
+
from?: Date;
|
|
174
|
+
to?: Date;
|
|
175
|
+
launcher?: string;
|
|
176
|
+
}
|
|
177
|
+
export interface IWorker {
|
|
178
|
+
id: string;
|
|
179
|
+
address: string;
|
|
180
|
+
totalHMTAmountReceived: number;
|
|
181
|
+
payoutCount: number;
|
|
182
|
+
}
|
|
183
|
+
export interface IWorkersFilter extends IPagination {
|
|
184
|
+
chainId: ChainId;
|
|
185
|
+
address?: string;
|
|
186
|
+
orderBy?: string;
|
|
187
|
+
}
|
|
145
188
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,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C;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/statistics.js
CHANGED
|
@@ -278,11 +278,11 @@ class StatisticsClient {
|
|
|
278
278
|
return {
|
|
279
279
|
dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
|
|
280
280
|
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
281
|
-
totalAmountPaid: ethers_1.ethers.toBigInt(eventDayData.
|
|
281
|
+
totalAmountPaid: ethers_1.ethers.toBigInt(eventDayData.dailyHMTPayoutAmount),
|
|
282
282
|
totalCount: +eventDayData.dailyPayoutCount,
|
|
283
283
|
averageAmountPerWorker: eventDayData.dailyWorkerCount === '0'
|
|
284
284
|
? ethers_1.ethers.toBigInt(0)
|
|
285
|
-
: ethers_1.ethers.toBigInt(eventDayData.
|
|
285
|
+
: ethers_1.ethers.toBigInt(eventDayData.dailyHMTPayoutAmount) /
|
|
286
286
|
ethers_1.ethers.toBigInt(eventDayData.dailyWorkerCount),
|
|
287
287
|
})),
|
|
288
288
|
};
|
package/dist/transaction.d.ts
CHANGED
|
@@ -4,6 +4,22 @@ export declare class TransactionUtils {
|
|
|
4
4
|
/**
|
|
5
5
|
* This function returns the transaction data for the given hash.
|
|
6
6
|
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* type ITransaction = {
|
|
9
|
+
* block: bigint;
|
|
10
|
+
* txHash: string;
|
|
11
|
+
* from: string;
|
|
12
|
+
* to: string;
|
|
13
|
+
* timestamp: bigint;
|
|
14
|
+
* value: string;
|
|
15
|
+
* method: string;
|
|
16
|
+
* receiver?: string;
|
|
17
|
+
* escrow?: string;
|
|
18
|
+
* token?: string;
|
|
19
|
+
* internalTransactions: InternalTransaction[];
|
|
20
|
+
* };
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
7
23
|
* @param {ChainId} chainId The chain ID.
|
|
8
24
|
* @param {string} hash The transaction hash.
|
|
9
25
|
* @returns {Promise<ITransaction>} Returns the transaction details.
|
|
@@ -29,6 +45,9 @@ export declare class TransactionUtils {
|
|
|
29
45
|
* chainId: ChainId; // List of chain IDs to query.
|
|
30
46
|
* fromAddress?: string; // (Optional) The address from which transactions are sent.
|
|
31
47
|
* toAddress?: string; // (Optional) The address to which transactions are sent.
|
|
48
|
+
* method?: string; // (Optional) The method of the transaction to filter by.
|
|
49
|
+
* escrow?: string; // (Optional) The escrow address to filter transactions.
|
|
50
|
+
* token?: string; // (Optional) The token address to filter transactions.
|
|
32
51
|
* startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
|
|
33
52
|
* endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
|
|
34
53
|
* startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
|
|
@@ -41,13 +60,17 @@ export declare class TransactionUtils {
|
|
|
41
60
|
*
|
|
42
61
|
* ```ts
|
|
43
62
|
* type ITransaction = {
|
|
44
|
-
* block:
|
|
63
|
+
* block: bigint;
|
|
45
64
|
* txHash: string;
|
|
46
65
|
* from: string;
|
|
47
66
|
* to: string;
|
|
48
|
-
* timestamp:
|
|
67
|
+
* timestamp: bigint;
|
|
49
68
|
* value: string;
|
|
50
69
|
* method: string;
|
|
70
|
+
* receiver?: string;
|
|
71
|
+
* escrow?: string;
|
|
72
|
+
* token?: string;
|
|
73
|
+
* internalTransactions: InternalTransaction[];
|
|
51
74
|
* };
|
|
52
75
|
* ```
|
|
53
76
|
*
|
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
|
package/dist/transaction.js
CHANGED
|
@@ -16,6 +16,22 @@ class TransactionUtils {
|
|
|
16
16
|
/**
|
|
17
17
|
* This function returns the transaction data for the given hash.
|
|
18
18
|
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* type ITransaction = {
|
|
21
|
+
* block: bigint;
|
|
22
|
+
* txHash: string;
|
|
23
|
+
* from: string;
|
|
24
|
+
* to: string;
|
|
25
|
+
* timestamp: bigint;
|
|
26
|
+
* value: string;
|
|
27
|
+
* method: string;
|
|
28
|
+
* receiver?: string;
|
|
29
|
+
* escrow?: string;
|
|
30
|
+
* token?: string;
|
|
31
|
+
* internalTransactions: InternalTransaction[];
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
19
35
|
* @param {ChainId} chainId The chain ID.
|
|
20
36
|
* @param {string} hash The transaction hash.
|
|
21
37
|
* @returns {Promise<ITransaction>} Returns the transaction details.
|
|
@@ -53,6 +69,9 @@ class TransactionUtils {
|
|
|
53
69
|
* chainId: ChainId; // List of chain IDs to query.
|
|
54
70
|
* fromAddress?: string; // (Optional) The address from which transactions are sent.
|
|
55
71
|
* toAddress?: string; // (Optional) The address to which transactions are sent.
|
|
72
|
+
* method?: string; // (Optional) The method of the transaction to filter by.
|
|
73
|
+
* escrow?: string; // (Optional) The escrow address to filter transactions.
|
|
74
|
+
* token?: string; // (Optional) The token address to filter transactions.
|
|
56
75
|
* startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
|
|
57
76
|
* endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
|
|
58
77
|
* startBlock?: number; // (Optional) The start block number to filter transactions (inclusive).
|
|
@@ -65,13 +84,17 @@ class TransactionUtils {
|
|
|
65
84
|
*
|
|
66
85
|
* ```ts
|
|
67
86
|
* type ITransaction = {
|
|
68
|
-
* block:
|
|
87
|
+
* block: bigint;
|
|
69
88
|
* txHash: string;
|
|
70
89
|
* from: string;
|
|
71
90
|
* to: string;
|
|
72
|
-
* timestamp:
|
|
91
|
+
* timestamp: bigint;
|
|
73
92
|
* value: string;
|
|
74
93
|
* method: string;
|
|
94
|
+
* receiver?: string;
|
|
95
|
+
* escrow?: string;
|
|
96
|
+
* token?: string;
|
|
97
|
+
* internalTransactions: InternalTransaction[];
|
|
75
98
|
* };
|
|
76
99
|
* ```
|
|
77
100
|
*
|
|
@@ -115,6 +138,9 @@ class TransactionUtils {
|
|
|
115
138
|
endDate: filter.endDate ? (0, utils_1.getUnixTimestamp)(filter.endDate) : undefined,
|
|
116
139
|
startBlock: filter.startBlock ? filter.startBlock : undefined,
|
|
117
140
|
endBlock: filter.endBlock ? filter.endBlock : undefined,
|
|
141
|
+
method: filter.method ? filter.method : undefined,
|
|
142
|
+
escrow: filter.escrow ? filter.escrow : undefined,
|
|
143
|
+
token: filter.token ? filter.token : undefined,
|
|
118
144
|
orderDirection: orderDirection,
|
|
119
145
|
first: first,
|
|
120
146
|
skip: skip,
|
package/dist/types.d.ts
CHANGED
|
@@ -163,6 +163,31 @@ export type EscrowWithdraw = {
|
|
|
163
163
|
*/
|
|
164
164
|
amountWithdrawn: bigint;
|
|
165
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* Represents a payout from an escrow.
|
|
168
|
+
*/
|
|
169
|
+
export type Payout = {
|
|
170
|
+
/**
|
|
171
|
+
* Unique identifier of the payout.
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
/**
|
|
175
|
+
* The address of the escrow associated with the payout.
|
|
176
|
+
*/
|
|
177
|
+
escrowAddress: string;
|
|
178
|
+
/**
|
|
179
|
+
* The address of the recipient who received the payout.
|
|
180
|
+
*/
|
|
181
|
+
recipient: string;
|
|
182
|
+
/**
|
|
183
|
+
* The amount paid to the recipient.
|
|
184
|
+
*/
|
|
185
|
+
amount: bigint;
|
|
186
|
+
/**
|
|
187
|
+
* The timestamp when the payout was created (in UNIX format).
|
|
188
|
+
*/
|
|
189
|
+
createdAt: number;
|
|
190
|
+
};
|
|
166
191
|
export type TransactionLikeWithNonce = TransactionLike & {
|
|
167
192
|
nonce: number;
|
|
168
193
|
};
|
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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AM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,GAAG,UAgBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,YAOrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,WAAW,WAatD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,KAAG,MAE7C,CAAC"}
|
package/dist/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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
|
+
const enums_1 = require("./enums");
|
|
6
7
|
const error_1 = require("./error");
|
|
7
8
|
const constants_1 = require("./constants");
|
|
8
9
|
/**
|
|
@@ -62,7 +63,7 @@ const getSubgraphUrl = (networkData) => {
|
|
|
62
63
|
if (process.env.SUBGRAPH_API_KEY) {
|
|
63
64
|
subgraphUrl = networkData.subgraphUrlApiKey.replace(constants_1.SUBGRAPH_API_KEY_PLACEHOLDER, process.env.SUBGRAPH_API_KEY);
|
|
64
65
|
}
|
|
65
|
-
else {
|
|
66
|
+
else if (networkData.chainId !== enums_1.ChainId.LOCALHOST) {
|
|
66
67
|
// eslint-disable-next-line no-console
|
|
67
68
|
console.warn(error_1.WarnSubgraphApiKeyNotProvided);
|
|
68
69
|
}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ChainId } from './enums';
|
|
2
|
+
import { IWorker, IWorkersFilter } from './interfaces';
|
|
3
|
+
export declare class WorkerUtils {
|
|
4
|
+
/**
|
|
5
|
+
* This function returns the worker data for the given address.
|
|
6
|
+
*
|
|
7
|
+
* @param {ChainId} chainId The chain ID.
|
|
8
|
+
* @param {string} address The worker address.
|
|
9
|
+
* @returns {Promise<IWorker>} Returns the worker details.
|
|
10
|
+
*
|
|
11
|
+
* **Code example**
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { WorkerUtils, ChainId } from '@human-protocol/sdk';
|
|
15
|
+
*
|
|
16
|
+
* const worker = await WorkerUtils.getWorker(ChainId.POLYGON, '0x1234567890abcdef1234567890abcdef12345678');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
static getWorker(chainId: ChainId, address: string): Promise<IWorker | null>;
|
|
20
|
+
/**
|
|
21
|
+
* This function returns all worker details based on the provided filter.
|
|
22
|
+
*
|
|
23
|
+
* **Input parameters**
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* interface IWorkersFilter {
|
|
27
|
+
* chainId: ChainId; // List of chain IDs to query.
|
|
28
|
+
* address?: string; // (Optional) The worker address to filter by.
|
|
29
|
+
* orderBy?: string; // (Optional) The field to order by. Default is 'payoutCount'.
|
|
30
|
+
* orderDirection?: OrderDirection; // (Optional) The direction of the order. Default is 'DESC'.
|
|
31
|
+
* first?: number; // (Optional) Number of workers per page. Default is 10.
|
|
32
|
+
* skip?: number; // (Optional) Number of workers to skip. Default is 0.
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* type IWorker = {
|
|
38
|
+
* id: string;
|
|
39
|
+
* address: string;
|
|
40
|
+
* totalHMTAmountReceived: string;
|
|
41
|
+
* payoutCount: number;
|
|
42
|
+
* };
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param {IWorkersFilter} filter Filter for the workers.
|
|
46
|
+
* @returns {Promise<IWorker[]>} Returns an array with all the worker details.
|
|
47
|
+
*
|
|
48
|
+
* **Code example**
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { WorkerUtils, ChainId } from '@human-protocol/sdk';
|
|
52
|
+
*
|
|
53
|
+
* const filter: IWorkersFilter = {
|
|
54
|
+
* chainId: ChainId.POLYGON,
|
|
55
|
+
* first: 10,
|
|
56
|
+
* skip: 0,
|
|
57
|
+
* };
|
|
58
|
+
* const workers = await WorkerUtils.getWorkers(filter);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static getWorkers(filter: IWorkersFilter): Promise<IWorker[]>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIvD,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAmB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA+B3E"}
|
package/dist/worker.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WorkerUtils = void 0;
|
|
7
|
+
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const enums_1 = require("./enums");
|
|
10
|
+
const error_1 = require("./error");
|
|
11
|
+
const worker_1 = require("./graphql/queries/worker");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const ethers_1 = require("ethers");
|
|
14
|
+
class WorkerUtils {
|
|
15
|
+
/**
|
|
16
|
+
* This function returns the worker data for the given address.
|
|
17
|
+
*
|
|
18
|
+
* @param {ChainId} chainId The chain ID.
|
|
19
|
+
* @param {string} address The worker address.
|
|
20
|
+
* @returns {Promise<IWorker>} Returns the worker details.
|
|
21
|
+
*
|
|
22
|
+
* **Code example**
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { WorkerUtils, ChainId } from '@human-protocol/sdk';
|
|
26
|
+
*
|
|
27
|
+
* const worker = await WorkerUtils.getWorker(ChainId.POLYGON, '0x1234567890abcdef1234567890abcdef12345678');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
static async getWorker(chainId, address) {
|
|
31
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
32
|
+
if (!networkData) {
|
|
33
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
34
|
+
}
|
|
35
|
+
if (!ethers_1.ethers.isAddress(address)) {
|
|
36
|
+
throw error_1.ErrorInvalidAddress;
|
|
37
|
+
}
|
|
38
|
+
const { worker } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), worker_1.GET_WORKER_QUERY, {
|
|
39
|
+
address: address.toLowerCase(),
|
|
40
|
+
});
|
|
41
|
+
return worker || null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This function returns all worker details based on the provided filter.
|
|
45
|
+
*
|
|
46
|
+
* **Input parameters**
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* interface IWorkersFilter {
|
|
50
|
+
* chainId: ChainId; // List of chain IDs to query.
|
|
51
|
+
* address?: string; // (Optional) The worker address to filter by.
|
|
52
|
+
* orderBy?: string; // (Optional) The field to order by. Default is 'payoutCount'.
|
|
53
|
+
* orderDirection?: OrderDirection; // (Optional) The direction of the order. Default is 'DESC'.
|
|
54
|
+
* first?: number; // (Optional) Number of workers per page. Default is 10.
|
|
55
|
+
* skip?: number; // (Optional) Number of workers to skip. Default is 0.
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* type IWorker = {
|
|
61
|
+
* id: string;
|
|
62
|
+
* address: string;
|
|
63
|
+
* totalHMTAmountReceived: string;
|
|
64
|
+
* payoutCount: number;
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param {IWorkersFilter} filter Filter for the workers.
|
|
69
|
+
* @returns {Promise<IWorker[]>} Returns an array with all the worker details.
|
|
70
|
+
*
|
|
71
|
+
* **Code example**
|
|
72
|
+
*
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { WorkerUtils, ChainId } from '@human-protocol/sdk';
|
|
75
|
+
*
|
|
76
|
+
* const filter: IWorkersFilter = {
|
|
77
|
+
* chainId: ChainId.POLYGON,
|
|
78
|
+
* first: 10,
|
|
79
|
+
* skip: 0,
|
|
80
|
+
* };
|
|
81
|
+
* const workers = await WorkerUtils.getWorkers(filter);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
static async getWorkers(filter) {
|
|
85
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
86
|
+
const skip = filter.skip || 0;
|
|
87
|
+
const orderBy = filter.orderBy || 'payoutCount';
|
|
88
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
89
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
90
|
+
if (!networkData) {
|
|
91
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
92
|
+
}
|
|
93
|
+
if (filter.address && !ethers_1.ethers.isAddress(filter.address)) {
|
|
94
|
+
throw error_1.ErrorInvalidAddress;
|
|
95
|
+
}
|
|
96
|
+
const { workers } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, worker_1.GET_WORKERS_QUERY)(filter), {
|
|
97
|
+
address: filter?.address?.toLowerCase(),
|
|
98
|
+
first: first,
|
|
99
|
+
skip: skip,
|
|
100
|
+
orderBy: orderBy,
|
|
101
|
+
orderDirection: orderDirection,
|
|
102
|
+
});
|
|
103
|
+
if (!workers) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
return workers;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.WorkerUtils = WorkerUtils;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist"
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"types": "dist/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"clean": "rm -rf ./dist",
|
|
12
|
+
"clean": "tsc --build --clean && rm -rf ./dist",
|
|
13
13
|
"clean:doc": "rm -rf ../../../../docs/sdk/typescript/",
|
|
14
|
-
"
|
|
15
|
-
"build": "yarn clean &&
|
|
16
|
-
"build:doc": "yarn clean:doc && npx typedoc --plugin typedoc-plugin-markdown --out ../../../../docs/sdk/typescript/",
|
|
14
|
+
"build": "tsc --build",
|
|
15
|
+
"build:doc": "yarn clean:doc && typedoc --plugin typedoc-plugin-markdown --out ../../../../docs/sdk/typescript/",
|
|
17
16
|
"prepublish": "yarn build",
|
|
18
17
|
"test": "vitest -u",
|
|
19
18
|
"lint": "eslint .",
|
|
@@ -39,19 +38,24 @@
|
|
|
39
38
|
]
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@human-protocol/core": "
|
|
41
|
+
"@human-protocol/core": "x",
|
|
43
42
|
"axios": "^1.4.0",
|
|
43
|
+
"ethers": "~6.13.5",
|
|
44
44
|
"graphql": "^16.8.1",
|
|
45
45
|
"graphql-request": "^6.1.0",
|
|
46
46
|
"graphql-tag": "^2.12.6",
|
|
47
47
|
"minio": "7.1.3",
|
|
48
48
|
"openpgp": "^5.11.2",
|
|
49
49
|
"secp256k1": "^5.0.1",
|
|
50
|
-
"vitest": "^
|
|
50
|
+
"vitest": "^3.0.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
53
|
+
"eslint": "^8.55.0",
|
|
54
|
+
"prettier": "^3.4.2",
|
|
55
|
+
"ts-node": "^10.9.2",
|
|
56
|
+
"typedoc": "^0.28.4",
|
|
57
|
+
"typedoc-plugin-markdown": "^4.2.3",
|
|
58
|
+
"typescript": "^5.8.3"
|
|
55
59
|
},
|
|
56
60
|
"typedocOptions": {
|
|
57
61
|
"entryPoints": [
|
package/src/constants.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const NETWORKS: {
|
|
|
36
36
|
subgraphUrl:
|
|
37
37
|
'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
|
|
38
38
|
subgraphUrlApiKey:
|
|
39
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
39
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZEF1exsjDwjDXy1kmN3MbdZKxfkkoTj2MbEPUyhLfEG3',
|
|
40
40
|
oldSubgraphUrl: '',
|
|
41
41
|
oldFactoryAddress: '',
|
|
42
42
|
},
|
|
@@ -51,7 +51,7 @@ export const NETWORKS: {
|
|
|
51
51
|
subgraphUrl:
|
|
52
52
|
'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
|
|
53
53
|
subgraphUrlApiKey:
|
|
54
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
54
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmeHhtntEYGdgTqHQTJu5mUXHS8JPt3RiwidLYeeEu6VpP',
|
|
55
55
|
oldSubgraphUrl: '',
|
|
56
56
|
oldFactoryAddress: '',
|
|
57
57
|
},
|
|
@@ -66,7 +66,7 @@ export const NETWORKS: {
|
|
|
66
66
|
subgraphUrl:
|
|
67
67
|
'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
|
|
68
68
|
subgraphUrlApiKey:
|
|
69
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
69
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmWsXVhdFuZZcXDjXrv1QLSBYcjNShazFQmNUdpAErjQqD',
|
|
70
70
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
|
|
71
71
|
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
|
|
72
72
|
},
|
|
@@ -81,7 +81,7 @@ export const NETWORKS: {
|
|
|
81
81
|
subgraphUrl:
|
|
82
82
|
'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
|
|
83
83
|
subgraphUrlApiKey:
|
|
84
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
84
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmPv7asd21BA5LZJxjDPfoL5ZJkEGMvahrdMqgNQnP5sxn',
|
|
85
85
|
oldSubgraphUrl:
|
|
86
86
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
|
|
87
87
|
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
|
|
@@ -97,7 +97,7 @@ export const NETWORKS: {
|
|
|
97
97
|
subgraphUrl:
|
|
98
98
|
'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
|
|
99
99
|
subgraphUrlApiKey:
|
|
100
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
100
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmZSsJn5TERyEfRrrbY926hLHD321ijoMynrxWxc3boRa6',
|
|
101
101
|
oldSubgraphUrl:
|
|
102
102
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
|
|
103
103
|
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
|
|
@@ -113,7 +113,7 @@ export const NETWORKS: {
|
|
|
113
113
|
subgraphUrl:
|
|
114
114
|
'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
|
|
115
115
|
subgraphUrlApiKey:
|
|
116
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
116
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYWc4ciJbAvTvcjoBzRSTWZrf1xD8WPRqEk3xtJZUKZqY',
|
|
117
117
|
oldSubgraphUrl: '',
|
|
118
118
|
oldFactoryAddress: '',
|
|
119
119
|
},
|