@human-protocol/sdk 6.0.0 → 7.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 (129) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/base.d.ts +4 -2
  3. package/dist/base.d.ts.map +1 -1
  4. package/dist/base.js +14 -0
  5. package/dist/constants.d.ts +0 -1
  6. package/dist/constants.d.ts.map +1 -1
  7. package/dist/constants.js +27 -16
  8. package/dist/encryption/encryption.d.ts +84 -0
  9. package/dist/encryption/encryption.d.ts.map +1 -0
  10. package/dist/{encryption.js → encryption/encryption.js} +3 -161
  11. package/dist/encryption/encryption_utils.d.ts +101 -0
  12. package/dist/encryption/encryption_utils.d.ts.map +1 -0
  13. package/dist/encryption/encryption_utils.js +191 -0
  14. package/dist/encryption/index.d.ts +4 -0
  15. package/dist/encryption/index.d.ts.map +1 -0
  16. package/dist/encryption/index.js +7 -0
  17. package/dist/encryption/types.d.ts +9 -0
  18. package/dist/encryption/types.d.ts.map +1 -0
  19. package/dist/encryption/types.js +9 -0
  20. package/dist/error.d.ts +6 -10
  21. package/dist/error.d.ts.map +1 -1
  22. package/dist/error.js +12 -14
  23. package/dist/{escrow.d.ts → escrow/escrow_client.d.ts} +16 -196
  24. package/dist/escrow/escrow_client.d.ts.map +1 -0
  25. package/dist/{escrow.js → escrow/escrow_client.js} +50 -430
  26. package/dist/escrow/escrow_utils.d.ts +172 -0
  27. package/dist/escrow/escrow_utils.d.ts.map +1 -0
  28. package/dist/escrow/escrow_utils.js +388 -0
  29. package/dist/escrow/index.d.ts +3 -0
  30. package/dist/escrow/index.d.ts.map +1 -0
  31. package/dist/escrow/index.js +7 -0
  32. package/dist/graphql/queries/statistics.d.ts +1 -0
  33. package/dist/graphql/queries/statistics.d.ts.map +1 -1
  34. package/dist/graphql/queries/statistics.js +36 -2
  35. package/dist/graphql/types.d.ts +3 -1
  36. package/dist/graphql/types.d.ts.map +1 -1
  37. package/dist/index.d.ts +10 -10
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +23 -22
  40. package/dist/interfaces.d.ts +2 -7
  41. package/dist/interfaces.d.ts.map +1 -1
  42. package/dist/kvstore/index.d.ts +3 -0
  43. package/dist/kvstore/index.d.ts.map +1 -0
  44. package/dist/kvstore/index.js +7 -0
  45. package/dist/{kvstore.d.ts → kvstore/kvstore_client.d.ts} +7 -112
  46. package/dist/kvstore/kvstore_client.d.ts.map +1 -0
  47. package/dist/{kvstore.js → kvstore/kvstore_client.js} +25 -187
  48. package/dist/kvstore/kvstore_utils.d.ts +105 -0
  49. package/dist/kvstore/kvstore_utils.d.ts.map +1 -0
  50. package/dist/kvstore/kvstore_utils.js +184 -0
  51. package/dist/operator/index.d.ts +2 -0
  52. package/dist/operator/index.d.ts.map +1 -0
  53. package/dist/operator/index.js +5 -0
  54. package/dist/{operator.d.ts → operator/operator_utils.d.ts} +3 -3
  55. package/dist/operator/operator_utils.d.ts.map +1 -0
  56. package/dist/{operator.js → operator/operator_utils.js} +6 -6
  57. package/dist/staking/index.d.ts +3 -0
  58. package/dist/staking/index.d.ts.map +1 -0
  59. package/dist/staking/index.js +7 -0
  60. package/dist/{staking.d.ts → staking/staking_client.d.ts} +10 -71
  61. package/dist/staking/staking_client.d.ts.map +1 -0
  62. package/dist/{staking.js → staking/staking_client.js} +11 -141
  63. package/dist/staking/staking_utils.d.ts +63 -0
  64. package/dist/staking/staking_utils.d.ts.map +1 -0
  65. package/dist/staking/staking_utils.js +137 -0
  66. package/dist/statistics/index.d.ts +2 -0
  67. package/dist/statistics/index.d.ts.map +1 -0
  68. package/dist/statistics/index.js +5 -0
  69. package/dist/{statistics.d.ts → statistics/statistics_utils.d.ts} +4 -13
  70. package/dist/statistics/statistics_utils.d.ts.map +1 -0
  71. package/dist/{statistics.js → statistics/statistics_utils.js} +8 -22
  72. package/dist/transaction/index.d.ts +2 -0
  73. package/dist/transaction/index.d.ts.map +1 -0
  74. package/dist/transaction/index.js +5 -0
  75. package/dist/{transaction.d.ts → transaction/transaction_utils.d.ts} +5 -5
  76. package/dist/transaction/transaction_utils.d.ts.map +1 -0
  77. package/dist/{transaction.js → transaction/transaction_utils.js} +9 -9
  78. package/dist/types.d.ts +22 -1
  79. package/dist/types.d.ts.map +1 -1
  80. package/dist/utils.d.ts +16 -1
  81. package/dist/utils.d.ts.map +1 -1
  82. package/dist/utils.js +72 -6
  83. package/dist/worker/index.d.ts +2 -0
  84. package/dist/worker/index.d.ts.map +1 -0
  85. package/dist/worker/index.js +5 -0
  86. package/dist/{worker.d.ts → worker/worker_utils.d.ts} +3 -3
  87. package/dist/worker/worker_utils.d.ts.map +1 -0
  88. package/dist/{worker.js → worker/worker_utils.js} +5 -5
  89. package/package.json +5 -5
  90. package/src/base.ts +38 -2
  91. package/src/constants.ts +38 -16
  92. package/src/{encryption.ts → encryption/encryption.ts} +1 -193
  93. package/src/encryption/encryption_utils.ts +179 -0
  94. package/src/encryption/index.ts +3 -0
  95. package/src/encryption/types.ts +15 -0
  96. package/src/error.ts +11 -17
  97. package/src/{escrow.ts → escrow/escrow_client.ts} +151 -659
  98. package/src/escrow/escrow_utils.ts +510 -0
  99. package/src/escrow/index.ts +2 -0
  100. package/src/graphql/queries/statistics.ts +37 -1
  101. package/src/graphql/types.ts +4 -1
  102. package/src/index.ts +11 -25
  103. package/src/interfaces.ts +2 -7
  104. package/src/kvstore/index.ts +2 -0
  105. package/src/kvstore/kvstore_client.ts +291 -0
  106. package/src/kvstore/kvstore_utils.ts +244 -0
  107. package/src/operator/index.ts +1 -0
  108. package/src/{operator.ts → operator/operator_utils.ts} +8 -8
  109. package/src/staking/index.ts +2 -0
  110. package/src/{staking.ts → staking/staking_client.ts} +49 -199
  111. package/src/staking/staking_utils.ts +170 -0
  112. package/src/statistics/index.ts +1 -0
  113. package/src/{statistics.ts → statistics/statistics_utils.ts} +14 -26
  114. package/src/transaction/index.ts +1 -0
  115. package/src/{transaction.ts → transaction/transaction_utils.ts} +11 -11
  116. package/src/types.ts +24 -1
  117. package/src/utils.ts +82 -9
  118. package/src/worker/index.ts +1 -0
  119. package/src/{worker.ts → worker/worker_utils.ts} +7 -7
  120. package/dist/encryption.d.ts +0 -189
  121. package/dist/encryption.d.ts.map +0 -1
  122. package/dist/escrow.d.ts.map +0 -1
  123. package/dist/kvstore.d.ts.map +0 -1
  124. package/dist/operator.d.ts.map +0 -1
  125. package/dist/staking.d.ts.map +0 -1
  126. package/dist/statistics.d.ts.map +0 -1
  127. package/dist/transaction.d.ts.map +0 -1
  128. package/dist/worker.d.ts.map +0 -1
  129. package/src/kvstore.ts +0 -497
@@ -0,0 +1,105 @@
1
+ import { ChainId } from '../enums';
2
+ import { IKVStore, SubgraphOptions } from '../interfaces';
3
+ /**
4
+ * Utility helpers for KVStore-related queries.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
9
+ *
10
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
11
+ * ChainId.POLYGON_AMOY,
12
+ * "0x1234567890123456789012345678901234567890"
13
+ * );
14
+ * console.log('KVStore data:', kvStoreData);
15
+ * ```
16
+ */
17
+ export declare class KVStoreUtils {
18
+ /**
19
+ * This function returns the KVStore data for a given address.
20
+ *
21
+ * @param chainId - Network in which the KVStore is deployed
22
+ * @param address - Address of the KVStore
23
+ * @param options - Optional configuration for subgraph requests.
24
+ * @returns KVStore data
25
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
26
+ * @throws ErrorInvalidAddress If the address is invalid
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
31
+ * ChainId.POLYGON_AMOY,
32
+ * "0x1234567890123456789012345678901234567890"
33
+ * );
34
+ * console.log('KVStore data:', kvStoreData);
35
+ * ```
36
+ */
37
+ static getKVStoreData(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IKVStore[]>;
38
+ /**
39
+ * Gets the value of a key-value pair in the KVStore using the subgraph.
40
+ *
41
+ * @param chainId - Network in which the KVStore is deployed
42
+ * @param address - Address from which to get the key value.
43
+ * @param key - Key to obtain the value.
44
+ * @param options - Optional configuration for subgraph requests.
45
+ * @returns Value of the key.
46
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
47
+ * @throws ErrorInvalidAddress If the address is invalid
48
+ * @throws ErrorKVStoreEmptyKey If the key is empty
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const value = await KVStoreUtils.get(
53
+ * ChainId.POLYGON_AMOY,
54
+ * '0x1234567890123456789012345678901234567890',
55
+ * 'role'
56
+ * );
57
+ * console.log('Value:', value);
58
+ * ```
59
+ */
60
+ static get(chainId: ChainId, address: string, key: string, options?: SubgraphOptions): Promise<string>;
61
+ /**
62
+ * Gets the URL value of the given entity, and verifies its hash.
63
+ *
64
+ * @param chainId - Network in which the KVStore is deployed
65
+ * @param address - Address from which to get the URL value.
66
+ * @param urlKey - Configurable URL key. `url` by default.
67
+ * @param options - Optional configuration for subgraph requests.
68
+ * @returns URL value for the given address if it exists, and the content is valid
69
+ * @throws ErrorInvalidAddress If the address is invalid
70
+ * @throws ErrorInvalidHash If the hash verification fails
71
+ * @throws Error If fetching URL or hash fails
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const url = await KVStoreUtils.getFileUrlAndVerifyHash(
76
+ * ChainId.POLYGON_AMOY,
77
+ * '0x1234567890123456789012345678901234567890'
78
+ * );
79
+ * console.log('Verified URL:', url);
80
+ * ```
81
+ */
82
+ static getFileUrlAndVerifyHash(chainId: ChainId, address: string, urlKey?: string, options?: SubgraphOptions): Promise<string>;
83
+ /**
84
+ * Gets the public key of the given entity, and verifies its hash.
85
+ *
86
+ * @param chainId - Network in which the KVStore is deployed
87
+ * @param address - Address from which to get the public key.
88
+ * @param options - Optional configuration for subgraph requests.
89
+ * @returns Public key for the given address if it exists, and the content is valid
90
+ * @throws ErrorInvalidAddress If the address is invalid
91
+ * @throws ErrorInvalidHash If the hash verification fails
92
+ * @throws Error If fetching the public key fails
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const publicKey = await KVStoreUtils.getPublicKey(
97
+ * ChainId.POLYGON_AMOY,
98
+ * '0x1234567890123456789012345678901234567890'
99
+ * );
100
+ * console.log('Public key:', publicKey);
101
+ * ```
102
+ */
103
+ static getPublicKey(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<string>;
104
+ }
105
+ //# sourceMappingURL=kvstore_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvstore_utils.d.ts","sourceRoot":"","sources":["../../src/kvstore/kvstore_utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAYnC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;;;;;OAkBG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,QAAQ,EAAE,CAAC;IA0BtB;;;;;;;;;;;;;;;;;;;;;OAqBG;WACiB,GAAG,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IAwBlB;;;;;;;;;;;;;;;;;;;;OAoBG;WACiB,uBAAuB,CACzC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,SAAQ,EACd,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;IA8ClB;;;;;;;;;;;;;;;;;;;OAmBG;WACiB,YAAY,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,MAAM,CAAC;CAgBnB"}
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KVStoreUtils = void 0;
4
+ const ethers_1 = require("ethers");
5
+ const constants_1 = require("../constants");
6
+ const error_1 = require("../error");
7
+ const kvstore_1 = require("../graphql/queries/kvstore");
8
+ const utils_1 = require("../utils");
9
+ /**
10
+ * Utility helpers for KVStore-related queries.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
15
+ *
16
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
17
+ * ChainId.POLYGON_AMOY,
18
+ * "0x1234567890123456789012345678901234567890"
19
+ * );
20
+ * console.log('KVStore data:', kvStoreData);
21
+ * ```
22
+ */
23
+ class KVStoreUtils {
24
+ /**
25
+ * This function returns the KVStore data for a given address.
26
+ *
27
+ * @param chainId - Network in which the KVStore is deployed
28
+ * @param address - Address of the KVStore
29
+ * @param options - Optional configuration for subgraph requests.
30
+ * @returns KVStore data
31
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
32
+ * @throws ErrorInvalidAddress If the address is invalid
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const kvStoreData = await KVStoreUtils.getKVStoreData(
37
+ * ChainId.POLYGON_AMOY,
38
+ * "0x1234567890123456789012345678901234567890"
39
+ * );
40
+ * console.log('KVStore data:', kvStoreData);
41
+ * ```
42
+ */
43
+ static async getKVStoreData(chainId, address, options) {
44
+ const networkData = constants_1.NETWORKS[chainId];
45
+ if (!networkData) {
46
+ throw error_1.ErrorUnsupportedChainID;
47
+ }
48
+ if (address && !ethers_1.ethers.isAddress(address)) {
49
+ throw error_1.ErrorInvalidAddress;
50
+ }
51
+ const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_QUERY)(), { address: address.toLowerCase() }, options);
52
+ const kvStoreData = kvstores.map((item) => ({
53
+ key: item.key,
54
+ value: item.value,
55
+ }));
56
+ return kvStoreData || [];
57
+ }
58
+ /**
59
+ * Gets the value of a key-value pair in the KVStore using the subgraph.
60
+ *
61
+ * @param chainId - Network in which the KVStore is deployed
62
+ * @param address - Address from which to get the key value.
63
+ * @param key - Key to obtain the value.
64
+ * @param options - Optional configuration for subgraph requests.
65
+ * @returns Value of the key.
66
+ * @throws ErrorUnsupportedChainID If the network's chainId is not supported
67
+ * @throws ErrorInvalidAddress If the address is invalid
68
+ * @throws ErrorKVStoreEmptyKey If the key is empty
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const value = await KVStoreUtils.get(
73
+ * ChainId.POLYGON_AMOY,
74
+ * '0x1234567890123456789012345678901234567890',
75
+ * 'role'
76
+ * );
77
+ * console.log('Value:', value);
78
+ * ```
79
+ */
80
+ static async get(chainId, address, key, options) {
81
+ if (key === '')
82
+ throw error_1.ErrorKVStoreEmptyKey;
83
+ if (!ethers_1.ethers.isAddress(address))
84
+ throw error_1.ErrorInvalidAddress;
85
+ const networkData = constants_1.NETWORKS[chainId];
86
+ if (!networkData) {
87
+ throw error_1.ErrorUnsupportedChainID;
88
+ }
89
+ const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY)(), { address: address.toLowerCase(), key }, options);
90
+ if (!kvstores || kvstores.length === 0) {
91
+ return '';
92
+ }
93
+ return kvstores[0].value;
94
+ }
95
+ /**
96
+ * Gets the URL value of the given entity, and verifies its hash.
97
+ *
98
+ * @param chainId - Network in which the KVStore is deployed
99
+ * @param address - Address from which to get the URL value.
100
+ * @param urlKey - Configurable URL key. `url` by default.
101
+ * @param options - Optional configuration for subgraph requests.
102
+ * @returns URL value for the given address if it exists, and the content is valid
103
+ * @throws ErrorInvalidAddress If the address is invalid
104
+ * @throws ErrorInvalidHash If the hash verification fails
105
+ * @throws Error If fetching URL or hash fails
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const url = await KVStoreUtils.getFileUrlAndVerifyHash(
110
+ * ChainId.POLYGON_AMOY,
111
+ * '0x1234567890123456789012345678901234567890'
112
+ * );
113
+ * console.log('Verified URL:', url);
114
+ * ```
115
+ */
116
+ static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url', options) {
117
+ if (!ethers_1.ethers.isAddress(address))
118
+ throw error_1.ErrorInvalidAddress;
119
+ const hashKey = urlKey + '_hash';
120
+ let url;
121
+ try {
122
+ url = await this.get(chainId, address, urlKey, options);
123
+ }
124
+ catch (e) {
125
+ if (e instanceof Error) {
126
+ throw Error(`Failed to get URL: ${e.message}`);
127
+ }
128
+ throw e;
129
+ }
130
+ if (!url) {
131
+ throw new Error('No URL found for the given address and key');
132
+ }
133
+ let hash;
134
+ try {
135
+ hash = await this.get(chainId, address, hashKey);
136
+ }
137
+ catch (e) {
138
+ if (e instanceof Error) {
139
+ throw Error(`Failed to get Hash: ${e.message}`);
140
+ }
141
+ throw e;
142
+ }
143
+ if (!hash) {
144
+ throw new Error('No hash found for the given address and url');
145
+ }
146
+ const content = await fetch(url).then((res) => res.text());
147
+ const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
148
+ const formattedHash = hash?.replace(/^0x/, '');
149
+ const formattedContentHash = contentHash?.replace(/^0x/, '');
150
+ if (formattedHash !== formattedContentHash) {
151
+ throw error_1.ErrorInvalidHash;
152
+ }
153
+ return url;
154
+ }
155
+ /**
156
+ * Gets the public key of the given entity, and verifies its hash.
157
+ *
158
+ * @param chainId - Network in which the KVStore is deployed
159
+ * @param address - Address from which to get the public key.
160
+ * @param options - Optional configuration for subgraph requests.
161
+ * @returns Public key for the given address if it exists, and the content is valid
162
+ * @throws ErrorInvalidAddress If the address is invalid
163
+ * @throws ErrorInvalidHash If the hash verification fails
164
+ * @throws Error If fetching the public key fails
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * const publicKey = await KVStoreUtils.getPublicKey(
169
+ * ChainId.POLYGON_AMOY,
170
+ * '0x1234567890123456789012345678901234567890'
171
+ * );
172
+ * console.log('Public key:', publicKey);
173
+ * ```
174
+ */
175
+ static async getPublicKey(chainId, address, options) {
176
+ const publicKeyUrl = await this.getFileUrlAndVerifyHash(chainId, address, constants_1.KVStoreKeys.publicKey, options);
177
+ if (publicKeyUrl === '') {
178
+ return '';
179
+ }
180
+ const publicKey = await fetch(publicKeyUrl).then((res) => res.text());
181
+ return publicKey;
182
+ }
183
+ }
184
+ exports.KVStoreUtils = KVStoreUtils;
@@ -0,0 +1,2 @@
1
+ export { OperatorUtils } from './operator_utils';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperatorUtils = void 0;
4
+ var operator_utils_1 = require("./operator_utils");
5
+ Object.defineProperty(exports, "OperatorUtils", { enumerable: true, get: function () { return operator_utils_1.OperatorUtils; } });
@@ -1,5 +1,5 @@
1
- import { IOperator, IOperatorsFilter, IReward, SubgraphOptions } from './interfaces';
2
- import { ChainId } from './enums';
1
+ import { IOperator, IOperatorsFilter, IReward, SubgraphOptions } from '../interfaces';
2
+ import { ChainId } from '../enums';
3
3
  /**
4
4
  * Utility helpers for operator-related queries.
5
5
  *
@@ -102,4 +102,4 @@ export declare class OperatorUtils {
102
102
  */
103
103
  static getRewards(chainId: ChainId, slasherAddress: string, options?: SubgraphOptions): Promise<IReward[]>;
104
104
  }
105
- //# sourceMappingURL=operator.d.ts.map
105
+ //# sourceMappingURL=operator_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator_utils.d.ts","sourceRoot":"","sources":["../../src/operator/operator_utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,eAAe,EAChB,MAAM,eAAe,CAAC;AAmBvB,OAAO,EAAE,OAAO,EAAkB,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;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"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OperatorUtils = void 0;
4
- const reward_1 = require("./graphql/queries/reward");
5
- const operator_1 = require("./graphql/queries/operator");
4
+ const reward_1 = require("../graphql/queries/reward");
5
+ const operator_1 = require("../graphql/queries/operator");
6
6
  const ethers_1 = require("ethers");
7
- const error_1 = require("./error");
8
- const utils_1 = require("./utils");
9
- const enums_1 = require("./enums");
10
- const constants_1 = require("./constants");
7
+ const error_1 = require("../error");
8
+ const utils_1 = require("../utils");
9
+ const enums_1 = require("../enums");
10
+ const constants_1 = require("../constants");
11
11
  /**
12
12
  * Utility helpers for operator-related queries.
13
13
  *
@@ -0,0 +1,3 @@
1
+ export { StakingClient } from './staking_client';
2
+ export { StakingUtils } from './staking_utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/staking/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StakingUtils = exports.StakingClient = void 0;
4
+ var staking_client_1 = require("./staking_client");
5
+ Object.defineProperty(exports, "StakingClient", { enumerable: true, get: function () { return staking_client_1.StakingClient; } });
6
+ var staking_utils_1 = require("./staking_utils");
7
+ Object.defineProperty(exports, "StakingUtils", { enumerable: true, get: function () { return staking_utils_1.StakingUtils; } });
@@ -1,9 +1,8 @@
1
1
  import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
2
- import { ContractRunner, Overrides } from 'ethers';
3
- import { BaseEthersClient } from './base';
4
- import { ChainId } from './enums';
5
- import { IStaker, IStakersFilter, StakerInfo, SubgraphOptions } from './interfaces';
6
- import { NetworkData } from './types';
2
+ import { ContractRunner } from 'ethers';
3
+ import { BaseEthersClient } from '../base';
4
+ import { StakerInfo } from '../interfaces';
5
+ import { NetworkData, TransactionOverrides } from '../types';
7
6
  /**
8
7
  * Client for staking actions on HUMAN Protocol.
9
8
  *
@@ -115,7 +114,7 @@ export declare class StakingClient extends BaseEthersClient {
115
114
  * await stakingClient.approveStake(amount);
116
115
  * ```
117
116
  */
118
- approveStake(amount: bigint, txOptions?: Overrides): Promise<void>;
117
+ approveStake(amount: bigint, txOptions?: TransactionOverrides): Promise<void>;
119
118
  /**
120
119
  * This function stakes a specified amount of tokens on a specific network.
121
120
  *
@@ -137,7 +136,7 @@ export declare class StakingClient extends BaseEthersClient {
137
136
  * await stakingClient.stake(amount);
138
137
  * ```
139
138
  */
140
- stake(amount: bigint, txOptions?: Overrides): Promise<void>;
139
+ stake(amount: bigint, txOptions?: TransactionOverrides): Promise<void>;
141
140
  /**
142
141
  * This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
143
142
  *
@@ -158,7 +157,7 @@ export declare class StakingClient extends BaseEthersClient {
158
157
  * await stakingClient.unstake(amount);
159
158
  * ```
160
159
  */
161
- unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
160
+ unstake(amount: bigint, txOptions?: TransactionOverrides): Promise<void>;
162
161
  /**
163
162
  * This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
164
163
  * !!! note
@@ -172,7 +171,7 @@ export declare class StakingClient extends BaseEthersClient {
172
171
  * await stakingClient.withdraw();
173
172
  * ```
174
173
  */
175
- withdraw(txOptions?: Overrides): Promise<void>;
174
+ withdraw(txOptions?: TransactionOverrides): Promise<void>;
176
175
  /**
177
176
  * 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.
178
177
  *
@@ -202,7 +201,7 @@ export declare class StakingClient extends BaseEthersClient {
202
201
  * );
203
202
  * ```
204
203
  */
205
- slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
204
+ slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: TransactionOverrides): Promise<void>;
206
205
  /**
207
206
  * Retrieves comprehensive staking information for a staker.
208
207
  *
@@ -218,64 +217,4 @@ export declare class StakingClient extends BaseEthersClient {
218
217
  */
219
218
  getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
220
219
  }
221
- /**
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
- * ```
234
- */
235
- export declare class StakingUtils {
236
- /**
237
- * Gets staking info for a staker from the subgraph.
238
- *
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
- * ```
257
- */
258
- static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
259
- /**
260
- * Gets all stakers from the subgraph with filters, pagination and ordering.
261
- *
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
- * ```
278
- */
279
- static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
280
- }
281
- //# sourceMappingURL=staking.d.ts.map
220
+ //# sourceMappingURL=staking_client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staking_client.d.ts","sourceRoot":"","sources":["../../src/staking/staking_client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAU,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAc3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAmB5D;;;;;;;;;;;;;;;;;;;;OAoBG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;OAgBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC;IAyBhB;;;;;;;;;;;;;;;;;;;;OAoBG;IAEU,KAAK,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;;;;;;;;;;;;;;;;OAmBG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;;;;;;;;;OAYG;IAEU,QAAQ,CAAC,SAAS,GAAE,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC;IAsChB;;;;;;;;;;;;OAYG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiCvE"}