@obolnetwork/obol-sdk 2.12.5 → 2.13.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.
@@ -124,7 +124,7 @@ var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError
124
124
  };
125
125
 
126
126
  // src/verification/common.ts
127
- var import_ssz7 = require("@chainsafe/ssz");
127
+ var import_ssz8 = require("@chainsafe/ssz");
128
128
  var import_elliptic = __toESM(require("elliptic"));
129
129
 
130
130
  // src/types.ts
@@ -154,7 +154,7 @@ var import_ethers = require("ethers");
154
154
  // package.json
155
155
  var package_default = {
156
156
  name: "@obolnetwork/obol-sdk",
157
- version: "2.12.5",
157
+ version: "2.13.0",
158
158
  description: "A package for creating Distributed Validators using the Obol API.",
159
159
  bugs: {
160
160
  url: "https://github.com/obolnetwork/obol-sdk/issues"
@@ -215,7 +215,8 @@ var package_default = {
215
215
  "@typescript-eslint/* stays at ^6.x \u2014 eslint-config-standard-with-typescript@43 requires plugin ^6; v8 causes peer conflict.",
216
216
  "uuid stays at ^9.x \u2014 v11+ sets type:module (ESM-only).",
217
217
  "viem override pins a single resolved version to prevent duplicates across @safe-global/protocol-kit.",
218
- "@noble/curves replaces @chainsafe/bls \u2014 pure-JS CJS+ESM, no native addon, same ETH2 BLS12-381 spec. See CHAINSAFE_MIGRATION_PLAN.md."
218
+ "@noble/curves replaces @chainsafe/bls \u2014 pure-JS CJS+ESM, no native addon, same ETH2 BLS12-381 spec. See CHAINSAFE_MIGRATION_PLAN.md.",
219
+ "@noble/curves is in devDependencies (not dependencies) because tsup bundles it inline via noExternal. Keeping it in dependencies caused consumers to install @noble/hashes@2.2.0 (major-version 2) which shadowed @noble/hashes@1.x used by ethereum-cryptography, @coinbase/wallet-sdk, etc., breaking their @noble/curves initialisation with 'anumber is not a function'."
219
220
  ],
220
221
  resolutions: {},
221
222
  overrides: {
@@ -223,7 +224,6 @@ var package_default = {
223
224
  },
224
225
  dependencies: {
225
226
  "@chainsafe/enr": "6.0.1",
226
- "@noble/curves": "2.2.0",
227
227
  "@chainsafe/ssz": "0.14.3",
228
228
  "@metamask/eth-sig-util": "8.2.0",
229
229
  "@safe-global/protocol-kit": "7.1.0",
@@ -238,6 +238,7 @@ var package_default = {
238
238
  uuid: "9.0.1"
239
239
  },
240
240
  devDependencies: {
241
+ "@noble/curves": "2.2.0",
241
242
  "@release-it/conventional-changelog": "11.0.0",
242
243
  "@types/elliptic": "6.4.18",
243
244
  "@types/jest": "29.5.14",
@@ -574,10 +575,25 @@ var operatorContainerType = new import_ssz.ContainerType({
574
575
  config_signature: new import_ssz.ByteVectorType(65),
575
576
  enr_signature: new import_ssz.ByteVectorType(65)
576
577
  });
578
+ var k1SignatureListType = new import_ssz.ListCompositeType(
579
+ new import_ssz.ByteVectorType(65),
580
+ 32
581
+ );
582
+ var operatorContainerTypeV1X11 = new import_ssz.ContainerType({
583
+ address: new import_ssz.ByteVectorType(20),
584
+ enr: new import_ssz.ByteListType(1024),
585
+ // This needs to be dynamic, since ENRs do not have a fixed length.
586
+ config_signature: k1SignatureListType,
587
+ enr_signature: k1SignatureListType
588
+ });
577
589
  var creatorContainerType = new import_ssz.ContainerType({
578
590
  address: new import_ssz.ByteVectorType(20),
579
591
  config_signature: new import_ssz.ByteVectorType(65)
580
592
  });
593
+ var creatorContainerTypeV1X11 = new import_ssz.ContainerType({
594
+ address: new import_ssz.ByteVectorType(20),
595
+ config_signature: k1SignatureListType
596
+ });
581
597
  var validatorsContainerType = new import_ssz.ContainerType({
582
598
  fee_recipient_address: new import_ssz.ByteVectorType(20),
583
599
  withdrawal_address: new import_ssz.ByteVectorType(20)
@@ -585,9 +601,15 @@ var validatorsContainerType = new import_ssz.ContainerType({
585
601
  var newCreatorContainerType = (configOnly) => {
586
602
  return configOnly ? creatorAddressWrapperType : creatorContainerType;
587
603
  };
604
+ var newCreatorContainerTypeV1X11 = (configOnly) => {
605
+ return configOnly ? creatorAddressWrapperType : creatorContainerTypeV1X11;
606
+ };
588
607
  var newOperatorContainerType = (configOnly) => {
589
608
  return configOnly ? operatorAddressWrapperType : operatorContainerType;
590
609
  };
610
+ var newOperatorContainerTypeV1X11 = (configOnly) => {
611
+ return configOnly ? operatorAddressWrapperType : operatorContainerTypeV1X11;
612
+ };
591
613
  var depositDataContainer = new import_ssz.ContainerType({
592
614
  pubkey: new import_ssz.ByteVectorType(48),
593
615
  withdrawal_credentials: new import_ssz.ByteVectorType(32),
@@ -14342,6 +14364,165 @@ var hashClusterLockV1X10 = (cluster) => {
14342
14364
  };
14343
14365
  var verifyDVV1X10 = verifyDVV1X8;
14344
14366
 
14367
+ // src/verification/v1.11.0.ts
14368
+ var import_uint5 = require("@chainsafe/ssz/lib/type/uint.js");
14369
+ var import_ssz7 = require("@chainsafe/ssz");
14370
+ var splitK1SignatureList = (signature) => {
14371
+ const bytes = (0, import_ssz7.fromHexString)(signature);
14372
+ if (bytes.length === 0) return [];
14373
+ if (bytes.length % 65 !== 0) {
14374
+ throw new Error("Signature length must be a multiple of 65 bytes");
14375
+ }
14376
+ const chunks = [];
14377
+ for (let i = 0; i < bytes.length; i += 65) {
14378
+ chunks.push(bytes.slice(i, i + 65));
14379
+ }
14380
+ return chunks;
14381
+ };
14382
+ var clusterDefinitionContainerTypeV1X11 = (configOnly) => {
14383
+ let returnedContainerType = {
14384
+ uuid: new import_ssz7.ByteListType(64),
14385
+ name: new import_ssz7.ByteListType(256),
14386
+ version: new import_ssz7.ByteListType(16),
14387
+ timestamp: new import_ssz7.ByteListType(32),
14388
+ num_validators: new import_uint5.UintNumberType(8),
14389
+ threshold: new import_uint5.UintNumberType(8),
14390
+ dkg_algorithm: new import_ssz7.ByteListType(32),
14391
+ fork_version: new import_ssz7.ByteVectorType(4),
14392
+ operators: new import_ssz7.ListCompositeType(
14393
+ newOperatorContainerTypeV1X11(configOnly),
14394
+ 256
14395
+ ),
14396
+ creator: newCreatorContainerTypeV1X11(configOnly),
14397
+ validators: new import_ssz7.ListCompositeType(validatorsContainerType, 65536),
14398
+ deposit_amounts: new import_ssz7.ListBasicType(
14399
+ new import_uint5.UintNumberType(8),
14400
+ 256
14401
+ ),
14402
+ consensus_protocol: new import_ssz7.ByteListType(256),
14403
+ target_gas_limit: new import_uint5.UintNumberType(8),
14404
+ compounding: new import_ssz7.BooleanType()
14405
+ };
14406
+ if (!configOnly) {
14407
+ returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
14408
+ config_hash: new import_ssz7.ByteVectorType(32)
14409
+ });
14410
+ }
14411
+ return new import_ssz7.ContainerType(returnedContainerType);
14412
+ };
14413
+ var hashClusterDefinitionV1X11 = (cluster, configOnly) => {
14414
+ const definitionType = clusterDefinitionContainerTypeV1X11(configOnly);
14415
+ const val = definitionType.defaultValue();
14416
+ val.uuid = strToUint8Array(cluster.uuid);
14417
+ val.name = strToUint8Array(cluster.name);
14418
+ val.version = strToUint8Array(cluster.version);
14419
+ val.timestamp = strToUint8Array(cluster.timestamp);
14420
+ val.num_validators = cluster.num_validators;
14421
+ val.threshold = cluster.threshold;
14422
+ val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
14423
+ val.fork_version = (0, import_ssz7.fromHexString)(cluster.fork_version);
14424
+ val.operators = cluster.operators.map((operator) => {
14425
+ return configOnly ? { address: (0, import_ssz7.fromHexString)(operator.address) } : {
14426
+ address: (0, import_ssz7.fromHexString)(operator.address),
14427
+ enr: strToUint8Array(operator.enr),
14428
+ config_signature: splitK1SignatureList(
14429
+ operator.config_signature
14430
+ ),
14431
+ enr_signature: splitK1SignatureList(operator.enr_signature)
14432
+ };
14433
+ });
14434
+ val.creator = configOnly ? { address: (0, import_ssz7.fromHexString)(cluster.creator.address) } : {
14435
+ address: (0, import_ssz7.fromHexString)(cluster.creator.address),
14436
+ config_signature: splitK1SignatureList(
14437
+ cluster.creator.config_signature
14438
+ )
14439
+ };
14440
+ val.validators = cluster.validators.map((validator) => {
14441
+ return {
14442
+ fee_recipient_address: (0, import_ssz7.fromHexString)(validator.fee_recipient_address),
14443
+ withdrawal_address: (0, import_ssz7.fromHexString)(validator.withdrawal_address)
14444
+ };
14445
+ });
14446
+ if (cluster.deposit_amounts) {
14447
+ val.deposit_amounts = cluster.deposit_amounts.map((amount) => {
14448
+ return parseInt(amount);
14449
+ });
14450
+ }
14451
+ if (cluster.consensus_protocol) {
14452
+ val.consensus_protocol = strToUint8Array(cluster.consensus_protocol);
14453
+ }
14454
+ if (cluster.target_gas_limit) {
14455
+ val.target_gas_limit = cluster.target_gas_limit;
14456
+ }
14457
+ if (cluster.compounding) {
14458
+ val.compounding = cluster.compounding;
14459
+ }
14460
+ if (!configOnly) {
14461
+ val.config_hash = (0, import_ssz7.fromHexString)(cluster.config_hash);
14462
+ }
14463
+ return val;
14464
+ };
14465
+ var dvContainerTypeV1X11 = new import_ssz7.ContainerType({
14466
+ distributed_public_key: new import_ssz7.ByteVectorType(48),
14467
+ public_shares: new import_ssz7.ListCompositeType(new import_ssz7.ByteVectorType(48), 256),
14468
+ partial_deposit_data: new import_ssz7.ListCompositeType(depositDataContainer, 256),
14469
+ builder_registration: builderRegistrationContainer
14470
+ });
14471
+ var clusterLockContainerTypeV1X11 = () => {
14472
+ return new import_ssz7.ContainerType({
14473
+ cluster_definition: clusterDefinitionContainerTypeV1X11(false),
14474
+ distributed_validators: new import_ssz7.ListCompositeType(dvContainerTypeV1X11, 65536)
14475
+ });
14476
+ };
14477
+ var hashClusterLockV1X11 = (cluster) => {
14478
+ const lockType = clusterLockContainerTypeV1X11();
14479
+ const val = lockType.defaultValue();
14480
+ val.cluster_definition = hashClusterDefinitionV1X11(
14481
+ cluster.cluster_definition,
14482
+ false
14483
+ );
14484
+ val.distributed_validators = cluster.distributed_validators.map(
14485
+ (dValidator) => {
14486
+ var _a6, _b2, _c, _d, _e;
14487
+ return {
14488
+ distributed_public_key: (0, import_ssz7.fromHexString)(
14489
+ dValidator.distributed_public_key
14490
+ ),
14491
+ public_shares: dValidator.public_shares.map(
14492
+ (publicShare) => (0, import_ssz7.fromHexString)(publicShare)
14493
+ ),
14494
+ partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
14495
+ return {
14496
+ pubkey: (0, import_ssz7.fromHexString)(depositData.pubkey),
14497
+ withdrawal_credentials: (0, import_ssz7.fromHexString)(
14498
+ depositData.withdrawal_credentials
14499
+ ),
14500
+ amount: parseInt(depositData.amount),
14501
+ signature: (0, import_ssz7.fromHexString)(depositData.signature)
14502
+ };
14503
+ }),
14504
+ builder_registration: {
14505
+ message: {
14506
+ fee_recipient: (0, import_ssz7.fromHexString)(
14507
+ (_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
14508
+ ),
14509
+ gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
14510
+ timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
14511
+ pubkey: (0, import_ssz7.fromHexString)(
14512
+ (_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
14513
+ )
14514
+ },
14515
+ signature: (0, import_ssz7.fromHexString)(
14516
+ (_e = dValidator.builder_registration) == null ? void 0 : _e.signature
14517
+ )
14518
+ }
14519
+ };
14520
+ }
14521
+ );
14522
+ return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
14523
+ };
14524
+ var verifyDVV1X11 = verifyDVV1X8;
14525
+
14345
14526
  // src/verification/common.ts
14346
14527
  var clusterConfigOrDefinitionHash = (cluster, configOnly) => {
14347
14528
  let definitionType, val;
@@ -14366,6 +14547,11 @@ var clusterConfigOrDefinitionHash = (cluster, configOnly) => {
14366
14547
  const x = "0x" + Buffer.from(definitionType.hashTreeRoot(val).buffer).toString("hex");
14367
14548
  return x;
14368
14549
  }
14550
+ if (semver.eq(cluster.version, "v1.11.0")) {
14551
+ definitionType = clusterDefinitionContainerTypeV1X11(configOnly);
14552
+ val = hashClusterDefinitionV1X11(cluster, configOnly);
14553
+ return "0x" + Buffer.from(definitionType.hashTreeRoot(val).buffer).toString("hex");
14554
+ }
14369
14555
  throw new Error("unsupported version");
14370
14556
  };
14371
14557
  var clusterLockHash = (clusterLock) => {
@@ -14391,6 +14577,9 @@ var clusterLockHash = (clusterLock) => {
14391
14577
  if (semver.eq(clusterLock.cluster_definition.version, "v1.10.0")) {
14392
14578
  return hashClusterLockV1X10(clusterLock);
14393
14579
  }
14580
+ if (semver.eq(clusterLock.cluster_definition.version, "v1.11.0")) {
14581
+ return hashClusterLockV1X11(clusterLock);
14582
+ }
14394
14583
  throw new Error("unsupported version");
14395
14584
  };
14396
14585
  var validatePOSTConfigHashSigner = (address, signature, configHash, chainId, safeRpcUrl) => __async(null, null, function* () {
@@ -14490,8 +14679,8 @@ var computeSigningRoot = (sszObjectRoot, domain) => {
14490
14679
  };
14491
14680
  var computeDepositMsgRoot = (msg) => {
14492
14681
  const depositMsgVal = depositMessageType.defaultValue();
14493
- depositMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
14494
- depositMsgVal.withdrawal_credentials = (0, import_ssz7.fromHexString)(
14682
+ depositMsgVal.pubkey = (0, import_ssz8.fromHexString)(msg.pubkey);
14683
+ depositMsgVal.withdrawal_credentials = (0, import_ssz8.fromHexString)(
14495
14684
  msg.withdrawal_credentials
14496
14685
  );
14497
14686
  depositMsgVal.amount = parseInt(msg.amount);
@@ -14505,16 +14694,16 @@ var computeForkDataRoot = (currentVersion, genesisValidatorsRoot) => {
14505
14694
  };
14506
14695
  var computebuilderRegistrationMsgRoot = (msg) => {
14507
14696
  const builderRegistrationMsgVal = builderRegistrationMessageType.defaultValue();
14508
- builderRegistrationMsgVal.fee_recipient = (0, import_ssz7.fromHexString)(msg.fee_recipient);
14697
+ builderRegistrationMsgVal.fee_recipient = (0, import_ssz8.fromHexString)(msg.fee_recipient);
14509
14698
  builderRegistrationMsgVal.gas_limit = msg.gas_limit;
14510
14699
  builderRegistrationMsgVal.timestamp = msg.timestamp;
14511
- builderRegistrationMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
14700
+ builderRegistrationMsgVal.pubkey = (0, import_ssz8.fromHexString)(msg.pubkey);
14512
14701
  return Buffer.from(
14513
14702
  builderRegistrationMessageType.hashTreeRoot(builderRegistrationMsgVal).buffer
14514
14703
  );
14515
14704
  };
14516
- var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, import_ssz7.fromHexString)(GENESIS_VALIDATOR_ROOT)) => {
14517
- const forkVersion = (0, import_ssz7.fromHexString)(
14705
+ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, import_ssz8.fromHexString)(GENESIS_VALIDATOR_ROOT)) => {
14706
+ const forkVersion = (0, import_ssz8.fromHexString)(
14518
14707
  lockForkVersion.substring(2, lockForkVersion.length)
14519
14708
  );
14520
14709
  const forkDataRoot = computeForkDataRoot(forkVersion, genesisValidatorsRoot);
@@ -14523,10 +14712,10 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, im
14523
14712
  domain.set(forkDataRoot.subarray(0, 28), 4);
14524
14713
  return domain;
14525
14714
  };
14526
- var depositDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14527
- var builderDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14715
+ var depositDomainForFork = (forkVersion) => computeDomain((0, import_ssz8.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14716
+ var builderDomainForFork = (forkVersion) => computeDomain((0, import_ssz8.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14528
14717
  var validateDepositDataStructure = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
14529
- const depositDomain = precomputedDepositDomain != null ? precomputedDepositDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14718
+ const depositDomain = precomputedDepositDomain != null ? precomputedDepositDomain : computeDomain((0, import_ssz8.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14530
14719
  const withdrawalPrefix = compounding ? "0x02" : "0x01";
14531
14720
  const expectedWithdrawalCredentials = withdrawalPrefix + "0".repeat(22) + withdrawalAddress.toLowerCase().slice(2);
14532
14721
  if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
@@ -14553,14 +14742,14 @@ var depositBlsCheck = (distributedPublicKey, depositData, withdrawalAddress, for
14553
14742
  );
14554
14743
  if (!valid || !depositData.signature || !depositData.pubkey) return null;
14555
14744
  return {
14556
- pubkey: (0, import_ssz7.fromHexString)(depositData.pubkey),
14745
+ pubkey: (0, import_ssz8.fromHexString)(depositData.pubkey),
14557
14746
  message: message2,
14558
- signature: (0, import_ssz7.fromHexString)(depositData.signature)
14747
+ signature: (0, import_ssz8.fromHexString)(depositData.signature)
14559
14748
  };
14560
14749
  };
14561
14750
  var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
14562
14751
  var _a6;
14563
- const builderDomain = precomputedBuilderDomain != null ? precomputedBuilderDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14752
+ const builderDomain = precomputedBuilderDomain != null ? precomputedBuilderDomain : computeDomain((0, import_ssz8.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14564
14753
  if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
14565
14754
  return {
14566
14755
  isValidBuilderRegistration: false,
@@ -14596,9 +14785,9 @@ var builderBlsCheck = (validator, feeRecipientAddress, forkVersion, precomputedB
14596
14785
  const sig = (_a6 = validator.builder_registration) == null ? void 0 : _a6.signature;
14597
14786
  if (!isValidBuilderRegistration || !sig) return null;
14598
14787
  return {
14599
- pubkey: (0, import_ssz7.fromHexString)(validator.distributed_public_key),
14788
+ pubkey: (0, import_ssz8.fromHexString)(validator.distributed_public_key),
14600
14789
  message: builderRegistrationMsg,
14601
- signature: (0, import_ssz7.fromHexString)(sig)
14790
+ signature: (0, import_ssz8.fromHexString)(sig)
14602
14791
  };
14603
14792
  };
14604
14793
  var verifyNodeSignatures = (clusterLock) => {
@@ -14640,6 +14829,9 @@ var verifyLockData = (clusterLock) => __async(null, null, function* () {
14640
14829
  if (semver.eq(clusterLock.cluster_definition.version, "v1.10.0")) {
14641
14830
  return yield verifyDVV1X10(clusterLock);
14642
14831
  }
14832
+ if (semver.eq(clusterLock.cluster_definition.version, "v1.11.0")) {
14833
+ return yield verifyDVV1X11(clusterLock);
14834
+ }
14643
14835
  return false;
14644
14836
  });
14645
14837
  var hasUniqueDistributedKeys = (clusterLock) => {