@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/dist/staking.js
CHANGED
|
@@ -20,9 +20,7 @@ const error_1 = require("./error");
|
|
|
20
20
|
const utils_1 = require("./utils");
|
|
21
21
|
const staking_1 = require("./graphql/queries/staking");
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* This client enables performing actions on staking contracts and obtaining staking information from both the contracts and subgraph.
|
|
23
|
+
* Client for staking actions on HUMAN Protocol.
|
|
26
24
|
*
|
|
27
25
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
28
26
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
@@ -36,37 +34,25 @@ const staking_1 = require("./graphql/queries/staking");
|
|
|
36
34
|
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
37
35
|
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
38
36
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* ### npm
|
|
42
|
-
* ```bash
|
|
43
|
-
* npm install @human-protocol/sdk
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* ### yarn
|
|
47
|
-
* ```bash
|
|
48
|
-
* yarn install @human-protocol/sdk
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* ## Code example
|
|
37
|
+
* @example
|
|
52
38
|
*
|
|
53
|
-
* ### Signer
|
|
39
|
+
* ###Using Signer
|
|
54
40
|
*
|
|
55
|
-
*
|
|
41
|
+
* ####Using private key (backend)
|
|
56
42
|
*
|
|
57
43
|
* ```ts
|
|
58
44
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
59
|
-
* import { Wallet,
|
|
45
|
+
* import { Wallet, JsonRpcProvider } from 'ethers';
|
|
60
46
|
*
|
|
61
47
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
62
48
|
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
63
49
|
*
|
|
64
|
-
* const provider = new
|
|
50
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
65
51
|
* const signer = new Wallet(privateKey, provider);
|
|
66
52
|
* const stakingClient = await StakingClient.build(signer);
|
|
67
53
|
* ```
|
|
68
54
|
*
|
|
69
|
-
*
|
|
55
|
+
* ####Using Wagmi (frontend)
|
|
70
56
|
*
|
|
71
57
|
* ```ts
|
|
72
58
|
* import { useSigner, useChainId } from 'wagmi';
|
|
@@ -76,15 +62,15 @@ const staking_1 = require("./graphql/queries/staking");
|
|
|
76
62
|
* const stakingClient = await StakingClient.build(signer);
|
|
77
63
|
* ```
|
|
78
64
|
*
|
|
79
|
-
* ### Provider
|
|
65
|
+
* ###Using Provider
|
|
80
66
|
*
|
|
81
67
|
* ```ts
|
|
82
68
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
83
|
-
* import {
|
|
69
|
+
* import { JsonRpcProvider } from 'ethers';
|
|
84
70
|
*
|
|
85
71
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
86
72
|
*
|
|
87
|
-
* const provider = new
|
|
73
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
88
74
|
* const stakingClient = await StakingClient.build(provider);
|
|
89
75
|
* ```
|
|
90
76
|
*/
|
|
@@ -92,8 +78,8 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
92
78
|
/**
|
|
93
79
|
* **StakingClient constructor**
|
|
94
80
|
*
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
81
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
82
|
+
* @param networkData - The network information required to connect to the Staking contract
|
|
97
83
|
*/
|
|
98
84
|
constructor(runner, networkData) {
|
|
99
85
|
super(runner, networkData);
|
|
@@ -104,11 +90,23 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
104
90
|
/**
|
|
105
91
|
* Creates an instance of StakingClient from a Runner.
|
|
106
92
|
*
|
|
107
|
-
* @param
|
|
93
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
94
|
+
* @returns An instance of StakingClient
|
|
95
|
+
* @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
|
|
96
|
+
* @throws ErrorUnsupportedChainID If the network's chainId is not supported
|
|
108
97
|
*
|
|
109
|
-
* @
|
|
110
|
-
*
|
|
111
|
-
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { StakingClient } from '@human-protocol/sdk';
|
|
101
|
+
* import { Wallet, JsonRpcProvider } from 'ethers';
|
|
102
|
+
*
|
|
103
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
104
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
105
|
+
*
|
|
106
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
107
|
+
* const signer = new Wallet(privateKey, provider);
|
|
108
|
+
* const stakingClient = await StakingClient.build(signer);
|
|
109
|
+
* ```
|
|
112
110
|
*/
|
|
113
111
|
static async build(runner) {
|
|
114
112
|
if (!runner.provider) {
|
|
@@ -138,24 +136,17 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
138
136
|
/**
|
|
139
137
|
* 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.
|
|
140
138
|
*
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @returns
|
|
144
|
-
*
|
|
145
|
-
*
|
|
139
|
+
* @param amount - Amount in WEI of tokens to approve for stake.
|
|
140
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
141
|
+
* @returns -
|
|
142
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
143
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
146
144
|
*
|
|
145
|
+
* @example
|
|
147
146
|
* ```ts
|
|
148
|
-
* import { ethers
|
|
149
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
150
|
-
*
|
|
151
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
152
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
147
|
+
* import { ethers } from 'ethers';
|
|
153
148
|
*
|
|
154
|
-
* const
|
|
155
|
-
* const signer = new Wallet(privateKey, provider);
|
|
156
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
157
|
-
*
|
|
158
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
149
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
159
150
|
* await stakingClient.approveStake(amount);
|
|
160
151
|
* ```
|
|
161
152
|
*/
|
|
@@ -177,26 +168,20 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
177
168
|
/**
|
|
178
169
|
* This function stakes a specified amount of tokens on a specific network.
|
|
179
170
|
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @param {bigint} amount Amount in WEI of tokens to stake.
|
|
183
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
184
|
-
* @returns Returns void if successful. Throws error if any.
|
|
171
|
+
* !!! note
|
|
172
|
+
* `approveStake` must be called before
|
|
185
173
|
*
|
|
186
|
-
*
|
|
174
|
+
* @param amount - Amount in WEI of tokens to stake.
|
|
175
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
176
|
+
* @returns -
|
|
177
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
178
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
187
179
|
*
|
|
180
|
+
* @example
|
|
188
181
|
* ```ts
|
|
189
|
-
* import { ethers
|
|
190
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
182
|
+
* import { ethers } from 'ethers';
|
|
191
183
|
*
|
|
192
|
-
* const
|
|
193
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
194
|
-
*
|
|
195
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
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
|
|
184
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
200
185
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
201
186
|
* await stakingClient.stake(amount);
|
|
202
187
|
* ```
|
|
@@ -219,26 +204,20 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
219
204
|
/**
|
|
220
205
|
* This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
|
|
221
206
|
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
225
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
226
|
-
* @returns Returns void if successful. Throws error if any.
|
|
207
|
+
* !!! note
|
|
208
|
+
* Must have tokens available to unstake
|
|
227
209
|
*
|
|
228
|
-
*
|
|
210
|
+
* @param amount - Amount in WEI of tokens to unstake.
|
|
211
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
212
|
+
* @returns -
|
|
213
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
214
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
229
215
|
*
|
|
216
|
+
* @example
|
|
230
217
|
* ```ts
|
|
231
|
-
* import { ethers
|
|
232
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
233
|
-
*
|
|
234
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
235
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
236
|
-
*
|
|
237
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
238
|
-
* const signer = new Wallet(privateKey, provider);
|
|
239
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
218
|
+
* import { ethers } from 'ethers';
|
|
240
219
|
*
|
|
241
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
220
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
242
221
|
* await stakingClient.unstake(amount);
|
|
243
222
|
* ```
|
|
244
223
|
*/
|
|
@@ -259,25 +238,14 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
259
238
|
}
|
|
260
239
|
/**
|
|
261
240
|
* This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
|
|
241
|
+
* !!! note
|
|
242
|
+
* Must have tokens available to withdraw
|
|
262
243
|
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
266
|
-
* @returns Returns void if successful. Throws error if any.
|
|
267
|
-
*
|
|
268
|
-
* **Code example**
|
|
244
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
245
|
+
* @returns -
|
|
269
246
|
*
|
|
247
|
+
* @example
|
|
270
248
|
* ```ts
|
|
271
|
-
* import { Wallet, providers } from 'ethers';
|
|
272
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
273
|
-
*
|
|
274
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
275
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
276
|
-
*
|
|
277
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
278
|
-
* const signer = new Wallet(privateKey, provider);
|
|
279
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
280
|
-
*
|
|
281
249
|
* await stakingClient.withdraw();
|
|
282
250
|
* ```
|
|
283
251
|
*/
|
|
@@ -293,28 +261,30 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
293
261
|
/**
|
|
294
262
|
* 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.
|
|
295
263
|
*
|
|
296
|
-
* @param
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @param
|
|
301
|
-
* @returns
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
264
|
+
* @param slasher - Wallet address from who requested the slash
|
|
265
|
+
* @param staker - Wallet address from who is going to be slashed
|
|
266
|
+
* @param escrowAddress - Address of the escrow that the slash is made
|
|
267
|
+
* @param amount - Amount in WEI of tokens to slash.
|
|
268
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
269
|
+
* @returns -
|
|
270
|
+
* @throws ErrorInvalidStakingValueType If the amount is not a bigint
|
|
271
|
+
* @throws ErrorInvalidStakingValueSign If the amount is negative
|
|
272
|
+
* @throws ErrorInvalidSlasherAddressProvided If the slasher address is invalid
|
|
273
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
274
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
275
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
305
278
|
* ```ts
|
|
306
|
-
* import { ethers
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
317
|
-
* await stakingClient.slash('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
279
|
+
* import { ethers } from 'ethers';
|
|
280
|
+
*
|
|
281
|
+
* const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
|
|
282
|
+
* await stakingClient.slash(
|
|
283
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
284
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
285
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
286
|
+
* amount
|
|
287
|
+
* );
|
|
318
288
|
* ```
|
|
319
289
|
*/
|
|
320
290
|
async slash(slasher, staker, escrowAddress, amount, txOptions = {}) {
|
|
@@ -342,21 +312,14 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
342
312
|
/**
|
|
343
313
|
* Retrieves comprehensive staking information for a staker.
|
|
344
314
|
*
|
|
345
|
-
* @param
|
|
346
|
-
* @returns
|
|
347
|
-
*
|
|
348
|
-
* **Code example**
|
|
315
|
+
* @param stakerAddress - The address of the staker.
|
|
316
|
+
* @returns Staking information for the staker
|
|
317
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
349
318
|
*
|
|
319
|
+
* @example
|
|
350
320
|
* ```ts
|
|
351
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
352
|
-
*
|
|
353
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
354
|
-
*
|
|
355
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
356
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
357
|
-
*
|
|
358
321
|
* const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
|
|
359
|
-
* console.log(stakingInfo.
|
|
322
|
+
* console.log('Tokens staked:', stakingInfo.stakedAmount);
|
|
360
323
|
* ```
|
|
361
324
|
*/
|
|
362
325
|
async getStakerInfo(stakerAddress) {
|
|
@@ -418,16 +381,41 @@ __decorate([
|
|
|
418
381
|
__metadata("design:returntype", Promise)
|
|
419
382
|
], StakingClient.prototype, "slash", null);
|
|
420
383
|
/**
|
|
421
|
-
* Utility
|
|
384
|
+
* Utility helpers for Staking-related queries.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```ts
|
|
388
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
389
|
+
*
|
|
390
|
+
* const staker = await StakingUtils.getStaker(
|
|
391
|
+
* ChainId.POLYGON_AMOY,
|
|
392
|
+
* '0xYourStakerAddress'
|
|
393
|
+
* );
|
|
394
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
395
|
+
* ```
|
|
422
396
|
*/
|
|
423
397
|
class StakingUtils {
|
|
424
398
|
/**
|
|
425
399
|
* Gets staking info for a staker from the subgraph.
|
|
426
400
|
*
|
|
427
|
-
* @param
|
|
428
|
-
* @param
|
|
429
|
-
* @param
|
|
430
|
-
* @returns
|
|
401
|
+
* @param chainId - Network in which the staking contract is deployed
|
|
402
|
+
* @param stakerAddress - Address of the staker
|
|
403
|
+
* @param options - Optional configuration for subgraph requests.
|
|
404
|
+
* @returns Staker info from subgraph
|
|
405
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
406
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
407
|
+
* @throws ErrorStakerNotFound If the staker is not found
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
412
|
+
*
|
|
413
|
+
* const staker = await StakingUtils.getStaker(
|
|
414
|
+
* ChainId.POLYGON_AMOY,
|
|
415
|
+
* '0xYourStakerAddress'
|
|
416
|
+
* );
|
|
417
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
418
|
+
* ```
|
|
431
419
|
*/
|
|
432
420
|
static async getStaker(chainId, stakerAddress, options) {
|
|
433
421
|
if (!ethers_1.ethers.isAddress(stakerAddress)) {
|
|
@@ -446,9 +434,22 @@ class StakingUtils {
|
|
|
446
434
|
/**
|
|
447
435
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
448
436
|
*
|
|
449
|
-
* @param
|
|
450
|
-
* @param
|
|
451
|
-
* @returns
|
|
437
|
+
* @param filter - Stakers filter with pagination and ordering
|
|
438
|
+
* @param options - Optional configuration for subgraph requests.
|
|
439
|
+
* @returns Array of stakers
|
|
440
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
445
|
+
*
|
|
446
|
+
* const filter = {
|
|
447
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
448
|
+
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
449
|
+
* };
|
|
450
|
+
* const stakers = await StakingUtils.getStakers(filter);
|
|
451
|
+
* console.log('Stakers:', stakers.length);
|
|
452
|
+
* ```
|
|
452
453
|
*/
|
|
453
454
|
static async getStakers(filter, options) {
|
|
454
455
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|