@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.
Files changed (63) hide show
  1. package/dist/base.d.ts +4 -5
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +4 -5
  4. package/dist/constants.js +6 -6
  5. package/dist/encryption.d.ts +68 -203
  6. package/dist/encryption.d.ts.map +1 -1
  7. package/dist/encryption.js +66 -202
  8. package/dist/error.d.ts +0 -24
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/error.js +2 -26
  11. package/dist/escrow.d.ts +427 -780
  12. package/dist/escrow.d.ts.map +1 -1
  13. package/dist/escrow.js +314 -684
  14. package/dist/graphql/queries/operator.d.ts.map +1 -1
  15. package/dist/graphql/queries/operator.js +3 -1
  16. package/dist/graphql/types.d.ts.map +1 -1
  17. package/dist/index.d.ts +3 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -4
  20. package/dist/kvstore.d.ts +119 -181
  21. package/dist/kvstore.d.ts.map +1 -1
  22. package/dist/kvstore.js +119 -182
  23. package/dist/operator.d.ts +59 -30
  24. package/dist/operator.d.ts.map +1 -1
  25. package/dist/operator.js +59 -30
  26. package/dist/staking.d.ts +135 -134
  27. package/dist/staking.d.ts.map +1 -1
  28. package/dist/staking.js +135 -134
  29. package/dist/statistics.d.ts +104 -134
  30. package/dist/statistics.d.ts.map +1 -1
  31. package/dist/statistics.js +119 -144
  32. package/dist/transaction.d.ts +36 -15
  33. package/dist/transaction.d.ts.map +1 -1
  34. package/dist/transaction.js +36 -15
  35. package/dist/types.d.ts +0 -54
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/utils.d.ts +31 -17
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +31 -17
  40. package/dist/worker.d.ts +35 -14
  41. package/dist/worker.d.ts.map +1 -1
  42. package/dist/worker.js +35 -14
  43. package/package.json +7 -24
  44. package/src/base.ts +4 -5
  45. package/src/constants.ts +6 -6
  46. package/src/encryption.ts +69 -203
  47. package/src/error.ts +0 -36
  48. package/src/escrow.ts +425 -780
  49. package/src/graphql/queries/operator.ts +3 -1
  50. package/src/graphql/types.ts +4 -2
  51. package/src/index.ts +4 -5
  52. package/src/kvstore.ts +120 -183
  53. package/src/operator.ts +59 -30
  54. package/src/staking.ts +135 -134
  55. package/src/statistics.ts +125 -146
  56. package/src/transaction.ts +36 -15
  57. package/src/types.ts +0 -57
  58. package/src/utils.ts +31 -17
  59. package/src/worker.ts +35 -14
  60. package/dist/storage.d.ts +0 -186
  61. package/dist/storage.d.ts.map +0 -1
  62. package/dist/storage.js +0 -319
  63. package/src/storage.ts +0 -313
package/dist/operator.js CHANGED
@@ -8,21 +8,40 @@ const error_1 = require("./error");
8
8
  const utils_1 = require("./utils");
9
9
  const enums_1 = require("./enums");
10
10
  const constants_1 = require("./constants");
11
+ /**
12
+ * Utility helpers for operator-related queries.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
17
+ *
18
+ * const operator = await OperatorUtils.getOperator(
19
+ * ChainId.POLYGON_AMOY,
20
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
21
+ * );
22
+ * console.log('Operator:', operator);
23
+ * ```
24
+ */
11
25
  class OperatorUtils {
12
26
  /**
13
27
  * This function returns the operator data for the given address.
14
28
  *
15
- * @param {ChainId} chainId Network in which the operator is deployed
16
- * @param {string} address Operator address.
17
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
18
- * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
19
- *
20
- * **Code example**
29
+ * @param chainId - Network in which the operator is deployed
30
+ * @param address - Operator address.
31
+ * @param options - Optional configuration for subgraph requests.
32
+ * @returns Returns the operator details or null if not found.
33
+ * @throws ErrorInvalidStakerAddressProvided If the address is invalid
34
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
21
35
  *
36
+ * @example
22
37
  * ```ts
23
38
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
24
39
  *
25
- * const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
40
+ * const operator = await OperatorUtils.getOperator(
41
+ * ChainId.POLYGON_AMOY,
42
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
43
+ * );
44
+ * console.log('Operator:', operator);
26
45
  * ```
27
46
  */
28
47
  static async getOperator(chainId, address, options) {
@@ -45,19 +64,20 @@ class OperatorUtils {
45
64
  /**
46
65
  * This function returns all the operator details of the protocol.
47
66
  *
48
- * @param {IOperatorsFilter} filter Filter for the operators.
49
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
50
- * @returns {Promise<IOperator[]>} Returns an array with all the operator details.
51
- *
52
- * **Code example**
67
+ * @param filter - Filter for the operators.
68
+ * @param options - Optional configuration for subgraph requests.
69
+ * @returns Returns an array with all the operator details.
70
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
53
71
  *
72
+ * @example
54
73
  * ```ts
55
- * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
74
+ * import { ChainId } from '@human-protocol/sdk';
56
75
  *
57
- * const filter: IOperatorsFilter = {
58
- * chainId: ChainId.POLYGON
76
+ * const filter = {
77
+ * chainId: ChainId.POLYGON_AMOY
59
78
  * };
60
79
  * const operators = await OperatorUtils.getOperators(filter);
80
+ * console.log('Operators:', operators.length);
61
81
  * ```
62
82
  */
63
83
  static async getOperators(filter, options) {
@@ -95,18 +115,22 @@ class OperatorUtils {
95
115
  /**
96
116
  * Retrieves the reputation network operators of the specified address.
97
117
  *
98
- * @param {ChainId} chainId Network in which the reputation network is deployed
99
- * @param {string} address Address of the reputation oracle.
100
- * @param {string} [role] - (Optional) Role of the operator.
101
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
102
- * @returns {Promise<IOperator[]>} - Returns an array of operator details.
103
- *
104
- * **Code example**
118
+ * @param chainId - Network in which the reputation network is deployed
119
+ * @param address - Address of the reputation oracle.
120
+ * @param role - Role of the operator (optional).
121
+ * @param options - Optional configuration for subgraph requests.
122
+ * @returns Returns an array of operator details.
123
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
105
124
  *
125
+ * @example
106
126
  * ```ts
107
127
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
108
128
  *
109
- * const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
129
+ * const operators = await OperatorUtils.getReputationNetworkOperators(
130
+ * ChainId.POLYGON_AMOY,
131
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
132
+ * );
133
+ * console.log('Operators:', operators.length);
110
134
  * ```
111
135
  */
112
136
  static async getReputationNetworkOperators(chainId, address, role, options) {
@@ -125,17 +149,22 @@ class OperatorUtils {
125
149
  /**
126
150
  * This function returns information about the rewards for a given slasher address.
127
151
  *
128
- * @param {ChainId} chainId Network in which the rewards are deployed
129
- * @param {string} slasherAddress Slasher address.
130
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
131
- * @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
132
- *
133
- * **Code example**
152
+ * @param chainId - Network in which the rewards are deployed
153
+ * @param slasherAddress - Slasher address.
154
+ * @param options - Optional configuration for subgraph requests.
155
+ * @returns Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
156
+ * @throws ErrorInvalidSlasherAddressProvided If the slasher address is invalid
157
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
134
158
  *
159
+ * @example
135
160
  * ```ts
136
161
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
137
162
  *
138
- * const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
163
+ * const rewards = await OperatorUtils.getRewards(
164
+ * ChainId.POLYGON_AMOY,
165
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
166
+ * );
167
+ * console.log('Rewards:', rewards.length);
139
168
  * ```
140
169
  */
141
170
  static async getRewards(chainId, slasherAddress, options) {
package/dist/staking.d.ts CHANGED
@@ -5,9 +5,7 @@ import { ChainId } from './enums';
5
5
  import { IStaker, IStakersFilter, StakerInfo, SubgraphOptions } from './interfaces';
6
6
  import { NetworkData } from './types';
7
7
  /**
8
- * ## Introduction
9
- *
10
- * This client enables performing actions on staking contracts and obtaining staking information from both the contracts and subgraph.
8
+ * Client for staking actions on HUMAN Protocol.
11
9
  *
12
10
  * Internally, the SDK will use one network or another according to the network ID of the `runner`.
13
11
  * To use this client, it is recommended to initialize it using the static `build` method.
@@ -21,37 +19,25 @@ import { NetworkData } from './types';
21
19
  * - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
22
20
  * - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
23
21
  *
24
- * ## Installation
25
- *
26
- * ### npm
27
- * ```bash
28
- * npm install @human-protocol/sdk
29
- * ```
30
- *
31
- * ### yarn
32
- * ```bash
33
- * yarn install @human-protocol/sdk
34
- * ```
35
- *
36
- * ## Code example
22
+ * @example
37
23
  *
38
- * ### Signer
24
+ * ###Using Signer
39
25
  *
40
- * **Using private key (backend)**
26
+ * ####Using private key (backend)
41
27
  *
42
28
  * ```ts
43
29
  * import { StakingClient } from '@human-protocol/sdk';
44
- * import { Wallet, providers } from 'ethers';
30
+ * import { Wallet, JsonRpcProvider } from 'ethers';
45
31
  *
46
32
  * const rpcUrl = 'YOUR_RPC_URL';
47
33
  * const privateKey = 'YOUR_PRIVATE_KEY';
48
34
  *
49
- * const provider = new providers.JsonRpcProvider(rpcUrl);
35
+ * const provider = new JsonRpcProvider(rpcUrl);
50
36
  * const signer = new Wallet(privateKey, provider);
51
37
  * const stakingClient = await StakingClient.build(signer);
52
38
  * ```
53
39
  *
54
- * **Using Wagmi (frontend)**
40
+ * ####Using Wagmi (frontend)
55
41
  *
56
42
  * ```ts
57
43
  * import { useSigner, useChainId } from 'wagmi';
@@ -61,15 +47,15 @@ import { NetworkData } from './types';
61
47
  * const stakingClient = await StakingClient.build(signer);
62
48
  * ```
63
49
  *
64
- * ### Provider
50
+ * ###Using Provider
65
51
  *
66
52
  * ```ts
67
53
  * import { StakingClient } from '@human-protocol/sdk';
68
- * import { providers } from 'ethers';
54
+ * import { JsonRpcProvider } from 'ethers';
69
55
  *
70
56
  * const rpcUrl = 'YOUR_RPC_URL';
71
57
  *
72
- * const provider = new providers.JsonRpcProvider(rpcUrl);
58
+ * const provider = new JsonRpcProvider(rpcUrl);
73
59
  * const stakingClient = await StakingClient.build(provider);
74
60
  * ```
75
61
  */
@@ -80,18 +66,30 @@ export declare class StakingClient extends BaseEthersClient {
80
66
  /**
81
67
  * **StakingClient constructor**
82
68
  *
83
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
84
- * @param {NetworkData} networkData - The network information required to connect to the Staking contract
69
+ * @param runner - The Runner object to interact with the Ethereum network
70
+ * @param networkData - The network information required to connect to the Staking contract
85
71
  */
86
72
  constructor(runner: ContractRunner, networkData: NetworkData);
87
73
  /**
88
74
  * Creates an instance of StakingClient from a Runner.
89
75
  *
90
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
76
+ * @param runner - The Runner object to interact with the Ethereum network
77
+ * @returns An instance of StakingClient
78
+ * @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
79
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
91
80
  *
92
- * @returns {Promise<StakingClient>} - An instance of StakingClient
93
- * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
94
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
81
+ * @example
82
+ * ```ts
83
+ * import { StakingClient } from '@human-protocol/sdk';
84
+ * import { Wallet, JsonRpcProvider } from 'ethers';
85
+ *
86
+ * const rpcUrl = 'YOUR_RPC_URL';
87
+ * const privateKey = 'YOUR_PRIVATE_KEY';
88
+ *
89
+ * const provider = new JsonRpcProvider(rpcUrl);
90
+ * const signer = new Wallet(privateKey, provider);
91
+ * const stakingClient = await StakingClient.build(signer);
92
+ * ```
95
93
  */
96
94
  static build(runner: ContractRunner): Promise<StakingClient>;
97
95
  /**
@@ -103,24 +101,17 @@ export declare class StakingClient extends BaseEthersClient {
103
101
  /**
104
102
  * 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.
105
103
  *
106
- * @param {bigint} amount Amount in WEI of tokens to approve for stake.
107
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
108
- * @returns Returns void if successful. Throws error if any.
109
- *
110
- * **Code example**
104
+ * @param amount - Amount in WEI of tokens to approve for stake.
105
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
106
+ * @returns -
107
+ * @throws ErrorInvalidStakingValueType If the amount is not a bigint
108
+ * @throws ErrorInvalidStakingValueSign If the amount is negative
111
109
  *
110
+ * @example
112
111
  * ```ts
113
- * import { ethers, Wallet, providers } from 'ethers';
114
- * import { StakingClient } from '@human-protocol/sdk';
115
- *
116
- * const rpcUrl = 'YOUR_RPC_URL';
117
- * const privateKey = 'YOUR_PRIVATE_KEY';
112
+ * import { ethers } from 'ethers';
118
113
  *
119
- * const provider = new providers.JsonRpcProvider(rpcUrl);
120
- * const signer = new Wallet(privateKey, provider);
121
- * const stakingClient = await StakingClient.build(signer);
122
- *
123
- * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
114
+ * const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
124
115
  * await stakingClient.approveStake(amount);
125
116
  * ```
126
117
  */
@@ -128,26 +119,20 @@ export declare class StakingClient extends BaseEthersClient {
128
119
  /**
129
120
  * This function stakes a specified amount of tokens on a specific network.
130
121
  *
131
- * > `approveStake` must be called before
132
- *
133
- * @param {bigint} amount Amount in WEI of tokens to stake.
134
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
135
- * @returns Returns void if successful. Throws error if any.
122
+ * !!! note
123
+ * `approveStake` must be called before
136
124
  *
137
- * **Code example**
125
+ * @param amount - Amount in WEI of tokens to stake.
126
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
127
+ * @returns -
128
+ * @throws ErrorInvalidStakingValueType If the amount is not a bigint
129
+ * @throws ErrorInvalidStakingValueSign If the amount is negative
138
130
  *
131
+ * @example
139
132
  * ```ts
140
- * import { ethers, Wallet, providers } from 'ethers';
141
- * import { StakingClient } from '@human-protocol/sdk';
133
+ * import { ethers } from 'ethers';
142
134
  *
143
- * const rpcUrl = 'YOUR_RPC_URL';
144
- * const privateKey = 'YOUR_PRIVATE_KEY';
145
- *
146
- * const provider = new providers.JsonRpcProvider(rpcUrl);
147
- * const signer = new Wallet(privateKey, provider);
148
- * const stakingClient = await StakingClient.build(signer);
149
- *
150
- * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
135
+ * const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
151
136
  * await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
152
137
  * await stakingClient.stake(amount);
153
138
  * ```
@@ -156,51 +141,34 @@ export declare class StakingClient extends BaseEthersClient {
156
141
  /**
157
142
  * This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
158
143
  *
159
- * > Must have tokens available to unstake
160
- *
161
- * @param {bigint} amount Amount in WEI of tokens to unstake.
162
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
163
- * @returns Returns void if successful. Throws error if any.
144
+ * !!! note
145
+ * Must have tokens available to unstake
164
146
  *
165
- * **Code example**
147
+ * @param amount - Amount in WEI of tokens to unstake.
148
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
149
+ * @returns -
150
+ * @throws ErrorInvalidStakingValueType If the amount is not a bigint
151
+ * @throws ErrorInvalidStakingValueSign If the amount is negative
166
152
  *
153
+ * @example
167
154
  * ```ts
168
- * import { ethers, Wallet, providers } from 'ethers';
169
- * import { StakingClient } from '@human-protocol/sdk';
170
- *
171
- * const rpcUrl = 'YOUR_RPC_URL';
172
- * const privateKey = 'YOUR_PRIVATE_KEY';
173
- *
174
- * const provider = new providers.JsonRpcProvider(rpcUrl);
175
- * const signer = new Wallet(privateKey, provider);
176
- * const stakingClient = await StakingClient.build(signer);
155
+ * import { ethers } from 'ethers';
177
156
  *
178
- * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
157
+ * const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
179
158
  * await stakingClient.unstake(amount);
180
159
  * ```
181
160
  */
182
161
  unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
183
162
  /**
184
163
  * This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
164
+ * !!! note
165
+ * Must have tokens available to withdraw
185
166
  *
186
- * > Must have tokens available to withdraw
187
- *
188
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
189
- * @returns Returns void if successful. Throws error if any.
190
- *
191
- * **Code example**
167
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
168
+ * @returns -
192
169
  *
170
+ * @example
193
171
  * ```ts
194
- * import { Wallet, providers } from 'ethers';
195
- * import { StakingClient } from '@human-protocol/sdk';
196
- *
197
- * const rpcUrl = 'YOUR_RPC_URL';
198
- * const privateKey = 'YOUR_PRIVATE_KEY';
199
- *
200
- * const provider = new providers.JsonRpcProvider(rpcUrl);
201
- * const signer = new Wallet(privateKey, provider);
202
- * const stakingClient = await StakingClient.build(signer);
203
- *
204
172
  * await stakingClient.withdraw();
205
173
  * ```
206
174
  */
@@ -208,72 +176,105 @@ export declare class StakingClient extends BaseEthersClient {
208
176
  /**
209
177
  * 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.
210
178
  *
211
- * @param {string} slasher Wallet address from who requested the slash
212
- * @param {string} staker Wallet address from who is going to be slashed
213
- * @param {string} escrowAddress Address of the escrow that the slash is made
214
- * @param {bigint} amount Amount in WEI of tokens to slash.
215
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
216
- * @returns Returns void if successful. Throws error if any.
217
- *
218
- * **Code example**
219
- *
179
+ * @param slasher - Wallet address from who requested the slash
180
+ * @param staker - Wallet address from who is going to be slashed
181
+ * @param escrowAddress - Address of the escrow that the slash is made
182
+ * @param amount - Amount in WEI of tokens to slash.
183
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
184
+ * @returns -
185
+ * @throws ErrorInvalidStakingValueType If the amount is not a bigint
186
+ * @throws ErrorInvalidStakingValueSign If the amount is negative
187
+ * @throws ErrorInvalidSlasherAddressProvided If the slasher address is invalid
188
+ * @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
189
+ * @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
190
+ * @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
191
+ *
192
+ * @example
220
193
  * ```ts
221
- * import { ethers, Wallet, providers } from 'ethers';
222
- * import { StakingClient } from '@human-protocol/sdk';
223
- *
224
- * const rpcUrl = 'YOUR_RPC_URL';
225
- * const privateKey = 'YOUR_PRIVATE_KEY';
226
- *
227
- * const provider = new providers.JsonRpcProvider(rpcUrl);
228
- * const signer = new Wallet(privateKey, provider);
229
- * const stakingClient = await StakingClient.build(signer);
230
- *
231
- * const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
232
- * await stakingClient.slash('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
194
+ * import { ethers } from 'ethers';
195
+ *
196
+ * const amount = ethers.parseUnits('5', 'ether'); //convert from ETH to WEI
197
+ * await stakingClient.slash(
198
+ * '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
199
+ * '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
200
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
201
+ * amount
202
+ * );
233
203
  * ```
234
204
  */
235
205
  slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
236
206
  /**
237
207
  * Retrieves comprehensive staking information for a staker.
238
208
  *
239
- * @param {string} stakerAddress - The address of the staker.
240
- * @returns {Promise<StakerInfo>}
241
- *
242
- * **Code example**
209
+ * @param stakerAddress - The address of the staker.
210
+ * @returns Staking information for the staker
211
+ * @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
243
212
  *
213
+ * @example
244
214
  * ```ts
245
- * import { StakingClient } from '@human-protocol/sdk';
246
- *
247
- * const rpcUrl = 'YOUR_RPC_URL';
248
- *
249
- * const provider = new providers.JsonRpcProvider(rpcUrl);
250
- * const stakingClient = await StakingClient.build(provider);
251
- *
252
215
  * const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
253
- * console.log(stakingInfo.tokensStaked);
216
+ * console.log('Tokens staked:', stakingInfo.stakedAmount);
254
217
  * ```
255
218
  */
256
219
  getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
257
220
  }
258
221
  /**
259
- * Utility class for Staking-related subgraph queries.
222
+ * Utility helpers for Staking-related queries.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * import { StakingUtils, ChainId } from '@human-protocol/sdk';
227
+ *
228
+ * const staker = await StakingUtils.getStaker(
229
+ * ChainId.POLYGON_AMOY,
230
+ * '0xYourStakerAddress'
231
+ * );
232
+ * console.log('Staked amount:', staker.stakedAmount);
233
+ * ```
260
234
  */
261
235
  export declare class StakingUtils {
262
236
  /**
263
237
  * Gets staking info for a staker from the subgraph.
264
238
  *
265
- * @param {ChainId} chainId Network in which the staking contract is deployed
266
- * @param {string} stakerAddress Address of the staker
267
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
268
- * @returns {Promise<IStaker>} Staker info from subgraph
239
+ * @param chainId - Network in which the staking contract is deployed
240
+ * @param stakerAddress - Address of the staker
241
+ * @param options - Optional configuration for subgraph requests.
242
+ * @returns Staker info from subgraph
243
+ * @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
244
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
245
+ * @throws ErrorStakerNotFound If the staker is not found
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * import { StakingUtils, ChainId } from '@human-protocol/sdk';
250
+ *
251
+ * const staker = await StakingUtils.getStaker(
252
+ * ChainId.POLYGON_AMOY,
253
+ * '0xYourStakerAddress'
254
+ * );
255
+ * console.log('Staked amount:', staker.stakedAmount);
256
+ * ```
269
257
  */
270
258
  static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
271
259
  /**
272
260
  * Gets all stakers from the subgraph with filters, pagination and ordering.
273
261
  *
274
- * @param {IStakersFilter} filter Stakers filter with pagination and ordering
275
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
276
- * @returns {Promise<IStaker[]>} Array of stakers
262
+ * @param filter - Stakers filter with pagination and ordering
263
+ * @param options - Optional configuration for subgraph requests.
264
+ * @returns Array of stakers
265
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
266
+ *
267
+ * @example
268
+ * ```ts
269
+ * import { ChainId } from '@human-protocol/sdk';
270
+ *
271
+ * const filter = {
272
+ * chainId: ChainId.POLYGON_AMOY,
273
+ * minStakedAmount: '1000000000000000000', // 1 token in WEI
274
+ * };
275
+ * const stakers = await StakingUtils.getStakers(filter);
276
+ * console.log('Stakers:', stakers.length);
277
+ * ```
277
278
  */
278
279
  static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
279
280
  }
@@ -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;AAC3D,OA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