@obolnetwork/obol-sdk 2.12.1 → 2.12.4

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 (38) hide show
  1. package/README.md +6 -4
  2. package/dist/browser/src/index.js +146 -62
  3. package/dist/browser/src/index.js.map +1 -1
  4. package/dist/cjs/src/index.js +149 -62
  5. package/dist/cjs/src/index.js.map +1 -1
  6. package/dist/cjs/src/verification/clusterLockValidationWorker.js +39 -10
  7. package/dist/cjs/src/verification/clusterLockValidationWorker.js.map +1 -1
  8. package/dist/cjs/src/verification/parallelPool.js +33 -14
  9. package/dist/cjs/src/verification/parallelPool.js.map +1 -1
  10. package/dist/esm/src/{chunk-RYTIXFRX.js → chunk-FGMJVLIN.js} +53 -15
  11. package/dist/esm/src/chunk-FGMJVLIN.js.map +1 -0
  12. package/dist/esm/src/{chunk-5ASVONSJ.js → chunk-YZWJJHPO.js} +9 -7
  13. package/dist/esm/src/chunk-YZWJJHPO.js.map +1 -0
  14. package/dist/esm/src/index.js +56 -7
  15. package/dist/esm/src/index.js.map +1 -1
  16. package/dist/esm/src/verification/clusterLockValidationWorker.js +9 -3
  17. package/dist/esm/src/verification/clusterLockValidationWorker.js.map +1 -1
  18. package/dist/esm/src/verification/parallelPool.js +1 -1
  19. package/dist/types/src/base.d.ts +5 -3
  20. package/dist/types/src/errors.d.ts +22 -4
  21. package/dist/types/src/index.d.ts +5 -6
  22. package/dist/types/src/services.d.ts +6 -3
  23. package/dist/types/src/verification/parallelPool.d.ts +4 -0
  24. package/dist/types/src/verification/validationConcurrency.d.ts +11 -0
  25. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  26. package/package.json +3 -3
  27. package/dist/esm/src/chunk-5ASVONSJ.js.map +0 -1
  28. package/dist/esm/src/chunk-RYTIXFRX.js.map +0 -1
  29. package/dist/types/test/client/ajv.spec.d.ts +0 -1
  30. package/dist/types/test/client/methods.spec.d.ts +0 -18
  31. package/dist/types/test/eoa/eoa.spec.d.ts +0 -1
  32. package/dist/types/test/exit/ethUtils.spec.d.ts +0 -1
  33. package/dist/types/test/exit/exit.spec.d.ts +0 -1
  34. package/dist/types/test/exit/verificationHelpers.spec.d.ts +0 -1
  35. package/dist/types/test/fixtures.d.ts +0 -359
  36. package/dist/types/test/incentives/incentives.spec.d.ts +0 -1
  37. package/dist/types/test/splits/splits.spec.d.ts +0 -1
  38. package/dist/types/test/verification/parallelPool.spec.d.ts +0 -1
@@ -57,14 +57,16 @@ import {
57
57
  verifyBuilderRegistration,
58
58
  verifyDepositData,
59
59
  verifyNodeSignatures
60
- } from "./chunk-5ASVONSJ.js";
60
+ } from "./chunk-YZWJJHPO.js";
61
61
  import {
62
+ ClusterLockValidationBusyError,
62
63
  ClusterLockValidationTimeoutError,
63
64
  ConflictError,
65
+ InvalidBaseUrlError,
64
66
  SignerRequiredError,
65
67
  UnsupportedChainError,
66
68
  validateClusterLockInWorker
67
- } from "./chunk-RYTIXFRX.js";
69
+ } from "./chunk-FGMJVLIN.js";
68
70
  import {
69
71
  __async,
70
72
  __spreadProps,
@@ -77,12 +79,30 @@ import {
77
79
  import { v4 as uuidv4 } from "uuid";
78
80
 
79
81
  // src/base.ts
82
+ var ALLOWED_OBOL_API_BASE_URLS = [
83
+ DEFAULT_BASE_URL,
84
+ "https://obol-api-nonprod-dev.dev.obol.tech",
85
+ "https://obol-api-nonprod-qa.dev.obol.tech"
86
+ ];
87
+ var ALLOWED_BASE_URLS = new Set(ALLOWED_OBOL_API_BASE_URLS);
88
+ function assertAllowedBaseUrl(baseUrl) {
89
+ let candidate = baseUrl.trim();
90
+ while (candidate.endsWith("/")) {
91
+ candidate = candidate.slice(0, -1);
92
+ }
93
+ if (!ALLOWED_BASE_URLS.has(candidate)) {
94
+ throw new InvalidBaseUrlError(
95
+ `baseUrl must be one of: ${ALLOWED_OBOL_API_BASE_URLS.join(", ")}`
96
+ );
97
+ }
98
+ return candidate;
99
+ }
80
100
  var Base = class {
81
101
  constructor({
82
102
  baseUrl = DEFAULT_BASE_URL,
83
103
  chainId = DEFAULT_CHAIN_ID
84
104
  }) {
85
- this.baseUrl = baseUrl;
105
+ this.baseUrl = assertAllowedBaseUrl(baseUrl);
86
106
  this.chainId = chainId;
87
107
  this.fork_version = FORK_MAPPING[this.chainId];
88
108
  }
@@ -5046,15 +5066,40 @@ var EOA = class {
5046
5066
  }
5047
5067
  };
5048
5068
 
5069
+ // src/verification/validationConcurrency.ts
5070
+ function getMaxConcurrentLockValidations() {
5071
+ const raw = process.env.OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS;
5072
+ if (raw === "0") return 0;
5073
+ if (raw !== void 0 && raw !== "") {
5074
+ const n = Number.parseInt(raw, 10);
5075
+ if (Number.isFinite(n) && n > 0) return n;
5076
+ }
5077
+ return 2;
5078
+ }
5079
+ var activeValidations = 0;
5080
+ function withLockValidationConcurrency(fn) {
5081
+ return __async(this, null, function* () {
5082
+ const max = getMaxConcurrentLockValidations();
5083
+ if (max === 0) return yield fn();
5084
+ if (activeValidations >= max) {
5085
+ throw new ClusterLockValidationBusyError(max);
5086
+ }
5087
+ activeValidations++;
5088
+ try {
5089
+ return yield fn();
5090
+ } finally {
5091
+ activeValidations--;
5092
+ }
5093
+ });
5094
+ }
5095
+
5049
5096
  // src/services.ts
5050
5097
  var validateClusterLock = (lock, safeRpcUrl) => __async(null, null, function* () {
5051
- try {
5098
+ return yield withLockValidationConcurrency(() => __async(null, null, function* () {
5052
5099
  const inWorker = yield validateClusterLockInWorker(lock, safeRpcUrl);
5053
5100
  if (inWorker !== null) return inWorker;
5054
5101
  return yield isValidClusterLock(lock, safeRpcUrl);
5055
- } catch (err) {
5056
- throw err;
5057
- }
5102
+ }));
5058
5103
  });
5059
5104
 
5060
5105
  // src/index.ts
@@ -5064,6 +5109,7 @@ var Client = class extends Base {
5064
5109
  *
5065
5110
  * @param config - Client configuration object.
5066
5111
  * @param config.baseUrl - Obol API base URL. Defaults to `https://api.obol.tech`.
5112
+ * Must match one of {@link ALLOWED_OBOL_API_BASE_URLS} (API paths use `/v1/...` separately).
5067
5113
  * @param config.chainId - Target chain ID. Defaults to `560048` (Hoodi).
5068
5114
  * Supported: 1 (Mainnet), 560048 (Hoodi), 100 (Gnosis), 11155111 (Sepolia).
5069
5115
  * @param signer - An ethers `Wallet` or `JsonRpcSigner`. Required for any
@@ -5644,12 +5690,14 @@ var Client = class extends Base {
5644
5690
  }
5645
5691
  };
5646
5692
  export {
5693
+ ALLOWED_OBOL_API_BASE_URLS,
5647
5694
  AVAILABLE_SPLITTER_CHAINS,
5648
5695
  CAPELLA_FORK_MAPPING,
5649
5696
  CHAIN_CONFIGURATION,
5650
5697
  CONFIG_VERSION,
5651
5698
  CONFLICT_ERROR_MSG,
5652
5699
  Client,
5700
+ ClusterLockValidationBusyError,
5653
5701
  ClusterLockValidationTimeoutError,
5654
5702
  ConflictError,
5655
5703
  CreatorConfigHashSigningTypes,
@@ -5676,6 +5724,7 @@ export {
5676
5724
  FORK_NAMES,
5677
5725
  GENESIS_VALIDATOR_ROOT,
5678
5726
  Incentives,
5727
+ InvalidBaseUrlError,
5679
5728
  OBOL_SDK_EMAIL,
5680
5729
  ObolSplits,
5681
5730
  OperatorConfigHashSigningTypes,