@obolnetwork/obol-sdk 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/cjs/package.json +11 -6
- package/dist/cjs/src/ajv.js +27 -0
- package/dist/cjs/src/constants.js +8 -4
- package/dist/cjs/src/index.js +21 -18
- package/dist/cjs/src/schema.js +8 -0
- package/dist/cjs/src/services.js +1 -1
- package/dist/cjs/src/utils.js +3 -3
- package/dist/cjs/src/verification/common.js +19 -7
- package/dist/cjs/src/verification/termsAndConditions.js +1 -1
- package/dist/cjs/src/verification/v1.6.0.js +1 -1
- package/dist/cjs/src/verification/v1.7.0.js +3 -3
- package/dist/cjs/src/verification/v1.8.0.js +3 -3
- package/dist/cjs/test/fixtures.js +71 -82
- package/dist/cjs/test/methods.test.js +54 -27
- package/dist/esm/package.json +11 -6
- package/dist/esm/src/ajv.js +27 -0
- package/dist/esm/src/base.js +1 -1
- package/dist/esm/src/constants.js +7 -3
- package/dist/esm/src/index.js +22 -19
- package/dist/esm/src/schema.js +8 -0
- package/dist/esm/src/services.js +1 -1
- package/dist/esm/src/utils.js +3 -3
- package/dist/esm/src/verification/common.js +27 -15
- package/dist/esm/src/verification/sszTypes.js +1 -1
- package/dist/esm/src/verification/termsAndConditions.js +1 -1
- package/dist/esm/src/verification/v1.6.0.js +5 -5
- package/dist/esm/src/verification/v1.7.0.js +8 -8
- package/dist/esm/src/verification/v1.8.0.js +8 -8
- package/dist/esm/test/fixtures.js +71 -82
- package/dist/esm/test/methods.test.js +55 -28
- package/dist/types/src/constants.d.ts +3 -1
- package/dist/types/src/index.d.ts +11 -9
- package/dist/types/src/schema.d.ts +8 -0
- package/dist/types/src/services.d.ts +1 -1
- package/dist/types/src/types.d.ts +18 -18
- package/package.json +12 -7
- package/src/ajv.ts +38 -7
- package/src/base.ts +22 -18
- package/src/constants.ts +42 -36
- package/src/errors.ts +4 -4
- package/src/index.ts +96 -84
- package/src/schema.ts +10 -2
- package/src/services.ts +7 -7
- package/src/types.ts +65 -65
- package/src/utils.ts +17 -17
- package/src/verification/common.ts +374 -333
- package/src/verification/sszTypes.ts +60 -51
- package/src/verification/termsAndConditions.ts +16 -14
- package/src/verification/v1.6.0.ts +214 -184
- package/src/verification/v1.7.0.ts +268 -233
- package/src/verification/v1.8.0.ts +266 -225
|
@@ -187,133 +187,122 @@ exports.clusterConfigV1X8 = {
|
|
|
187
187
|
withdrawal_address: '0xE0C5ceA4D3869F156717C66E188Ae81C80914a6e',
|
|
188
188
|
},
|
|
189
189
|
],
|
|
190
|
-
deposit_amounts: [
|
|
191
|
-
'8000000000',
|
|
192
|
-
'16000000000',
|
|
193
|
-
'8000000000'
|
|
194
|
-
],
|
|
190
|
+
deposit_amounts: ['8000000000', '16000000000', '8000000000'],
|
|
195
191
|
};
|
|
196
192
|
exports.clusterLockV1X8 = {
|
|
197
193
|
cluster_definition: {
|
|
198
|
-
name: '
|
|
194
|
+
name: 'xxxx',
|
|
199
195
|
creator: {
|
|
200
|
-
address: '
|
|
201
|
-
config_signature: '
|
|
196
|
+
address: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
197
|
+
config_signature: '0xd30b182fadbc2c5b2bb3f3f6ed6ac2588f297ceb610ed5509bf3e5a25a9b30c70f8a09ef1d2c8e1dbe5ff441299fe66ec677734cc08beec87e94b7effcb089701b',
|
|
202
198
|
},
|
|
203
199
|
operators: [
|
|
204
200
|
{
|
|
205
|
-
address: '
|
|
206
|
-
enr: 'enr:-
|
|
207
|
-
config_signature: '
|
|
208
|
-
enr_signature: '
|
|
201
|
+
address: '0x86B8145c98e5BD25BA722645b15eD65f024a87EC',
|
|
202
|
+
enr: 'enr:-HW4QLlrtMjFLGkFT1bwdGbvZQlH8hLi0M2g44JAxEYP3BZmYpcsy9Q56HPPD87fMucjvLv4-obEFacpsg0ehRilbHeAgmlkgnY0iXNlY3AyNTZrMaEDRaa5o2aSgqyFq_ERZcQTztrOij1mFtXX1bJuVI6ieak',
|
|
203
|
+
config_signature: '0x3df771ecfc9ae2d01da9249dc636a42893e48759c0fa5c51f5e5e14f3ea4513233d1e3bbdd0e11d4b67c8a907201fd08225a75a1e2d6f510a439d6b15f0c36341c',
|
|
204
|
+
enr_signature: '0x3fe2a124dabe3d517e4c274074b3529d36d9528ca6fa8a4e74ef356f86a07c1462fe72a5336421c2647be7babc4ce1835c2101133e0779cf81d4a8d8cb9fe5591c',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
address: '0xC35CfCd67b9C27345a54EDEcC1033F2284148c81',
|
|
208
|
+
enr: 'enr:-Iu4QNbiUUUwT18LynBbVPJhNxvzQsaSpUr40mQTWscnZaqKb6vAlvV8j-eDDR3E0wjMQumGRbGm2IAb5_k4bVWJiVGAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPOiodUji0ohgJb5sNK1hgv8g6xO5_znZz3NkkBkyYyKIN0Y3CCDhqDdWRwgg4u',
|
|
209
|
+
config_signature: '0x12d19d6fc4c1a5d9e7be09f47c2f2357dd89f47aba8ae0185f5345e08bcc3adc324bdd51e68a12c3ca34c604d786cfde5f0798aa928dac496edb16c70e7086551b',
|
|
210
|
+
enr_signature: '0xa3d49832dfaf0ad87c5796f9bc151009343da70b91fd53bee3645baa63d001d3207662da8f67b3a20f2ee30c9cacb24a5719a78dc24e030c8ac93e7b3b46bf881b',
|
|
209
211
|
},
|
|
210
212
|
{
|
|
211
|
-
address: '
|
|
212
|
-
enr: 'enr:-
|
|
213
|
-
config_signature: '
|
|
214
|
-
enr_signature: '
|
|
213
|
+
address: '0x33807D6F1DCe44b9C599fFE03640762A6F08C496',
|
|
214
|
+
enr: 'enr:-Iu4QJyserRukhG0Vgi2csu7GjpHYUGufNEbZ8Q7ZBrcZUb0KqpL5QzHonkh1xxHlxatTxrIcX_IS5J3SEWR_sa0ptGAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQMAUgEqczOjevyculnUIofhCj0DkgJudErM7qCYIvIkzIN0Y3CCDhqDdWRwgg4u',
|
|
215
|
+
config_signature: '0x665d287c46921aad0dde389291b982f24dbbeb4b7ce5ee7bbc4a7d1fb55134f7136889eb3ce70208a7f276b9d4aefb1fbc6159476934567e5bf11765b2c9649b1b',
|
|
216
|
+
enr_signature: '0xc32d5ea29569b01354d48ddaf56df1481a5ae618ffb47602ef40e0e77357de5f23a5258923be5fa06ecce20f5692847860c25c38b97a4e306c94decd99c0519a1b',
|
|
215
217
|
},
|
|
216
218
|
{
|
|
217
|
-
address: '
|
|
218
|
-
enr: 'enr:-
|
|
219
|
-
config_signature: '
|
|
220
|
-
enr_signature: '
|
|
221
|
-
}
|
|
219
|
+
address: '0xc6e76F72Ea672FAe05C357157CfC37720F0aF26f',
|
|
220
|
+
enr: 'enr:-HW4QKJTwXC6Chw6zbnA3HFZi6Jo0DkIgjKy4eUBpsSOGnAeWE6ChEjEyk_6R6Qrm7jI-iqfs3_HYxiKde8vFgvHHrCAgmlkgnY0iXNlY3AyNTZrMaECfFKQH4spdZCHqrKVz1Q02xYla6J_RQECDNNYBRWdzv8',
|
|
221
|
+
config_signature: '0x610f7be9c7c38878cde1cb391de08eee2f86e62f31f450843b4e37164e738fc8769046e53ad1f018f54ddaf858ff372d22169702c60d68bda19c96fdd20150b61c',
|
|
222
|
+
enr_signature: '0xe2977c79f63b8fe6cb6551efec0cf69041c7f4aaa8ea338997a397450ee946023b03ccb70ad3cc97b1319e1eea9f7472a2ca161bc8b33acdcde689d84c7e771c1b',
|
|
223
|
+
},
|
|
222
224
|
],
|
|
223
|
-
uuid: '
|
|
225
|
+
uuid: 'bc2fec0c-0b8b-4415-bf48-1e96b07f50eb',
|
|
224
226
|
version: 'v1.8.0',
|
|
225
|
-
timestamp: '2024-
|
|
227
|
+
timestamp: '2024-05-24T15:04:08.322Z',
|
|
226
228
|
num_validators: 2,
|
|
227
229
|
threshold: 3,
|
|
228
230
|
validators: [
|
|
229
231
|
{
|
|
230
|
-
fee_recipient_address: '
|
|
231
|
-
withdrawal_address: '
|
|
232
|
+
fee_recipient_address: '0x7aC193bF9a9C6e6DD6302969E8Ea6EdF6df490d8',
|
|
233
|
+
withdrawal_address: '0x9e0AC0078F10d28E875577bb3A4A9EDAB60c03EC',
|
|
232
234
|
},
|
|
233
235
|
{
|
|
234
|
-
fee_recipient_address: '
|
|
235
|
-
withdrawal_address: '
|
|
236
|
-
}
|
|
237
|
-
],
|
|
238
|
-
dkg_algorithm: 'frost',
|
|
239
|
-
fork_version: '0x00001020',
|
|
240
|
-
deposit_amounts: [
|
|
241
|
-
'8000000000',
|
|
242
|
-
'16000000000',
|
|
243
|
-
'8000000000'
|
|
236
|
+
fee_recipient_address: '0x7aC193bF9a9C6e6DD6302969E8Ea6EdF6df490d8',
|
|
237
|
+
withdrawal_address: '0x9e0AC0078F10d28E875577bb3A4A9EDAB60c03EC',
|
|
238
|
+
},
|
|
244
239
|
],
|
|
245
|
-
|
|
246
|
-
|
|
240
|
+
dkg_algorithm: 'default',
|
|
241
|
+
fork_version: '0x01017000',
|
|
242
|
+
deposit_amounts: ['32000000000'],
|
|
243
|
+
config_hash: '0xb2601f51d277f699acb8ea3b9fb4fc68087c0f1f2c6ae83d00fdd853a6cddb31',
|
|
244
|
+
definition_hash: '0x2a9d52b1dd13fd91661d81e3786512ffdcc3689e2ec97105add153f543c642b4',
|
|
247
245
|
},
|
|
248
246
|
distributed_validators: [
|
|
249
247
|
{
|
|
250
|
-
distributed_public_key: '
|
|
248
|
+
distributed_public_key: '0xa33ae80f967a669d8df3ae769acc114577fab185d53e10154b0b50cc0cf9b9f35e466a318f174e8cecdc12173d95cb27',
|
|
251
249
|
public_shares: [
|
|
252
|
-
'
|
|
253
|
-
'
|
|
254
|
-
'
|
|
250
|
+
'0x849db297f690a26e76d5930f99eac9e3f95d9232256d6e39124fe071745b43c8b5418c733b06683aa240a2a0e44b9b8f',
|
|
251
|
+
'0xa1051bf5692153d5bc418946763bb5c82780a05e97bd5b258ea7abe6705047628edd8277366f6b5d0469abfee18988d9',
|
|
252
|
+
'0x87d0342e5dc49a0a0c8f08ec011da3bd859a333bfc46ddd0a194485aa5aa954b7c18d05a2c1ae148d4dc45331101f496',
|
|
253
|
+
'0xa4fa0e971e1a5e38ebe89c6457bc9316b3dd0933660b17e1c717ac148f8340a5db20d867c7a24758c701f6b6bec4d552',
|
|
255
254
|
],
|
|
256
255
|
builder_registration: {
|
|
257
256
|
message: {
|
|
258
|
-
fee_recipient: '
|
|
257
|
+
fee_recipient: '0x7ac193bf9a9c6e6dd6302969e8ea6edf6df490d8',
|
|
259
258
|
gas_limit: 30000000,
|
|
260
|
-
timestamp:
|
|
261
|
-
pubkey: '
|
|
259
|
+
timestamp: 1696000704,
|
|
260
|
+
pubkey: '0xa33ae80f967a669d8df3ae769acc114577fab185d53e10154b0b50cc0cf9b9f35e466a318f174e8cecdc12173d95cb27',
|
|
262
261
|
},
|
|
263
|
-
signature: '
|
|
262
|
+
signature: '0xb39977fe7c45bab28cfd1bcf356a71b0557187a75e0dfa0facaf5eddba05988c0da85800a4b4528704df44f280913ebc125eb3f9c091d6dd220c92dfcc3c80bc7a9ed2f1b96bffaeaa1053cf117b02b48eb755139c5623b6e61dd92c27d15813',
|
|
264
263
|
},
|
|
265
264
|
partial_deposit_data: [
|
|
266
265
|
{
|
|
267
|
-
pubkey: '
|
|
268
|
-
withdrawal_credentials: '
|
|
269
|
-
amount: '
|
|
270
|
-
signature: '
|
|
266
|
+
pubkey: '0xa33ae80f967a669d8df3ae769acc114577fab185d53e10154b0b50cc0cf9b9f35e466a318f174e8cecdc12173d95cb27',
|
|
267
|
+
withdrawal_credentials: '0x0100000000000000000000009e0ac0078f10d28e875577bb3a4a9edab60c03ec',
|
|
268
|
+
amount: '32000000000',
|
|
269
|
+
signature: '0x9861022ca71cf18aad49a201b023356b8c5ca090086614b681cb84a54327caeff53c0a71c5f55f49976114bb86de2ad6052d174d7948e6c8a924d9bfbbbc2181fad967d818454c6c4f7cffb7bb93dc2c4f4c87fc5598cb4582fa08eff0c7bc08',
|
|
271
270
|
},
|
|
272
|
-
|
|
273
|
-
pubkey: '0x87382e8cc3e2c9c2d03ac1af7ae0bcc1be468c596a8a8b8059153ca9ce7746d459dd0603858e858355cb96d67a2a87a7',
|
|
274
|
-
withdrawal_credentials: '0x01000000000000000000000081855ad8681d0d86d1e91e00167939cb6694d2c4',
|
|
275
|
-
amount: '16000000000',
|
|
276
|
-
signature: '0xac5bcb369e8dde110604f6ae829a3432f82a99b0a996e15f4be6426acbe690a1aadb4b365d8b10a36737b2cd8c7f561214d4e4df3626cc9664f663111d15efbd8d18cffff5c3eff407fe2cc478244caea7f9f2afee83a0ae8aa2587365b8e54a'
|
|
277
|
-
}
|
|
278
|
-
]
|
|
271
|
+
],
|
|
279
272
|
},
|
|
280
273
|
{
|
|
281
|
-
distributed_public_key: '
|
|
274
|
+
distributed_public_key: '0xaa888bf805bec7da7ac18dea3afefbf5b8510cbf76367229dab830b3ecdd4533b9d50fb9fcb454df5cbe08e4b31e8479',
|
|
282
275
|
public_shares: [
|
|
283
|
-
'
|
|
284
|
-
'
|
|
285
|
-
'
|
|
276
|
+
'0x8279ae646839d946a622d096296ffcccd289e8c49ea2308560bbb731c63d4b49ea46db817a955e47634edbded4919d82',
|
|
277
|
+
'0xa8a12b5b645b015c55515b3220395e015fc051c58bf243e1b638770652c67f863852f9190e3e182aa86b99823b4cf28d',
|
|
278
|
+
'0xb0c557f812060bb1c409e5324c7b54f35fee8f1180c714e60784f7df6a58e3ba3da6cc8b3cebc01975f9f41efcd777cb',
|
|
279
|
+
'0xa7a8576c3b21221f2a6adefc41b4c1f979ee0761e9a7ff50d30434d1a0c4e7fc505b308636801925e698286b802de421',
|
|
286
280
|
],
|
|
287
281
|
builder_registration: {
|
|
288
282
|
message: {
|
|
289
|
-
fee_recipient: '
|
|
283
|
+
fee_recipient: '0x7ac193bf9a9c6e6dd6302969e8ea6edf6df490d8',
|
|
290
284
|
gas_limit: 30000000,
|
|
291
|
-
timestamp:
|
|
292
|
-
pubkey: '
|
|
285
|
+
timestamp: 1696000704,
|
|
286
|
+
pubkey: '0xaa888bf805bec7da7ac18dea3afefbf5b8510cbf76367229dab830b3ecdd4533b9d50fb9fcb454df5cbe08e4b31e8479',
|
|
293
287
|
},
|
|
294
|
-
signature: '
|
|
288
|
+
signature: '0x8dcb54028adb8f5601b6ab20ded381dabb6739b3e506df795a279043997908c7d38a68b8e8dda27516165f18e437a84603935bfefc1a83befbd1a90ac43fcc7fb0eed81122852a2ee71fef414aa8879198da239527036b0eaebcdc88d6eca3d1',
|
|
295
289
|
},
|
|
296
290
|
partial_deposit_data: [
|
|
297
291
|
{
|
|
298
|
-
pubkey: '
|
|
299
|
-
withdrawal_credentials: '
|
|
300
|
-
amount: '
|
|
301
|
-
signature: '
|
|
292
|
+
pubkey: '0xaa888bf805bec7da7ac18dea3afefbf5b8510cbf76367229dab830b3ecdd4533b9d50fb9fcb454df5cbe08e4b31e8479',
|
|
293
|
+
withdrawal_credentials: '0x0100000000000000000000009e0ac0078f10d28e875577bb3a4a9edab60c03ec',
|
|
294
|
+
amount: '32000000000',
|
|
295
|
+
signature: '0x95ee68e5191d34e10f567ab0f565cd927211b29be9ab830d39bf74d0486aee7bff78d8fe12d455cb40ec707378eea1040a9d80806f82afa58295de9d4db2dccc48cfaf3c98e9020c6b5c8a9aacf5bbfc7e316871f505000304d9d39b7ad5c5d8',
|
|
302
296
|
},
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
withdrawal_credentials: '0x0100000000000000000000005fb90badb37c5821b6d95526a41a9504680b4e7c',
|
|
306
|
-
amount: '16000000000',
|
|
307
|
-
signature: '0x94d9db7b4527e6eb308d387f168089a51d1deffc2c985faf1f7f8e82fbc9cb93c7f10c6a7bbca4fc25a1cfc95de28432037cf7727c1db0ad6d1fb0f1813d5904fba4ab8aebfeccfcded2f915bd48fb46155131b24adb0ba5e764d7ff6d3c82a5'
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
}
|
|
297
|
+
],
|
|
298
|
+
},
|
|
311
299
|
],
|
|
312
|
-
signature_aggregate: '
|
|
313
|
-
lock_hash: '
|
|
300
|
+
signature_aggregate: '0x81ab6319191e3b9065f14231a71fe480b4a45e5e5db4a064faa19a31d04b9cb55fa88b8aa3c966b054b97ae7db2233ee060ae333c5ca3a55ed16b9a3de1894087901cb2d3a177de1cd40030c93301c23ca3edd28dfd1ad04e210b7e2c7625f89',
|
|
301
|
+
lock_hash: '0x186e7e61fb49373d9034d101f2f08429cb379bfcc2f7fa5e9598e8a14ae13ed7',
|
|
314
302
|
node_signatures: [
|
|
315
|
-
'
|
|
316
|
-
'
|
|
317
|
-
'
|
|
318
|
-
|
|
303
|
+
'0xd4b1b6f7b363015b9d1c1c4f199fffc3f9238b7326fdfc5059b175519b05c90a022a18bf2e3eae7d7b0e833384131c2e7be17cc78f6ca23644ae345904dc2d2601',
|
|
304
|
+
'0xc186f930d8d281ab3999fb0ff62b5d96045a4e2330d9d8b300d5d1014f6b4bd925d9c2fedbb53047a49d4008f82600f46e1131b981222c5e423c12b1c9fd544900',
|
|
305
|
+
'0xbc0831fa82b1a70e17eb4fe6f79249a8f5aab1d1f196dd07e32766eb27e72354757d7146b64fca4ad4efa554f7a5d4e7ef835aab6348e9afa37c9eeab069ff4e01',
|
|
306
|
+
'0x0135f307831fa58ff64f9af46e00b92e2375162646af88f6991ba6f98a8c262f2c41846af59da68eadb8ff9c94db42ee8005bd4236e5897635573db2911460aa00',
|
|
307
|
+
],
|
|
319
308
|
};
|
|
@@ -45,51 +45,72 @@ describe('Cluster Client', () => {
|
|
|
45
45
|
clientInstance['request'] = jest
|
|
46
46
|
.fn()
|
|
47
47
|
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
48
|
-
const configHash = yield clientInstance.createClusterDefinition(fixtures_js_1.
|
|
48
|
+
const configHash = yield clientInstance.createClusterDefinition(fixtures_js_1.clusterConfigV1X8);
|
|
49
49
|
expect(configHash).toEqual(mockConfigHash);
|
|
50
50
|
}));
|
|
51
51
|
test('acceptClusterDefinition should return cluster definition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
clientInstance['request'] = jest
|
|
53
53
|
.fn()
|
|
54
|
-
.mockReturnValue(Promise.resolve(fixtures_js_1.
|
|
54
|
+
.mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8.cluster_definition));
|
|
55
55
|
const clusterDefinition = yield clientInstance.acceptClusterDefinition({
|
|
56
|
-
enr: fixtures_js_1.
|
|
57
|
-
version: fixtures_js_1.
|
|
58
|
-
}, fixtures_js_1.
|
|
59
|
-
expect(clusterDefinition).toEqual(fixtures_js_1.
|
|
56
|
+
enr: fixtures_js_1.clusterLockV1X8.cluster_definition.operators[0].enr,
|
|
57
|
+
version: fixtures_js_1.clusterLockV1X8.cluster_definition.version,
|
|
58
|
+
}, fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
59
|
+
expect(clusterDefinition).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition);
|
|
60
60
|
}));
|
|
61
61
|
test('createClusterDefinition should throw an error on invalid operators', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
62
|
clientInstance['request'] = jest
|
|
63
63
|
.fn()
|
|
64
64
|
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
65
65
|
try {
|
|
66
|
-
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({}, fixtures_js_1.
|
|
66
|
+
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({}, fixtures_js_1.clusterConfigV1X8), { operators: [] }));
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
69
|
expect(error.message).toEqual("Schema compilation errors', must NOT have fewer than 4 items");
|
|
70
70
|
}
|
|
71
71
|
}));
|
|
72
|
+
// cause we default to 32000000000
|
|
73
|
+
test('createClusterDefinition should accept a configuration without deposit_amounts', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
clientInstance['request'] = jest
|
|
75
|
+
.fn()
|
|
76
|
+
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
77
|
+
const configHash = yield clientInstance.createClusterDefinition(Object.assign({}, fixtures_js_1.clusterConfigV1X7));
|
|
78
|
+
expect(configHash).toEqual(mockConfigHash);
|
|
79
|
+
}));
|
|
80
|
+
test('createClusterDefinition should throw on not valid deposit_amounts ', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
clientInstance['request'] = jest
|
|
82
|
+
.fn()
|
|
83
|
+
.mockReturnValue(Promise.resolve({ config_hash: mockConfigHash }));
|
|
84
|
+
try {
|
|
85
|
+
yield clientInstance.createClusterDefinition(Object.assign(Object.assign({}, fixtures_js_1.clusterConfigV1X7), { deposit_amounts: ['34000000'] }));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
expect(error.message).toEqual('Schema compilation errors\', must pass "validDepositAmounts" keyword validation');
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
72
91
|
test('validatePayload should throw an error on empty schema', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
92
|
try {
|
|
74
|
-
(0, ajv_1.validatePayload)(Object.assign(Object.assign({}, fixtures_js_1.
|
|
93
|
+
(0, ajv_1.validatePayload)(Object.assign(Object.assign({}, fixtures_js_1.clusterConfigV1X8), { operators: [] }), '');
|
|
75
94
|
}
|
|
76
95
|
catch (error) {
|
|
77
96
|
expect(error.message).toEqual('schema must be object or boolean');
|
|
78
97
|
}
|
|
79
98
|
}));
|
|
80
99
|
test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
var _c;
|
|
81
101
|
clientInstance['request'] = jest
|
|
82
102
|
.fn()
|
|
83
|
-
.mockReturnValue(Promise.resolve(fixtures_js_1.
|
|
84
|
-
const clusterDefinition = yield clientInstance.getClusterDefinition(fixtures_js_1.
|
|
85
|
-
expect(clusterDefinition.
|
|
103
|
+
.mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8.cluster_definition));
|
|
104
|
+
const clusterDefinition = yield clientInstance.getClusterDefinition(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
105
|
+
expect((_c = clusterDefinition.deposit_amounts) === null || _c === void 0 ? void 0 : _c.length).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.deposit_amounts.length);
|
|
106
|
+
expect(clusterDefinition.config_hash).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
86
107
|
}));
|
|
87
108
|
test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
109
|
clientInstance['request'] = jest
|
|
89
110
|
.fn()
|
|
90
|
-
.mockReturnValue(Promise.resolve(fixtures_js_1.
|
|
91
|
-
const clusterLock = yield clientInstance.getClusterLock(fixtures_js_1.
|
|
92
|
-
expect(clusterLock.lock_hash).toEqual(fixtures_js_1.
|
|
111
|
+
.mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8));
|
|
112
|
+
const clusterLock = yield clientInstance.getClusterLock(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
113
|
+
expect(clusterLock.lock_hash).toEqual(fixtures_js_1.clusterLockV1X8.lock_hash);
|
|
93
114
|
}));
|
|
94
115
|
test('request method should set user agent header', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
116
|
const server = (0, node_1.setupServer)(msw_1.http.get('http://testexample.com/test', ({ request }) => {
|
|
@@ -106,7 +127,9 @@ describe('Cluster Client', () => {
|
|
|
106
127
|
});
|
|
107
128
|
}
|
|
108
129
|
}
|
|
109
|
-
const testBaseInstance = new TestBase({
|
|
130
|
+
const testBaseInstance = new TestBase({
|
|
131
|
+
baseUrl: 'http://testExample.com',
|
|
132
|
+
});
|
|
110
133
|
const result = yield testBaseInstance.callProtectedRequest('/test', {
|
|
111
134
|
method: 'GET',
|
|
112
135
|
});
|
|
@@ -121,7 +144,7 @@ describe('Cluster Client without a signer', () => {
|
|
|
121
144
|
});
|
|
122
145
|
test('createClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
146
|
try {
|
|
124
|
-
yield clientInstance.createClusterDefinition(fixtures_js_1.
|
|
147
|
+
yield clientInstance.createClusterDefinition(fixtures_js_1.clusterConfigV1X8);
|
|
125
148
|
}
|
|
126
149
|
catch (err) {
|
|
127
150
|
expect(err.message).toEqual('Signer is required in createClusterDefinition');
|
|
@@ -130,9 +153,9 @@ describe('Cluster Client without a signer', () => {
|
|
|
130
153
|
test('acceptClusterDefinition should throw an error without signer', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
154
|
try {
|
|
132
155
|
yield clientInstance.acceptClusterDefinition({
|
|
133
|
-
enr: fixtures_js_1.
|
|
134
|
-
version: fixtures_js_1.
|
|
135
|
-
}, fixtures_js_1.
|
|
156
|
+
enr: fixtures_js_1.clusterLockV1X8.cluster_definition.operators[0].enr,
|
|
157
|
+
version: fixtures_js_1.clusterLockV1X8.cluster_definition.version,
|
|
158
|
+
}, fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
136
159
|
}
|
|
137
160
|
catch (err) {
|
|
138
161
|
expect(err.message).toEqual('Signer is required in acceptClusterDefinition');
|
|
@@ -141,23 +164,27 @@ describe('Cluster Client without a signer', () => {
|
|
|
141
164
|
test('getClusterdefinition should return cluster definition if config hash exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
165
|
clientInstance['request'] = jest
|
|
143
166
|
.fn()
|
|
144
|
-
.mockReturnValue(Promise.resolve(fixtures_js_1.
|
|
145
|
-
const clusterDefinition = yield clientInstance.getClusterDefinition(fixtures_js_1.
|
|
146
|
-
expect(clusterDefinition.config_hash).toEqual(fixtures_js_1.
|
|
167
|
+
.mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8.cluster_definition));
|
|
168
|
+
const clusterDefinition = yield clientInstance.getClusterDefinition(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
169
|
+
expect(clusterDefinition.config_hash).toEqual(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
147
170
|
}));
|
|
148
171
|
test('getClusterLock should return lockFile if exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
172
|
clientInstance['request'] = jest
|
|
150
173
|
.fn()
|
|
151
|
-
.mockReturnValue(Promise.resolve(fixtures_js_1.
|
|
152
|
-
const clusterLock = yield clientInstance.getClusterLock(fixtures_js_1.
|
|
153
|
-
expect(clusterLock.lock_hash).toEqual(fixtures_js_1.
|
|
174
|
+
.mockReturnValue(Promise.resolve(fixtures_js_1.clusterLockV1X8));
|
|
175
|
+
const clusterLock = yield clientInstance.getClusterLock(fixtures_js_1.clusterLockV1X8.cluster_definition.config_hash);
|
|
176
|
+
expect(clusterLock.lock_hash).toEqual(fixtures_js_1.clusterLockV1X8.lock_hash);
|
|
154
177
|
}));
|
|
155
|
-
test.each([
|
|
178
|
+
test.each([
|
|
179
|
+
{ version: 'v1.6.0', clusterLock: fixtures_js_1.clusterLockV1X6 },
|
|
180
|
+
{ version: 'v1.7.0', clusterLock: fixtures_js_1.clusterLockV1X7 },
|
|
181
|
+
{ version: 'v1.8.0', clusterLock: fixtures_js_1.clusterLockV1X8 },
|
|
182
|
+
])("$version: 'should return true on verified cluster lock'", ({ clusterLock }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
183
|
const isValidLock = yield (0, index_1.validateClusterLock)(clusterLock);
|
|
157
184
|
expect(isValidLock).toEqual(true);
|
|
158
185
|
}));
|
|
159
186
|
test('Finds the hash of the latest version of terms and conditions', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
187
|
const termsAndConditionsHash = yield (0, termsAndConditions_1.hashTermsAndConditions)();
|
|
161
|
-
expect(termsAndConditionsHash).toEqual('
|
|
188
|
+
expect(termsAndConditionsHash).toEqual('0xd33721644e8f3afab1495a74abe3523cec12d48b8da6cb760972492ca3f1a273');
|
|
162
189
|
}));
|
|
163
190
|
});
|
package/dist/esm/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obolnetwork/obol-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "A package for creating Distributed Validators using the Obol API.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/obolnetwork/obol-sdk/issues"
|
|
7
7
|
},
|
|
8
|
-
"homepage": "https://docs.obol.
|
|
8
|
+
"homepage": "https://docs.obol.org/",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"Obol",
|
|
11
11
|
"Distributed Validators",
|
|
@@ -20,13 +20,15 @@
|
|
|
20
20
|
"npm:publish": "npm publish --tag latest",
|
|
21
21
|
"release": "release-it",
|
|
22
22
|
"release:dry": "release-it --dry-run --no-npm",
|
|
23
|
-
"lint": "eslint \"{src,
|
|
24
|
-
"lint-ci": "eslint \"{src,
|
|
23
|
+
"lint": "eslint \"{src,test}/**/*.{js,ts}\" --fix",
|
|
24
|
+
"lint-ci": "eslint \"{src,test}/**/*.{js,ts}\"",
|
|
25
|
+
"prettier-ci": "prettier --check \"{src,test}/**/*.{js,ts}\"",
|
|
26
|
+
"prettier": "prettier --write \"{src,test}/**/*.{js,ts}\""
|
|
25
27
|
},
|
|
26
28
|
"main": "./dist/cjs/src/index.js",
|
|
27
29
|
"module": "./dist/esm/src/index.js",
|
|
28
30
|
"typings": "./dist/types/src/index.d.ts",
|
|
29
|
-
"author": "Obol Labs (https://obol.
|
|
31
|
+
"author": "Obol Labs (https://obol.org)",
|
|
30
32
|
"repository": {
|
|
31
33
|
"type": "git",
|
|
32
34
|
"url": "git+https://github.com/obolnetwork/obol-sdk.git"
|
|
@@ -65,15 +67,18 @@
|
|
|
65
67
|
"@types/semver": "^7.5.8",
|
|
66
68
|
"@types/uuid": "^9.0.1",
|
|
67
69
|
"eslint": "^8.57.0",
|
|
70
|
+
"husky": "^9.0.11",
|
|
68
71
|
"jest": "^28.1.3",
|
|
72
|
+
"lint-staged": "^15.2.2",
|
|
69
73
|
"msw": "^2.2.1",
|
|
70
74
|
"npm-run-all": "^4.1.5",
|
|
75
|
+
"prettier": "^3.2.5",
|
|
71
76
|
"release-it": "^17.2.1",
|
|
72
77
|
"ts-jest": "^28.0.8",
|
|
73
78
|
"tsup": "^6.7.0",
|
|
74
79
|
"typedoc": "^0.25.7",
|
|
75
80
|
"typedoc-plugin-markdown": "^4.0.0-next.50",
|
|
76
|
-
"typescript": "
|
|
81
|
+
"typescript": "~5.3.3"
|
|
77
82
|
},
|
|
78
83
|
"engines": {
|
|
79
84
|
"node": ">= 16"
|
package/dist/esm/src/ajv.js
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
|
+
import { parseUnits } from 'ethers';
|
|
3
|
+
function validDepositAmounts(data, deposits) {
|
|
4
|
+
let sum = 0;
|
|
5
|
+
// from ether togwei is same as from gwei to wei
|
|
6
|
+
const maxDeposit = Number(parseUnits('32', 'gwei'));
|
|
7
|
+
const minDeposit = Number(parseUnits('1', 'gwei'));
|
|
8
|
+
for (const element of deposits) {
|
|
9
|
+
const amountInGWei = Number(element);
|
|
10
|
+
if (!Number.isInteger(amountInGWei) ||
|
|
11
|
+
amountInGWei > maxDeposit ||
|
|
12
|
+
amountInGWei < minDeposit) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
sum += amountInGWei;
|
|
16
|
+
}
|
|
17
|
+
if (sum / minDeposit !== 32) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
2
24
|
export function validatePayload(data, schema) {
|
|
3
25
|
var _a;
|
|
4
26
|
const ajv = new Ajv();
|
|
27
|
+
ajv.addKeyword({
|
|
28
|
+
keyword: 'validDepositAmounts',
|
|
29
|
+
validate: validDepositAmounts,
|
|
30
|
+
errors: true,
|
|
31
|
+
});
|
|
5
32
|
const validate = ajv.compile(schema);
|
|
6
33
|
const isValid = validate(data);
|
|
7
34
|
if (!isValid) {
|
package/dist/esm/src/base.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
// src/resources/base.ts
|
|
11
|
-
import { DEFAULT_BASE_URL, DEFAULT_CHAIN_ID, SDK_VERSION } from './constants.js';
|
|
11
|
+
import { DEFAULT_BASE_URL, DEFAULT_CHAIN_ID, SDK_VERSION, } from './constants.js';
|
|
12
12
|
import { FORK_MAPPING } from './types.js';
|
|
13
13
|
export class Base {
|
|
14
14
|
constructor({ baseUrl = DEFAULT_BASE_URL, chainId = DEFAULT_CHAIN_ID, }) {
|
|
@@ -9,7 +9,7 @@ export const TermsAndConditionsSigningTypes = {
|
|
|
9
9
|
TermsAndConditions: [
|
|
10
10
|
{ name: 'terms_and_conditions_hash', type: 'string' },
|
|
11
11
|
{ name: 'version', type: 'uint256' },
|
|
12
|
-
]
|
|
12
|
+
],
|
|
13
13
|
};
|
|
14
14
|
const EIP712Domain = [
|
|
15
15
|
{ name: 'name', type: 'string' },
|
|
@@ -73,7 +73,7 @@ export const signEnrPayload = (payload, chainId) => {
|
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
export const DKG_ALGORITHM = 'default';
|
|
76
|
-
export const CONFIG_VERSION = 'v1.
|
|
76
|
+
export const CONFIG_VERSION = 'v1.8.0';
|
|
77
77
|
export const SDK_VERSION = pjson.version;
|
|
78
78
|
export const DOMAIN_APPLICATION_BUILDER = '00000001';
|
|
79
79
|
export const DOMAIN_DEPOSIT = '03000000';
|
|
@@ -86,7 +86,11 @@ export var DefinitionFlow;
|
|
|
86
86
|
DefinitionFlow["Charon"] = "Charon-Command";
|
|
87
87
|
})(DefinitionFlow || (DefinitionFlow = {}));
|
|
88
88
|
export const DEFAULT_BASE_URL = 'https://api.obol.tech';
|
|
89
|
+
export const DEFAULT_BASE_VERSION = 'v1';
|
|
89
90
|
export const DEFAULT_CHAIN_ID = 17000;
|
|
90
91
|
export const ETHER_TO_GWEI = 10 ** 9;
|
|
91
92
|
export const TERMS_AND_CONDITIONS_VERSION = 1;
|
|
92
|
-
export const TERMS_AND_CONDITIONS_URL =
|
|
93
|
+
export const TERMS_AND_CONDITIONS_URL = TERMS_AND_CONDITIONS_VERSION === 1
|
|
94
|
+
? 'https://obol.org/terms.pdf'
|
|
95
|
+
: `https://obol.org/${TERMS_AND_CONDITIONS_VERSION}/terms.pdf`;
|
|
96
|
+
export const TERMS_AND_CONDITIONS_HASH = '0xd33721644e8f3afab1495a74abe3523cec12d48b8da6cb760972492ca3f1a273';
|
package/dist/esm/src/index.js
CHANGED
|
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { v4 as uuidv4 } from 'uuid';
|
|
11
11
|
import { Base } from './base.js';
|
|
12
|
-
import { CONFLICT_ERROR_MSG, CreatorConfigHashSigningTypes, Domain, DKG_ALGORITHM, CONFIG_VERSION, OperatorConfigHashSigningTypes, EnrSigningTypes, TERMS_AND_CONDITIONS_VERSION, TermsAndConditionsSigningTypes, } from './constants.js';
|
|
12
|
+
import { CONFLICT_ERROR_MSG, CreatorConfigHashSigningTypes, Domain, DKG_ALGORITHM, CONFIG_VERSION, OperatorConfigHashSigningTypes, EnrSigningTypes, TERMS_AND_CONDITIONS_VERSION, TermsAndConditionsSigningTypes, DEFAULT_BASE_VERSION, TERMS_AND_CONDITIONS_HASH, } from './constants.js';
|
|
13
13
|
import { ConflictError } from './errors.js';
|
|
14
14
|
import { clusterConfigOrDefinitionHash } from './verification/common.js';
|
|
15
15
|
import { validatePayload } from './ajv.js';
|
|
16
16
|
import { definitionSchema, operatorPayloadSchema } from './schema.js';
|
|
17
|
-
import { hashTermsAndConditions } from './verification/termsAndConditions.js';
|
|
18
17
|
export * from './types.js';
|
|
19
18
|
export * from './services.js';
|
|
20
19
|
/**
|
|
@@ -36,29 +35,31 @@ export class Client extends Base {
|
|
|
36
35
|
this.signer = signer;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
* Accepts Obol terms and conditions to be able to create or update data.
|
|
39
|
+
* @returns {Promise<string>} terms and conditions acceptance success message.
|
|
40
|
+
* @throws On unverified signature or wrong hash.
|
|
41
|
+
*
|
|
42
|
+
* An example of how to use acceptObolLatestTermsAndConditions:
|
|
43
|
+
* [acceptObolLatestTermsAndConditions](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L44)
|
|
44
|
+
*/
|
|
44
45
|
acceptObolLatestTermsAndConditions() {
|
|
45
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
47
|
if (!this.signer) {
|
|
47
48
|
throw new Error('Signer is required in acceptObolTermsAndConditions');
|
|
48
49
|
}
|
|
49
50
|
try {
|
|
50
|
-
const termsAndConditionsHash =
|
|
51
|
+
const termsAndConditionsHash = TERMS_AND_CONDITIONS_HASH;
|
|
51
52
|
const address = yield this.signer.getAddress();
|
|
52
53
|
const termsAndConditionsPayload = {
|
|
53
54
|
address,
|
|
54
55
|
version: TERMS_AND_CONDITIONS_VERSION,
|
|
55
|
-
terms_and_conditions_hash: termsAndConditionsHash
|
|
56
|
+
terms_and_conditions_hash: termsAndConditionsHash,
|
|
56
57
|
};
|
|
57
58
|
const termsAndConditionsSignature = yield this.signer.signTypedData(Domain(), TermsAndConditionsSigningTypes, {
|
|
58
59
|
terms_and_conditions_hash: termsAndConditionsHash,
|
|
59
60
|
version: TERMS_AND_CONDITIONS_VERSION,
|
|
60
61
|
});
|
|
61
|
-
const termsAndConditionsResponse = yield this.request(
|
|
62
|
+
const termsAndConditionsResponse = yield this.request(`/${DEFAULT_BASE_VERSION}/termsAndConditions`, {
|
|
62
63
|
method: 'POST',
|
|
63
64
|
body: JSON.stringify(termsAndConditionsPayload),
|
|
64
65
|
headers: {
|
|
@@ -82,7 +83,7 @@ export class Client extends Base {
|
|
|
82
83
|
* @throws On duplicate entries, missing or wrong cluster keys.
|
|
83
84
|
*
|
|
84
85
|
* An example of how to use createClusterDefinition:
|
|
85
|
-
* [createObolCluster](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
86
|
+
* [createObolCluster](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L59)
|
|
86
87
|
*/
|
|
87
88
|
createClusterDefinition(newCluster) {
|
|
88
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -90,13 +91,15 @@ export class Client extends Base {
|
|
|
90
91
|
throw new Error('Signer is required in createClusterDefinition');
|
|
91
92
|
}
|
|
92
93
|
validatePayload(newCluster, definitionSchema);
|
|
93
|
-
const clusterConfig = Object.assign(Object.assign({}, newCluster), { fork_version: this.fork_version, dkg_algorithm: DKG_ALGORITHM, version: CONFIG_VERSION, uuid: uuidv4(), timestamp: new Date().toISOString(), threshold: Math.ceil((2 * newCluster.operators.length) / 3), num_validators: newCluster.validators.length
|
|
94
|
+
const clusterConfig = Object.assign(Object.assign({}, newCluster), { fork_version: this.fork_version, dkg_algorithm: DKG_ALGORITHM, version: CONFIG_VERSION, uuid: uuidv4(), timestamp: new Date().toISOString(), threshold: Math.ceil((2 * newCluster.operators.length) / 3), num_validators: newCluster.validators.length, deposit_amounts: newCluster.deposit_amounts
|
|
95
|
+
? newCluster.deposit_amounts
|
|
96
|
+
: ['32000000000'] });
|
|
94
97
|
try {
|
|
95
98
|
const address = yield this.signer.getAddress();
|
|
96
99
|
clusterConfig.creator = { address };
|
|
97
100
|
clusterConfig.config_hash = clusterConfigOrDefinitionHash(clusterConfig, true);
|
|
98
101
|
const creatorConfigSignature = yield this.signer.signTypedData(Domain(this.chainId), CreatorConfigHashSigningTypes, { creator_config_hash: clusterConfig.config_hash });
|
|
99
|
-
const clusterDefinition = yield this.request(
|
|
102
|
+
const clusterDefinition = yield this.request(`/${DEFAULT_BASE_VERSION}/definition`, {
|
|
100
103
|
method: 'POST',
|
|
101
104
|
body: JSON.stringify(clusterConfig),
|
|
102
105
|
headers: {
|
|
@@ -122,7 +125,7 @@ export class Client extends Base {
|
|
|
122
125
|
* @throws On unauthorized, duplicate entries, missing keys, not found cluster or invalid data.
|
|
123
126
|
*
|
|
124
127
|
* An example of how to use acceptClusterDefinition:
|
|
125
|
-
* [acceptClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
128
|
+
* [acceptClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L106)
|
|
126
129
|
*/
|
|
127
130
|
acceptClusterDefinition(operatorPayload, configHash) {
|
|
128
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -135,7 +138,7 @@ export class Client extends Base {
|
|
|
135
138
|
const operatorConfigSignature = yield this.signer.signTypedData(Domain(this.chainId), OperatorConfigHashSigningTypes, { operator_config_hash: configHash });
|
|
136
139
|
const operatorENRSignature = yield this.signer.signTypedData(Domain(this.chainId), EnrSigningTypes, { enr: operatorPayload.enr });
|
|
137
140
|
const operatorData = Object.assign(Object.assign({}, operatorPayload), { address, enr_signature: operatorENRSignature, fork_version: this.fork_version });
|
|
138
|
-
const clusterDefinition = yield this.request(
|
|
141
|
+
const clusterDefinition = yield this.request(`/${DEFAULT_BASE_VERSION}/definition/${configHash}`, {
|
|
139
142
|
method: 'PUT',
|
|
140
143
|
body: JSON.stringify(operatorData),
|
|
141
144
|
headers: {
|
|
@@ -155,11 +158,11 @@ export class Client extends Base {
|
|
|
155
158
|
* @throws On not found config hash.
|
|
156
159
|
*
|
|
157
160
|
* An example of how to use getClusterDefinition:
|
|
158
|
-
* [getObolClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
161
|
+
* [getObolClusterDefinition](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L74)
|
|
159
162
|
*/
|
|
160
163
|
getClusterDefinition(configHash) {
|
|
161
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const clusterDefinition = yield this.request(
|
|
165
|
+
const clusterDefinition = yield this.request(`/${DEFAULT_BASE_VERSION}/definition/${configHash}`, {
|
|
163
166
|
method: 'GET',
|
|
164
167
|
});
|
|
165
168
|
return clusterDefinition;
|
|
@@ -171,11 +174,11 @@ export class Client extends Base {
|
|
|
171
174
|
* @throws On not found cluster definition or lock.
|
|
172
175
|
*
|
|
173
176
|
* An example of how to use getClusterLock:
|
|
174
|
-
* [getObolClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts)
|
|
177
|
+
* [getObolClusterLock](https://github.com/ObolNetwork/obol-sdk-examples/blob/main/TS-Example/index.ts#L89)
|
|
175
178
|
*/
|
|
176
179
|
getClusterLock(configHash) {
|
|
177
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
const lock = yield this.request(
|
|
181
|
+
const lock = yield this.request(`/${DEFAULT_BASE_VERSION}/lock/configHash/${configHash}`, {
|
|
179
182
|
method: 'GET',
|
|
180
183
|
});
|
|
181
184
|
return lock;
|