@human-protocol/sdk 5.2.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/base.d.ts +8 -7
  3. package/dist/base.d.ts.map +1 -1
  4. package/dist/base.js +18 -5
  5. package/dist/constants.d.ts +0 -1
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/constants.js +7 -8
  8. package/dist/encryption.d.ts +68 -203
  9. package/dist/encryption.d.ts.map +1 -1
  10. package/dist/encryption.js +66 -202
  11. package/dist/error.d.ts +0 -24
  12. package/dist/error.d.ts.map +1 -1
  13. package/dist/error.js +2 -26
  14. package/dist/escrow.d.ts +438 -791
  15. package/dist/escrow.d.ts.map +1 -1
  16. package/dist/escrow.js +331 -705
  17. package/dist/graphql/queries/operator.d.ts.map +1 -1
  18. package/dist/graphql/queries/operator.js +3 -1
  19. package/dist/graphql/types.d.ts.map +1 -1
  20. package/dist/index.d.ts +3 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -4
  23. package/dist/interfaces.d.ts +2 -2
  24. package/dist/interfaces.d.ts.map +1 -1
  25. package/dist/kvstore.d.ts +124 -186
  26. package/dist/kvstore.d.ts.map +1 -1
  27. package/dist/kvstore.js +122 -185
  28. package/dist/operator.d.ts +59 -30
  29. package/dist/operator.d.ts.map +1 -1
  30. package/dist/operator.js +59 -30
  31. package/dist/staking.d.ts +142 -141
  32. package/dist/staking.d.ts.map +1 -1
  33. package/dist/staking.js +140 -139
  34. package/dist/statistics.d.ts +104 -134
  35. package/dist/statistics.d.ts.map +1 -1
  36. package/dist/statistics.js +119 -144
  37. package/dist/transaction.d.ts +38 -17
  38. package/dist/transaction.d.ts.map +1 -1
  39. package/dist/transaction.js +40 -19
  40. package/dist/types.d.ts +14 -55
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/utils.d.ts +32 -18
  43. package/dist/utils.d.ts.map +1 -1
  44. package/dist/utils.js +32 -19
  45. package/dist/worker.d.ts +35 -14
  46. package/dist/worker.d.ts.map +1 -1
  47. package/dist/worker.js +35 -14
  48. package/package.json +8 -25
  49. package/src/base.ts +42 -7
  50. package/src/constants.ts +6 -8
  51. package/src/encryption.ts +69 -203
  52. package/src/error.ts +0 -36
  53. package/src/escrow.ts +548 -891
  54. package/src/graphql/queries/operator.ts +3 -1
  55. package/src/graphql/types.ts +4 -2
  56. package/src/index.ts +4 -5
  57. package/src/interfaces.ts +2 -2
  58. package/src/kvstore.ts +142 -197
  59. package/src/operator.ts +59 -30
  60. package/src/staking.ts +177 -160
  61. package/src/statistics.ts +125 -146
  62. package/src/transaction.ts +40 -19
  63. package/src/types.ts +16 -58
  64. package/src/utils.ts +33 -23
  65. package/src/worker.ts +35 -14
  66. package/dist/storage.d.ts +0 -186
  67. package/dist/storage.d.ts.map +0 -1
  68. package/dist/storage.js +0 -319
  69. package/src/storage.ts +0 -313
@@ -15,7 +15,9 @@ const LEADER_FRAGMENT = gql`
15
15
  jobTypes
16
16
  registrationNeeded
17
17
  registrationInstructions
18
- reputationNetworks
18
+ reputationNetworks {
19
+ address
20
+ }
19
21
  name
20
22
  category
21
23
  staker {
@@ -166,8 +166,10 @@ export interface IOperatorSubgraph {
166
166
  } | null;
167
167
  }
168
168
 
169
- export interface IReputationNetworkSubgraph
170
- extends Omit<IReputationNetwork, 'operators'> {
169
+ export interface IReputationNetworkSubgraph extends Omit<
170
+ IReputationNetwork,
171
+ 'operators'
172
+ > {
171
173
  operators: IOperatorSubgraph[];
172
174
  }
173
175
 
package/src/index.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { StakingClient, StakingUtils } from './staking';
2
- import { StorageClient } from './storage';
3
2
  import { KVStoreClient, KVStoreUtils } from './kvstore';
4
3
  import { EscrowClient, EscrowUtils } from './escrow';
5
- import { StatisticsClient } from './statistics';
6
- import { Encryption, EncryptionUtils } from './encryption';
4
+ import { StatisticsUtils } from './statistics';
5
+ import { Encryption, EncryptionUtils, MessageDataType } from './encryption';
7
6
  import { OperatorUtils } from './operator';
8
7
  import { TransactionUtils } from './transaction';
9
8
  import { WorkerUtils } from './worker';
@@ -27,16 +26,16 @@ export {
27
26
 
28
27
  export {
29
28
  StakingClient,
30
- StorageClient,
31
29
  KVStoreClient,
32
30
  KVStoreUtils,
33
31
  EscrowClient,
34
32
  EscrowUtils,
35
- StatisticsClient,
33
+ StatisticsUtils,
36
34
  Encryption,
37
35
  EncryptionUtils,
38
36
  OperatorUtils,
39
37
  TransactionUtils,
40
38
  WorkerUtils,
41
39
  StakingUtils,
40
+ MessageDataType,
42
41
  };
package/src/interfaces.ts CHANGED
@@ -149,8 +149,8 @@ export interface ITransaction {
149
149
 
150
150
  export interface ITransactionsFilter extends IPagination {
151
151
  chainId: ChainId;
152
- startBlock?: number;
153
- endBlock?: number;
152
+ startBlock?: number | bigint;
153
+ endBlock?: number | bigint;
154
154
  startDate?: Date;
155
155
  endDate?: Date;
156
156
  fromAddress?: string;
package/src/kvstore.ts CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  KVStore,
3
3
  KVStore__factory,
4
4
  } from '@human-protocol/core/typechain-types';
5
- import { ContractRunner, Overrides, ethers } from 'ethers';
5
+ import { ContractRunner, ethers } from 'ethers';
6
6
  import { BaseEthersClient } from './base';
7
7
  import { KVStoreKeys, NETWORKS } from './constants';
8
8
  import { requiresSigner } from './decorators';
@@ -17,7 +17,7 @@ import {
17
17
  ErrorUnsupportedChainID,
18
18
  InvalidKeyError,
19
19
  } from './error';
20
- import { NetworkData } from './types';
20
+ import { NetworkData, TransactionOverrides } from './types';
21
21
  import { getSubgraphUrl, customGqlFetch, isValidUrl } from './utils';
22
22
  import {
23
23
  GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY,
@@ -26,12 +26,10 @@ import {
26
26
  import { KVStoreData } from './graphql';
27
27
  import { IKVStore, SubgraphOptions } from './interfaces';
28
28
  /**
29
- * ## Introduction
30
- *
31
- * This client enables performing actions on KVStore contract and obtaining information from both the contracts and subgraph.
29
+ * Client for interacting with the KVStore contract.
32
30
  *
33
31
  * Internally, the SDK will use one network or another according to the network ID of the `runner`.
34
- * To use this client, it is recommended to initialize it using the static `build` method.
32
+ * To use this client, it is recommended to initialize it using the static [`build`](/ts/classes/KVStoreClient/#build) method.
35
33
  *
36
34
  * ```ts
37
35
  * static async build(runner: ContractRunner): Promise<KVStoreClient>;
@@ -42,37 +40,25 @@ import { IKVStore, SubgraphOptions } from './interfaces';
42
40
  * - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
43
41
  * - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
44
42
  *
45
- * ## Installation
46
- *
47
- * ### npm
48
- * ```bash
49
- * npm install @human-protocol/sdk
50
- * ```
51
- *
52
- * ### yarn
53
- * ```bash
54
- * yarn install @human-protocol/sdk
55
- * ```
56
- *
57
- * ## Code example
43
+ * @example
58
44
  *
59
- * ### Signer
45
+ * ###Using Signer
60
46
  *
61
- * **Using private key (backend)**
47
+ * ####Using private key (backend)
62
48
  *
63
49
  * ```ts
64
50
  * import { KVStoreClient } from '@human-protocol/sdk';
65
- * import { Wallet, providers } from 'ethers';
51
+ * import { Wallet, JsonRpcProvider } from 'ethers';
66
52
  *
67
53
  * const rpcUrl = 'YOUR_RPC_URL';
68
54
  * const privateKey = 'YOUR_PRIVATE_KEY';
69
55
  *
70
- * const provider = new providers.JsonRpcProvider(rpcUrl);
56
+ * const provider = new JsonRpcProvider(rpcUrl);
71
57
  * const signer = new Wallet(privateKey, provider);
72
58
  * const kvstoreClient = await KVStoreClient.build(signer);
73
59
  * ```
74
60
  *
75
- * **Using Wagmi (frontend)**
61
+ * ####Using Wagmi (frontend)
76
62
  *
77
63
  * ```ts
78
64
  * import { useSigner, useChainId } from 'wagmi';
@@ -82,27 +68,27 @@ import { IKVStore, SubgraphOptions } from './interfaces';
82
68
  * const kvstoreClient = await KVStoreClient.build(signer);
83
69
  * ```
84
70
  *
85
- * ### Provider
71
+ * ###Using Provider
86
72
  *
87
73
  * ```ts
88
74
  * import { KVStoreClient } from '@human-protocol/sdk';
89
- * import { providers } from 'ethers';
75
+ * import { JsonRpcProvider } from 'ethers';
90
76
  *
91
77
  * const rpcUrl = 'YOUR_RPC_URL';
92
78
  *
93
- * const provider = new providers.JsonRpcProvider(rpcUrl);
79
+ * const provider = new JsonRpcProvider(rpcUrl);
94
80
  * const kvstoreClient = await KVStoreClient.build(provider);
95
81
  * ```
96
82
  */
97
83
 
98
84
  export class KVStoreClient extends BaseEthersClient {
99
- private contract: KVStore;
85
+ public contract: KVStore;
100
86
 
101
87
  /**
102
88
  * **KVStoreClient constructor**
103
89
  *
104
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
105
- * @param {NetworkData} networkData - The network information required to connect to the KVStore contract
90
+ * @param runner - The Runner object to interact with the Ethereum network
91
+ * @param networkData - The network information required to connect to the KVStore contract
106
92
  */
107
93
  constructor(runner: ContractRunner, networkData: NetworkData) {
108
94
  super(runner, networkData);
@@ -116,11 +102,23 @@ export class KVStoreClient extends BaseEthersClient {
116
102
  /**
117
103
  * Creates an instance of KVStoreClient from a runner.
118
104
  *
119
- * @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
105
+ * @param runner - The Runner object to interact with the Ethereum network
106
+ * @returns An instance of KVStoreClient
107
+ * @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
108
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
120
109
  *
121
- * @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
122
- * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
123
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
110
+ * @example
111
+ * ```ts
112
+ * import { KVStoreClient } from '@human-protocol/sdk';
113
+ * import { Wallet, JsonRpcProvider } from 'ethers';
114
+ *
115
+ * const rpcUrl = 'YOUR_RPC_URL';
116
+ * const privateKey = 'YOUR_PRIVATE_KEY';
117
+ *
118
+ * const provider = new JsonRpcProvider(rpcUrl);
119
+ * const signer = new Wallet(privateKey, provider);
120
+ * const kvstoreClient = await KVStoreClient.build(signer);
121
+ * ```
124
122
  */
125
123
  public static async build(runner: ContractRunner): Promise<KVStoreClient> {
126
124
  if (!runner.provider) {
@@ -142,27 +140,15 @@ export class KVStoreClient extends BaseEthersClient {
142
140
  /**
143
141
  * This function sets a key-value pair associated with the address that submits the transaction.
144
142
  *
145
- * @param {string} key Key of the key-value pair
146
- * @param {string} value Value of the key-value pair
147
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
148
- * @returns Returns void if successful. Throws error if any.
149
- *
150
- *
151
- * **Code example**
152
- *
153
- * > Need to have available stake.
143
+ * @param key - Key of the key-value pair
144
+ * @param value - Value of the key-value pair
145
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
146
+ * @returns -
147
+ * @throws ErrorKVStoreEmptyKey If the key is empty
148
+ * @throws Error If the transaction fails
154
149
  *
150
+ * @example
155
151
  * ```ts
156
- * import { Wallet, providers } from 'ethers';
157
- * import { KVStoreClient } from '@human-protocol/sdk';
158
- *
159
- * const rpcUrl = 'YOUR_RPC_URL';
160
- * const privateKey = 'YOUR_PRIVATE_KEY';
161
- *
162
- * const provider = new providers.JsonRpcProvider(rpcUrl);
163
- * const signer = new Wallet(privateKey, provider);
164
- * const kvstoreClient = await KVStoreClient.build(signer);
165
- *
166
152
  * await kvstoreClient.set('Role', 'RecordingOracle');
167
153
  * ```
168
154
  */
@@ -170,11 +156,14 @@ export class KVStoreClient extends BaseEthersClient {
170
156
  public async set(
171
157
  key: string,
172
158
  value: string,
173
- txOptions: Overrides = {}
159
+ txOptions: TransactionOverrides = {}
174
160
  ): Promise<void> {
175
161
  if (key === '') throw ErrorKVStoreEmptyKey;
176
162
  try {
177
- await (await this.contract.set(key, value, txOptions)).wait();
163
+ await this.sendTxAndWait(
164
+ (overrides) => this.contract.set(key, value, overrides),
165
+ txOptions
166
+ );
178
167
  } catch (e) {
179
168
  if (e instanceof Error) throw Error(`Failed to set value: ${e.message}`);
180
169
  }
@@ -183,27 +172,16 @@ export class KVStoreClient extends BaseEthersClient {
183
172
  /**
184
173
  * This function sets key-value pairs in bulk associated with the address that submits the transaction.
185
174
  *
186
- * @param {string[]} keys Array of keys (keys and value must have the same order)
187
- * @param {string[]} values Array of values
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
- *
192
- * **Code example**
193
- *
194
- * > Need to have available stake.
175
+ * @param keys - Array of keys (keys and value must have the same order)
176
+ * @param values - Array of values
177
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
178
+ * @returns -
179
+ * @throws ErrorKVStoreArrayLength If keys and values arrays have different lengths
180
+ * @throws ErrorKVStoreEmptyKey If any key is empty
181
+ * @throws Error If the transaction fails
195
182
  *
183
+ * @example
196
184
  * ```ts
197
- * import { Wallet, providers } from 'ethers';
198
- * import { KVStoreClient } from '@human-protocol/sdk';
199
- *
200
- * const rpcUrl = 'YOUR_RPC_URL';
201
- * const privateKey = 'YOUR_PRIVATE_KEY';
202
- *
203
- * const provider = new providers.JsonRpcProvider(rpcUrl);
204
- * const signer = new Wallet(privateKey, provider);
205
- * const kvstoreClient = await KVStoreClient.build(signer);
206
- *
207
185
  * const keys = ['role', 'webhook_url'];
208
186
  * const values = ['RecordingOracle', 'http://localhost'];
209
187
  * await kvstoreClient.setBulk(keys, values);
@@ -213,13 +191,16 @@ export class KVStoreClient extends BaseEthersClient {
213
191
  public async setBulk(
214
192
  keys: string[],
215
193
  values: string[],
216
- txOptions: Overrides = {}
194
+ txOptions: TransactionOverrides = {}
217
195
  ): Promise<void> {
218
196
  if (keys.length !== values.length) throw ErrorKVStoreArrayLength;
219
197
  if (keys.includes('')) throw ErrorKVStoreEmptyKey;
220
198
 
221
199
  try {
222
- await (await this.contract.setBulk(keys, values, txOptions)).wait();
200
+ await this.sendTxAndWait(
201
+ (overrides) => this.contract.setBulk(keys, values, overrides),
202
+ txOptions
203
+ );
223
204
  } catch (e) {
224
205
  if (e instanceof Error)
225
206
  throw Error(`Failed to set bulk values: ${e.message}`);
@@ -229,25 +210,15 @@ export class KVStoreClient extends BaseEthersClient {
229
210
  /**
230
211
  * Sets a URL value for the address that submits the transaction, and its hash.
231
212
  *
232
- * @param {string} url URL to set
233
- * @param {string | undefined} urlKey Configurable URL key. `url` by default.
234
- * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
235
- * @returns Returns void if successful. Throws error if any.
236
- *
237
- *
238
- * **Code example**
213
+ * @param url - URL to set
214
+ * @param urlKey - Configurable URL key. `url` by default.
215
+ * @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
216
+ * @returns -
217
+ * @throws ErrorInvalidUrl If the URL is invalid
218
+ * @throws Error If the transaction fails
239
219
  *
220
+ * @example
240
221
  * ```ts
241
- * import { Wallet, providers } from 'ethers';
242
- * import { KVStoreClient } from '@human-protocol/sdk';
243
- *
244
- * const rpcUrl = 'YOUR_RPC_URL';
245
- * const privateKey = 'YOUR_PRIVATE_KEY';
246
- *
247
- * const provider = new providers.JsonRpcProvider(rpcUrl);
248
- * const signer = new Wallet(privateKey, provider);
249
- * const kvstoreClient = await KVStoreClient.build(signer);
250
- *
251
222
  * await kvstoreClient.setFileUrlAndHash('example.com');
252
223
  * await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url');
253
224
  * ```
@@ -256,7 +227,7 @@ export class KVStoreClient extends BaseEthersClient {
256
227
  public async setFileUrlAndHash(
257
228
  url: string,
258
229
  urlKey = 'url',
259
- txOptions: Overrides = {}
230
+ txOptions: TransactionOverrides = {}
260
231
  ): Promise<void> {
261
232
  if (!isValidUrl(url)) {
262
233
  throw ErrorInvalidUrl;
@@ -268,13 +239,15 @@ export class KVStoreClient extends BaseEthersClient {
268
239
  const hashKey = urlKey + '_hash';
269
240
 
270
241
  try {
271
- await (
272
- await this.contract.setBulk(
273
- [urlKey, hashKey],
274
- [url, contentHash],
275
- txOptions
276
- )
277
- ).wait();
242
+ await this.sendTxAndWait(
243
+ (overrides) =>
244
+ this.contract.setBulk(
245
+ [urlKey, hashKey],
246
+ [url, contentHash],
247
+ overrides
248
+ ),
249
+ txOptions
250
+ );
278
251
  } catch (e) {
279
252
  if (e instanceof Error)
280
253
  throw Error(`Failed to set URL and hash: ${e.message}`);
@@ -283,26 +256,17 @@ export class KVStoreClient extends BaseEthersClient {
283
256
  /**
284
257
  * Gets the value of a key-value pair in the contract.
285
258
  *
286
- * @param {string} address Address from which to get the key value.
287
- * @param {string} key Key to obtain the value.
288
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
289
- * @returns {string} Value of the key.
290
- *
291
- *
292
- * **Code example**
293
- *
294
- * > Need to have available stake.
259
+ * @param address - Address from which to get the key value.
260
+ * @param key - Key to obtain the value.
261
+ * @returns Value of the key.
262
+ * @throws ErrorKVStoreEmptyKey If the key is empty
263
+ * @throws ErrorInvalidAddress If the address is invalid
264
+ * @throws Error If the contract call fails
295
265
  *
266
+ * @example
296
267
  * ```ts
297
- * import { providers } from 'ethers';
298
- * import { KVStoreClient } from '@human-protocol/sdk';
299
- *
300
- * const rpcUrl = 'YOUR_RPC_URL';
301
- *
302
- * const provider = new providers.JsonRpcProvider(rpcUrl);
303
- * const kvstoreClient = await KVStoreClient.build(provider);
304
- *
305
268
  * const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
269
+ * console.log('Value:', value);
306
270
  * ```
307
271
  */
308
272
  public async get(address: string, key: string): Promise<string> {
@@ -320,55 +284,37 @@ export class KVStoreClient extends BaseEthersClient {
320
284
  }
321
285
 
322
286
  /**
323
- * ## Introduction
324
- *
325
- * Utility class for KVStore-related operations.
326
- *
327
- * ## Installation
328
- *
329
- * ### npm
330
- * ```bash
331
- * npm install @human-protocol/sdk
332
- * ```
333
- *
334
- * ### yarn
335
- * ```bash
336
- * yarn install @human-protocol/sdk
337
- * ```
338
- *
339
- * ## Code example
340
- *
341
- * ### Signer
342
- *
343
- * **Using private key (backend)**
287
+ * Utility helpers for KVStore-related queries.
344
288
  *
289
+ * @example
345
290
  * ```ts
346
291
  * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
347
292
  *
348
- * const KVStoreAddresses = await KVStoreUtils.getKVStoreData(
293
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
349
294
  * ChainId.POLYGON_AMOY,
350
295
  * "0x1234567890123456789012345678901234567890"
351
296
  * );
297
+ * console.log('KVStore data:', kvStoreData);
352
298
  * ```
353
299
  */
354
300
  export class KVStoreUtils {
355
301
  /**
356
302
  * This function returns the KVStore data for a given address.
357
303
  *
358
- * @param {ChainId} chainId Network in which the KVStore is deployed
359
- * @param {string} address Address of the KVStore
360
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
361
- * @returns {Promise<IKVStore[]>} KVStore data
362
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
363
- * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
364
- *
365
- * **Code example**
304
+ * @param chainId - Network in which the KVStore is deployed
305
+ * @param address - Address of the KVStore
306
+ * @param options - Optional configuration for subgraph requests.
307
+ * @returns KVStore data
308
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
309
+ * @throws ErrorInvalidAddress If the address is invalid
366
310
  *
311
+ * @example
367
312
  * ```ts
368
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
369
- *
370
- * const kvStoreData = await KVStoreUtils.getKVStoreData(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
371
- * console.log(kvStoreData);
313
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
314
+ * ChainId.POLYGON_AMOY,
315
+ * "0x1234567890123456789012345678901234567890"
316
+ * );
317
+ * console.log('KVStore data:', kvStoreData);
372
318
  * ```
373
319
  */
374
320
  public static async getKVStoreData(
@@ -404,26 +350,24 @@ export class KVStoreUtils {
404
350
  /**
405
351
  * Gets the value of a key-value pair in the KVStore using the subgraph.
406
352
  *
407
- * @param {ChainId} chainId Network in which the KVStore is deployed
408
- * @param {string} address Address from which to get the key value.
409
- * @param {string} key Key to obtain the value.
410
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
411
- * @returns {Promise<string>} Value of the key.
412
- * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
413
- * @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
414
- * @throws {ErrorKVStoreEmptyKey} - Thrown if the key is empty
415
- *
416
- * **Code example**
417
- *
353
+ * @param chainId - Network in which the KVStore is deployed
354
+ * @param address - Address from which to get the key value.
355
+ * @param key - Key to obtain the value.
356
+ * @param options - Optional configuration for subgraph requests.
357
+ * @returns Value of the key.
358
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
359
+ * @throws ErrorInvalidAddress If the address is invalid
360
+ * @throws ErrorKVStoreEmptyKey If the key is empty
361
+ * @throws InvalidKeyError If the key is not found
362
+ *
363
+ * @example
418
364
  * ```ts
419
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
420
- *
421
- * const chainId = ChainId.POLYGON_AMOY;
422
- * const address = '0x1234567890123456789012345678901234567890';
423
- * const key = 'role';
424
- *
425
- * const value = await KVStoreUtils.get(chainId, address, key);
426
- * console.log(value);
365
+ * const value = await KVStoreUtils.get(
366
+ * ChainId.POLYGON_AMOY,
367
+ * '0x1234567890123456789012345678901234567890',
368
+ * 'role'
369
+ * );
370
+ * console.log('Value:', value);
427
371
  * ```
428
372
  */
429
373
  public static async get(
@@ -458,22 +402,22 @@ export class KVStoreUtils {
458
402
  /**
459
403
  * Gets the URL value of the given entity, and verifies its hash.
460
404
  *
461
- * @param {ChainId} chainId Network in which the KVStore is deployed
462
- * @param {string} address Address from which to get the URL value.
463
- * @param {string} urlKey Configurable URL key. `url` by default.
464
- * @param {SubgraphOptions} options Optional configuration for subgraph requests.
465
- * @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
466
- *
467
- * **Code example**
405
+ * @param chainId - Network in which the KVStore is deployed
406
+ * @param address - Address from which to get the URL value.
407
+ * @param urlKey - Configurable URL key. `url` by default.
408
+ * @param options - Optional configuration for subgraph requests.
409
+ * @returns URL value for the given address if it exists, and the content is valid
410
+ * @throws ErrorInvalidAddress If the address is invalid
411
+ * @throws ErrorInvalidHash If the hash verification fails
412
+ * @throws Error If fetching URL or hash fails
468
413
  *
414
+ * @example
469
415
  * ```ts
470
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
471
- *
472
- * const chainId = ChainId.POLYGON_AMOY;
473
- * const address = '0x1234567890123456789012345678901234567890';
474
- *
475
- * const url = await KVStoreUtils.getFileUrlAndVerifyHash(chainId, address);
476
- * console.log(url);
416
+ * const url = await KVStoreUtils.getFileUrlAndVerifyHash(
417
+ * ChainId.POLYGON_AMOY,
418
+ * '0x1234567890123456789012345678901234567890'
419
+ * );
420
+ * console.log('Verified URL:', url);
477
421
  * ```
478
422
  */
479
423
  public static async getFileUrlAndVerifyHash(
@@ -521,20 +465,21 @@ export class KVStoreUtils {
521
465
  /**
522
466
  * Gets the public key of the given entity, and verifies its hash.
523
467
  *
524
- * @param {ChainId} chainId Network in which the KVStore is deployed
525
- * @param {string} address Address from which to get the public key.
526
- * @returns {Promise<string>} Public key for the given address if it exists, and the content is valid
527
- *
528
- * **Code example**
468
+ * @param chainId - Network in which the KVStore is deployed
469
+ * @param address - Address from which to get the public key.
470
+ * @param options - Optional configuration for subgraph requests.
471
+ * @returns Public key for the given address if it exists, and the content is valid
472
+ * @throws ErrorInvalidAddress If the address is invalid
473
+ * @throws ErrorInvalidHash If the hash verification fails
474
+ * @throws Error If fetching the public key fails
529
475
  *
476
+ * @example
530
477
  * ```ts
531
- * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
532
- *
533
- * const chainId = ChainId.POLYGON_AMOY;
534
- * const address = '0x1234567890123456789012345678901234567890';
535
- *
536
- * const publicKey = await KVStoreUtils.getPublicKey(chainId, address);
537
- * console.log(publicKey);
478
+ * const publicKey = await KVStoreUtils.getPublicKey(
479
+ * ChainId.POLYGON_AMOY,
480
+ * '0x1234567890123456789012345678901234567890'
481
+ * );
482
+ * console.log('Public key:', publicKey);
538
483
  * ```
539
484
  */
540
485
  public static async getPublicKey(