@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/kvstore.js CHANGED
@@ -19,12 +19,10 @@ const error_1 = require("./error");
19
19
  const utils_1 = require("./utils");
20
20
  const kvstore_1 = require("./graphql/queries/kvstore");
21
21
  /**
22
- * ## Introduction
23
- *
24
- * This client enables performing actions on KVStore contract and obtaining information from both the contracts and subgraph.
22
+ * Client for interacting with the KVStore contract.
25
23
  *
26
24
  * Internally, the SDK will use one network or another according to the network ID of the `runner`.
27
- * To use this client, it is recommended to initialize it using the static `build` method.
25
+ * To use this client, it is recommended to initialize it using the static [`build`](/ts/classes/KVStoreClient/#build) method.
28
26
  *
29
27
  * ```ts
30
28
  * static async build(runner: ContractRunner): Promise<KVStoreClient>;
@@ -35,37 +33,25 @@ const kvstore_1 = require("./graphql/queries/kvstore");
35
33
  * - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
36
34
  * - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
37
35
  *
38
- * ## Installation
39
- *
40
- * ### npm
41
- * ```bash
42
- * npm install @human-protocol/sdk
43
- * ```
44
- *
45
- * ### yarn
46
- * ```bash
47
- * yarn install @human-protocol/sdk
48
- * ```
49
- *
50
- * ## Code example
36
+ * @example
51
37
  *
52
- * ### Signer
38
+ * ###Using Signer
53
39
  *
54
- * **Using private key (backend)**
40
+ * ####Using private key (backend)
55
41
  *
56
42
  * ```ts
57
43
  * import { KVStoreClient } from '@human-protocol/sdk';
58
- * import { Wallet, providers } from 'ethers';
44
+ * import { Wallet, JsonRpcProvider } from 'ethers';
59
45
  *
60
46
  * const rpcUrl = 'YOUR_RPC_URL';
61
47
  * const privateKey = 'YOUR_PRIVATE_KEY';
62
48
  *
63
- * const provider = new providers.JsonRpcProvider(rpcUrl);
49
+ * const provider = new JsonRpcProvider(rpcUrl);
64
50
  * const signer = new Wallet(privateKey, provider);
65
51
  * const kvstoreClient = await KVStoreClient.build(signer);
66
52
  * ```
67
53
  *
68
- * **Using Wagmi (frontend)**
54
+ * ####Using Wagmi (frontend)
69
55
  *
70
56
  * ```ts
71
57
  * import { useSigner, useChainId } from 'wagmi';
@@ -75,15 +61,15 @@ const kvstore_1 = require("./graphql/queries/kvstore");
75
61
  * const kvstoreClient = await KVStoreClient.build(signer);
76
62
  * ```
77
63
  *
78
- * ### Provider
64
+ * ###Using Provider
79
65
  *
80
66
  * ```ts
81
67
  * import { KVStoreClient } from '@human-protocol/sdk';
82
- * import { providers } from 'ethers';
68
+ * import { JsonRpcProvider } from 'ethers';
83
69
  *
84
70
  * const rpcUrl = 'YOUR_RPC_URL';
85
71
  *
86
- * const provider = new providers.JsonRpcProvider(rpcUrl);
72
+ * const provider = new JsonRpcProvider(rpcUrl);
87
73
  * const kvstoreClient = await KVStoreClient.build(provider);
88
74
  * ```
89
75
  */
@@ -91,8 +77,8 @@ class KVStoreClient extends base_1.BaseEthersClient {
91
77
  /**
92
78
  * **KVStoreClient constructor**
93
79
  *
94
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
95
- * @param {NetworkData} networkData - The network information required to connect to the KVStore contract
80
+ * @param runner - The Runner object to interact with the Ethereum network
81
+ * @param networkData - The network information required to connect to the KVStore contract
96
82
  */
97
83
  constructor(runner, networkData) {
98
84
  super(runner, networkData);
@@ -101,11 +87,23 @@ class KVStoreClient extends base_1.BaseEthersClient {
101
87
  /**
102
88
  * Creates an instance of KVStoreClient from a runner.
103
89
  *
104
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
90
+ * @param runner - The Runner object to interact with the Ethereum network
91
+ * @returns An instance of KVStoreClient
92
+ * @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
93
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
105
94
  *
106
- * @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
107
- * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
108
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
95
+ * @example
96
+ * ```ts
97
+ * import { KVStoreClient } from '@human-protocol/sdk';
98
+ * import { Wallet, JsonRpcProvider } from 'ethers';
99
+ *
100
+ * const rpcUrl = 'YOUR_RPC_URL';
101
+ * const privateKey = 'YOUR_PRIVATE_KEY';
102
+ *
103
+ * const provider = new JsonRpcProvider(rpcUrl);
104
+ * const signer = new Wallet(privateKey, provider);
105
+ * const kvstoreClient = await KVStoreClient.build(signer);
106
+ * ```
109
107
  */
110
108
  static async build(runner) {
111
109
  if (!runner.provider) {
@@ -122,27 +120,15 @@ class KVStoreClient extends base_1.BaseEthersClient {
122
120
  /**
123
121
  * This function sets a key-value pair associated with the address that submits the transaction.
124
122
  *
125
- * @param {string} key Key of the key-value pair
126
- * @param {string} value Value of the key-value pair
127
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
128
- * @returns Returns void if successful. Throws error if any.
129
- *
130
- *
131
- * **Code example**
132
- *
133
- * > Need to have available stake.
123
+ * @param key - Key of the key-value pair
124
+ * @param value - Value of the key-value pair
125
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
126
+ * @returns -
127
+ * @throws ErrorKVStoreEmptyKey If the key is empty
128
+ * @throws Error If the transaction fails
134
129
  *
130
+ * @example
135
131
  * ```ts
136
- * import { Wallet, providers } from 'ethers';
137
- * import { KVStoreClient } from '@human-protocol/sdk';
138
- *
139
- * const rpcUrl = 'YOUR_RPC_URL';
140
- * const privateKey = 'YOUR_PRIVATE_KEY';
141
- *
142
- * const provider = new providers.JsonRpcProvider(rpcUrl);
143
- * const signer = new Wallet(privateKey, provider);
144
- * const kvstoreClient = await KVStoreClient.build(signer);
145
- *
146
132
  * await kvstoreClient.set('Role', 'RecordingOracle');
147
133
  * ```
148
134
  */
@@ -160,27 +146,16 @@ class KVStoreClient extends base_1.BaseEthersClient {
160
146
  /**
161
147
  * This function sets key-value pairs in bulk associated with the address that submits the transaction.
162
148
  *
163
- * @param {string[]} keys Array of keys (keys and value must have the same order)
164
- * @param {string[]} values Array of values
165
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
166
- * @returns Returns void if successful. Throws error if any.
167
- *
168
- *
169
- * **Code example**
170
- *
171
- * > Need to have available stake.
149
+ * @param keys - Array of keys (keys and value must have the same order)
150
+ * @param values - Array of values
151
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
152
+ * @returns -
153
+ * @throws ErrorKVStoreArrayLength If keys and values arrays have different lengths
154
+ * @throws ErrorKVStoreEmptyKey If any key is empty
155
+ * @throws Error If the transaction fails
172
156
  *
157
+ * @example
173
158
  * ```ts
174
- * import { Wallet, providers } from 'ethers';
175
- * import { KVStoreClient } from '@human-protocol/sdk';
176
- *
177
- * const rpcUrl = 'YOUR_RPC_URL';
178
- * const privateKey = 'YOUR_PRIVATE_KEY';
179
- *
180
- * const provider = new providers.JsonRpcProvider(rpcUrl);
181
- * const signer = new Wallet(privateKey, provider);
182
- * const kvstoreClient = await KVStoreClient.build(signer);
183
- *
184
159
  * const keys = ['role', 'webhook_url'];
185
160
  * const values = ['RecordingOracle', 'http://localhost'];
186
161
  * await kvstoreClient.setBulk(keys, values);
@@ -202,25 +177,15 @@ class KVStoreClient extends base_1.BaseEthersClient {
202
177
  /**
203
178
  * Sets a URL value for the address that submits the transaction, and its hash.
204
179
  *
205
- * @param {string} url URL to set
206
- * @param {string | undefined} urlKey Configurable URL key. `url` by default.
207
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
208
- * @returns Returns void if successful. Throws error if any.
209
- *
210
- *
211
- * **Code example**
180
+ * @param url - URL to set
181
+ * @param urlKey - Configurable URL key. `url` by default.
182
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
183
+ * @returns -
184
+ * @throws ErrorInvalidUrl If the URL is invalid
185
+ * @throws Error If the transaction fails
212
186
  *
187
+ * @example
213
188
  * ```ts
214
- * import { Wallet, providers } from 'ethers';
215
- * import { KVStoreClient } from '@human-protocol/sdk';
216
- *
217
- * const rpcUrl = 'YOUR_RPC_URL';
218
- * const privateKey = 'YOUR_PRIVATE_KEY';
219
- *
220
- * const provider = new providers.JsonRpcProvider(rpcUrl);
221
- * const signer = new Wallet(privateKey, provider);
222
- * const kvstoreClient = await KVStoreClient.build(signer);
223
- *
224
189
  * await kvstoreClient.setFileUrlAndHash('example.com');
225
190
  * await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url');
226
191
  * ```
@@ -243,26 +208,17 @@ class KVStoreClient extends base_1.BaseEthersClient {
243
208
  /**
244
209
  * Gets the value of a key-value pair in the contract.
245
210
  *
246
- * @param {string} address Address from which to get the key value.
247
- * @param {string} key Key to obtain the value.
248
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
249
- * @returns {string} Value of the key.
250
- *
251
- *
252
- * **Code example**
253
- *
254
- * > Need to have available stake.
211
+ * @param address - Address from which to get the key value.
212
+ * @param key - Key to obtain the value.
213
+ * @returns Value of the key.
214
+ * @throws ErrorKVStoreEmptyKey If the key is empty
215
+ * @throws ErrorInvalidAddress If the address is invalid
216
+ * @throws Error If the contract call fails
255
217
  *
218
+ * @example
256
219
  * ```ts
257
- * import { providers } from 'ethers';
258
- * import { KVStoreClient } from '@human-protocol/sdk';
259
- *
260
- * const rpcUrl = 'YOUR_RPC_URL';
261
- *
262
- * const provider = new providers.JsonRpcProvider(rpcUrl);
263
- * const kvstoreClient = await KVStoreClient.build(provider);
264
- *
265
220
  * const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
221
+ * console.log('Value:', value);
266
222
  * ```
267
223
  */
268
224
  async get(address, key) {
@@ -301,55 +257,37 @@ __decorate([
301
257
  __metadata("design:returntype", Promise)
302
258
  ], KVStoreClient.prototype, "setFileUrlAndHash", null);
303
259
  /**
304
- * ## Introduction
305
- *
306
- * Utility class for KVStore-related operations.
307
- *
308
- * ## Installation
309
- *
310
- * ### npm
311
- * ```bash
312
- * npm install @human-protocol/sdk
313
- * ```
314
- *
315
- * ### yarn
316
- * ```bash
317
- * yarn install @human-protocol/sdk
318
- * ```
319
- *
320
- * ## Code example
321
- *
322
- * ### Signer
323
- *
324
- * **Using private key (backend)**
260
+ * Utility helpers for KVStore-related queries.
325
261
  *
262
+ * @example
326
263
  * ```ts
327
264
  * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
328
265
  *
329
- * const KVStoreAddresses = await KVStoreUtils.getKVStoreData(
266
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
330
267
  * ChainId.POLYGON_AMOY,
331
268
  * "0x1234567890123456789012345678901234567890"
332
269
  * );
270
+ * console.log('KVStore data:', kvStoreData);
333
271
  * ```
334
272
  */
335
273
  class KVStoreUtils {
336
274
  /**
337
275
  * This function returns the KVStore data for a given address.
338
276
  *
339
- * @param {ChainId} chainId Network in which the KVStore is deployed
340
- * @param {string} address Address of the KVStore
341
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
342
- * @returns {Promise<IKVStore[]>} KVStore data
343
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
344
- * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
345
- *
346
- * **Code example**
277
+ * @param chainId - Network in which the KVStore is deployed
278
+ * @param address - Address of the KVStore
279
+ * @param options - Optional configuration for subgraph requests.
280
+ * @returns KVStore data
281
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
282
+ * @throws ErrorInvalidAddress If the address is invalid
347
283
  *
284
+ * @example
348
285
  * ```ts
349
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
350
- *
351
- * const kvStoreData = await KVStoreUtils.getKVStoreData(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
352
- * console.log(kvStoreData);
286
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
287
+ * ChainId.POLYGON_AMOY,
288
+ * "0x1234567890123456789012345678901234567890"
289
+ * );
290
+ * console.log('KVStore data:', kvStoreData);
353
291
  * ```
354
292
  */
355
293
  static async getKVStoreData(chainId, address, options) {
@@ -370,26 +308,24 @@ class KVStoreUtils {
370
308
  /**
371
309
  * Gets the value of a key-value pair in the KVStore using the subgraph.
372
310
  *
373
- * @param {ChainId} chainId Network in which the KVStore is deployed
374
- * @param {string} address Address from which to get the key value.
375
- * @param {string} key Key to obtain the value.
376
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
377
- * @returns {Promise<string>} Value of the key.
378
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
379
- * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
380
- * @throws {ErrorKVStoreEmptyKey} - Thrown if the key is empty
381
- *
382
- * **Code example**
383
- *
311
+ * @param chainId - Network in which the KVStore is deployed
312
+ * @param address - Address from which to get the key value.
313
+ * @param key - Key to obtain the value.
314
+ * @param options - Optional configuration for subgraph requests.
315
+ * @returns Value of the key.
316
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
317
+ * @throws ErrorInvalidAddress If the address is invalid
318
+ * @throws ErrorKVStoreEmptyKey If the key is empty
319
+ * @throws InvalidKeyError If the key is not found
320
+ *
321
+ * @example
384
322
  * ```ts
385
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
386
- *
387
- * const chainId = ChainId.POLYGON_AMOY;
388
- * const address = '0x1234567890123456789012345678901234567890';
389
- * const key = 'role';
390
- *
391
- * const value = await KVStoreUtils.get(chainId, address, key);
392
- * console.log(value);
323
+ * const value = await KVStoreUtils.get(
324
+ * ChainId.POLYGON_AMOY,
325
+ * '0x1234567890123456789012345678901234567890',
326
+ * 'role'
327
+ * );
328
+ * console.log('Value:', value);
393
329
  * ```
394
330
  */
395
331
  static async get(chainId, address, key, options) {
@@ -410,22 +346,22 @@ class KVStoreUtils {
410
346
  /**
411
347
  * Gets the URL value of the given entity, and verifies its hash.
412
348
  *
413
- * @param {ChainId} chainId Network in which the KVStore is deployed
414
- * @param {string} address Address from which to get the URL value.
415
- * @param {string} urlKey Configurable URL key. `url` by default.
416
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
417
- * @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
418
- *
419
- * **Code example**
349
+ * @param chainId - Network in which the KVStore is deployed
350
+ * @param address - Address from which to get the URL value.
351
+ * @param urlKey - Configurable URL key. `url` by default.
352
+ * @param options - Optional configuration for subgraph requests.
353
+ * @returns URL value for the given address if it exists, and the content is valid
354
+ * @throws ErrorInvalidAddress If the address is invalid
355
+ * @throws ErrorInvalidHash If the hash verification fails
356
+ * @throws Error If fetching URL or hash fails
420
357
  *
358
+ * @example
421
359
  * ```ts
422
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
423
- *
424
- * const chainId = ChainId.POLYGON_AMOY;
425
- * const address = '0x1234567890123456789012345678901234567890';
426
- *
427
- * const url = await KVStoreUtils.getFileUrlAndVerifyHash(chainId, address);
428
- * console.log(url);
360
+ * const url = await KVStoreUtils.getFileUrlAndVerifyHash(
361
+ * ChainId.POLYGON_AMOY,
362
+ * '0x1234567890123456789012345678901234567890'
363
+ * );
364
+ * console.log('Verified URL:', url);
429
365
  * ```
430
366
  */
431
367
  static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url', options) {
@@ -463,20 +399,21 @@ class KVStoreUtils {
463
399
  /**
464
400
  * Gets the public key of the given entity, and verifies its hash.
465
401
  *
466
- * @param {ChainId} chainId Network in which the KVStore is deployed
467
- * @param {string} address Address from which to get the public key.
468
- * @returns {Promise<string>} Public key for the given address if it exists, and the content is valid
469
- *
470
- * **Code example**
402
+ * @param chainId - Network in which the KVStore is deployed
403
+ * @param address - Address from which to get the public key.
404
+ * @param options - Optional configuration for subgraph requests.
405
+ * @returns Public key for the given address if it exists, and the content is valid
406
+ * @throws ErrorInvalidAddress If the address is invalid
407
+ * @throws ErrorInvalidHash If the hash verification fails
408
+ * @throws Error If fetching the public key fails
471
409
  *
410
+ * @example
472
411
  * ```ts
473
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
474
- *
475
- * const chainId = ChainId.POLYGON_AMOY;
476
- * const address = '0x1234567890123456789012345678901234567890';
477
- *
478
- * const publicKey = await KVStoreUtils.getPublicKey(chainId, address);
479
- * console.log(publicKey);
412
+ * const publicKey = await KVStoreUtils.getPublicKey(
413
+ * ChainId.POLYGON_AMOY,
414
+ * '0x1234567890123456789012345678901234567890'
415
+ * );
416
+ * console.log('Public key:', publicKey);
480
417
  * ```
481
418
  */
482
419
  static async getPublicKey(chainId, address, options) {
@@ -1,74 +1,103 @@
1
1
  import { IOperator, IOperatorsFilter, IReward, SubgraphOptions } from './interfaces';
2
2
  import { ChainId } from './enums';
3
+ /**
4
+ * Utility helpers for operator-related queries.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
9
+ *
10
+ * const operator = await OperatorUtils.getOperator(
11
+ * ChainId.POLYGON_AMOY,
12
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
13
+ * );
14
+ * console.log('Operator:', operator);
15
+ * ```
16
+ */
3
17
  export declare class OperatorUtils {
4
18
  /**
5
19
  * This function returns the operator data for the given address.
6
20
  *
7
- * @param {ChainId} chainId Network in which the operator is deployed
8
- * @param {string} address Operator address.
9
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
10
- * @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
11
- *
12
- * **Code example**
21
+ * @param chainId - Network in which the operator is deployed
22
+ * @param address - Operator address.
23
+ * @param options - Optional configuration for subgraph requests.
24
+ * @returns Returns the operator details or null if not found.
25
+ * @throws ErrorInvalidStakerAddressProvided If the address is invalid
26
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
13
27
  *
28
+ * @example
14
29
  * ```ts
15
30
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
16
31
  *
17
- * const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
32
+ * const operator = await OperatorUtils.getOperator(
33
+ * ChainId.POLYGON_AMOY,
34
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
35
+ * );
36
+ * console.log('Operator:', operator);
18
37
  * ```
19
38
  */
20
39
  static getOperator(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IOperator | null>;
21
40
  /**
22
41
  * This function returns all the operator details of the protocol.
23
42
  *
24
- * @param {IOperatorsFilter} filter Filter for the operators.
25
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
26
- * @returns {Promise<IOperator[]>} Returns an array with all the operator details.
27
- *
28
- * **Code example**
43
+ * @param filter - Filter for the operators.
44
+ * @param options - Optional configuration for subgraph requests.
45
+ * @returns Returns an array with all the operator details.
46
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
29
47
  *
48
+ * @example
30
49
  * ```ts
31
- * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
50
+ * import { ChainId } from '@human-protocol/sdk';
32
51
  *
33
- * const filter: IOperatorsFilter = {
34
- * chainId: ChainId.POLYGON
52
+ * const filter = {
53
+ * chainId: ChainId.POLYGON_AMOY
35
54
  * };
36
55
  * const operators = await OperatorUtils.getOperators(filter);
56
+ * console.log('Operators:', operators.length);
37
57
  * ```
38
58
  */
39
59
  static getOperators(filter: IOperatorsFilter, options?: SubgraphOptions): Promise<IOperator[]>;
40
60
  /**
41
61
  * Retrieves the reputation network operators of the specified address.
42
62
  *
43
- * @param {ChainId} chainId Network in which the reputation network is deployed
44
- * @param {string} address Address of the reputation oracle.
45
- * @param {string} [role] - (Optional) Role of the operator.
46
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
47
- * @returns {Promise<IOperator[]>} - Returns an array of operator details.
48
- *
49
- * **Code example**
63
+ * @param chainId - Network in which the reputation network is deployed
64
+ * @param address - Address of the reputation oracle.
65
+ * @param role - Role of the operator (optional).
66
+ * @param options - Optional configuration for subgraph requests.
67
+ * @returns Returns an array of operator details.
68
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
50
69
  *
70
+ * @example
51
71
  * ```ts
52
72
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
53
73
  *
54
- * const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
74
+ * const operators = await OperatorUtils.getReputationNetworkOperators(
75
+ * ChainId.POLYGON_AMOY,
76
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
77
+ * );
78
+ * console.log('Operators:', operators.length);
55
79
  * ```
56
80
  */
57
81
  static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string, options?: SubgraphOptions): Promise<IOperator[]>;
58
82
  /**
59
83
  * This function returns information about the rewards for a given slasher address.
60
84
  *
61
- * @param {ChainId} chainId Network in which the rewards are deployed
62
- * @param {string} slasherAddress Slasher address.
63
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
64
- * @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
65
- *
66
- * **Code example**
85
+ * @param chainId - Network in which the rewards are deployed
86
+ * @param slasherAddress - Slasher address.
87
+ * @param options - Optional configuration for subgraph requests.
88
+ * @returns Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
89
+ * @throws ErrorInvalidSlasherAddressProvided If the slasher address is invalid
90
+ * @throws ErrorUnsupportedChainID If the chain ID is not supported
67
91
  *
92
+ * @example
68
93
  * ```ts
69
94
  * import { OperatorUtils, ChainId } from '@human-protocol/sdk';
70
95
  *
71
- * const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
96
+ * const rewards = await OperatorUtils.getRewards(
97
+ * ChainId.POLYGON_AMOY,
98
+ * '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
99
+ * );
100
+ * console.log('Rewards:', rewards.length);
72
101
  * ```
73
102
  */
74
103
  static getRewards(chainId: ChainId, slasherAddress: string, options?: SubgraphOptions): Promise<IReward[]>;
@@ -1 +1 @@
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"}
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;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;;;;;;OAoBG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAwB5B;;;;;;;;;;;;;;;;;;OAkBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+CvB;;;;;;;;;;;;;;;;;;;;OAoBG;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;;;;;;;;;;;;;;;;;;;;OAoBG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CA8BtB"}