@human-protocol/sdk 5.0.0 → 5.1.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/base.d.ts +1 -10
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +0 -21
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -16
- package/dist/enums.d.ts +0 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +0 -1
- package/dist/error.d.ts +4 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +5 -1
- package/dist/escrow.d.ts +14 -17
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +34 -33
- package/dist/interfaces.d.ts +9 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +9 -5
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +9 -5
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +16 -16
- package/dist/staking.d.ts +6 -3
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -14
- package/dist/statistics.d.ts +13 -7
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +24 -22
- package/dist/transaction.d.ts +5 -3
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +8 -10
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +51 -1
- package/dist/worker.d.ts +5 -3
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +8 -10
- package/package.json +2 -1
- package/src/base.ts +1 -23
- package/src/constants.ts +0 -18
- package/src/enums.ts +0 -1
- package/src/error.ts +7 -0
- package/src/escrow.ts +69 -64
- package/src/interfaces.ts +10 -0
- package/src/kvstore.ts +26 -24
- package/src/operator.ts +54 -26
- package/src/staking.ts +27 -26
- package/src/statistics.ts +87 -47
- package/src/transaction.ts +39 -25
- package/src/utils.ts +64 -0
- package/src/worker.ts +32 -17
package/dist/interfaces.d.ts
CHANGED
|
@@ -272,4 +272,13 @@ export interface IEscrowWithdraw {
|
|
|
272
272
|
tokenAddress: string;
|
|
273
273
|
withdrawnAmount: bigint;
|
|
274
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Configuration options for subgraph requests with retry logic.
|
|
277
|
+
*/
|
|
278
|
+
export interface SubgraphOptions {
|
|
279
|
+
/** Maximum number of retry attempts */
|
|
280
|
+
maxRetries?: number;
|
|
281
|
+
/** Base delay between retries in milliseconds */
|
|
282
|
+
baseDelay?: number;
|
|
283
|
+
}
|
|
275
284
|
//# 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,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAA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zB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/kvstore.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ContractRunner, Overrides } from 'ethers';
|
|
|
2
2
|
import { BaseEthersClient } from './base';
|
|
3
3
|
import { ChainId } from './enums';
|
|
4
4
|
import { NetworkData } from './types';
|
|
5
|
-
import { IKVStore } from './interfaces';
|
|
5
|
+
import { IKVStore, SubgraphOptions } from './interfaces';
|
|
6
6
|
/**
|
|
7
7
|
* ## Introduction
|
|
8
8
|
*
|
|
@@ -181,6 +181,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
181
181
|
*
|
|
182
182
|
* @param {string} address Address from which to get the key value.
|
|
183
183
|
* @param {string} key Key to obtain the value.
|
|
184
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
184
185
|
* @returns {string} Value of the key.
|
|
185
186
|
*
|
|
186
187
|
*
|
|
@@ -240,6 +241,7 @@ export declare class KVStoreUtils {
|
|
|
240
241
|
*
|
|
241
242
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
242
243
|
* @param {string} address Address of the KVStore
|
|
244
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
243
245
|
* @returns {Promise<IKVStore[]>} KVStore data
|
|
244
246
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
245
247
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -253,13 +255,14 @@ export declare class KVStoreUtils {
|
|
|
253
255
|
* console.log(kvStoreData);
|
|
254
256
|
* ```
|
|
255
257
|
*/
|
|
256
|
-
static getKVStoreData(chainId: ChainId, address: string): Promise<IKVStore[]>;
|
|
258
|
+
static getKVStoreData(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IKVStore[]>;
|
|
257
259
|
/**
|
|
258
260
|
* Gets the value of a key-value pair in the KVStore using the subgraph.
|
|
259
261
|
*
|
|
260
262
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
261
263
|
* @param {string} address Address from which to get the key value.
|
|
262
264
|
* @param {string} key Key to obtain the value.
|
|
265
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
263
266
|
* @returns {Promise<string>} Value of the key.
|
|
264
267
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
265
268
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -278,13 +281,14 @@ export declare class KVStoreUtils {
|
|
|
278
281
|
* console.log(value);
|
|
279
282
|
* ```
|
|
280
283
|
*/
|
|
281
|
-
static get(chainId: ChainId, address: string, key: string): Promise<string>;
|
|
284
|
+
static get(chainId: ChainId, address: string, key: string, options?: SubgraphOptions): Promise<string>;
|
|
282
285
|
/**
|
|
283
286
|
* Gets the URL value of the given entity, and verifies its hash.
|
|
284
287
|
*
|
|
285
288
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
286
289
|
* @param {string} address Address from which to get the URL value.
|
|
287
290
|
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
291
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
288
292
|
* @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
|
|
289
293
|
*
|
|
290
294
|
* **Code example**
|
|
@@ -299,7 +303,7 @@ export declare class KVStoreUtils {
|
|
|
299
303
|
* console.log(url);
|
|
300
304
|
* ```
|
|
301
305
|
*/
|
|
302
|
-
static getFileUrlAndVerifyHash(chainId: ChainId, address: string, urlKey?: string): Promise<string>;
|
|
306
|
+
static getFileUrlAndVerifyHash(chainId: ChainId, address: string, urlKey?: string, options?: SubgraphOptions): Promise<string>;
|
|
303
307
|
/**
|
|
304
308
|
* Gets the public key of the given entity, and verifies its hash.
|
|
305
309
|
*
|
|
@@ -319,6 +323,6 @@ export declare class KVStoreUtils {
|
|
|
319
323
|
* console.log(publicKey);
|
|
320
324
|
* ```
|
|
321
325
|
*/
|
|
322
|
-
static getPublicKey(chainId: ChainId, address: string): Promise<string>;
|
|
326
|
+
static getPublicKey(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<string>;
|
|
323
327
|
}
|
|
324
328
|
//# sourceMappingURL=kvstore.d.ts.map
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAWlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAS5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;;;;;;;;;;;;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CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;CAgBnB"}
|
package/dist/kvstore.js
CHANGED
|
@@ -8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.KVStoreUtils = exports.KVStoreClient = void 0;
|
|
16
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
@@ -19,7 +16,6 @@ const base_1 = require("./base");
|
|
|
19
16
|
const constants_1 = require("./constants");
|
|
20
17
|
const decorators_1 = require("./decorators");
|
|
21
18
|
const error_1 = require("./error");
|
|
22
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
23
19
|
const utils_1 = require("./utils");
|
|
24
20
|
const kvstore_1 = require("./graphql/queries/kvstore");
|
|
25
21
|
/**
|
|
@@ -154,7 +150,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
154
150
|
if (key === '')
|
|
155
151
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
156
152
|
try {
|
|
157
|
-
await (await this.contract.set(key, value,
|
|
153
|
+
await (await this.contract.set(key, value, txOptions)).wait();
|
|
158
154
|
}
|
|
159
155
|
catch (e) {
|
|
160
156
|
if (e instanceof Error)
|
|
@@ -196,7 +192,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
196
192
|
if (keys.includes(''))
|
|
197
193
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
198
194
|
try {
|
|
199
|
-
await (await this.contract.setBulk(keys, values,
|
|
195
|
+
await (await this.contract.setBulk(keys, values, txOptions)).wait();
|
|
200
196
|
}
|
|
201
197
|
catch (e) {
|
|
202
198
|
if (e instanceof Error)
|
|
@@ -237,7 +233,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
237
233
|
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
238
234
|
const hashKey = urlKey + '_hash';
|
|
239
235
|
try {
|
|
240
|
-
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash],
|
|
236
|
+
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], txOptions)).wait();
|
|
241
237
|
}
|
|
242
238
|
catch (e) {
|
|
243
239
|
if (e instanceof Error)
|
|
@@ -249,6 +245,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
249
245
|
*
|
|
250
246
|
* @param {string} address Address from which to get the key value.
|
|
251
247
|
* @param {string} key Key to obtain the value.
|
|
248
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
252
249
|
* @returns {string} Value of the key.
|
|
253
250
|
*
|
|
254
251
|
*
|
|
@@ -341,6 +338,7 @@ class KVStoreUtils {
|
|
|
341
338
|
*
|
|
342
339
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
343
340
|
* @param {string} address Address of the KVStore
|
|
341
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
344
342
|
* @returns {Promise<IKVStore[]>} KVStore data
|
|
345
343
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
346
344
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -354,7 +352,7 @@ class KVStoreUtils {
|
|
|
354
352
|
* console.log(kvStoreData);
|
|
355
353
|
* ```
|
|
356
354
|
*/
|
|
357
|
-
static async getKVStoreData(chainId, address) {
|
|
355
|
+
static async getKVStoreData(chainId, address, options) {
|
|
358
356
|
const networkData = constants_1.NETWORKS[chainId];
|
|
359
357
|
if (!networkData) {
|
|
360
358
|
throw error_1.ErrorUnsupportedChainID;
|
|
@@ -362,7 +360,7 @@ class KVStoreUtils {
|
|
|
362
360
|
if (address && !ethers_1.ethers.isAddress(address)) {
|
|
363
361
|
throw error_1.ErrorInvalidAddress;
|
|
364
362
|
}
|
|
365
|
-
const { kvstores } = await (0,
|
|
363
|
+
const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_QUERY)(), { address: address.toLowerCase() }, options);
|
|
366
364
|
const kvStoreData = kvstores.map((item) => ({
|
|
367
365
|
key: item.key,
|
|
368
366
|
value: item.value,
|
|
@@ -375,6 +373,7 @@ class KVStoreUtils {
|
|
|
375
373
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
376
374
|
* @param {string} address Address from which to get the key value.
|
|
377
375
|
* @param {string} key Key to obtain the value.
|
|
376
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
378
377
|
* @returns {Promise<string>} Value of the key.
|
|
379
378
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
380
379
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -393,7 +392,7 @@ class KVStoreUtils {
|
|
|
393
392
|
* console.log(value);
|
|
394
393
|
* ```
|
|
395
394
|
*/
|
|
396
|
-
static async get(chainId, address, key) {
|
|
395
|
+
static async get(chainId, address, key, options) {
|
|
397
396
|
if (key === '')
|
|
398
397
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
399
398
|
if (!ethers_1.ethers.isAddress(address))
|
|
@@ -402,7 +401,7 @@ class KVStoreUtils {
|
|
|
402
401
|
if (!networkData) {
|
|
403
402
|
throw error_1.ErrorUnsupportedChainID;
|
|
404
403
|
}
|
|
405
|
-
const { kvstores } = await (0,
|
|
404
|
+
const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY)(), { address: address.toLowerCase(), key }, options);
|
|
406
405
|
if (!kvstores || kvstores.length === 0) {
|
|
407
406
|
throw new error_1.InvalidKeyError(key, address);
|
|
408
407
|
}
|
|
@@ -414,6 +413,7 @@ class KVStoreUtils {
|
|
|
414
413
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
415
414
|
* @param {string} address Address from which to get the URL value.
|
|
416
415
|
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
416
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
417
417
|
* @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
|
|
418
418
|
*
|
|
419
419
|
* **Code example**
|
|
@@ -428,13 +428,13 @@ class KVStoreUtils {
|
|
|
428
428
|
* console.log(url);
|
|
429
429
|
* ```
|
|
430
430
|
*/
|
|
431
|
-
static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url') {
|
|
431
|
+
static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url', options) {
|
|
432
432
|
if (!ethers_1.ethers.isAddress(address))
|
|
433
433
|
throw error_1.ErrorInvalidAddress;
|
|
434
434
|
const hashKey = urlKey + '_hash';
|
|
435
435
|
let url = '', hash = '';
|
|
436
436
|
try {
|
|
437
|
-
url = await this.get(chainId, address, urlKey);
|
|
437
|
+
url = await this.get(chainId, address, urlKey, options);
|
|
438
438
|
}
|
|
439
439
|
catch (e) {
|
|
440
440
|
if (e instanceof Error)
|
|
@@ -479,8 +479,8 @@ class KVStoreUtils {
|
|
|
479
479
|
* console.log(publicKey);
|
|
480
480
|
* ```
|
|
481
481
|
*/
|
|
482
|
-
static async getPublicKey(chainId, address) {
|
|
483
|
-
const publicKeyUrl = await this.getFileUrlAndVerifyHash(chainId, address, constants_1.KVStoreKeys.publicKey);
|
|
482
|
+
static async getPublicKey(chainId, address, options) {
|
|
483
|
+
const publicKeyUrl = await this.getFileUrlAndVerifyHash(chainId, address, constants_1.KVStoreKeys.publicKey, options);
|
|
484
484
|
if (publicKeyUrl === '') {
|
|
485
485
|
return '';
|
|
486
486
|
}
|
package/dist/operator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IOperator, IOperatorsFilter, IReward } from './interfaces';
|
|
1
|
+
import { IOperator, IOperatorsFilter, IReward, SubgraphOptions } from './interfaces';
|
|
2
2
|
import { ChainId } from './enums';
|
|
3
3
|
export declare class OperatorUtils {
|
|
4
4
|
/**
|
|
@@ -6,6 +6,7 @@ export declare class OperatorUtils {
|
|
|
6
6
|
*
|
|
7
7
|
* @param {ChainId} chainId Network in which the operator is deployed
|
|
8
8
|
* @param {string} address Operator address.
|
|
9
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
9
10
|
* @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
|
|
10
11
|
*
|
|
11
12
|
* **Code example**
|
|
@@ -16,11 +17,12 @@ export declare class OperatorUtils {
|
|
|
16
17
|
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
static getOperator(chainId: ChainId, address: string): Promise<IOperator | null>;
|
|
20
|
+
static getOperator(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IOperator | null>;
|
|
20
21
|
/**
|
|
21
22
|
* This function returns all the operator details of the protocol.
|
|
22
23
|
*
|
|
23
24
|
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
25
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
24
26
|
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
25
27
|
*
|
|
26
28
|
* **Code example**
|
|
@@ -34,13 +36,14 @@ export declare class OperatorUtils {
|
|
|
34
36
|
* const operators = await OperatorUtils.getOperators(filter);
|
|
35
37
|
* ```
|
|
36
38
|
*/
|
|
37
|
-
static getOperators(filter: IOperatorsFilter): Promise<IOperator[]>;
|
|
39
|
+
static getOperators(filter: IOperatorsFilter, options?: SubgraphOptions): Promise<IOperator[]>;
|
|
38
40
|
/**
|
|
39
41
|
* Retrieves the reputation network operators of the specified address.
|
|
40
42
|
*
|
|
41
43
|
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
42
44
|
* @param {string} address Address of the reputation oracle.
|
|
43
45
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
46
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
44
47
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
45
48
|
*
|
|
46
49
|
* **Code example**
|
|
@@ -51,12 +54,13 @@ export declare class OperatorUtils {
|
|
|
51
54
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
52
55
|
* ```
|
|
53
56
|
*/
|
|
54
|
-
static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string): Promise<IOperator[]>;
|
|
57
|
+
static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string, options?: SubgraphOptions): Promise<IOperator[]>;
|
|
55
58
|
/**
|
|
56
59
|
* This function returns information about the rewards for a given slasher address.
|
|
57
60
|
*
|
|
58
61
|
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
59
62
|
* @param {string} slasherAddress Slasher address.
|
|
63
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
60
64
|
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
61
65
|
*
|
|
62
66
|
* **Code example**
|
|
@@ -67,6 +71,6 @@ export declare class OperatorUtils {
|
|
|
67
71
|
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
68
72
|
* ```
|
|
69
73
|
*/
|
|
70
|
-
static getRewards(chainId: ChainId, slasherAddress: string): Promise<IReward[]>;
|
|
74
|
+
static getRewards(chainId: ChainId, slasherAddress: string, options?: SubgraphOptions): Promise<IReward[]>;
|
|
71
75
|
}
|
|
72
76
|
//# sourceMappingURL=operator.d.ts.map
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,eAAe,EAChB,MAAM,cAAc,CAAC;AAmBtB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;OAeG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAwB5B;;;;;;;;;;;;;;;;;OAiBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+CvB;;;;;;;;;;;;;;;;OAgBG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IAyBvB;;;;;;;;;;;;;;;OAeG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CA8BtB"}
|
package/dist/operator.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.OperatorUtils = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
9
4
|
const reward_1 = require("./graphql/queries/reward");
|
|
10
5
|
const operator_1 = require("./graphql/queries/operator");
|
|
11
6
|
const ethers_1 = require("ethers");
|
|
@@ -19,6 +14,7 @@ class OperatorUtils {
|
|
|
19
14
|
*
|
|
20
15
|
* @param {ChainId} chainId Network in which the operator is deployed
|
|
21
16
|
* @param {string} address Operator address.
|
|
17
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
22
18
|
* @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
|
|
23
19
|
*
|
|
24
20
|
* **Code example**
|
|
@@ -29,7 +25,7 @@ class OperatorUtils {
|
|
|
29
25
|
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
30
26
|
* ```
|
|
31
27
|
*/
|
|
32
|
-
static async getOperator(chainId, address) {
|
|
28
|
+
static async getOperator(chainId, address, options) {
|
|
33
29
|
if (!ethers_1.ethers.isAddress(address)) {
|
|
34
30
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
35
31
|
}
|
|
@@ -37,8 +33,9 @@ class OperatorUtils {
|
|
|
37
33
|
if (!networkData) {
|
|
38
34
|
throw error_1.ErrorUnsupportedChainID;
|
|
39
35
|
}
|
|
40
|
-
const { operator } = await (0,
|
|
36
|
+
const { operator } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), operator_1.GET_LEADER_QUERY, {
|
|
41
37
|
address: address.toLowerCase(),
|
|
38
|
+
options,
|
|
42
39
|
});
|
|
43
40
|
if (!operator) {
|
|
44
41
|
return null;
|
|
@@ -49,6 +46,7 @@ class OperatorUtils {
|
|
|
49
46
|
* This function returns all the operator details of the protocol.
|
|
50
47
|
*
|
|
51
48
|
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
49
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
52
50
|
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
53
51
|
*
|
|
54
52
|
* **Code example**
|
|
@@ -62,7 +60,7 @@ class OperatorUtils {
|
|
|
62
60
|
* const operators = await OperatorUtils.getOperators(filter);
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
|
-
static async getOperators(filter) {
|
|
63
|
+
static async getOperators(filter, options) {
|
|
66
64
|
const first = filter.first !== undefined && filter.first > 0
|
|
67
65
|
? Math.min(filter.first, 1000)
|
|
68
66
|
: 10;
|
|
@@ -81,14 +79,14 @@ class OperatorUtils {
|
|
|
81
79
|
if (!networkData) {
|
|
82
80
|
throw error_1.ErrorUnsupportedChainID;
|
|
83
81
|
}
|
|
84
|
-
const { operators } = await (0,
|
|
82
|
+
const { operators } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
85
83
|
minStakedAmount: filter?.minStakedAmount,
|
|
86
84
|
roles: filter?.roles,
|
|
87
85
|
orderBy: orderBy,
|
|
88
86
|
orderDirection: orderDirection,
|
|
89
87
|
first: first,
|
|
90
88
|
skip: skip,
|
|
91
|
-
});
|
|
89
|
+
}, options);
|
|
92
90
|
if (!operators) {
|
|
93
91
|
return [];
|
|
94
92
|
}
|
|
@@ -100,6 +98,7 @@ class OperatorUtils {
|
|
|
100
98
|
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
101
99
|
* @param {string} address Address of the reputation oracle.
|
|
102
100
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
101
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
103
102
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
104
103
|
*
|
|
105
104
|
* **Code example**
|
|
@@ -110,15 +109,15 @@ class OperatorUtils {
|
|
|
110
109
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
111
110
|
* ```
|
|
112
111
|
*/
|
|
113
|
-
static async getReputationNetworkOperators(chainId, address, role) {
|
|
112
|
+
static async getReputationNetworkOperators(chainId, address, role, options) {
|
|
114
113
|
const networkData = constants_1.NETWORKS[chainId];
|
|
115
114
|
if (!networkData) {
|
|
116
115
|
throw error_1.ErrorUnsupportedChainID;
|
|
117
116
|
}
|
|
118
|
-
const { reputationNetwork } = await (0,
|
|
117
|
+
const { reputationNetwork } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_REPUTATION_NETWORK_QUERY)(role), {
|
|
119
118
|
address: address.toLowerCase(),
|
|
120
119
|
role: role,
|
|
121
|
-
});
|
|
120
|
+
}, options);
|
|
122
121
|
if (!reputationNetwork)
|
|
123
122
|
return [];
|
|
124
123
|
return reputationNetwork.operators.map((operator) => mapOperator(operator, chainId));
|
|
@@ -128,6 +127,7 @@ class OperatorUtils {
|
|
|
128
127
|
*
|
|
129
128
|
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
130
129
|
* @param {string} slasherAddress Slasher address.
|
|
130
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
131
131
|
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
132
132
|
*
|
|
133
133
|
* **Code example**
|
|
@@ -138,7 +138,7 @@ class OperatorUtils {
|
|
|
138
138
|
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
|
-
static async getRewards(chainId, slasherAddress) {
|
|
141
|
+
static async getRewards(chainId, slasherAddress, options) {
|
|
142
142
|
if (!ethers_1.ethers.isAddress(slasherAddress)) {
|
|
143
143
|
throw error_1.ErrorInvalidSlasherAddressProvided;
|
|
144
144
|
}
|
|
@@ -146,9 +146,9 @@ class OperatorUtils {
|
|
|
146
146
|
if (!networkData) {
|
|
147
147
|
throw error_1.ErrorUnsupportedChainID;
|
|
148
148
|
}
|
|
149
|
-
const { rewardAddedEvents } = await (0,
|
|
149
|
+
const { rewardAddedEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
|
|
150
150
|
slasherAddress: slasherAddress.toLowerCase(),
|
|
151
|
-
});
|
|
151
|
+
}, options);
|
|
152
152
|
if (!rewardAddedEvents)
|
|
153
153
|
return [];
|
|
154
154
|
return rewardAddedEvents.map((reward) => {
|
package/dist/staking.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-
|
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
3
|
import { BaseEthersClient } from './base';
|
|
4
4
|
import { ChainId } from './enums';
|
|
5
|
-
import { IStaker, IStakersFilter, StakerInfo } from './interfaces';
|
|
5
|
+
import { IStaker, IStakersFilter, StakerInfo, SubgraphOptions } from './interfaces';
|
|
6
6
|
import { NetworkData } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* ## Introduction
|
|
@@ -264,14 +264,17 @@ export declare class StakingUtils {
|
|
|
264
264
|
*
|
|
265
265
|
* @param {ChainId} chainId Network in which the staking contract is deployed
|
|
266
266
|
* @param {string} stakerAddress Address of the staker
|
|
267
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
267
268
|
* @returns {Promise<IStaker>} Staker info from subgraph
|
|
268
269
|
*/
|
|
269
|
-
static getStaker(chainId: ChainId, stakerAddress: string): Promise<IStaker>;
|
|
270
|
+
static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
|
|
270
271
|
/**
|
|
271
272
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
272
273
|
*
|
|
274
|
+
* @param {IStakersFilter} filter Stakers filter with pagination and ordering
|
|
275
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
273
276
|
* @returns {Promise<IStaker[]>} Array of stakers
|
|
274
277
|
*/
|
|
275
|
-
static getStakers(filter: IStakersFilter): Promise<IStaker[]>;
|
|
278
|
+
static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
|
|
276
279
|
}
|
|
277
280
|
//# sourceMappingURL=staking.d.ts.map
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAYlD,OAAO,EACL,OAAO,EACP,cAAc,EACd,UAAU,EACV,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;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AAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC;IAwBnB;;;;;;OAMG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CAqDtB"}
|
package/dist/staking.js
CHANGED
|
@@ -8,14 +8,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.StakingUtils = exports.StakingClient = void 0;
|
|
16
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
17
14
|
const ethers_1 = require("ethers");
|
|
18
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
19
15
|
const base_1 = require("./base");
|
|
20
16
|
const constants_1 = require("./constants");
|
|
21
17
|
const decorators_1 = require("./decorators");
|
|
@@ -171,7 +167,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
171
167
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
172
168
|
}
|
|
173
169
|
try {
|
|
174
|
-
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount,
|
|
170
|
+
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, txOptions)).wait();
|
|
175
171
|
return;
|
|
176
172
|
}
|
|
177
173
|
catch (e) {
|
|
@@ -213,7 +209,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
213
209
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
214
210
|
}
|
|
215
211
|
try {
|
|
216
|
-
await (await this.stakingContract.stake(amount,
|
|
212
|
+
await (await this.stakingContract.stake(amount, txOptions)).wait();
|
|
217
213
|
return;
|
|
218
214
|
}
|
|
219
215
|
catch (e) {
|
|
@@ -254,7 +250,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
254
250
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
255
251
|
}
|
|
256
252
|
try {
|
|
257
|
-
await (await this.stakingContract.unstake(amount,
|
|
253
|
+
await (await this.stakingContract.unstake(amount, txOptions)).wait();
|
|
258
254
|
return;
|
|
259
255
|
}
|
|
260
256
|
catch (e) {
|
|
@@ -287,7 +283,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
287
283
|
*/
|
|
288
284
|
async withdraw(txOptions = {}) {
|
|
289
285
|
try {
|
|
290
|
-
await (await this.stakingContract.withdraw(
|
|
286
|
+
await (await this.stakingContract.withdraw(txOptions)).wait();
|
|
291
287
|
return;
|
|
292
288
|
}
|
|
293
289
|
catch (e) {
|
|
@@ -336,7 +332,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
336
332
|
}
|
|
337
333
|
await this.checkValidEscrow(escrowAddress);
|
|
338
334
|
try {
|
|
339
|
-
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount,
|
|
335
|
+
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, txOptions)).wait();
|
|
340
336
|
return;
|
|
341
337
|
}
|
|
342
338
|
catch (e) {
|
|
@@ -431,9 +427,10 @@ class StakingUtils {
|
|
|
431
427
|
*
|
|
432
428
|
* @param {ChainId} chainId Network in which the staking contract is deployed
|
|
433
429
|
* @param {string} stakerAddress Address of the staker
|
|
430
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
434
431
|
* @returns {Promise<IStaker>} Staker info from subgraph
|
|
435
432
|
*/
|
|
436
|
-
static async getStaker(chainId, stakerAddress) {
|
|
433
|
+
static async getStaker(chainId, stakerAddress, options) {
|
|
437
434
|
if (!ethers_1.ethers.isAddress(stakerAddress)) {
|
|
438
435
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
439
436
|
}
|
|
@@ -441,7 +438,7 @@ class StakingUtils {
|
|
|
441
438
|
if (!networkData) {
|
|
442
439
|
throw error_1.ErrorUnsupportedChainID;
|
|
443
440
|
}
|
|
444
|
-
const { staker } = await (0,
|
|
441
|
+
const { staker } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), staking_1.GET_STAKER_BY_ADDRESS_QUERY, { id: stakerAddress.toLowerCase() }, options);
|
|
445
442
|
if (!staker) {
|
|
446
443
|
throw error_1.ErrorStakerNotFound;
|
|
447
444
|
}
|
|
@@ -450,9 +447,11 @@ class StakingUtils {
|
|
|
450
447
|
/**
|
|
451
448
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
452
449
|
*
|
|
450
|
+
* @param {IStakersFilter} filter Stakers filter with pagination and ordering
|
|
451
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
453
452
|
* @returns {Promise<IStaker[]>} Array of stakers
|
|
454
453
|
*/
|
|
455
|
-
static async getStakers(filter) {
|
|
454
|
+
static async getStakers(filter, options) {
|
|
456
455
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
457
456
|
const skip = filter.skip || 0;
|
|
458
457
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
@@ -461,7 +460,7 @@ class StakingUtils {
|
|
|
461
460
|
if (!networkData) {
|
|
462
461
|
throw error_1.ErrorUnsupportedChainID;
|
|
463
462
|
}
|
|
464
|
-
const { stakers } = await (0,
|
|
463
|
+
const { stakers } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, staking_1.GET_STAKERS_QUERY)(filter), {
|
|
465
464
|
minStakedAmount: filter.minStakedAmount
|
|
466
465
|
? filter.minStakedAmount
|
|
467
466
|
: undefined,
|
|
@@ -490,7 +489,7 @@ class StakingUtils {
|
|
|
490
489
|
orderDirection: orderDirection,
|
|
491
490
|
first: first,
|
|
492
491
|
skip: skip,
|
|
493
|
-
});
|
|
492
|
+
}, options);
|
|
494
493
|
if (!stakers) {
|
|
495
494
|
return [];
|
|
496
495
|
}
|