@human-protocol/sdk 5.2.0 → 6.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/base.d.ts +4 -5
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +4 -5
- package/dist/constants.js +6 -6
- package/dist/encryption.d.ts +68 -203
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +66 -202
- package/dist/error.d.ts +0 -24
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -26
- package/dist/escrow.d.ts +427 -780
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +314 -684
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +3 -1
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/kvstore.d.ts +119 -181
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +119 -182
- package/dist/operator.d.ts +59 -30
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +59 -30
- package/dist/staking.d.ts +135 -134
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +135 -134
- package/dist/statistics.d.ts +104 -134
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +119 -144
- package/dist/transaction.d.ts +36 -15
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +36 -15
- package/dist/types.d.ts +0 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +31 -17
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +31 -17
- package/dist/worker.d.ts +35 -14
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +35 -14
- package/package.json +7 -24
- package/src/base.ts +4 -5
- package/src/constants.ts +6 -6
- package/src/encryption.ts +69 -203
- package/src/error.ts +0 -36
- package/src/escrow.ts +425 -780
- package/src/graphql/queries/operator.ts +3 -1
- package/src/graphql/types.ts +4 -2
- package/src/index.ts +4 -5
- package/src/kvstore.ts +120 -183
- package/src/operator.ts +59 -30
- package/src/staking.ts +135 -134
- package/src/statistics.ts +125 -146
- package/src/transaction.ts +36 -15
- package/src/types.ts +0 -57
- package/src/utils.ts +31 -17
- package/src/worker.ts +35 -14
- package/dist/storage.d.ts +0 -186
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -319
- package/src/storage.ts +0 -313
package/src/staking.ts
CHANGED
|
@@ -37,9 +37,7 @@ import {
|
|
|
37
37
|
} from './graphql/queries/staking';
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* This client enables performing actions on staking contracts and obtaining staking information from both the contracts and subgraph.
|
|
40
|
+
* Client for staking actions on HUMAN Protocol.
|
|
43
41
|
*
|
|
44
42
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
45
43
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
@@ -53,37 +51,25 @@ import {
|
|
|
53
51
|
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
54
52
|
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
55
53
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* ### npm
|
|
59
|
-
* ```bash
|
|
60
|
-
* npm install @human-protocol/sdk
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* ### yarn
|
|
64
|
-
* ```bash
|
|
65
|
-
* yarn install @human-protocol/sdk
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* ## Code example
|
|
54
|
+
* @example
|
|
69
55
|
*
|
|
70
|
-
* ### Signer
|
|
56
|
+
* ###Using Signer
|
|
71
57
|
*
|
|
72
|
-
*
|
|
58
|
+
* ####Using private key (backend)
|
|
73
59
|
*
|
|
74
60
|
* ```ts
|
|
75
61
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
76
|
-
* import { Wallet,
|
|
62
|
+
* import { Wallet, JsonRpcProvider } from 'ethers';
|
|
77
63
|
*
|
|
78
64
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
79
65
|
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
80
66
|
*
|
|
81
|
-
* const provider = new
|
|
67
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
82
68
|
* const signer = new Wallet(privateKey, provider);
|
|
83
69
|
* const stakingClient = await StakingClient.build(signer);
|
|
84
70
|
* ```
|
|
85
71
|
*
|
|
86
|
-
*
|
|
72
|
+
* ####Using Wagmi (frontend)
|
|
87
73
|
*
|
|
88
74
|
* ```ts
|
|
89
75
|
* import { useSigner, useChainId } from 'wagmi';
|
|
@@ -93,15 +79,15 @@ import {
|
|
|
93
79
|
* const stakingClient = await StakingClient.build(signer);
|
|
94
80
|
* ```
|
|
95
81
|
*
|
|
96
|
-
* ### Provider
|
|
82
|
+
* ###Using Provider
|
|
97
83
|
*
|
|
98
84
|
* ```ts
|
|
99
85
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
100
|
-
* import {
|
|
86
|
+
* import { JsonRpcProvider } from 'ethers';
|
|
101
87
|
*
|
|
102
88
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
103
89
|
*
|
|
104
|
-
* const provider = new
|
|
90
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
105
91
|
* const stakingClient = await StakingClient.build(provider);
|
|
106
92
|
* ```
|
|
107
93
|
*/
|
|
@@ -113,8 +99,8 @@ export class StakingClient extends BaseEthersClient {
|
|
|
113
99
|
/**
|
|
114
100
|
* **StakingClient constructor**
|
|
115
101
|
*
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
102
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
103
|
+
* @param networkData - The network information required to connect to the Staking contract
|
|
118
104
|
*/
|
|
119
105
|
constructor(runner: ContractRunner, networkData: NetworkData) {
|
|
120
106
|
super(runner, networkData);
|
|
@@ -138,11 +124,23 @@ export class StakingClient extends BaseEthersClient {
|
|
|
138
124
|
/**
|
|
139
125
|
* Creates an instance of StakingClient from a Runner.
|
|
140
126
|
*
|
|
141
|
-
* @param
|
|
127
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
128
|
+
* @returns An instance of StakingClient
|
|
129
|
+
* @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
|
|
130
|
+
* @throws ErrorUnsupportedChainID If the network's chainId is not supported
|
|
142
131
|
*
|
|
143
|
-
* @
|
|
144
|
-
*
|
|
145
|
-
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { StakingClient } from '@human-protocol/sdk';
|
|
135
|
+
* import { Wallet, JsonRpcProvider } from 'ethers';
|
|
136
|
+
*
|
|
137
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
138
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
139
|
+
*
|
|
140
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
141
|
+
* const signer = new Wallet(privateKey, provider);
|
|
142
|
+
* const stakingClient = await StakingClient.build(signer);
|
|
143
|
+
* ```
|
|
146
144
|
*/
|
|
147
145
|
public static async build(runner: ContractRunner): Promise<StakingClient> {
|
|
148
146
|
if (!runner.provider) {
|
|
@@ -179,24 +177,17 @@ export class StakingClient extends BaseEthersClient {
|
|
|
179
177
|
/**
|
|
180
178
|
* This function approves the staking contract to transfer a specified amount of tokens when the user stakes. It increases the allowance for the staking contract.
|
|
181
179
|
*
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @returns
|
|
185
|
-
*
|
|
186
|
-
*
|
|
180
|
+
* @param amount - Amount in WEI of tokens to approve for stake.
|
|
181
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
182
|
+
* @returns -
|
|
183
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
184
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
187
185
|
*
|
|
186
|
+
* @example
|
|
188
187
|
* ```ts
|
|
189
|
-
* import { ethers
|
|
190
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
191
|
-
*
|
|
192
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
193
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
188
|
+
* import { ethers } from 'ethers';
|
|
194
189
|
*
|
|
195
|
-
* const
|
|
196
|
-
* const signer = new Wallet(privateKey, provider);
|
|
197
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
198
|
-
*
|
|
199
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
190
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
200
191
|
* await stakingClient.approveStake(amount);
|
|
201
192
|
* ```
|
|
202
193
|
*/
|
|
@@ -230,26 +221,20 @@ export class StakingClient extends BaseEthersClient {
|
|
|
230
221
|
/**
|
|
231
222
|
* This function stakes a specified amount of tokens on a specific network.
|
|
232
223
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* @param {bigint} amount Amount in WEI of tokens to stake.
|
|
236
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
237
|
-
* @returns Returns void if successful. Throws error if any.
|
|
224
|
+
* !!! note
|
|
225
|
+
* `approveStake` must be called before
|
|
238
226
|
*
|
|
239
|
-
*
|
|
227
|
+
* @param amount - Amount in WEI of tokens to stake.
|
|
228
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
229
|
+
* @returns -
|
|
230
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
231
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
240
232
|
*
|
|
233
|
+
* @example
|
|
241
234
|
* ```ts
|
|
242
|
-
* import { ethers
|
|
243
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
235
|
+
* import { ethers } from 'ethers';
|
|
244
236
|
*
|
|
245
|
-
* const
|
|
246
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
247
|
-
*
|
|
248
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
249
|
-
* const signer = new Wallet(privateKey, provider);
|
|
250
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
251
|
-
*
|
|
252
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
237
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
253
238
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
254
239
|
* await stakingClient.stake(amount);
|
|
255
240
|
* ```
|
|
@@ -275,26 +260,20 @@ export class StakingClient extends BaseEthersClient {
|
|
|
275
260
|
/**
|
|
276
261
|
* This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
|
|
277
262
|
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
281
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
282
|
-
* @returns Returns void if successful. Throws error if any.
|
|
263
|
+
* !!! note
|
|
264
|
+
* Must have tokens available to unstake
|
|
283
265
|
*
|
|
284
|
-
*
|
|
266
|
+
* @param amount - Amount in WEI of tokens to unstake.
|
|
267
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
268
|
+
* @returns -
|
|
269
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
270
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
285
271
|
*
|
|
272
|
+
* @example
|
|
286
273
|
* ```ts
|
|
287
|
-
* import { ethers
|
|
288
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
289
|
-
*
|
|
290
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
291
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
292
|
-
*
|
|
293
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
294
|
-
* const signer = new Wallet(privateKey, provider);
|
|
295
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
274
|
+
* import { ethers } from 'ethers';
|
|
296
275
|
*
|
|
297
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
276
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
298
277
|
* await stakingClient.unstake(amount);
|
|
299
278
|
* ```
|
|
300
279
|
*/
|
|
@@ -321,25 +300,14 @@ export class StakingClient extends BaseEthersClient {
|
|
|
321
300
|
|
|
322
301
|
/**
|
|
323
302
|
* This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
|
|
303
|
+
* !!! note
|
|
304
|
+
* Must have tokens available to withdraw
|
|
324
305
|
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
328
|
-
* @returns Returns void if successful. Throws error if any.
|
|
329
|
-
*
|
|
330
|
-
* **Code example**
|
|
306
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
307
|
+
* @returns -
|
|
331
308
|
*
|
|
309
|
+
* @example
|
|
332
310
|
* ```ts
|
|
333
|
-
* import { Wallet, providers } from 'ethers';
|
|
334
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
335
|
-
*
|
|
336
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
337
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
338
|
-
*
|
|
339
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
340
|
-
* const signer = new Wallet(privateKey, provider);
|
|
341
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
342
|
-
*
|
|
343
311
|
* await stakingClient.withdraw();
|
|
344
312
|
* ```
|
|
345
313
|
*/
|
|
@@ -356,28 +324,30 @@ export class StakingClient extends BaseEthersClient {
|
|
|
356
324
|
/**
|
|
357
325
|
* This function reduces the allocated amount by a staker in an escrow and transfers those tokens to the reward pool. This allows the slasher to claim them later.
|
|
358
326
|
*
|
|
359
|
-
* @param
|
|
360
|
-
* @param
|
|
361
|
-
* @param
|
|
362
|
-
* @param
|
|
363
|
-
* @param
|
|
364
|
-
* @returns
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
327
|
+
* @param slasher - Wallet address from who requested the slash
|
|
328
|
+
* @param staker - Wallet address from who is going to be slashed
|
|
329
|
+
* @param escrowAddress - Address of the escrow that the slash is made
|
|
330
|
+
* @param amount - Amount in WEI of tokens to slash.
|
|
331
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
332
|
+
* @returns -
|
|
333
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
334
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
335
|
+
* @throws ErrorInvalidSlasherAddressProvided If the slasher address is invalid
|
|
336
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
337
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
338
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
368
341
|
* ```ts
|
|
369
|
-
* import { ethers
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
380
|
-
* await stakingClient.slash('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
342
|
+
* import { ethers } from 'ethers';
|
|
343
|
+
*
|
|
344
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
345
|
+
* await stakingClient.slash(
|
|
346
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
347
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
348
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
349
|
+
* amount
|
|
350
|
+
* );
|
|
381
351
|
* ```
|
|
382
352
|
*/
|
|
383
353
|
@requiresSigner
|
|
@@ -426,21 +396,14 @@ export class StakingClient extends BaseEthersClient {
|
|
|
426
396
|
/**
|
|
427
397
|
* Retrieves comprehensive staking information for a staker.
|
|
428
398
|
*
|
|
429
|
-
* @param
|
|
430
|
-
* @returns
|
|
431
|
-
*
|
|
432
|
-
* **Code example**
|
|
399
|
+
* @param stakerAddress - The address of the staker.
|
|
400
|
+
* @returns Staking information for the staker
|
|
401
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
433
402
|
*
|
|
403
|
+
* @example
|
|
434
404
|
* ```ts
|
|
435
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
436
|
-
*
|
|
437
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
438
|
-
*
|
|
439
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
440
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
441
|
-
*
|
|
442
405
|
* const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
|
|
443
|
-
* console.log(stakingInfo.
|
|
406
|
+
* console.log('Tokens staked:', stakingInfo.stakedAmount);
|
|
444
407
|
* ```
|
|
445
408
|
*/
|
|
446
409
|
public async getStakerInfo(stakerAddress: string): Promise<StakerInfo> {
|
|
@@ -479,16 +442,41 @@ export class StakingClient extends BaseEthersClient {
|
|
|
479
442
|
}
|
|
480
443
|
|
|
481
444
|
/**
|
|
482
|
-
* Utility
|
|
445
|
+
* Utility helpers for Staking-related queries.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
450
|
+
*
|
|
451
|
+
* const staker = await StakingUtils.getStaker(
|
|
452
|
+
* ChainId.POLYGON_AMOY,
|
|
453
|
+
* '0xYourStakerAddress'
|
|
454
|
+
* );
|
|
455
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
456
|
+
* ```
|
|
483
457
|
*/
|
|
484
458
|
export class StakingUtils {
|
|
485
459
|
/**
|
|
486
460
|
* Gets staking info for a staker from the subgraph.
|
|
487
461
|
*
|
|
488
|
-
* @param
|
|
489
|
-
* @param
|
|
490
|
-
* @param
|
|
491
|
-
* @returns
|
|
462
|
+
* @param chainId - Network in which the staking contract is deployed
|
|
463
|
+
* @param stakerAddress - Address of the staker
|
|
464
|
+
* @param options - Optional configuration for subgraph requests.
|
|
465
|
+
* @returns Staker info from subgraph
|
|
466
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
467
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
468
|
+
* @throws ErrorStakerNotFound If the staker is not found
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
473
|
+
*
|
|
474
|
+
* const staker = await StakingUtils.getStaker(
|
|
475
|
+
* ChainId.POLYGON_AMOY,
|
|
476
|
+
* '0xYourStakerAddress'
|
|
477
|
+
* );
|
|
478
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
479
|
+
* ```
|
|
492
480
|
*/
|
|
493
481
|
public static async getStaker(
|
|
494
482
|
chainId: ChainId,
|
|
@@ -521,9 +509,22 @@ export class StakingUtils {
|
|
|
521
509
|
/**
|
|
522
510
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
523
511
|
*
|
|
524
|
-
* @param
|
|
525
|
-
* @param
|
|
526
|
-
* @returns
|
|
512
|
+
* @param filter - Stakers filter with pagination and ordering
|
|
513
|
+
* @param options - Optional configuration for subgraph requests.
|
|
514
|
+
* @returns Array of stakers
|
|
515
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```ts
|
|
519
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
520
|
+
*
|
|
521
|
+
* const filter = {
|
|
522
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
523
|
+
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
524
|
+
* };
|
|
525
|
+
* const stakers = await StakingUtils.getStakers(filter);
|
|
526
|
+
* console.log('Stakers:', stakers.length);
|
|
527
|
+
* ```
|
|
527
528
|
*/
|
|
528
529
|
public static async getStakers(
|
|
529
530
|
filter: IStakersFilter,
|