@ssv-labs/ssv-sdk 0.1.3 → 1.0.1

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 (59) hide show
  1. package/README.html +4 -7
  2. package/README.md +37 -26
  3. package/dist/{KeyShares-B_4l2THg.js → KeyShares-Bk9uzOlK.js} +194 -51
  4. package/dist/{KeyShares-ClzHwMUy.mjs → KeyShares-Dlp4Pa3b.mjs} +198 -55
  5. package/dist/abi/mainnet/v4/getter.d.ts +699 -74
  6. package/dist/abi/mainnet/v4/setter.d.ts +939 -59
  7. package/dist/api/subgraph/index.d.ts +36 -1
  8. package/dist/config/create.d.ts +2 -2
  9. package/dist/config/globals.d.ts +3 -0
  10. package/dist/{globals-CDOcDUnk.mjs → config-BdEJjnYA.mjs} +107 -79
  11. package/dist/{globals-DsaKgq3v.js → config-ClGS9Tic.js} +73 -45
  12. package/dist/contract-interactions/create.d.ts +1 -1
  13. package/dist/contract-interactions/types.d.ts +9 -3
  14. package/dist/graphql/graphql.d.ts +4663 -922
  15. package/dist/keys.js +1 -1
  16. package/dist/keys.mjs +5 -5
  17. package/dist/libs/api/index.d.ts +2 -0
  18. package/dist/libs/cluster/index.d.ts +3 -1
  19. package/dist/libs/cluster/methods/deposit.d.ts +150 -4
  20. package/dist/libs/cluster/methods/exit-validators.d.ts +149 -0
  21. package/dist/libs/cluster/methods/index.d.ts +3 -1
  22. package/dist/libs/cluster/methods/liquidate-cluster.d.ts +149 -0
  23. package/dist/libs/cluster/methods/liquidate-ssv.d.ts +430 -0
  24. package/dist/libs/cluster/methods/migrate-cluster-to-eth.d.ts +431 -0
  25. package/dist/libs/cluster/methods/reactivate-cluster.d.ts +149 -0
  26. package/dist/libs/cluster/methods/register-validators.d.ts +2222 -309
  27. package/dist/libs/cluster/methods/remove-validators.d.ts +149 -0
  28. package/dist/libs/cluster/methods/set-fee-recipient.d.ts +149 -0
  29. package/dist/libs/cluster/methods/withdraw.d.ts +149 -0
  30. package/dist/libs/dao/index.d.ts +8 -0
  31. package/dist/libs/dao/methods/commit-root.d.ts +432 -0
  32. package/dist/libs/dao/methods/index.d.ts +3 -0
  33. package/dist/libs/dao/methods/update-network-fee-ssv.d.ts +430 -0
  34. package/dist/libs/dao/methods/withdraw-network-ssv-earnings.d.ts +430 -0
  35. package/dist/libs/operator/index.d.ts +1525 -32
  36. package/dist/libs/operator/methods.d.ts +1731 -2
  37. package/dist/libs/ssv-keys/Encryption/__test__/RsaKeys.d.ts +1 -1
  38. package/dist/libs/ssv-keys/KeyShares/KeySharesItem.d.ts +1 -1
  39. package/dist/libs/ssv-keys/SSVKeys.d.ts +1 -1
  40. package/dist/libs/ssv-keys/exceptions/index.d.ts +1 -1
  41. package/dist/libs/ssv-keys/index.d.ts +1 -1
  42. package/dist/libs/ssv-keys/interfaces/index.d.ts +2 -2
  43. package/dist/libs/utils/index.d.ts +6 -4
  44. package/dist/libs/utils/methods/calc-deposit-from-runway.d.ts +11 -0
  45. package/dist/libs/utils/methods/get-cluster-balance.d.ts +3 -1
  46. package/dist/libs/utils/methods/keyshares.d.ts +4 -2
  47. package/dist/libs/utils/methods/keystores.d.ts +4 -4
  48. package/dist/main.d.ts +1 -0
  49. package/dist/main.js +2714 -729
  50. package/dist/main.mjs +2746 -761
  51. package/dist/sdk.d.ts +8 -4
  52. package/dist/types/contract-interactions.d.ts +11 -0
  53. package/dist/types/methods.d.ts +4 -3
  54. package/dist/utils/cluster.d.ts +3 -3
  55. package/dist/utils/funding.d.ts +29 -0
  56. package/dist/utils/zod/config.d.ts +1 -1
  57. package/dist/utils.js +38 -38
  58. package/dist/utils.mjs +34 -34
  59. package/package.json +18 -6
@@ -3,10 +3,6 @@ const bls = require("bls-eth-wasm");
3
3
  const crypto$1 = require("crypto");
4
4
  const viem = require("viem");
5
5
  const classValidator = require("class-validator");
6
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7
- function getDefaultExportFromCjs(x) {
8
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
9
- }
10
6
  (async () => {
11
7
  await bls.init(bls.BLS12_381);
12
8
  })();
@@ -65,6 +61,10 @@ class OwnerNonceFormatError extends SSVKeysException {
65
61
  this.data = data;
66
62
  }
67
63
  }
64
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
65
+ function getDefaultExportFromCjs(x) {
66
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
67
+ }
68
68
  var forge$C = {
69
69
  // default options
70
70
  options: {
@@ -1327,6 +1327,9 @@ util$1.format = function(format) {
1327
1327
  parts.push("<?>");
1328
1328
  }
1329
1329
  break;
1330
+ // FIXME: do proper formatting for numbers, etc
1331
+ //case 'f':
1332
+ //case 'd':
1330
1333
  case "%":
1331
1334
  parts.push("%");
1332
1335
  break;
@@ -9876,6 +9879,7 @@ var _readSignatureParameters = function(oid, obj, fillDefaults) {
9876
9879
  var _createSignatureDigest = function(options) {
9877
9880
  switch (oids[options.signatureOid]) {
9878
9881
  case "sha1WithRSAEncryption":
9882
+ // deprecated alias
9879
9883
  case "sha1WithRSASignature":
9880
9884
  return forge$b.md.sha1.create();
9881
9885
  case "md5WithRSAEncryption":
@@ -9901,6 +9905,7 @@ var _verifySignature = function(options) {
9901
9905
  var scheme;
9902
9906
  switch (cert.signatureOid) {
9903
9907
  case oids.sha1WithRSAEncryption:
9908
+ // deprecated alias
9904
9909
  case oids.sha1WithRSASignature:
9905
9910
  break;
9906
9911
  case oids["RSASSA-PSS"]:
@@ -10391,13 +10396,18 @@ pki$2.certificateExtensionFromAsn1 = function(ext) {
10391
10396
  };
10392
10397
  e.altNames.push(altName);
10393
10398
  switch (gn.type) {
10399
+ // rfc822Name
10394
10400
  case 1:
10401
+ // dNSName
10395
10402
  case 2:
10403
+ // uniformResourceIdentifier (URI)
10396
10404
  case 6:
10397
10405
  break;
10406
+ // IPAddress
10398
10407
  case 7:
10399
10408
  altName.ip = forge$b.util.bytesToIP(gn.value);
10400
10409
  break;
10410
+ // registeredID
10401
10411
  case 8:
10402
10412
  altName.oid = asn1$4.derToOid(gn.value);
10403
10413
  break;
@@ -11952,6 +11962,7 @@ function _decodeSafeContents(safeContents, strict, password) {
11952
11962
  "Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?"
11953
11963
  );
11954
11964
  }
11965
+ /* fall through */
11955
11966
  case pki$1.oids.keyBag:
11956
11967
  try {
11957
11968
  bag.key = pki$1.privateKeyFromAsn1(bagAsn1);
@@ -11960,6 +11971,7 @@ function _decodeSafeContents(safeContents, strict, password) {
11960
11971
  bag.asn1 = bagAsn1;
11961
11972
  }
11962
11973
  continue;
11974
+ /* Nothing more to do. */
11963
11975
  case pki$1.oids.certBag:
11964
11976
  validator = certBagValidator;
11965
11977
  decoder = function() {
@@ -17457,7 +17469,10 @@ class ForgeEncrypt {
17457
17469
  }
17458
17470
  try {
17459
17471
  const encryptedBytes = lib.util.decode64(encryptedData);
17460
- const decrypted = this.privateKey.decrypt(encryptedBytes, "RSAES-PKCS1-V1_5");
17472
+ const decrypted = this.privateKey.decrypt(
17473
+ encryptedBytes,
17474
+ "RSAES-PKCS1-V1_5"
17475
+ );
17461
17476
  return decrypted;
17462
17477
  } catch (error) {
17463
17478
  return false;
@@ -17522,12 +17537,16 @@ const OperatorPublicKeyValidator$1 = (publicKey) => {
17522
17537
  let decodedPublicKey = "";
17523
17538
  if (!publicKey.startsWith(begin)) {
17524
17539
  if (publicKey.length < 98) {
17525
- throw new Error("The length of the operator public key must be at least 98 characters.");
17540
+ throw new Error(
17541
+ "The length of the operator public key must be at least 98 characters."
17542
+ );
17526
17543
  }
17527
17544
  try {
17528
17545
  decodedPublicKey = lib.util.decode64(publicKey).trim();
17529
17546
  } catch (error) {
17530
- throw new Error("Failed to decode the operator public key. Ensure it's correctly base64 encoded.");
17547
+ throw new Error(
17548
+ "Failed to decode the operator public key. Ensure it's correctly base64 encoded."
17549
+ );
17531
17550
  }
17532
17551
  if (!decodedPublicKey.startsWith(begin)) {
17533
17552
  throw new Error(`Operator public key does not start with '${begin}'`);
@@ -17542,12 +17561,16 @@ const OperatorPublicKeyValidator$1 = (publicKey) => {
17542
17561
  const content = decodedPublicKey.slice(begin.length, publicKey.length - end.length).trim();
17543
17562
  decodedOperator = lib.util.decode64(content);
17544
17563
  } catch {
17545
- throw new Error("Failed to decode the RSA public key. Ensure it's correctly base64 encoded.");
17564
+ throw new Error(
17565
+ "Failed to decode the RSA public key. Ensure it's correctly base64 encoded."
17566
+ );
17546
17567
  }
17547
17568
  try {
17548
17569
  encrypt.setPublicKey(decodedOperator);
17549
17570
  } catch {
17550
- throw new Error("Invalid operator key format, make sure the operator exists in the network.");
17571
+ throw new Error(
17572
+ "Invalid operator key format, make sure the operator exists in the network."
17573
+ );
17551
17574
  }
17552
17575
  } catch (error) {
17553
17576
  throw new OperatorPublicKeyError(
@@ -17591,7 +17614,10 @@ class Threshold {
17591
17614
  */
17592
17615
  async create(privateKeyString, operatorIds) {
17593
17616
  if (!privateKeyString.startsWith("0x")) {
17594
- throw new PrivateKeyFormatError(privateKeyString, "The private key must be provided in the 0x format.");
17617
+ throw new PrivateKeyFormatError(
17618
+ privateKeyString,
17619
+ "The private key must be provided in the 0x format."
17620
+ );
17595
17621
  }
17596
17622
  operatorIds.map((operatorId) => {
17597
17623
  if (!Number.isInteger(operatorId)) {
@@ -17612,7 +17638,9 @@ class Threshold {
17612
17638
  if (!bls.deserializeHexStrToSecretKey) {
17613
17639
  await bls.init(bls.BLS12_381);
17614
17640
  }
17615
- this.privateKey = bls.deserializeHexStrToSecretKey(privateKeyString.replace("0x", ""));
17641
+ this.privateKey = bls.deserializeHexStrToSecretKey(
17642
+ privateKeyString.replace("0x", "")
17643
+ );
17616
17644
  this.publicKey = this.privateKey.getPublicKey();
17617
17645
  msk.push(this.privateKey);
17618
17646
  mpk.push(this.publicKey);
@@ -17986,6 +18014,7 @@ var scrypt = { exports: {} };
17986
18014
  arraycopy(B, Bi, XY, 0, Yi);
17987
18015
  state = 1;
17988
18016
  i1 = 0;
18017
+ // Fall through
17989
18018
  case 1:
17990
18019
  steps = N - i1;
17991
18020
  if (steps > limit) {
@@ -18012,6 +18041,7 @@ var scrypt = { exports: {} };
18012
18041
  }
18013
18042
  i1 = 0;
18014
18043
  state = 2;
18044
+ // Fall through
18015
18045
  case 2:
18016
18046
  steps = N - i1;
18017
18047
  if (steps > limit) {
@@ -18108,11 +18138,17 @@ class EthereumKeyStore {
18108
18138
  privateKey = "";
18109
18139
  constructor(keyStoreData) {
18110
18140
  if (!keyStoreData) {
18111
- throw new KeyStoreDataFormatError(keyStoreData, "Key store data should be JSON or string");
18141
+ throw new KeyStoreDataFormatError(
18142
+ keyStoreData,
18143
+ "Key store data should be JSON or string"
18144
+ );
18112
18145
  }
18113
18146
  this.keyStoreData = typeof keyStoreData === "string" ? JSON.parse(keyStoreData) : keyStoreData;
18114
18147
  if (!this.keyStoreData.version) {
18115
- throw new KeyStoreInvalidError(this.keyStoreData, "Invalid keystore file");
18148
+ throw new KeyStoreInvalidError(
18149
+ this.keyStoreData,
18150
+ "Invalid keystore file"
18151
+ );
18116
18152
  }
18117
18153
  }
18118
18154
  // getPublicKey(): string {
@@ -18152,15 +18188,32 @@ class EthereumKeyStore {
18152
18188
  const dklen = kdfparams.dklen;
18153
18189
  let derivedKey;
18154
18190
  if (json.crypto.kdf === "scrypt") {
18155
- derivedKey = scryptExports.syncScrypt(Buffer.from(password), salt, kdfparams.n, kdfparams.r, kdfparams.p, dklen);
18191
+ derivedKey = scryptExports.syncScrypt(
18192
+ Buffer.from(password),
18193
+ salt,
18194
+ kdfparams.n,
18195
+ kdfparams.r,
18196
+ kdfparams.p,
18197
+ dklen
18198
+ );
18156
18199
  } else if (json.crypto.kdf === "pbkdf2") {
18157
- if (kdfparams.prf !== "hmac-sha256") throw new EthereumWalletError("Unsupported PBKDF2 params");
18158
- derivedKey = crypto$1.pbkdf2Sync(Buffer.from(password), salt, kdfparams.c, dklen, "sha256");
18200
+ if (kdfparams.prf !== "hmac-sha256")
18201
+ throw new EthereumWalletError("Unsupported PBKDF2 params");
18202
+ derivedKey = crypto$1.pbkdf2Sync(
18203
+ Buffer.from(password),
18204
+ salt,
18205
+ kdfparams.c,
18206
+ dklen,
18207
+ "sha256"
18208
+ );
18159
18209
  } else {
18160
18210
  throw new EthereumWalletError("Unsupported kdf type");
18161
18211
  }
18162
18212
  const ciphertext = Buffer.from(json.crypto.ciphertext, "hex");
18163
- const macCheck = Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), ciphertext]);
18213
+ const macCheck = Buffer.concat([
18214
+ Buffer.from(derivedKey.slice(16, 32)),
18215
+ ciphertext
18216
+ ]);
18164
18217
  const mac = viem.keccak256(viem.toHex(macCheck)).replace(/^0x/, "");
18165
18218
  if (mac !== json.crypto.mac.toLowerCase()) {
18166
18219
  throw new EthereumWalletError("Invalid password");
@@ -18189,12 +18242,21 @@ class EthereumKeyStore {
18189
18242
  if (prf !== "hmac-sha256") {
18190
18243
  throw new EthereumWalletError("Unsupported parameters to PBKDF2");
18191
18244
  }
18192
- derivedKey = crypto$1.pbkdf2Sync(Buffer.from(password), salt, c, dklen, "sha256");
18245
+ derivedKey = crypto$1.pbkdf2Sync(
18246
+ Buffer.from(password),
18247
+ salt,
18248
+ c,
18249
+ dklen,
18250
+ "sha256"
18251
+ );
18193
18252
  } else {
18194
18253
  throw new EthereumWalletError("Unsupported key derivation scheme");
18195
18254
  }
18196
18255
  const ciphertext = Buffer.from(cipher.message, "hex");
18197
- const checksumBuffer = Buffer.concat([Buffer.from(derivedKey.slice(16, 32)), ciphertext]);
18256
+ const checksumBuffer = Buffer.concat([
18257
+ Buffer.from(derivedKey.slice(16, 32)),
18258
+ ciphertext
18259
+ ]);
18198
18260
  const hashFn = checksum.function === "sha256" ? viem.sha256 : viem.keccak256;
18199
18261
  const calculatedMac = hashFn(viem.toHex(checksumBuffer));
18200
18262
  if (calculatedMac.replace(/^0x/, "") !== checksum.message.toLowerCase()) {
@@ -18229,7 +18291,9 @@ class Encryption {
18229
18291
  OperatorPublicKeyValidator$1(operatorPublicKey);
18230
18292
  const forgeEncrypt = new ForgeEncrypt();
18231
18293
  forgeEncrypt.setPublicKey(operatorPublicKey);
18232
- const encryptedPrivateKey = forgeEncrypt.encrypt(this.shares[idx].privateKey);
18294
+ const encryptedPrivateKey = forgeEncrypt.encrypt(
18295
+ this.shares[idx].privateKey
18296
+ );
18233
18297
  if (!encryptedPrivateKey) {
18234
18298
  throw new OperatorPublicKeyError(
18235
18299
  {
@@ -18320,10 +18384,18 @@ const operatorSortedList = (operators) => {
18320
18384
  const validatedOperators = operators.map((operator) => {
18321
18385
  const id = parseInt(`${operator.id}`, 10);
18322
18386
  if (isNaN(id)) {
18323
- throw new OperatorsCountsMismatchError(ids, operatorKeys, `Invalid operator ID: ${operator.id}`);
18387
+ throw new OperatorsCountsMismatchError(
18388
+ ids,
18389
+ operatorKeys,
18390
+ `Invalid operator ID: ${operator.id}`
18391
+ );
18324
18392
  }
18325
18393
  if (!operator.operatorKey) {
18326
- throw new OperatorsCountsMismatchError(ids, operatorKeys, `Operator key is missing for operator ID: ${id}`);
18394
+ throw new OperatorsCountsMismatchError(
18395
+ ids,
18396
+ operatorKeys,
18397
+ `Operator key is missing for operator ID: ${id}`
18398
+ );
18327
18399
  }
18328
18400
  return { ...operator, id };
18329
18401
  });
@@ -18345,14 +18417,18 @@ class SingleSharesSignatureInvalid extends SSVKeysException {
18345
18417
  }
18346
18418
  }
18347
18419
  const hexArrayToBytes = (hexArr) => {
18348
- const uint8Array = new Uint8Array(hexArr.flatMap((hex) => Array.from(viem.toBytes(hex))));
18420
+ const uint8Array = new Uint8Array(
18421
+ hexArr.flatMap((hex) => Array.from(viem.toBytes(hex)))
18422
+ );
18349
18423
  return Buffer.from(uint8Array);
18350
18424
  };
18351
18425
  const buildSignature = async (dataToSign, privateKeyHex) => {
18352
18426
  if (!bls.deserializeHexStrToSecretKey) {
18353
18427
  await bls.init(bls.BLS12_381);
18354
18428
  }
18355
- const privateKey = bls.deserializeHexStrToSecretKey(privateKeyHex.replace("0x", ""));
18429
+ const privateKey = bls.deserializeHexStrToSecretKey(
18430
+ privateKeyHex.replace("0x", "")
18431
+ );
18356
18432
  const messageHash = viem.keccak256(viem.toBytes(dataToSign));
18357
18433
  const messageBytes = viem.fromHex(messageHash, "bytes");
18358
18434
  const signature = privateKey.sign(messageBytes);
@@ -18360,12 +18436,19 @@ const buildSignature = async (dataToSign, privateKeyHex) => {
18360
18436
  return `0x${signatureHex}`;
18361
18437
  };
18362
18438
  const validateSignature = async (signedData, signatureHex, publicKey) => {
18363
- const blsPublicKey = bls.deserializeHexStrToPublicKey(publicKey.replace("0x", ""));
18364
- const signature = bls.deserializeHexStrToSignature(signatureHex.replace("0x", ""));
18439
+ const blsPublicKey = bls.deserializeHexStrToPublicKey(
18440
+ publicKey.replace("0x", "")
18441
+ );
18442
+ const signature = bls.deserializeHexStrToSignature(
18443
+ signatureHex.replace("0x", "")
18444
+ );
18365
18445
  const messageHashHex = viem.keccak256(viem.toBytes(signedData));
18366
18446
  const messageHashBytes = viem.fromHex(messageHashHex, "bytes");
18367
18447
  if (!blsPublicKey.verify(signature, messageHashBytes)) {
18368
- throw new SingleSharesSignatureInvalid(signatureHex, "Single shares signature is invalid");
18448
+ throw new SingleSharesSignatureInvalid(
18449
+ signatureHex,
18450
+ "Single shares signature is invalid"
18451
+ );
18369
18452
  }
18370
18453
  };
18371
18454
  const privateToPublicKey = async (privateKey) => {
@@ -18387,11 +18470,17 @@ let OpeatorsListValidatorConstraint = class {
18387
18470
  const operatorIds = /* @__PURE__ */ new Set(), operatorPublicKeys = /* @__PURE__ */ new Set();
18388
18471
  for (const operator of operatorsList || []) {
18389
18472
  if (operatorIds.has(operator.id)) {
18390
- throw new DuplicatedOperatorIdError(operator, `The operator ID '${operator.id}' is duplicated in the list`);
18473
+ throw new DuplicatedOperatorIdError(
18474
+ operator,
18475
+ `The operator ID '${operator.id}' is duplicated in the list`
18476
+ );
18391
18477
  }
18392
18478
  operatorIds.add(operator.id);
18393
18479
  if (operatorPublicKeys.has(operator.operatorKey)) {
18394
- throw new DuplicatedOperatorPublicKeyError(operator, `The public key for operator ID ${operator.id} is duplicated in the list`);
18480
+ throw new DuplicatedOperatorPublicKeyError(
18481
+ operator,
18482
+ `The public key for operator ID ${operator.id} is duplicated in the list`
18483
+ );
18395
18484
  }
18396
18485
  operatorPublicKeys.add(operator.operatorKey);
18397
18486
  }
@@ -18429,10 +18518,15 @@ let PublicKeyValidatorConstraint = class {
18429
18518
  if (typeof value === "string") {
18430
18519
  bls.deserializeHexStrToPublicKey(value.replace("0x", ""));
18431
18520
  } else {
18432
- value.forEach((item) => bls.deserializeHexStrToPublicKey(item.replace("0x", "")));
18521
+ value.forEach(
18522
+ (item) => bls.deserializeHexStrToPublicKey(item.replace("0x", ""))
18523
+ );
18433
18524
  }
18434
18525
  } catch (e) {
18435
- throw new BLSDeserializeError(value, "Failed to BLS deserialize validator public key");
18526
+ throw new BLSDeserializeError(
18527
+ value,
18528
+ "Failed to BLS deserialize validator public key"
18529
+ );
18436
18530
  }
18437
18531
  return true;
18438
18532
  }
@@ -18472,7 +18566,10 @@ let OwnerAddressValidatorConstraint = class {
18472
18566
  try {
18473
18567
  viem.getAddress(value);
18474
18568
  } catch {
18475
- throw new OwnerAddressFormatError(value, "Owner address is not a valid Ethereum address");
18569
+ throw new OwnerAddressFormatError(
18570
+ value,
18571
+ "Owner address is not a valid Ethereum address"
18572
+ );
18476
18573
  }
18477
18574
  return true;
18478
18575
  }
@@ -18505,7 +18602,10 @@ var __decorateClass$5 = (decorators, target, key, kind) => {
18505
18602
  let OwnerNonceValidatorConstraint = class {
18506
18603
  validate(value) {
18507
18604
  if (!Number.isInteger(value) || value < 0) {
18508
- throw new OwnerNonceFormatError(value, "Owner nonce is not positive integer");
18605
+ throw new OwnerNonceFormatError(
18606
+ value,
18607
+ "Owner nonce is not positive integer"
18608
+ );
18509
18609
  }
18510
18610
  return true;
18511
18611
  }
@@ -18542,12 +18642,20 @@ let MatchLengthValidatorConstraint = class {
18542
18642
  if (!Array.isArray(value)) {
18543
18643
  Object.values(value).forEach((arr) => {
18544
18644
  if (relatedLength !== arr.length) {
18545
- throw new OperatorsCountsMismatchError(args.object[relatedPropertyName], value, customError.message);
18645
+ throw new OperatorsCountsMismatchError(
18646
+ args.object[relatedPropertyName],
18647
+ value,
18648
+ customError.message
18649
+ );
18546
18650
  }
18547
18651
  });
18548
18652
  } else {
18549
18653
  if (relatedLength !== value.length) {
18550
- throw new OperatorsCountsMismatchError(args.object[relatedPropertyName], value, customError.message);
18654
+ throw new OperatorsCountsMismatchError(
18655
+ args.object[relatedPropertyName],
18656
+ value,
18657
+ customError.message
18658
+ );
18551
18659
  }
18552
18660
  }
18553
18661
  return true;
@@ -18727,7 +18835,10 @@ const _KeySharesItem = class _KeySharesItem2 {
18727
18835
  async buildPayload(metaData, toSignatureData) {
18728
18836
  const { ownerAddress, ownerNonce, privateKey } = toSignatureData;
18729
18837
  if (!Number.isInteger(ownerNonce) || ownerNonce < 0) {
18730
- throw new OwnerNonceFormatError(ownerNonce, "Owner nonce is not positive integer");
18838
+ throw new OwnerNonceFormatError(
18839
+ ownerNonce,
18840
+ "Owner nonce is not positive integer"
18841
+ );
18731
18842
  }
18732
18843
  let address;
18733
18844
  try {
@@ -18740,10 +18851,15 @@ const _KeySharesItem = class _KeySharesItem2 {
18740
18851
  }
18741
18852
  const payload = this.payload.build({
18742
18853
  publicKey: metaData.publicKey,
18743
- operatorIds: operatorSortedList(metaData.operators).map((operator) => operator.id),
18854
+ operatorIds: operatorSortedList(metaData.operators).map(
18855
+ (operator) => operator.id
18856
+ ),
18744
18857
  encryptedShares: metaData.encryptedShares
18745
18858
  });
18746
- const signature = await buildSignature(`${address}:${ownerNonce}`, privateKey);
18859
+ const signature = await buildSignature(
18860
+ `${address}:${ownerNonce}`,
18861
+ privateKey
18862
+ );
18747
18863
  const signSharesBytes = hexArrayToBytes([signature, payload.sharesData]);
18748
18864
  payload.sharesData = `0x${signSharesBytes.toString("hex")}`;
18749
18865
  await this.validateSingleShares(payload.sharesData, {
@@ -18756,11 +18872,18 @@ const _KeySharesItem = class _KeySharesItem2 {
18756
18872
  async validateSingleShares(shares, fromSignatureData) {
18757
18873
  const { ownerAddress, ownerNonce, publicKey } = fromSignatureData;
18758
18874
  if (!Number.isInteger(ownerNonce) || ownerNonce < 0) {
18759
- throw new OwnerNonceFormatError(ownerNonce, "Owner nonce is not positive integer");
18875
+ throw new OwnerNonceFormatError(
18876
+ ownerNonce,
18877
+ "Owner nonce is not positive integer"
18878
+ );
18760
18879
  }
18761
18880
  const address = viem.getAddress(ownerAddress);
18762
18881
  const signaturePt = shares.replace("0x", "").substring(0, SIGNATURE_LENGTH);
18763
- await validateSignature(`${address}:${ownerNonce}`, `0x${signaturePt}`, publicKey);
18882
+ await validateSignature(
18883
+ `${address}:${ownerNonce}`,
18884
+ `0x${signaturePt}`,
18885
+ publicKey
18886
+ );
18764
18887
  }
18765
18888
  /**
18766
18889
  * Build shares from bytes string and operators list length
@@ -18777,7 +18900,9 @@ const _KeySharesItem = class _KeySharesItem2 {
18777
18900
  const sharesPt = bytes.slice(2 + SIGNATURE_LENGTH);
18778
18901
  const pkSplit = sharesPt.substring(0, operatorCount * PUBLIC_KEY_LENGTH);
18779
18902
  const pkBytes = viem.toBytes("0x" + pkSplit);
18780
- const sharesPublicKeys = this.splitArray(operatorCount, pkBytes).map((item) => viem.toHex(item));
18903
+ const sharesPublicKeys = this.splitArray(operatorCount, pkBytes).map(
18904
+ (item) => viem.toHex(item)
18905
+ );
18781
18906
  const eSplit = bytes.substring(operatorCount * PUBLIC_KEY_LENGTH);
18782
18907
  const eBytes = viem.toBytes("0x" + eSplit);
18783
18908
  const encryptedKeys = this.splitArray(operatorCount, eBytes).map(
@@ -18879,7 +19004,10 @@ class SSVKeys {
18879
19004
  */
18880
19005
  async createThreshold(privateKey, operators) {
18881
19006
  const sortedOperators = operatorSortedList(operators);
18882
- this.threshold = await new Threshold().create(privateKey, sortedOperators.map((item) => item.id));
19007
+ this.threshold = await new Threshold().create(
19008
+ privateKey,
19009
+ sortedOperators.map((item) => item.id)
19010
+ );
18883
19011
  return this.threshold;
18884
19012
  }
18885
19013
  /**
@@ -18889,7 +19017,9 @@ class SSVKeys {
18889
19017
  */
18890
19018
  async encryptShares(operators, shares) {
18891
19019
  const sortedOperators = operatorSortedList(operators);
18892
- const decodedOperatorPublicKeys = sortedOperators.map((item) => Buffer.from(item.operatorKey, "base64").toString());
19020
+ const decodedOperatorPublicKeys = sortedOperators.map(
19021
+ (item) => Buffer.from(item.operatorKey, "base64").toString()
19022
+ );
18893
19023
  return new Encryption(decodedOperatorPublicKeys, shares).encrypt();
18894
19024
  }
18895
19025
  /**
@@ -18925,7 +19055,10 @@ class SSVKeys {
18925
19055
  let signatureErrorMessage = "";
18926
19056
  let errorMessage = "";
18927
19057
  try {
18928
- const restoredShares = keySharesItem.buildSharesFromBytes(shares, operatorsCount);
19058
+ const restoredShares = keySharesItem.buildSharesFromBytes(
19059
+ shares,
19060
+ operatorsCount
19061
+ );
18929
19062
  const { sharesPublicKeys, encryptedKeys } = restoredShares;
18930
19063
  restoredSharesPublicKeys = sharesPublicKeys;
18931
19064
  restoredSharesEncryptedKeys = encryptedKeys;
@@ -18935,7 +19068,11 @@ class SSVKeys {
18935
19068
  errorMessage = "Can not extract shares from bytes";
18936
19069
  }
18937
19070
  if (!sharesError && !errorMessage) {
18938
- const signatureData = { ownerNonce, publicKey: validatorPublicKey, ownerAddress };
19071
+ const signatureData = {
19072
+ ownerNonce,
19073
+ publicKey: validatorPublicKey,
19074
+ ownerAddress
19075
+ };
18939
19076
  try {
18940
19077
  await keySharesItem.validateSingleShares(shares, signatureData);
18941
19078
  } catch (e) {
@@ -18958,12 +19095,14 @@ class SSVKeys {
18958
19095
  isSharesValid: !sharesError,
18959
19096
  sharesPublicKeys: restoredSharesPublicKeys,
18960
19097
  encryptedKeys: restoredSharesEncryptedKeys,
18961
- memo: !!sharesError || !!signatureError ? [{
18962
- message: errorMessage,
18963
- error: sharesError || signatureError,
18964
- data: `${sharesErrorMessage}${signatureErrorMessage ? ". " + signatureErrorMessage : ""}`,
18965
- blockNumber
18966
- }] : []
19098
+ memo: !!sharesError || !!signatureError ? [
19099
+ {
19100
+ message: errorMessage,
19101
+ error: sharesError || signatureError,
19102
+ data: `${sharesErrorMessage}${signatureErrorMessage ? ". " + signatureErrorMessage : ""}`,
19103
+ blockNumber
19104
+ }
19105
+ ] : []
18967
19106
  };
18968
19107
  }
18969
19108
  }
@@ -19263,6 +19402,8 @@ let SemVer$2 = class SemVer {
19263
19402
  this.inc("patch", identifier, identifierBase);
19264
19403
  this.inc("pre", identifier, identifierBase);
19265
19404
  break;
19405
+ // If the input is a non-prerelease version, this acts the same as
19406
+ // prepatch.
19266
19407
  case "prerelease":
19267
19408
  if (this.prerelease.length === 0) {
19268
19409
  this.inc("patch", identifier, identifierBase);
@@ -19296,6 +19437,8 @@ let SemVer$2 = class SemVer {
19296
19437
  }
19297
19438
  this.prerelease = [];
19298
19439
  break;
19440
+ // This probably shouldn't be used publicly.
19441
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
19299
19442
  case "pre": {
19300
19443
  const base = Number(identifierBase) ? 1 : 0;
19301
19444
  if (this.prerelease.length === 0) {