@zkp2p/sdk 0.12.1 → 0.12.2-rc.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 (36) hide show
  1. package/README.md +96 -24
  2. package/dist/build-metadata.json +22 -0
  3. package/dist/{chunk-GHQK65J2.mjs → chunk-3J4FPMPW.mjs} +2 -2
  4. package/dist/{chunk-GHQK65J2.mjs.map → chunk-3J4FPMPW.mjs.map} +1 -1
  5. package/dist/chunk-NCX4BO7G.mjs +12 -0
  6. package/dist/chunk-NCX4BO7G.mjs.map +1 -0
  7. package/dist/{chunk-DZQOCRT4.mjs → chunk-QVEW2DTE.mjs} +373 -373
  8. package/dist/{chunk-DZQOCRT4.mjs.map → chunk-QVEW2DTE.mjs.map} +1 -1
  9. package/dist/{chunk-FCOH36IX.mjs → chunk-YA67SM3A.mjs} +2 -2
  10. package/dist/{chunk-FCOH36IX.mjs.map → chunk-YA67SM3A.mjs.map} +1 -1
  11. package/dist/{chunk-ZFBH4HD7.mjs → chunk-ZB22BZLZ.mjs} +2 -2
  12. package/dist/{chunk-ZFBH4HD7.mjs.map → chunk-ZB22BZLZ.mjs.map} +1 -1
  13. package/dist/{currency-MARF3D2J.mjs → currency-XA62DCJH.mjs} +4 -4
  14. package/dist/{currency-MARF3D2J.mjs.map → currency-XA62DCJH.mjs.map} +1 -1
  15. package/dist/index.cjs +2263 -561
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.mts +34 -9
  18. package/dist/index.d.ts +34 -9
  19. package/dist/index.mjs +1638 -105
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/protocolViewerParsers-KB2FTOE6.mjs +5 -0
  22. package/dist/{protocolViewerParsers-WK2QPJH7.mjs.map → protocolViewerParsers-KB2FTOE6.mjs.map} +1 -1
  23. package/dist/react.cjs +41 -0
  24. package/dist/react.cjs.map +1 -1
  25. package/dist/react.d.mts +15 -3
  26. package/dist/react.d.ts +15 -3
  27. package/dist/react.mjs +44 -4
  28. package/dist/react.mjs.map +1 -1
  29. package/dist/{timeout-YLP3WHZF.mjs → timeout-7UJ6HZ4K.mjs} +4 -4
  30. package/dist/{timeout-YLP3WHZF.mjs.map → timeout-7UJ6HZ4K.mjs.map} +1 -1
  31. package/dist/{vaultUtils-Bc9KwywX.d.mts → vaultUtils-Dla_eG15.d.mts} +206 -43
  32. package/dist/{vaultUtils-Bc9KwywX.d.ts → vaultUtils-Dla_eG15.d.ts} +206 -43
  33. package/package.json +23 -22
  34. package/dist/chunk-J5LGTIGS.mjs +0 -9
  35. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  36. package/dist/protocolViewerParsers-WK2QPJH7.mjs +0 -5
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { IntentGuardianOperations } from './chunk-FCOH36IX.mjs';
2
- export { ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-FCOH36IX.mjs';
3
- import { NetworkError, ValidationError, APIError } from './chunk-GHQK65J2.mjs';
4
- export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
5
- import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-DZQOCRT4.mjs';
6
- export { CHARGEBACK_POLICY_ABI, ORCHESTRATOR_V3_ABI, PAYMENT_PLATFORMS, STAKE_VAULT_ABI, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getChargebackPolicyContract, getContracts, getGatingServiceAddress, getIntentGuardianContract, getOrchestratorV3Contract, getPaymentMethodsCatalog, getRateManagerContracts, getStakeVaultContract, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-DZQOCRT4.mjs';
7
- import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
8
- export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
9
- import './chunk-J5LGTIGS.mjs';
10
- import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, isAddress, zeroAddress, formatUnits } from 'viem';
1
+ import { IntentGuardianOperations } from './chunk-YA67SM3A.mjs';
2
+ export { ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-YA67SM3A.mjs';
3
+ import { NetworkError, ValidationError, APIError } from './chunk-3J4FPMPW.mjs';
4
+ export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-3J4FPMPW.mjs';
5
+ import { OrchestratorRegistry_default, DisputeProtectionPolicy_default, METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash, OrchestratorV3_default, MultiAttestationVerifier_default, DisputeNullifierRegistry_default, DisputeVerifier_default, WhitelistPolicy_default, StakeVault_default, IntentLifecycleHookV1_default } from './chunk-QVEW2DTE.mjs';
6
+ export { DISPUTE_PROTECTION_POLICY_ABI, ORCHESTRATOR_V3_ABI, PAYMENT_PLATFORMS, STAKE_VAULT_ABI, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getDisputeProtectionPolicyContract, getGatingServiceAddress, getIntentGuardianContract, getOrchestratorV3Contract, getPaymentMethodsCatalog, getRateManagerContracts, getStakeVaultContract, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-QVEW2DTE.mjs';
7
+ import { Currency, currencyKeccak256 } from './chunk-ZB22BZLZ.mjs';
8
+ export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZB22BZLZ.mjs';
9
+ import { define_ZKP2P_SDK_BUILD_METADATA_default } from './chunk-NCX4BO7G.mjs';
10
+ import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, isAddress, zeroAddress, keccak256, formatUnits } from 'viem';
11
11
  import { hardhat, base } from 'viem/chains';
12
12
  import { createEncryptedBuyerTeeSessionMaterial as createEncryptedBuyerTeeSessionMaterial$1, createEncryptedSellerCredentialUpload } from '@zkp2p/zkp2p-attestation';
13
13
  export { createNitroAttestationClient } from '@zkp2p/zkp2p-attestation';
@@ -357,7 +357,7 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
357
357
  for (let i = 0; i < maxRetries; i++) {
358
358
  try {
359
359
  if (timeoutMs) {
360
- const { withTimeout } = await import('./timeout-YLP3WHZF.mjs');
360
+ const { withTimeout } = await import('./timeout-7UJ6HZ4K.mjs');
361
361
  return await withTimeout(fn(), timeoutMs, `Operation timed out after ${timeoutMs}ms`);
362
362
  }
363
363
  return await fn();
@@ -852,7 +852,7 @@ async function sendTransactionWithAttribution(walletClient, request, referrer, o
852
852
  // src/utils/constants.ts
853
853
  var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
854
854
 
855
- // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
855
+ // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.1-rc.6_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
856
856
  var chainlink_default = {
857
857
  feeds: [
858
858
  {
@@ -1300,7 +1300,7 @@ var IntentOperations = class {
1300
1300
  }
1301
1301
  ];
1302
1302
  const { referrer } = params.txOverrides ?? {};
1303
- const data = encodeWithAttribution(
1303
+ const data3 = encodeWithAttribution(
1304
1304
  {
1305
1305
  abi: orchestratorContext.abi,
1306
1306
  functionName: "signalIntent",
@@ -1310,7 +1310,7 @@ var IntentOperations = class {
1310
1310
  );
1311
1311
  return {
1312
1312
  to: orchestratorContext.address,
1313
- data,
1313
+ data: data3,
1314
1314
  value: 0n,
1315
1315
  chainId: this.config.getChainId(),
1316
1316
  abi: orchestratorContext.abi,
@@ -1325,7 +1325,7 @@ var IntentOperations = class {
1325
1325
  });
1326
1326
  const args = [params.intentHash];
1327
1327
  const { referrer } = params.txOverrides ?? {};
1328
- const data = encodeWithAttribution(
1328
+ const data3 = encodeWithAttribution(
1329
1329
  {
1330
1330
  abi: orchestratorContext.abi,
1331
1331
  functionName: "cancelIntent",
@@ -1335,7 +1335,7 @@ var IntentOperations = class {
1335
1335
  );
1336
1336
  return {
1337
1337
  to: orchestratorContext.address,
1338
- data,
1338
+ data: data3,
1339
1339
  value: 0n,
1340
1340
  chainId: this.config.getChainId(),
1341
1341
  abi: orchestratorContext.abi,
@@ -1350,7 +1350,7 @@ var IntentOperations = class {
1350
1350
  });
1351
1351
  const args = [params.intentHash];
1352
1352
  const { referrer } = params.txOverrides ?? {};
1353
- const data = encodeWithAttribution(
1353
+ const data3 = encodeWithAttribution(
1354
1354
  {
1355
1355
  abi: orchestratorContext.abi,
1356
1356
  functionName: "releaseFundsToPayer",
@@ -1360,7 +1360,7 @@ var IntentOperations = class {
1360
1360
  );
1361
1361
  return {
1362
1362
  to: orchestratorContext.address,
1363
- data,
1363
+ data: data3,
1364
1364
  value: 0n,
1365
1365
  chainId: this.config.getChainId(),
1366
1366
  abi: orchestratorContext.abi,
@@ -1524,7 +1524,7 @@ var IntentOperations = class {
1524
1524
  }
1525
1525
  ];
1526
1526
  const { referrer } = params.txOverrides ?? {};
1527
- const data = encodeWithAttribution(
1527
+ const data3 = encodeWithAttribution(
1528
1528
  {
1529
1529
  abi: orchestratorContext.abi,
1530
1530
  functionName: "fulfillIntent",
@@ -1534,7 +1534,7 @@ var IntentOperations = class {
1534
1534
  );
1535
1535
  return {
1536
1536
  to: orchestratorContext.address,
1537
- data,
1537
+ data: data3,
1538
1538
  value: 0n,
1539
1539
  chainId: this.config.getChainId(),
1540
1540
  abi: orchestratorContext.abi,
@@ -1898,7 +1898,7 @@ var ProtocolViewerReader = class {
1898
1898
  if (inputCount === null) {
1899
1899
  throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
1900
1900
  }
1901
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
1901
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-KB2FTOE6.mjs');
1902
1902
  if (inputCount >= 3) {
1903
1903
  return tryContexts(
1904
1904
  protocolViewerContexts,
@@ -1984,7 +1984,7 @@ var ProtocolViewerReader = class {
1984
1984
  return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
1985
1985
  }
1986
1986
  const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
1987
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
1987
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-KB2FTOE6.mjs');
1988
1988
  if (inputCount >= 2) {
1989
1989
  const requests = ids.map((id, index) => ({
1990
1990
  index,
@@ -2089,7 +2089,7 @@ var ProtocolViewerReader = class {
2089
2089
  if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
2090
2090
  return this.config.host.getPvAccountDepositsFromIndexer(owner);
2091
2091
  }
2092
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
2092
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-KB2FTOE6.mjs');
2093
2093
  const { address, abi } = this.config.host.requireProtocolViewer();
2094
2094
  if (inputCount >= 2) {
2095
2095
  const readAndFilter = async (raw2) => {
@@ -2160,7 +2160,7 @@ var ProtocolViewerReader = class {
2160
2160
  if (protocolViewerEntries.length === 0) {
2161
2161
  throw new Error("ProtocolViewer not available for this network");
2162
2162
  }
2163
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
2163
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-KB2FTOE6.mjs');
2164
2164
  const intentsByHash = /* @__PURE__ */ new Map();
2165
2165
  let attemptedRead = false;
2166
2166
  let hadSuccessfulRead = false;
@@ -2268,7 +2268,7 @@ var ProtocolViewerReader = class {
2268
2268
  if (protocolViewerEntries.length === 0) {
2269
2269
  throw new Error("ProtocolViewer not available for this network");
2270
2270
  }
2271
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-WK2QPJH7.mjs');
2271
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-KB2FTOE6.mjs');
2272
2272
  let lastError;
2273
2273
  for (const pvEntry of protocolViewerEntries) {
2274
2274
  const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
@@ -3603,7 +3603,7 @@ var STAKING_STATE_QUERY = (
3603
3603
  updatedAtBlockNumber
3604
3604
  updatedAt
3605
3605
  }
3606
- ChargebackRiskWindow(
3606
+ DisputeProtectionRiskWindow(
3607
3607
  where: { chainId: { _eq: $chainId }, policyAddress: { _eq: $policy } }
3608
3608
  order_by: { paymentMethod: asc }
3609
3609
  ) {
@@ -3618,6 +3618,107 @@ var STAKING_STATE_QUERY = (
3618
3618
  updatedAtBlockNumber
3619
3619
  updatedAt
3620
3620
  }
3621
+ chain_metadata(where: { chain_id: { _eq: $chainId } }, limit: 1) {
3622
+ chain_id
3623
+ latest_processed_block
3624
+ }
3625
+ }
3626
+ `
3627
+ );
3628
+ var STAKE_LOCKS_QUERY = (
3629
+ /* GraphQL */
3630
+ `
3631
+ query StakeLocks($where: StakeLock_bool_exp!, $limit: Int!) {
3632
+ StakeLock(where: $where, order_by: [{ id: asc }], limit: $limit) {
3633
+ id
3634
+ chainId
3635
+ vaultAddress
3636
+ lockId
3637
+ stakeOwner
3638
+ initialAmount
3639
+ currentAmount
3640
+ maturesAt
3641
+ status
3642
+ unlockedAmount
3643
+ claimedAmount
3644
+ createdAt
3645
+ updatedAtBlockNumber
3646
+ updatedAt
3647
+ }
3648
+ }
3649
+ `
3650
+ );
3651
+ var STAKE_ACTIVITY_QUERY = (
3652
+ /* GraphQL */
3653
+ `
3654
+ query StakeActivityPage($where: StakeActivity_bool_exp!, $limit: Int!) {
3655
+ StakeActivity(
3656
+ where: $where
3657
+ order_by: [{ blockNumber: asc }, { logIndex: asc }, { id: asc }]
3658
+ limit: $limit
3659
+ ) {
3660
+ id
3661
+ chainId
3662
+ vaultAddress
3663
+ stakeOwner
3664
+ taker
3665
+ beneficiary
3666
+ kind
3667
+ lockId
3668
+ counterparty
3669
+ amount
3670
+ previousAmount
3671
+ stakeBalanceAfter
3672
+ lockedStakeAfter
3673
+ freeStakeAfter
3674
+ claimableAfter
3675
+ maturesAt
3676
+ blockNumber
3677
+ logIndex
3678
+ timestamp
3679
+ }
3680
+ }
3681
+ `
3682
+ );
3683
+ var DISPUTE_PROTECTION_INTENTS_QUERY = (
3684
+ /* GraphQL */
3685
+ `
3686
+ query FinalizedDisputeProtectionIntents($where: DisputeProtectionIntent_bool_exp!, $limit: Int!) {
3687
+ DisputeProtectionIntent(
3688
+ where: $where
3689
+ order_by: [{ disputedAtBlockNumber: asc }, { disputedAtLogIndex: asc }, { id: asc }]
3690
+ limit: $limit
3691
+ ) {
3692
+ id
3693
+ chainId
3694
+ policyAddress
3695
+ intentHash
3696
+ status
3697
+ stakeOwner
3698
+ depositor
3699
+ taker
3700
+ paymentMethod
3701
+ amount
3702
+ riskWindow
3703
+ releaseEligibleAt
3704
+ releaseAmount
3705
+ isManualRelease
3706
+ compensatedAmount
3707
+ disputeId
3708
+ openedAt
3709
+ openedTxHash
3710
+ cancelledAt
3711
+ cancelledTxHash
3712
+ settledAt
3713
+ settledTxHash
3714
+ releasedAt
3715
+ releasedTxHash
3716
+ disputedAt
3717
+ disputedTxHash
3718
+ disputedAtBlockNumber
3719
+ disputedAtLogIndex
3720
+ updatedAt
3721
+ }
3621
3722
  }
3622
3723
  `
3623
3724
  );
@@ -4527,19 +4628,19 @@ async function apiGetPayeeDetails(req, baseApiUrl, timeoutMs) {
4527
4628
  });
4528
4629
  }
4529
4630
  async function apiValidatePayeeDetails(req, baseApiUrl, timeoutMs) {
4530
- const data = await apiFetch({
4631
+ const data3 = await apiFetch({
4531
4632
  url: `${withApiBase(baseApiUrl)}/v2/makers/validate`,
4532
4633
  method: "POST",
4533
4634
  body: req,
4534
4635
  timeoutMs
4535
4636
  });
4536
- if (typeof data?.responseObject === "boolean") {
4637
+ if (typeof data3?.responseObject === "boolean") {
4537
4638
  return {
4538
- ...data,
4539
- responseObject: { isValid: data.responseObject }
4639
+ ...data3,
4640
+ responseObject: { isValid: data3.responseObject }
4540
4641
  };
4541
4642
  }
4542
- return data;
4643
+ return data3;
4543
4644
  }
4544
4645
  async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs) {
4545
4646
  const escrowAddress = requireEscrowAddress(
@@ -5529,10 +5630,10 @@ var StakeOperations = class {
5529
5630
  return { address, abi, stakeToken };
5530
5631
  }
5531
5632
  getPolicyContract() {
5532
- const address = this.config.getChargebackPolicyAddress();
5533
- const abi = this.config.getChargebackPolicyAbi();
5633
+ const address = this.config.getDisputeProtectionPolicyAddress();
5634
+ const abi = this.config.getDisputeProtectionPolicyAbi();
5534
5635
  if (!address || !abi) {
5535
- throw new Error("ChargebackPolicy not available for this chain/environment");
5636
+ throw new Error("DisputeProtectionPolicy not available for this chain/environment");
5536
5637
  }
5537
5638
  return { address, abi };
5538
5639
  }
@@ -5575,7 +5676,7 @@ var StakeOperations = class {
5575
5676
  getTakerAuthorization(stakeOwner, taker) {
5576
5677
  return this.read("authorizedTakers", [stakeOwner, taker]);
5577
5678
  }
5578
- /** Whether the policy is refusing new chargebackable admissions. */
5679
+ /** Whether the policy is refusing new dispute-protected admissions. */
5579
5680
  getAdmissionsPaused() {
5580
5681
  return this.readPolicy("admissionsPaused");
5581
5682
  }
@@ -5586,9 +5687,9 @@ var StakeOperations = class {
5586
5687
  getRiskWindow(paymentMethodHash) {
5587
5688
  return this.readPolicy("getRiskWindow", [paymentMethodHash]);
5588
5689
  }
5589
- /** Whether a specific escrow deposit has opted into chargeback coverage. */
5590
- isChargebackEnabled(escrow, depositId) {
5591
- return this.readPolicy("isChargebackEnabled", [escrow, depositId]);
5690
+ /** Whether a specific escrow deposit has opted into dispute protection. */
5691
+ isDisputeProtectionEnabled(escrow, depositId) {
5692
+ return this.readPolicy("isDisputeProtectionEnabled", [escrow, depositId]);
5592
5693
  }
5593
5694
  async getStakeVaultState(params) {
5594
5695
  const taker = params.taker ?? params.staker;
@@ -6338,6 +6439,8 @@ var IndexerRateManagerService = class {
6338
6439
  }
6339
6440
  }
6340
6441
  };
6442
+ var DEFAULT_PAGE_LIMIT = 50;
6443
+ var MAX_PAGE_LIMIT = 100;
6341
6444
  var ZERO_STAKE = {
6342
6445
  totalUsdc: "0",
6343
6446
  lockedUsdc: "0",
@@ -6358,6 +6461,262 @@ function normalizeDecimal(value, field) {
6358
6461
  }
6359
6462
  return value;
6360
6463
  }
6464
+ function normalizeOptionalDecimal(value, field) {
6465
+ return value === null || value === void 0 ? null : normalizeDecimal(value, field);
6466
+ }
6467
+ function validateChainId(chainId) {
6468
+ if (!Number.isInteger(chainId) || chainId <= 0) {
6469
+ throw new ValidationError("chainId must be a positive integer", "chainId");
6470
+ }
6471
+ }
6472
+ function validateLimit(limit) {
6473
+ const resolved = limit ?? DEFAULT_PAGE_LIMIT;
6474
+ if (!Number.isInteger(resolved) || resolved < 1 || resolved > MAX_PAGE_LIMIT) {
6475
+ throw new ValidationError("limit must be an integer from 1 to 100", "limit");
6476
+ }
6477
+ return resolved;
6478
+ }
6479
+ function encodeCursor(prefix, value) {
6480
+ const encoded = btoa(JSON.stringify(value)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
6481
+ return `${prefix}.${encoded}`;
6482
+ }
6483
+ function decodeCursor(cursor, prefix, validate) {
6484
+ try {
6485
+ const encoded = cursor.slice(prefix.length + 1).replace(/-/g, "+").replace(/_/g, "/");
6486
+ const padded = encoded.padEnd(Math.ceil(encoded.length / 4) * 4, "=");
6487
+ if (!cursor.startsWith(`${prefix}.`) || encoded.length === 0) {
6488
+ throw new Error("wrong cursor kind");
6489
+ }
6490
+ return validate(JSON.parse(atob(padded)));
6491
+ } catch {
6492
+ throw new ValidationError(`cursor must be a valid ${prefix} cursor`, "cursor");
6493
+ }
6494
+ }
6495
+ function decodeLockCursor(cursor) {
6496
+ return decodeCursor(cursor, "zkp2p-lock-v1", (value) => {
6497
+ if (typeof value !== "object" || value === null || typeof Reflect.get(value, "id") !== "string") {
6498
+ throw new Error("invalid lock cursor");
6499
+ }
6500
+ const id = Reflect.get(value, "id");
6501
+ if (id.length === 0) throw new Error("invalid lock cursor");
6502
+ return id;
6503
+ });
6504
+ }
6505
+ function decodeEventCursor(cursor, prefix) {
6506
+ return decodeCursor(cursor, prefix, (value) => {
6507
+ if (typeof value !== "object" || value === null) throw new Error("invalid event cursor");
6508
+ const blockNumber = Reflect.get(value, "blockNumber");
6509
+ const logIndex = Reflect.get(value, "logIndex");
6510
+ const id = Reflect.get(value, "id");
6511
+ if (typeof blockNumber !== "string" || typeof logIndex !== "string" || typeof id !== "string") {
6512
+ throw new Error("invalid event cursor");
6513
+ }
6514
+ if (id.length === 0) throw new Error("invalid event cursor");
6515
+ return {
6516
+ blockNumber: normalizeDecimal(blockNumber, "cursor.blockNumber"),
6517
+ logIndex: normalizeDecimal(logIndex, "cursor.logIndex"),
6518
+ id
6519
+ };
6520
+ });
6521
+ }
6522
+ function compareEventCursor(left, right) {
6523
+ const leftBlock = BigInt(left.blockNumber);
6524
+ const rightBlock = BigInt(right.blockNumber);
6525
+ if (leftBlock !== rightBlock) return leftBlock < rightBlock ? -1 : 1;
6526
+ const leftLog = BigInt(left.logIndex);
6527
+ const rightLog = BigInt(right.logIndex);
6528
+ if (leftLog !== rightLog) return leftLog < rightLog ? -1 : 1;
6529
+ return left.id === right.id ? 0 : left.id < right.id ? -1 : 1;
6530
+ }
6531
+ function eventKeysetPredicate(cursor, blockField, logField) {
6532
+ return {
6533
+ _or: [
6534
+ { [blockField]: { _gt: cursor.blockNumber } },
6535
+ {
6536
+ _and: [
6537
+ { [blockField]: { _eq: cursor.blockNumber } },
6538
+ { [logField]: { _gt: cursor.logIndex } }
6539
+ ]
6540
+ },
6541
+ {
6542
+ _and: [
6543
+ { [blockField]: { _eq: cursor.blockNumber } },
6544
+ { [logField]: { _eq: cursor.logIndex } },
6545
+ { id: { _gt: cursor.id } }
6546
+ ]
6547
+ }
6548
+ ]
6549
+ };
6550
+ }
6551
+ var STAKE_LOCK_STATUSES = /* @__PURE__ */ new Set(["ACTIVE", "UNLOCKED", "RESOLVED"]);
6552
+ var STAKE_ACTIVITY_KINDS = /* @__PURE__ */ new Set([
6553
+ "DEPOSITED",
6554
+ "WITHDRAWN",
6555
+ "TAKER_AUTHORIZATION_UPDATED",
6556
+ "STAKE_OWNER_SELECTED",
6557
+ "LOCK_FUNDED",
6558
+ "STAKE_LOCKED",
6559
+ "STAKE_LOCK_INCREASED",
6560
+ "STAKE_LOCK_RESIZED",
6561
+ "STAKE_UNLOCKED",
6562
+ "STAKE_LOCK_RESOLVED",
6563
+ "CLAIM_CREATED",
6564
+ "CLAIM_WITHDRAWN"
6565
+ ]);
6566
+ function normalizeLockStatus(value, field) {
6567
+ if (!STAKE_LOCK_STATUSES.has(value)) {
6568
+ throw new Error(`${field} is not a supported stake lock status`);
6569
+ }
6570
+ return value;
6571
+ }
6572
+ function normalizeActivityKind(value, field) {
6573
+ if (!STAKE_ACTIVITY_KINDS.has(value)) {
6574
+ throw new Error(`${field} is not a supported stake activity kind`);
6575
+ }
6576
+ return value;
6577
+ }
6578
+ function latestLockAsOf(items) {
6579
+ if (items.length === 0) return null;
6580
+ const latest = items.reduce(
6581
+ (current, item) => BigInt(item.updatedAtBlockNumber) > BigInt(current.updatedAtBlockNumber) ? item : current
6582
+ );
6583
+ return { blockNumber: latest.updatedAtBlockNumber, timestamp: latest.updatedAt };
6584
+ }
6585
+ function assertNonEmptyId(id, field) {
6586
+ if (id.length === 0) throw new Error(`${field} must not be empty`);
6587
+ return id;
6588
+ }
6589
+ function normalizeStakeLockRow(row, index, scope) {
6590
+ const field = `StakeLock[${index}]`;
6591
+ if (row.chainId !== scope.chainId) throw new Error(`${field}.chainId does not match the query`);
6592
+ if (normalizeAddress4(row.vaultAddress, `${field}.vaultAddress`) !== scope.vaultAddress) {
6593
+ throw new Error(`${field}.vaultAddress does not match the query`);
6594
+ }
6595
+ const stakeOwner = normalizeAddress4(row.stakeOwner, `${field}.stakeOwner`);
6596
+ if (stakeOwner !== scope.stakeOwner) {
6597
+ throw new Error(`${field}.stakeOwner does not match the query`);
6598
+ }
6599
+ const status = normalizeLockStatus(row.status, `${field}.status`);
6600
+ if (scope.status && status !== scope.status) {
6601
+ throw new Error(`${field}.status does not match the query`);
6602
+ }
6603
+ return {
6604
+ lockId: assertNonEmptyId(row.lockId, `${field}.lockId`),
6605
+ stakeOwner,
6606
+ initialAmount: normalizeDecimal(row.initialAmount, `${field}.initialAmount`),
6607
+ currentAmount: normalizeDecimal(row.currentAmount, `${field}.currentAmount`),
6608
+ maturesAt: normalizeDecimal(row.maturesAt, `${field}.maturesAt`),
6609
+ status,
6610
+ unlockedAmount: normalizeDecimal(row.unlockedAmount, `${field}.unlockedAmount`),
6611
+ claimedAmount: normalizeDecimal(row.claimedAmount, `${field}.claimedAmount`),
6612
+ createdAt: normalizeDecimal(row.createdAt, `${field}.createdAt`),
6613
+ updatedAtBlockNumber: normalizeDecimal(
6614
+ row.updatedAtBlockNumber,
6615
+ `${field}.updatedAtBlockNumber`
6616
+ ),
6617
+ updatedAt: normalizeDecimal(row.updatedAt, `${field}.updatedAt`)
6618
+ };
6619
+ }
6620
+ function normalizeStakeActivityRow(row, index, scope) {
6621
+ const field = `StakeActivity[${index}]`;
6622
+ if (row.chainId !== scope.chainId) throw new Error(`${field}.chainId does not match the query`);
6623
+ if (normalizeAddress4(row.vaultAddress, `${field}.vaultAddress`) !== scope.vaultAddress) {
6624
+ throw new Error(`${field}.vaultAddress does not match the query`);
6625
+ }
6626
+ const stakeOwner = normalizeNullableAddress(row.stakeOwner, `${field}.stakeOwner`);
6627
+ const taker = normalizeNullableAddress(row.taker, `${field}.taker`);
6628
+ if (stakeOwner !== scope.merchant && taker !== scope.merchant) {
6629
+ throw new Error(`${field} is not relevant to the requested merchant`);
6630
+ }
6631
+ const kind = normalizeActivityKind(row.kind, `${field}.kind`);
6632
+ if (scope.kind && kind !== scope.kind) {
6633
+ throw new Error(`${field}.kind does not match the query`);
6634
+ }
6635
+ const blockNumber = normalizeDecimal(row.blockNumber, `${field}.blockNumber`);
6636
+ const logIndex = normalizeDecimal(row.logIndex, `${field}.logIndex`);
6637
+ const id = assertNonEmptyId(row.id, `${field}.id`);
6638
+ return {
6639
+ item: {
6640
+ stakeOwner,
6641
+ taker,
6642
+ beneficiary: normalizeNullableAddress(row.beneficiary, `${field}.beneficiary`),
6643
+ kind,
6644
+ lockId: row.lockId ?? null,
6645
+ counterparty: normalizeNullableAddress(row.counterparty, `${field}.counterparty`),
6646
+ amount: normalizeDecimal(row.amount, `${field}.amount`),
6647
+ previousAmount: normalizeOptionalDecimal(row.previousAmount, `${field}.previousAmount`),
6648
+ stakeBalanceAfter: normalizeOptionalDecimal(
6649
+ row.stakeBalanceAfter,
6650
+ `${field}.stakeBalanceAfter`
6651
+ ),
6652
+ lockedStakeAfter: normalizeOptionalDecimal(row.lockedStakeAfter, `${field}.lockedStakeAfter`),
6653
+ freeStakeAfter: normalizeOptionalDecimal(row.freeStakeAfter, `${field}.freeStakeAfter`),
6654
+ claimableAfter: normalizeOptionalDecimal(row.claimableAfter, `${field}.claimableAfter`),
6655
+ maturesAt: normalizeOptionalDecimal(row.maturesAt, `${field}.maturesAt`),
6656
+ blockNumber,
6657
+ logIndex,
6658
+ timestamp: normalizeDecimal(row.timestamp, `${field}.timestamp`)
6659
+ },
6660
+ cursor: { blockNumber, logIndex, id }
6661
+ };
6662
+ }
6663
+ function normalizeDisputeRow(row, index, scope) {
6664
+ const field = `DisputeProtectionIntent[${index}]`;
6665
+ if (row.chainId !== scope.chainId) throw new Error(`${field}.chainId does not match the query`);
6666
+ const policyAddress = normalizeAddress4(row.policyAddress, `${field}.policyAddress`);
6667
+ if (policyAddress !== scope.policyAddress) {
6668
+ throw new Error(`${field}.policyAddress does not match the query`);
6669
+ }
6670
+ if (row.status !== "DISPUTED") throw new Error(`${field}.status must be DISPUTED`);
6671
+ if (row.disputedAtBlockNumber === null || row.disputedAtBlockNumber === void 0 || row.disputedAtLogIndex === null || row.disputedAtLogIndex === void 0 || row.disputedAt === null || row.disputedAt === void 0 || row.disputedTxHash === null || row.disputedTxHash === void 0) {
6672
+ throw new Error(`${field} DISPUTED row must include its finalized event cursor`);
6673
+ }
6674
+ const blockNumber = normalizeDecimal(row.disputedAtBlockNumber, `${field}.disputedAtBlockNumber`);
6675
+ if (BigInt(blockNumber) > BigInt(scope.throughBlockNumber)) {
6676
+ throw new Error(`${field}.disputedAtBlockNumber exceeds throughBlockNumber`);
6677
+ }
6678
+ const logIndex = normalizeDecimal(row.disputedAtLogIndex, `${field}.disputedAtLogIndex`);
6679
+ const disputedAt = normalizeDecimal(row.disputedAt, `${field}.disputedAt`);
6680
+ const id = assertNonEmptyId(row.id, `${field}.id`);
6681
+ return {
6682
+ item: {
6683
+ policyAddress,
6684
+ intentHash: row.intentHash,
6685
+ status: "DISPUTED",
6686
+ stakeOwner: normalizeAddress4(row.stakeOwner, `${field}.stakeOwner`),
6687
+ depositor: normalizeAddress4(row.depositor, `${field}.depositor`),
6688
+ taker: normalizeAddress4(row.taker, `${field}.taker`),
6689
+ paymentMethod: row.paymentMethod,
6690
+ amount: normalizeDecimal(row.amount, `${field}.amount`),
6691
+ riskWindow: normalizeDecimal(row.riskWindow, `${field}.riskWindow`),
6692
+ releaseEligibleAt: normalizeOptionalDecimal(
6693
+ row.releaseEligibleAt,
6694
+ `${field}.releaseEligibleAt`
6695
+ ),
6696
+ releaseAmount: normalizeOptionalDecimal(row.releaseAmount, `${field}.releaseAmount`),
6697
+ isManualRelease: row.isManualRelease ?? null,
6698
+ compensatedAmount: normalizeOptionalDecimal(
6699
+ row.compensatedAmount,
6700
+ `${field}.compensatedAmount`
6701
+ ),
6702
+ disputeId: row.disputeId ?? null,
6703
+ openedAt: normalizeDecimal(row.openedAt, `${field}.openedAt`),
6704
+ openedTxHash: row.openedTxHash,
6705
+ cancelledAt: normalizeOptionalDecimal(row.cancelledAt, `${field}.cancelledAt`),
6706
+ cancelledTxHash: row.cancelledTxHash ?? null,
6707
+ settledAt: normalizeOptionalDecimal(row.settledAt, `${field}.settledAt`),
6708
+ settledTxHash: row.settledTxHash ?? null,
6709
+ releasedAt: normalizeOptionalDecimal(row.releasedAt, `${field}.releasedAt`),
6710
+ releasedTxHash: row.releasedTxHash ?? null,
6711
+ disputedAt,
6712
+ disputedTxHash: row.disputedTxHash,
6713
+ disputedAtBlockNumber: blockNumber,
6714
+ disputedAtLogIndex: logIndex,
6715
+ updatedAt: normalizeDecimal(row.updatedAt, `${field}.updatedAt`)
6716
+ },
6717
+ cursor: { blockNumber, logIndex, id }
6718
+ };
6719
+ }
6361
6720
  function freshnessOf(row, field) {
6362
6721
  if (!row) return null;
6363
6722
  return {
@@ -6368,19 +6727,25 @@ function freshnessOf(row, field) {
6368
6727
  updatedAt: normalizeDecimal(row.updatedAt, `${field}.updatedAt`)
6369
6728
  };
6370
6729
  }
6371
- function minimumBlockNumber(rows) {
6372
- const blockNumbers = rows.filter((row) => row !== null).map((row) => BigInt(row.updatedAtBlockNumber));
6373
- if (blockNumbers.length === 0) return null;
6374
- return blockNumbers.reduce((minimum, block) => block < minimum ? block : minimum).toString();
6730
+ function indexerHeadBlockNumber(rows, chainId) {
6731
+ const row = rows[0];
6732
+ if (row === void 0) return null;
6733
+ if (row.chain_id !== chainId) {
6734
+ throw new Error("chain_metadata.chain_id does not match the query");
6735
+ }
6736
+ if (!Number.isSafeInteger(row.latest_processed_block) || row.latest_processed_block < 0) {
6737
+ throw new Error("chain_metadata.latest_processed_block must be a non-negative safe integer");
6738
+ }
6739
+ return row.latest_processed_block.toString();
6375
6740
  }
6376
6741
  function buildStakingEntityIds(params) {
6377
6742
  if (!Number.isInteger(params.chainId) || params.chainId <= 0) {
6378
6743
  throw new ValidationError("chainId must be a positive integer", "chainId");
6379
6744
  }
6380
6745
  const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
6381
- const chargebackPolicyAddress = normalizeAddress4(
6382
- params.chargebackPolicyAddress,
6383
- "chargebackPolicyAddress"
6746
+ const disputeProtectionPolicyAddress = normalizeAddress4(
6747
+ params.disputeProtectionPolicyAddress,
6748
+ "disputeProtectionPolicyAddress"
6384
6749
  );
6385
6750
  const taker = normalizeAddress4(params.taker, "taker");
6386
6751
  const stakeOwner = normalizeAddress4(params.stakeOwner, "stakeOwner");
@@ -6389,19 +6754,157 @@ function buildStakingEntityIds(params) {
6389
6754
  stakeAccountId: `${params.chainId}_${vaultAddress}_${stakeOwner}`,
6390
6755
  claimAccountId: `${params.chainId}_${vaultAddress}_${taker}`,
6391
6756
  vaultConfigId: `${params.chainId}_${vaultAddress}`,
6392
- policy: chargebackPolicyAddress
6757
+ policy: disputeProtectionPolicyAddress
6393
6758
  };
6394
6759
  }
6395
6760
  var IndexerStakingService = class {
6396
6761
  constructor(client) {
6397
6762
  this.client = client;
6398
6763
  }
6764
+ async fetchStakeLocks(params, init) {
6765
+ validateChainId(params.chainId);
6766
+ const limit = validateLimit(params.limit);
6767
+ const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
6768
+ const stakeOwner = normalizeAddress4(params.stakeOwner, "stakeOwner");
6769
+ const status = params.status ? normalizeLockStatus(params.status, "status") : void 0;
6770
+ const afterId = params.cursor ? decodeLockCursor(params.cursor) : void 0;
6771
+ const filters = [
6772
+ { chainId: { _eq: params.chainId } },
6773
+ { vaultAddress: { _eq: vaultAddress } },
6774
+ { stakeOwner: { _eq: stakeOwner } }
6775
+ ];
6776
+ if (status) filters.push({ status: { _eq: status } });
6777
+ if (afterId) filters.push({ id: { _gt: afterId } });
6778
+ const data3 = await this.client.query(
6779
+ {
6780
+ query: STAKE_LOCKS_QUERY,
6781
+ variables: { limit: limit + 1, where: { _and: filters } }
6782
+ },
6783
+ init
6784
+ );
6785
+ let previousId = afterId;
6786
+ const normalized = data3.StakeLock.map((row, index) => {
6787
+ const id = assertNonEmptyId(row.id, `StakeLock[${index}].id`);
6788
+ if (previousId !== void 0 && id <= previousId) {
6789
+ throw new Error("StakeLock cursor did not advance");
6790
+ }
6791
+ previousId = id;
6792
+ return {
6793
+ item: normalizeStakeLockRow(row, index, {
6794
+ chainId: params.chainId,
6795
+ vaultAddress,
6796
+ stakeOwner,
6797
+ status
6798
+ }),
6799
+ id
6800
+ };
6801
+ });
6802
+ const visible = normalized.slice(0, limit);
6803
+ const items = visible.map(({ item }) => item);
6804
+ return {
6805
+ items,
6806
+ nextCursor: normalized.length > limit ? encodeCursor("zkp2p-lock-v1", { id: visible[visible.length - 1].id }) : null,
6807
+ asOf: latestLockAsOf(items)
6808
+ };
6809
+ }
6810
+ async fetchStakeActivity(params, init) {
6811
+ validateChainId(params.chainId);
6812
+ const limit = validateLimit(params.limit);
6813
+ const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
6814
+ const merchant = normalizeAddress4(params.merchant, "merchant");
6815
+ const kind = params.kind ? normalizeActivityKind(params.kind, "kind") : void 0;
6816
+ const after = params.cursor ? decodeEventCursor(params.cursor, "zkp2p-activity-v1") : void 0;
6817
+ const filters = [
6818
+ { chainId: { _eq: params.chainId } },
6819
+ { vaultAddress: { _eq: vaultAddress } },
6820
+ {
6821
+ _or: [{ stakeOwner: { _eq: merchant } }, { taker: { _eq: merchant } }]
6822
+ }
6823
+ ];
6824
+ if (kind) filters.push({ kind: { _eq: kind } });
6825
+ if (after) filters.push(eventKeysetPredicate(after, "blockNumber", "logIndex"));
6826
+ const data3 = await this.client.query(
6827
+ {
6828
+ query: STAKE_ACTIVITY_QUERY,
6829
+ variables: { limit: limit + 1, where: { _and: filters } }
6830
+ },
6831
+ init
6832
+ );
6833
+ let previous = after;
6834
+ const normalized = data3.StakeActivity.map((row, index) => {
6835
+ const result = normalizeStakeActivityRow(row, index, {
6836
+ chainId: params.chainId,
6837
+ vaultAddress,
6838
+ merchant,
6839
+ kind
6840
+ });
6841
+ if (previous && compareEventCursor(result.cursor, previous) <= 0) {
6842
+ throw new Error("StakeActivity cursor did not advance");
6843
+ }
6844
+ previous = result.cursor;
6845
+ return result;
6846
+ });
6847
+ const visible = normalized.slice(0, limit);
6848
+ const last = visible[visible.length - 1];
6849
+ return {
6850
+ items: visible.map(({ item }) => item),
6851
+ nextCursor: normalized.length > limit && last ? encodeCursor("zkp2p-activity-v1", last.cursor) : null,
6852
+ asOf: last ? { blockNumber: last.item.blockNumber, timestamp: last.item.timestamp } : null
6853
+ };
6854
+ }
6855
+ async fetchDisputeProtectionIntents(params, init) {
6856
+ validateChainId(params.chainId);
6857
+ const limit = validateLimit(params.limit);
6858
+ const policyAddress = normalizeAddress4(params.policyAddress, "policyAddress");
6859
+ const throughBlockNumber = normalizeDecimal(params.throughBlockNumber, "throughBlockNumber");
6860
+ const after = params.cursor ? decodeEventCursor(params.cursor, "zkp2p-dispute-v1") : void 0;
6861
+ if (after && BigInt(after.blockNumber) > BigInt(throughBlockNumber)) {
6862
+ throw new ValidationError("cursor exceeds throughBlockNumber", "cursor");
6863
+ }
6864
+ const filters = [
6865
+ { chainId: { _eq: params.chainId } },
6866
+ { policyAddress: { _eq: policyAddress } },
6867
+ { status: { _eq: "DISPUTED" } },
6868
+ { disputedAtBlockNumber: { _lte: throughBlockNumber } }
6869
+ ];
6870
+ if (after) {
6871
+ filters.push(eventKeysetPredicate(after, "disputedAtBlockNumber", "disputedAtLogIndex"));
6872
+ }
6873
+ const data3 = await this.client.query(
6874
+ {
6875
+ query: DISPUTE_PROTECTION_INTENTS_QUERY,
6876
+ variables: { limit: limit + 1, where: { _and: filters } }
6877
+ },
6878
+ init
6879
+ );
6880
+ let previous = after;
6881
+ const normalized = data3.DisputeProtectionIntent.map((row, index) => {
6882
+ const result = normalizeDisputeRow(row, index, {
6883
+ chainId: params.chainId,
6884
+ policyAddress,
6885
+ throughBlockNumber
6886
+ });
6887
+ if (previous && compareEventCursor(result.cursor, previous) <= 0) {
6888
+ throw new Error("DisputeProtectionIntent cursor did not advance");
6889
+ }
6890
+ previous = result.cursor;
6891
+ return result;
6892
+ });
6893
+ const visible = normalized.slice(0, limit);
6894
+ const last = visible[visible.length - 1];
6895
+ return {
6896
+ items: visible.map(({ item }) => item),
6897
+ nextCursor: normalized.length > limit && last ? encodeCursor("zkp2p-dispute-v1", last.cursor) : null,
6898
+ endCursor: last ? encodeCursor("zkp2p-dispute-v1", last.cursor) : null,
6899
+ asOf: last ? { blockNumber: last.item.disputedAtBlockNumber, timestamp: last.item.disputedAt } : null
6900
+ };
6901
+ }
6399
6902
  async fetchStakingState(params, init) {
6400
6903
  const ids = buildStakingEntityIds(params);
6401
6904
  const vaultAddress = normalizeAddress4(params.vaultAddress, "vaultAddress");
6402
6905
  const taker = normalizeAddress4(params.taker, "taker");
6403
6906
  const requestedStakeOwner = normalizeAddress4(params.stakeOwner, "stakeOwner");
6404
- const data = await this.client.query(
6907
+ const data3 = await this.client.query(
6405
6908
  {
6406
6909
  query: STAKING_STATE_QUERY,
6407
6910
  variables: {
@@ -6413,20 +6916,20 @@ var IndexerStakingService = class {
6413
6916
  },
6414
6917
  init
6415
6918
  );
6416
- const takerState = data.TakerStakeState_by_pk;
6919
+ const takerState = data3.TakerStakeState_by_pk;
6417
6920
  const indexedStakeOwner = takerState ? normalizeAddress4(takerState.stakeOwner, "TakerStakeState.stakeOwner") : taker;
6418
6921
  const selectedStakeOwner = normalizeNullableAddress(
6419
6922
  takerState?.selectedStakeOwner,
6420
6923
  "TakerStakeState.selectedStakeOwner"
6421
6924
  );
6422
- const stakeAccount = data.StakeAccountState_by_pk;
6925
+ const stakeAccount = data3.StakeAccountState_by_pk;
6423
6926
  const stakeAccountOwner = stakeAccount ? normalizeAddress4(stakeAccount.stakeOwner, "StakeAccountState.stakeOwner") : requestedStakeOwner;
6424
6927
  const stakeAccountMatchesEffectiveOwner = requestedStakeOwner === indexedStakeOwner && stakeAccountOwner === indexedStakeOwner;
6425
- const claimAccount = data.ClaimAccountState_by_pk;
6928
+ const claimAccount = data3.ClaimAccountState_by_pk;
6426
6929
  if (claimAccount && normalizeAddress4(claimAccount.beneficiary, "ClaimAccountState.beneficiary") !== taker) {
6427
6930
  throw new Error("ClaimAccountState beneficiary does not match the requested taker");
6428
6931
  }
6429
- const authorizations = data.TakerStakeAuthorization.map((authorization, index) => ({
6932
+ const authorizations = data3.TakerStakeAuthorization.map((authorization, index) => ({
6430
6933
  stakeOwner: normalizeAddress4(
6431
6934
  authorization.stakeOwner,
6432
6935
  `TakerStakeAuthorization[${index}].stakeOwner`
@@ -6437,18 +6940,18 @@ var IndexerStakingService = class {
6437
6940
  `TakerStakeAuthorization[${index}]`
6438
6941
  )
6439
6942
  }));
6440
- const riskWindows = data.ChargebackRiskWindow.map((row, index) => ({
6943
+ const riskWindows = data3.DisputeProtectionRiskWindow.map((row, index) => ({
6441
6944
  paymentMethod: row.paymentMethod,
6442
6945
  riskWindowSeconds: normalizeDecimal(
6443
6946
  row.riskWindow,
6444
- `ChargebackRiskWindow[${index}].riskWindow`
6947
+ `DisputeProtectionRiskWindow[${index}].riskWindow`
6445
6948
  ),
6446
- updatedAt: normalizeDecimal(row.updatedAt, `ChargebackRiskWindow[${index}].updatedAt`)
6949
+ updatedAt: normalizeDecimal(row.updatedAt, `DisputeProtectionRiskWindow[${index}].updatedAt`)
6447
6950
  }));
6448
6951
  const takerFreshness = freshnessOf(takerState, "TakerStakeState");
6449
6952
  const stakeFreshness = freshnessOf(stakeAccount, "StakeAccountState");
6450
6953
  const claimFreshness = freshnessOf(claimAccount, "ClaimAccountState");
6451
- const vaultFreshness = freshnessOf(data.StakeVaultConfig_by_pk, "StakeVaultConfig");
6954
+ const vaultFreshness = freshnessOf(data3.StakeVaultConfig_by_pk, "StakeVaultConfig");
6452
6955
  const authorizationFreshness = authorizations.map((authorization) => authorization.freshness);
6453
6956
  return {
6454
6957
  chainId: params.chainId,
@@ -6468,17 +6971,17 @@ var IndexerStakingService = class {
6468
6971
  claimableUsdc: claimAccount ? normalizeDecimal(claimAccount.claimableAmount, "ClaimAccountState.claimableAmount") : "0",
6469
6972
  authorizations,
6470
6973
  riskWindows,
6471
- vault: data.StakeVaultConfig_by_pk ? {
6974
+ vault: data3.StakeVaultConfig_by_pk ? {
6472
6975
  controller: normalizeNullableAddress(
6473
- data.StakeVaultConfig_by_pk.controller,
6976
+ data3.StakeVaultConfig_by_pk.controller,
6474
6977
  "StakeVaultConfig.controller"
6475
6978
  ),
6476
6979
  pendingController: normalizeNullableAddress(
6477
- data.StakeVaultConfig_by_pk.pendingController,
6980
+ data3.StakeVaultConfig_by_pk.pendingController,
6478
6981
  "StakeVaultConfig.pendingController"
6479
6982
  ),
6480
- pendingControllerValidAt: data.StakeVaultConfig_by_pk.pendingControllerValidAt ? normalizeDecimal(
6481
- data.StakeVaultConfig_by_pk.pendingControllerValidAt,
6983
+ pendingControllerValidAt: data3.StakeVaultConfig_by_pk.pendingControllerValidAt ? normalizeDecimal(
6984
+ data3.StakeVaultConfig_by_pk.pendingControllerValidAt,
6482
6985
  "StakeVaultConfig.pendingControllerValidAt"
6483
6986
  ) : null
6484
6987
  } : null,
@@ -6489,18 +6992,1023 @@ var IndexerStakingService = class {
6489
6992
  claimAccountState: claimFreshness,
6490
6993
  stakeVaultConfig: vaultFreshness,
6491
6994
  authorizations: authorizationFreshness,
6492
- indexedBlockNumber: minimumBlockNumber([
6493
- takerFreshness,
6494
- stakeFreshness,
6495
- claimFreshness,
6496
- vaultFreshness,
6497
- ...authorizationFreshness
6498
- ])
6995
+ indexerHeadBlockNumber: indexerHeadBlockNumber(data3.chain_metadata, params.chainId)
6499
6996
  }
6500
6997
  };
6501
6998
  }
6502
6999
  };
6503
7000
 
7001
+ // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.1-rc.6_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/_esm/index.js
7002
+ var version = "0.4.1-rc.6";
7003
+
7004
+ // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.1-rc.6_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/_esm/disputeStack/base.js
7005
+ var data = {
7006
+ "schemaVersion": 1,
7007
+ "network": "base",
7008
+ "chainId": 8453,
7009
+ "activeDisputeStack": {
7010
+ "version": 1,
7011
+ "selectionHash": "a4f17ae7c1620ecfe7d036f0b9cc7b39c50e1382dc8dc14d2e5f7f21061cd5ad"
7012
+ },
7013
+ "runtimeIdentities": {
7014
+ "Orchestrator": {
7015
+ "address": "0x88888883Ed048FF0a415271B28b2F52d431810D0",
7016
+ "runtimeCodeHash": "0xf511343f2903dd1877c490796cc9423fac66b162b59004d55e522046c1ceb050"
7017
+ },
7018
+ "OrchestratorV2": {
7019
+ "address": "0x888888359E981B5225CA48fbCdCeff702FC3b888",
7020
+ "runtimeCodeHash": "0xcf70a08cc24fcc00799f9f365d0998abe37c718c93ee370a78d1ca06c60d01e0"
7021
+ },
7022
+ "OrchestratorV3": {
7023
+ "address": "0x014025fDE093f8701d86e9f38e2C3a9b779cb5c7",
7024
+ "runtimeCodeHash": "0x4e58f26129559301c017ff264b61dd2255ed2107593d308472ef32d07b8745e9"
7025
+ },
7026
+ "StakeVault": {
7027
+ "address": "0x4d16F4a9946CfC76b1c1A4B63aa9D94cdA2dbCEB",
7028
+ "runtimeCodeHash": "0xfd8d2a910b9ac2c55675ae06d0504f9aac43b02b7022755cf229b571156c681d"
7029
+ },
7030
+ "DisputeProtectionPolicy": {
7031
+ "address": "0xcEc48F7242eDBf02875BB4629115Bd927e1287aA",
7032
+ "runtimeCodeHash": "0x9c4be279da216021183638eaef79ebf98db248472685e9ecd0de3f24a513a641"
7033
+ },
7034
+ "IntentLifecycleHookV1": {
7035
+ "address": "0x71467dCac3B50eeED5A485aC6a70f27B1EAC1970",
7036
+ "runtimeCodeHash": "0x35789014e608a248f3244b61210fa259fee3566c33f50fd0e3fa1f5ae22e370b"
7037
+ },
7038
+ "RecognizedPredecessorHook": {
7039
+ "address": "0x251d78fb6bBb4071995Bce74bAfC9E4168638622",
7040
+ "runtimeCodeHash": "0x03d02863ed5eaa096d4089cb1e126681c0621d99409124f4af5be7ed83e341fe"
7041
+ },
7042
+ "RecognizedPredecessorPolicy": {
7043
+ "address": "0xc086b6120B5e61EF48221E6A78c69737c9948dF9",
7044
+ "runtimeCodeHash": "0xf08bce9ad622b9d45ce310493627cbef3bf6c4ac915661d5bc572bb59b61e084"
7045
+ },
7046
+ "OrchestratorRegistry": {
7047
+ "address": "0xBe9fED15ED7A4B915C03EFcEcb9662739C3382A9",
7048
+ "runtimeCodeHash": "0xf0d132d621ac03181a6fade6a93bd0968d33830c8bf393793236787e7978aee1"
7049
+ },
7050
+ "WhitelistPolicy": {
7051
+ "address": "0xBC53641b4B2504f0061D6a9426C61B8eBE9B4Ff0",
7052
+ "runtimeCodeHash": "0xa3cf0fdf3835887de432cbac9c192edf6c93a8589748aa93f8294333d57024b2"
7053
+ },
7054
+ "DisputeVerifier": {
7055
+ "address": "0x30d4947f005653637005eed991005119D9eB2f34",
7056
+ "runtimeCodeHash": "0x65246e11392befc33d92246cf3ac2467d1f338a8b73c6514b76fab0a70a01ead"
7057
+ },
7058
+ "DisputeNullifierRegistry": {
7059
+ "address": "0xA845615b5203F7a21321DdF5e3a1ca024D93a443",
7060
+ "runtimeCodeHash": "0x1a711749b7700142265363c9c184c195ac81a1415e2142aa84edcbf1cd88142a"
7061
+ },
7062
+ "MultiAttestationVerifier": {
7063
+ "address": "0x9Fe920b24e50e6a6362BA71a1BeB502A99c402d5",
7064
+ "runtimeCodeHash": "0x828a5dae520d3eaed904dfed56994dc6e892eb6416b58ad952c079e220ef841a"
7065
+ }
7066
+ },
7067
+ "addressExpectations": {
7068
+ "AddressGroupRegistry": "0x39F80118f9eB619135f116171b6Cb91D372C5AF2",
7069
+ "EscrowRegistry": "0xeD0e847B101abc96E796260AC358e12BAa2f5B21",
7070
+ "PaymentVerifierRegistry": "0x2b82D24437ff66Fb173eabDfD67ee2ACeb8bEb1e",
7071
+ "RelayerRegistry": "0xEbA979889a9c97382A92472fF3703786fF180083",
7072
+ "NullifierRegistryV2": "0x5455e761b866dfa6A2f5Dc6d6525825bf9C09aeB",
7073
+ "StakeToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
7074
+ },
7075
+ "expectedRelations": {
7076
+ "activeLifecycleHook": "0x71467dCac3B50eeED5A485aC6a70f27B1EAC1970",
7077
+ "recognizedPredecessorPolicy": "0xc086b6120B5e61EF48221E6A78c69737c9948dF9",
7078
+ "registeredOrchestrator": "0x014025fDE093f8701d86e9f38e2C3a9b779cb5c7",
7079
+ "authorizedLifecycleHook": "0x71467dCac3B50eeED5A485aC6a70f27B1EAC1970",
7080
+ "disputeNullifierAuthorizedWriter": "0xcEc48F7242eDBf02875BB4629115Bd927e1287aA",
7081
+ "orchestratorEscrowRegistry": "0xeD0e847B101abc96E796260AC358e12BAa2f5B21",
7082
+ "orchestratorPaymentVerifierRegistry": "0x2b82D24437ff66Fb173eabDfD67ee2ACeb8bEb1e",
7083
+ "orchestratorRelayerRegistry": "0xEbA979889a9c97382A92472fF3703786fF180083",
7084
+ "hookOrchestratorRegistry": "0xBe9fED15ED7A4B915C03EFcEcb9662739C3382A9",
7085
+ "hookWhitelistPolicy": "0xBC53641b4B2504f0061D6a9426C61B8eBE9B4Ff0",
7086
+ "hookDisputeProtectionPolicy": "0xcEc48F7242eDBf02875BB4629115Bd927e1287aA",
7087
+ "whitelistGroupRegistry": "0x39F80118f9eB619135f116171b6Cb91D372C5AF2",
7088
+ "whitelistEscrowRegistry": "0xeD0e847B101abc96E796260AC358e12BAa2f5B21",
7089
+ "whitelistOrchestratorRegistry": "0xBe9fED15ED7A4B915C03EFcEcb9662739C3382A9",
7090
+ "policyStakeVault": "0x4d16F4a9946CfC76b1c1A4B63aa9D94cdA2dbCEB",
7091
+ "policyDisputeVerifier": "0x30d4947f005653637005eed991005119D9eB2f34",
7092
+ "policyDisputeNullifierRegistry": "0xA845615b5203F7a21321DdF5e3a1ca024D93a443",
7093
+ "disputeVerifierNullifierRegistry": "0x5455e761b866dfa6A2f5Dc6d6525825bf9C09aeB",
7094
+ "disputeVerifierAttestationVerifier": "0x9Fe920b24e50e6a6362BA71a1BeB502A99c402d5",
7095
+ "vaultController": "0xcEc48F7242eDBf02875BB4629115Bd927e1287aA",
7096
+ "vaultStakeToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
7097
+ },
7098
+ "expectedGovernance": {
7099
+ "owner": "0x0bC26FF515411396DD588Abd6Ef6846E04470227",
7100
+ "governedRuntimeIdentities": [
7101
+ "OrchestratorRegistry",
7102
+ "OrchestratorV3",
7103
+ "StakeVault",
7104
+ "DisputeProtectionPolicy",
7105
+ "WhitelistPolicy",
7106
+ "DisputeVerifier",
7107
+ "DisputeNullifierRegistry",
7108
+ "MultiAttestationVerifier"
7109
+ ],
7110
+ "pendingOwner": "0x0000000000000000000000000000000000000000",
7111
+ "twoStepGovernedRuntimeIdentities": [
7112
+ "StakeVault",
7113
+ "DisputeProtectionPolicy",
7114
+ "DisputeVerifier"
7115
+ ]
7116
+ },
7117
+ "attestationTrust": {
7118
+ "requiredSignatures": "1",
7119
+ "witnesses": [
7120
+ "0xDB4Ed7FAF170F0f6493E3adaaCaaFaF47092c754",
7121
+ "0xE078D93bFdd87A8c5C5cCA5905DCbA0Dd7A1F0BD"
7122
+ ]
7123
+ },
7124
+ "exactAuthorizationSets": {
7125
+ "orchestratorAuthorizationFromBlock": "42878566",
7126
+ "authorizedOrchestrators": [
7127
+ "0x88888883Ed048FF0a415271B28b2F52d431810D0",
7128
+ "0x888888359E981B5225CA48fbCdCeff702FC3b888",
7129
+ "0x014025fDE093f8701d86e9f38e2C3a9b779cb5c7"
7130
+ ],
7131
+ "lifecycleHookAuthorizationFromBlock": "50201693",
7132
+ "authorizedLifecycleHooks": [
7133
+ "0x71467dCac3B50eeED5A485aC6a70f27B1EAC1970"
7134
+ ],
7135
+ "passiveDisputeNullifierWriters": [
7136
+ "0xc086b6120B5e61EF48221E6A78c69737c9948dF9"
7137
+ ],
7138
+ "activeDisputeNullifierWriters": [
7139
+ "0xcEc48F7242eDBf02875BB4629115Bd927e1287aA"
7140
+ ]
7141
+ },
7142
+ "riskWindowSecondsByPaymentMethod": {
7143
+ "0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d": "1209600",
7144
+ "0x3ccc3d4d5e769b1f82dc4988485551dc0cd3c7a3926d7d8a4dde91507199490f": "1209600",
7145
+ "0x554a007c2217df766b977723b276671aee5ebb4adaea0edb6433c88b3e61dac5": "0",
7146
+ "0x5908bb0c9b87763ac6171d4104847667e7f02b4c47b574fe890c1f439ed128bb": "0",
7147
+ "0x617f88ab82b5c1b014c539f7e75121427f0bb50a4c58b187a238531e7d58605d": "0",
7148
+ "0x62c7ed738ad3e7618111348af32691b5767777fbaf46a2d8943237625552645c": "0",
7149
+ "0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268": "1209600",
7150
+ "0xa5418819c024239299ea32e09defae8ec412c03e58f5c75f1b2fe84c857f5483": "0",
7151
+ "0xcac9daea62d7b89d75ac73af4ee14dcf25721012ae82b568c2ea5c808eaa04ff": "0",
7152
+ "0xf752c7d19698ecb0bb8988abf9b9a53a4c3657f3bc8850a6fb59fdf3e3ce8cd3": "0"
7153
+ },
7154
+ "sentinel": {
7155
+ "escrow": "0x0000000000000000000000000000000000000001",
7156
+ "depositId": "0",
7157
+ "expected": false
7158
+ },
7159
+ "prerequisites": {
7160
+ "orchestratorPaused": false,
7161
+ "admissionsPaused": false,
7162
+ "allowMultipleIntents": true,
7163
+ "orchestratorRegistered": true,
7164
+ "lifecycleHookAuthorized": true,
7165
+ "disputeNullifierWriterAuthorized": true,
7166
+ "vaultControllerActivated": true,
7167
+ "vaultPendingController": "0x0000000000000000000000000000000000000000",
7168
+ "vaultPendingControllerValidAt": "0",
7169
+ "pendingCoverageMaturity": "18446744073709551615"
7170
+ }
7171
+ };
7172
+ var base_default = data;
7173
+
7174
+ // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.1-rc.6_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.4.3/node_modules/@zkp2p/contracts-v2/_esm/disputeStack/baseStaging.js
7175
+ var data2 = {
7176
+ "schemaVersion": 1,
7177
+ "network": "base_staging",
7178
+ "chainId": 8453,
7179
+ "activeDisputeStack": {
7180
+ "version": 1,
7181
+ "selectionHash": "586c90f9de3d10b6d48f4286c709aa7f870fc2fdcfb0af1da947c1da76132dd0"
7182
+ },
7183
+ "runtimeIdentities": {
7184
+ "Orchestrator": {
7185
+ "address": "0xF9b9CD27Deea496B960b3cb5221b514705fCaF5e",
7186
+ "runtimeCodeHash": "0xf511343f2903dd1877c490796cc9423fac66b162b59004d55e522046c1ceb050"
7187
+ },
7188
+ "OrchestratorV2": {
7189
+ "address": "0xc17a59227B136c45fAa153086a15EF87ED14bE00",
7190
+ "runtimeCodeHash": "0xcf70a08cc24fcc00799f9f365d0998abe37c718c93ee370a78d1ca06c60d01e0"
7191
+ },
7192
+ "OrchestratorV3": {
7193
+ "address": "0x2b5E8Ab562e45fA89D73802605E145ED3E3EeF4f",
7194
+ "runtimeCodeHash": "0x4e58f26129559301c017ff264b61dd2255ed2107593d308472ef32d07b8745e9"
7195
+ },
7196
+ "StakeVault": {
7197
+ "address": "0x01075fdCB8D38fD5A1070db41B3c00DC2459e71e",
7198
+ "runtimeCodeHash": "0xfd8d2a910b9ac2c55675ae06d0504f9aac43b02b7022755cf229b571156c681d"
7199
+ },
7200
+ "DisputeProtectionPolicy": {
7201
+ "address": "0x51436B8051cCf52739A2090C29DA208B70eC2663",
7202
+ "runtimeCodeHash": "0xa4c6a33333e10da596805b6127e96f78e40fe5a0f0ab0cfa8f4683fbeac91a37"
7203
+ },
7204
+ "IntentLifecycleHookV1": {
7205
+ "address": "0x3AB0879499b28e03bfcA4F5bC2CBe2070Fba4E36",
7206
+ "runtimeCodeHash": "0x376364aa8b693ee8e02eacc48527114ce3cc529714be5a3f316c7323561721ab"
7207
+ },
7208
+ "RecognizedPredecessorHook": {
7209
+ "address": "0x19D9F0Fcb08C60D8bd0CD061C34eae27eF8b6e65",
7210
+ "runtimeCodeHash": "0xba70239e37624f5808e2f79e100e83a17daeb1558f310543187f5d8a121ec367"
7211
+ },
7212
+ "RecognizedPredecessorPolicy": {
7213
+ "address": "0x21517b7743E727ae47A66FafF93550B689c15020",
7214
+ "runtimeCodeHash": "0x4e6617a94819ad15693289b173a9a66a78cfe1dd706f6b4fdc5a5f6ad6a32971"
7215
+ },
7216
+ "OrchestratorRegistry": {
7217
+ "address": "0xfA6384EB6176cfEC049540526A3d2126C3666d8A",
7218
+ "runtimeCodeHash": "0xf0d132d621ac03181a6fade6a93bd0968d33830c8bf393793236787e7978aee1"
7219
+ },
7220
+ "WhitelistPolicy": {
7221
+ "address": "0x7d9277cb8bb78a51eeaafB7CFF306E7DA4C972fD",
7222
+ "runtimeCodeHash": "0x917965fdc75580147ad0787c86f8b2a0f0185ef6e101567b82dc1245d6eb63bc"
7223
+ },
7224
+ "DisputeVerifier": {
7225
+ "address": "0x973578148c5Fd49b9f68B50B26066555325AC708",
7226
+ "runtimeCodeHash": "0xb3b34734cfd162cd129d0c84285461c751321545213ec20164745b8e72f9dd6c"
7227
+ },
7228
+ "DisputeNullifierRegistry": {
7229
+ "address": "0xE0B05a9655AF0f31E32904267baa50FbC7f217ea",
7230
+ "runtimeCodeHash": "0x1a711749b7700142265363c9c184c195ac81a1415e2142aa84edcbf1cd88142a"
7231
+ },
7232
+ "MultiAttestationVerifier": {
7233
+ "address": "0x9855a39aC5975069632e91160d8712CBfF19e864",
7234
+ "runtimeCodeHash": "0x828a5dae520d3eaed904dfed56994dc6e892eb6416b58ad952c079e220ef841a"
7235
+ }
7236
+ },
7237
+ "addressExpectations": {
7238
+ "AddressGroupRegistry": "0x54Ff7788Cb42B46FE2F016a65Fd0f654Bb9BcF3D",
7239
+ "EscrowRegistry": "0xc545f336eC77E69bf115729acCbf2e557A00ac91",
7240
+ "PaymentVerifierRegistry": "0x2261416DA54C85f975C73FA56EF4D2D6b0aEF7Cc",
7241
+ "RelayerRegistry": "0xB214650b424E6b5fdcB1259566eB7A512D8Bd25E",
7242
+ "NullifierRegistryV2": "0x2eb43d6C7c7Ec4220Aa6B8735BC053824a71778C",
7243
+ "StakeToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
7244
+ },
7245
+ "expectedRelations": {
7246
+ "activeLifecycleHook": "0x3AB0879499b28e03bfcA4F5bC2CBe2070Fba4E36",
7247
+ "recognizedPredecessorPolicy": "0x21517b7743E727ae47A66FafF93550B689c15020",
7248
+ "registeredOrchestrator": "0x2b5E8Ab562e45fA89D73802605E145ED3E3EeF4f",
7249
+ "authorizedLifecycleHook": "0x3AB0879499b28e03bfcA4F5bC2CBe2070Fba4E36",
7250
+ "disputeNullifierAuthorizedWriter": "0x51436B8051cCf52739A2090C29DA208B70eC2663",
7251
+ "orchestratorEscrowRegistry": "0xc545f336eC77E69bf115729acCbf2e557A00ac91",
7252
+ "orchestratorPaymentVerifierRegistry": "0x2261416DA54C85f975C73FA56EF4D2D6b0aEF7Cc",
7253
+ "orchestratorRelayerRegistry": "0xB214650b424E6b5fdcB1259566eB7A512D8Bd25E",
7254
+ "hookOrchestratorRegistry": "0xfA6384EB6176cfEC049540526A3d2126C3666d8A",
7255
+ "hookWhitelistPolicy": "0x7d9277cb8bb78a51eeaafB7CFF306E7DA4C972fD",
7256
+ "hookDisputeProtectionPolicy": "0x51436B8051cCf52739A2090C29DA208B70eC2663",
7257
+ "whitelistGroupRegistry": "0x54Ff7788Cb42B46FE2F016a65Fd0f654Bb9BcF3D",
7258
+ "whitelistEscrowRegistry": "0xc545f336eC77E69bf115729acCbf2e557A00ac91",
7259
+ "whitelistOrchestratorRegistry": "0xfA6384EB6176cfEC049540526A3d2126C3666d8A",
7260
+ "policyStakeVault": "0x01075fdCB8D38fD5A1070db41B3c00DC2459e71e",
7261
+ "policyDisputeVerifier": "0x973578148c5Fd49b9f68B50B26066555325AC708",
7262
+ "policyDisputeNullifierRegistry": "0xE0B05a9655AF0f31E32904267baa50FbC7f217ea",
7263
+ "disputeVerifierNullifierRegistry": "0x2eb43d6C7c7Ec4220Aa6B8735BC053824a71778C",
7264
+ "disputeVerifierAttestationVerifier": "0x9855a39aC5975069632e91160d8712CBfF19e864",
7265
+ "vaultController": "0x51436B8051cCf52739A2090C29DA208B70eC2663",
7266
+ "vaultStakeToken": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
7267
+ },
7268
+ "expectedGovernance": {
7269
+ "owner": "0x84e113087C97Cd80eA9D78983D4B8Ff61ECa1929",
7270
+ "governedRuntimeIdentities": [
7271
+ "OrchestratorRegistry",
7272
+ "OrchestratorV3",
7273
+ "StakeVault",
7274
+ "DisputeProtectionPolicy",
7275
+ "WhitelistPolicy",
7276
+ "DisputeVerifier",
7277
+ "DisputeNullifierRegistry",
7278
+ "MultiAttestationVerifier"
7279
+ ],
7280
+ "pendingOwner": "0x0000000000000000000000000000000000000000",
7281
+ "twoStepGovernedRuntimeIdentities": [
7282
+ "StakeVault",
7283
+ "DisputeProtectionPolicy",
7284
+ "DisputeVerifier"
7285
+ ]
7286
+ },
7287
+ "attestationTrust": {
7288
+ "requiredSignatures": "1",
7289
+ "witnesses": [
7290
+ "0x66649F896521b0fb487fE2077b4FBDA283d7f19a",
7291
+ "0x4ab950AE1e3326578Bf7e643a2031E858aBa2927"
7292
+ ]
7293
+ },
7294
+ "exactAuthorizationSets": {
7295
+ "orchestratorAuthorizationFromBlock": "42614859",
7296
+ "authorizedOrchestrators": [
7297
+ "0xF9b9CD27Deea496B960b3cb5221b514705fCaF5e",
7298
+ "0xc17a59227B136c45fAa153086a15EF87ED14bE00",
7299
+ "0x2b5E8Ab562e45fA89D73802605E145ED3E3EeF4f"
7300
+ ],
7301
+ "lifecycleHookAuthorizationFromBlock": "50201496",
7302
+ "authorizedLifecycleHooks": [
7303
+ "0x3AB0879499b28e03bfcA4F5bC2CBe2070Fba4E36"
7304
+ ],
7305
+ "passiveDisputeNullifierWriters": [
7306
+ "0x21517b7743E727ae47A66FafF93550B689c15020"
7307
+ ],
7308
+ "activeDisputeNullifierWriters": [
7309
+ "0x51436B8051cCf52739A2090C29DA208B70eC2663"
7310
+ ]
7311
+ },
7312
+ "riskWindowSecondsByPaymentMethod": {
7313
+ "0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d": "1209600",
7314
+ "0x1d966dbd6aeb8674d7c05174bd0ded7b56a798672bfb862ef20bbe8c2bbfce18": "0",
7315
+ "0x3ccc3d4d5e769b1f82dc4988485551dc0cd3c7a3926d7d8a4dde91507199490f": "1209600",
7316
+ "0x554a007c2217df766b977723b276671aee5ebb4adaea0edb6433c88b3e61dac5": "0",
7317
+ "0x5908bb0c9b87763ac6171d4104847667e7f02b4c47b574fe890c1f439ed128bb": "0",
7318
+ "0x617f88ab82b5c1b014c539f7e75121427f0bb50a4c58b187a238531e7d58605d": "0",
7319
+ "0x62c7ed738ad3e7618111348af32691b5767777fbaf46a2d8943237625552645c": "0",
7320
+ "0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268": "1209600",
7321
+ "0xa5418819c024239299ea32e09defae8ec412c03e58f5c75f1b2fe84c857f5483": "0",
7322
+ "0xcac9daea62d7b89d75ac73af4ee14dcf25721012ae82b568c2ea5c808eaa04ff": "0",
7323
+ "0xf752c7d19698ecb0bb8988abf9b9a53a4c3657f3bc8850a6fb59fdf3e3ce8cd3": "0",
7324
+ "0xf81480907d808d639ad3230869e4b05a3b01b2d34e323af40f2efab807effd32": "0"
7325
+ },
7326
+ "sentinel": {
7327
+ "escrow": "0x0000000000000000000000000000000000000001",
7328
+ "depositId": "0",
7329
+ "expected": false
7330
+ },
7331
+ "prerequisites": {
7332
+ "orchestratorPaused": false,
7333
+ "admissionsPaused": false,
7334
+ "allowMultipleIntents": true,
7335
+ "orchestratorRegistered": true,
7336
+ "lifecycleHookAuthorized": true,
7337
+ "disputeNullifierWriterAuthorized": true,
7338
+ "vaultControllerActivated": true,
7339
+ "vaultPendingController": "0x0000000000000000000000000000000000000000",
7340
+ "vaultPendingControllerValidAt": "0",
7341
+ "pendingCoverageMaturity": "18446744073709551615"
7342
+ }
7343
+ };
7344
+ var baseStaging_default = data2;
7345
+
7346
+ // src/buildMetadata.ts
7347
+ var DEVELOPMENT_BUILD_METADATA = {
7348
+ schemaVersion: 1,
7349
+ source: {
7350
+ repository: "zkp2p/zkp2p-clients",
7351
+ commitSha: "development",
7352
+ kind: "development",
7353
+ distributable: false
7354
+ },
7355
+ sdkPackageVersion: "development",
7356
+ contractsPackageVersion: "development",
7357
+ indexerSchemaPackageVersion: "development",
7358
+ activeDisputeStack: {
7359
+ base: { version: 1, selectionHash: "development" },
7360
+ baseStaging: { version: 1, selectionHash: "development" }
7361
+ }
7362
+ };
7363
+ var SDK_BUILD_METADATA = typeof define_ZKP2P_SDK_BUILD_METADATA_default === "undefined" ? DEVELOPMENT_BUILD_METADATA : define_ZKP2P_SDK_BUILD_METADATA_default;
7364
+
7365
+ // src/client/DisputeProtectionReadiness.ts
7366
+ var SUCCESSOR_RUNTIME_IDENTITIES = [
7367
+ "IntentLifecycleHookV1",
7368
+ "StakeVault",
7369
+ "DisputeProtectionPolicy",
7370
+ "OrchestratorRegistry",
7371
+ "WhitelistPolicy",
7372
+ "DisputeVerifier",
7373
+ "DisputeNullifierRegistry",
7374
+ "MultiAttestationVerifier"
7375
+ ];
7376
+ var GOVERNANCE_ABIS = {
7377
+ OrchestratorRegistry: OrchestratorRegistry_default,
7378
+ OrchestratorV3: OrchestratorV3_default,
7379
+ StakeVault: StakeVault_default,
7380
+ DisputeProtectionPolicy: DisputeProtectionPolicy_default,
7381
+ WhitelistPolicy: WhitelistPolicy_default,
7382
+ DisputeVerifier: DisputeVerifier_default,
7383
+ DisputeNullifierRegistry: DisputeNullifierRegistry_default,
7384
+ MultiAttestationVerifier: MultiAttestationVerifier_default
7385
+ };
7386
+ var ORCHESTRATOR_AUTHORIZATION_EVENTS = OrchestratorRegistry_default.filter(
7387
+ (item) => item.type === "event" && (item.name === "OrchestratorAdded" || item.name === "OrchestratorRemoved")
7388
+ );
7389
+ var LIFECYCLE_HOOK_AUTHORIZATION_EVENTS = DisputeProtectionPolicy_default.filter(
7390
+ (item) => item.type === "event" && item.name === "LifecycleHookAuthorizationUpdated"
7391
+ );
7392
+ var FALLBACK_LOG_BLOCK_SPAN = 10000n;
7393
+ var LOG_QUERY_CONCURRENCY = 8;
7394
+ var ReadinessMismatch = class extends Error {
7395
+ };
7396
+ function sameAddress(actual, expected) {
7397
+ return typeof actual === "string" && actual.toLowerCase() === expected.toLowerCase();
7398
+ }
7399
+ function expectAddress(label, actual, expected) {
7400
+ if (!sameAddress(actual, expected)) throw new ReadinessMismatch(`${label} mismatch`);
7401
+ }
7402
+ function expectBoolean(label, actual, expected) {
7403
+ if (actual !== expected) throw new ReadinessMismatch(`${label} expected ${String(expected)}`);
7404
+ }
7405
+ function expectBigInt(label, actual, expected) {
7406
+ if (actual !== expected) throw new ReadinessMismatch(`${label} mismatch`);
7407
+ }
7408
+ function normalizeAddressSet(label, addresses) {
7409
+ if (!Array.isArray(addresses) || addresses.some((address) => typeof address !== "string")) {
7410
+ throw new ReadinessMismatch(`${label} is not an address array`);
7411
+ }
7412
+ const normalized = addresses.map((address) => address.toLowerCase()).sort();
7413
+ if (new Set(normalized).size !== normalized.length) {
7414
+ throw new ReadinessMismatch(`${label} contains duplicate addresses`);
7415
+ }
7416
+ return normalized;
7417
+ }
7418
+ function expectAddressSet(label, actual, expected) {
7419
+ const actualAddresses = normalizeAddressSet(label, actual);
7420
+ const expectedAddresses = normalizeAddressSet(label, expected);
7421
+ if (actualAddresses.length !== expectedAddresses.length || actualAddresses.some((address, index) => address !== expectedAddresses[index])) {
7422
+ throw new ReadinessMismatch(`${label} mismatch`);
7423
+ }
7424
+ }
7425
+ function fallbackBlockRanges(fromBlock, toBlock) {
7426
+ const ranges = [];
7427
+ for (let start = fromBlock; start <= toBlock; start += FALLBACK_LOG_BLOCK_SPAN) {
7428
+ const end = start + FALLBACK_LOG_BLOCK_SPAN - 1n;
7429
+ ranges.push([start, end < toBlock ? end : toBlock]);
7430
+ }
7431
+ return ranges;
7432
+ }
7433
+ function isLogRangeLimitError(cause) {
7434
+ let error = cause;
7435
+ while (error instanceof Error) {
7436
+ if (/(?:block range.{0,40}(?:too (?:large|wide)|exceed|limit)|limited to.{0,40}(?:blocks?|range)|response size exceeded|query returned more than|too many (?:logs|results)|maximum block range)/i.test(
7437
+ error.message
7438
+ )) {
7439
+ return true;
7440
+ }
7441
+ error = error.cause;
7442
+ }
7443
+ return false;
7444
+ }
7445
+ function compareAuthorizationEvents(left, right) {
7446
+ if ((left.blockNumber ?? 0n) !== (right.blockNumber ?? 0n)) {
7447
+ return (left.blockNumber ?? 0n) < (right.blockNumber ?? 0n) ? -1 : 1;
7448
+ }
7449
+ if ((left.transactionIndex ?? 0) !== (right.transactionIndex ?? 0)) {
7450
+ return (left.transactionIndex ?? 0) - (right.transactionIndex ?? 0);
7451
+ }
7452
+ return (left.logIndex ?? 0) - (right.logIndex ?? 0);
7453
+ }
7454
+ function replayAddressAuthorizations(label, events, addressField, enabledField) {
7455
+ const authorized = /* @__PURE__ */ new Set();
7456
+ for (const event of [...events].sort(compareAuthorizationEvents)) {
7457
+ const address = event.args?.[addressField];
7458
+ if (typeof address !== "string") {
7459
+ throw new ReadinessMismatch(`${label} event address is malformed`);
7460
+ }
7461
+ const normalized = address.toLowerCase();
7462
+ const enabled = enabledField ? event.args?.[enabledField] : event.args?.enabled;
7463
+ if (typeof enabled !== "boolean") {
7464
+ throw new ReadinessMismatch(`${label} event authorization is malformed`);
7465
+ }
7466
+ if (enabled) authorized.add(normalized);
7467
+ else authorized.delete(normalized);
7468
+ }
7469
+ return [...authorized];
7470
+ }
7471
+ function manifestForEnvironment(environment) {
7472
+ return environment === "staging" ? baseStaging_default : base_default;
7473
+ }
7474
+ function validatePackagedIdentity(config) {
7475
+ const { buildMetadata, chainId, contractsPackageVersion, manifest } = config;
7476
+ if (!buildMetadata.source.distributable) return "SDK build metadata is not distributable";
7477
+ if (buildMetadata.source.kind !== "github" || buildMetadata.source.repository !== "zkp2p/zkp2p-clients" || !/^[0-9a-f]{40}$/.test(buildMetadata.source.commitSha)) {
7478
+ return "SDK build source identity is invalid";
7479
+ }
7480
+ if (buildMetadata.contractsPackageVersion !== contractsPackageVersion) {
7481
+ return "contracts package version does not match SDK build metadata";
7482
+ }
7483
+ if (manifest.schemaVersion !== 1 || manifest.chainId !== chainId || manifest.network !== "base" && manifest.network !== "base_staging") {
7484
+ return "dispute readiness manifest chain identity mismatch";
7485
+ }
7486
+ const selected = manifest.network === "base" ? buildMetadata.activeDisputeStack.base : buildMetadata.activeDisputeStack.baseStaging;
7487
+ if (selected.version !== manifest.activeDisputeStack.version || selected.selectionHash !== manifest.activeDisputeStack.selectionHash) {
7488
+ return "active dispute manifest selection does not match SDK build metadata";
7489
+ }
7490
+ return null;
7491
+ }
7492
+ function knownResult(state, readyForDisputeProtection, blockNumber, config, lifecycleHook, paused, allowMultipleIntents, policyAdmissionsPaused) {
7493
+ return {
7494
+ state,
7495
+ readyForDisputeProtection,
7496
+ asOfBlock: blockNumber,
7497
+ manifestNetwork: config.manifest.network,
7498
+ manifestSelectionHash: config.manifest.activeDisputeStack.selectionHash,
7499
+ contractsPackageVersion: config.contractsPackageVersion,
7500
+ activeLifecycleHook: lifecycleHook,
7501
+ orchestratorPaused: paused,
7502
+ allowMultipleIntents,
7503
+ policyAdmissionsPaused
7504
+ };
7505
+ }
7506
+ var DisputeProtectionReadinessReader = class {
7507
+ constructor(config) {
7508
+ this.config = config;
7509
+ }
7510
+ async verifyRuntimeIdentities(names, blockNumber) {
7511
+ await Promise.all(
7512
+ names.map(async (name) => {
7513
+ const identity = this.config.manifest.runtimeIdentities[name];
7514
+ const bytecode = await this.config.publicClient.getBytecode({
7515
+ address: identity.address,
7516
+ blockNumber
7517
+ });
7518
+ if (!bytecode || bytecode === "0x") {
7519
+ throw new ReadinessMismatch(`${name} runtime bytecode unavailable`);
7520
+ }
7521
+ if (keccak256(bytecode).toLowerCase() !== identity.runtimeCodeHash.toLowerCase()) {
7522
+ throw new ReadinessMismatch(`${name} runtime code hash mismatch`);
7523
+ }
7524
+ })
7525
+ );
7526
+ }
7527
+ async readOrchestrator(blockNumber) {
7528
+ const { manifest, publicClient } = this.config;
7529
+ const orchestrator = manifest.runtimeIdentities.OrchestratorV3.address;
7530
+ const result = await publicClient.multicall({
7531
+ allowFailure: false,
7532
+ blockNumber,
7533
+ contracts: [
7534
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "lifecycleHook" },
7535
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "paused" },
7536
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "allowMultipleIntents" },
7537
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "chainId" },
7538
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "escrowRegistry" },
7539
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "paymentVerifierRegistry" },
7540
+ { address: orchestrator, abi: OrchestratorV3_default, functionName: "relayerRegistry" }
7541
+ ]
7542
+ });
7543
+ const lifecycleHook = result[0];
7544
+ if (typeof lifecycleHook !== "string") {
7545
+ throw new ReadinessMismatch("OrchestratorV3.lifecycleHook is not an address");
7546
+ }
7547
+ expectBigInt("OrchestratorV3.chainId", result[3], BigInt(manifest.chainId));
7548
+ expectAddress(
7549
+ "OrchestratorV3.escrowRegistry",
7550
+ result[4],
7551
+ manifest.expectedRelations.orchestratorEscrowRegistry
7552
+ );
7553
+ expectAddress(
7554
+ "OrchestratorV3.paymentVerifierRegistry",
7555
+ result[5],
7556
+ manifest.expectedRelations.orchestratorPaymentVerifierRegistry
7557
+ );
7558
+ expectAddress(
7559
+ "OrchestratorV3.relayerRegistry",
7560
+ result[6],
7561
+ manifest.expectedRelations.orchestratorRelayerRegistry
7562
+ );
7563
+ if (typeof result[1] !== "boolean" || typeof result[2] !== "boolean") {
7564
+ throw new ReadinessMismatch("OrchestratorV3 readiness flags are malformed");
7565
+ }
7566
+ return {
7567
+ lifecycleHook: lifecycleHook.toLowerCase(),
7568
+ paused: result[1],
7569
+ allowMultipleIntents: result[2]
7570
+ };
7571
+ }
7572
+ async verifyGovernance(blockNumber) {
7573
+ const { manifest, publicClient } = this.config;
7574
+ const governance = manifest.expectedGovernance;
7575
+ const ownerContracts = governance.governedRuntimeIdentities.map((name) => ({
7576
+ address: manifest.runtimeIdentities[name].address,
7577
+ abi: GOVERNANCE_ABIS[name],
7578
+ functionName: "owner"
7579
+ }));
7580
+ const pendingOwnerContracts = governance.twoStepGovernedRuntimeIdentities.map((name) => ({
7581
+ address: manifest.runtimeIdentities[name].address,
7582
+ abi: GOVERNANCE_ABIS[name],
7583
+ functionName: "pendingOwner"
7584
+ }));
7585
+ const results = await publicClient.multicall({
7586
+ allowFailure: false,
7587
+ blockNumber,
7588
+ contracts: [...ownerContracts, ...pendingOwnerContracts]
7589
+ });
7590
+ governance.governedRuntimeIdentities.forEach((name, index) => {
7591
+ expectAddress(`${name}.owner`, results[index], governance.owner);
7592
+ });
7593
+ governance.twoStepGovernedRuntimeIdentities.forEach((name, index) => {
7594
+ expectAddress(
7595
+ `${name}.pendingOwner`,
7596
+ results[ownerContracts.length + index],
7597
+ governance.pendingOwner
7598
+ );
7599
+ });
7600
+ }
7601
+ async verifyAttestationTrust(blockNumber) {
7602
+ const { manifest, publicClient } = this.config;
7603
+ const verifier = manifest.runtimeIdentities.MultiAttestationVerifier.address;
7604
+ const results = await publicClient.multicall({
7605
+ allowFailure: false,
7606
+ blockNumber,
7607
+ contracts: [
7608
+ {
7609
+ address: verifier,
7610
+ abi: MultiAttestationVerifier_default,
7611
+ functionName: "requiredSignatures"
7612
+ },
7613
+ { address: verifier, abi: MultiAttestationVerifier_default, functionName: "witnesses" }
7614
+ ]
7615
+ });
7616
+ expectBigInt(
7617
+ "MultiAttestationVerifier.requiredSignatures",
7618
+ results[0],
7619
+ BigInt(manifest.attestationTrust.requiredSignatures)
7620
+ );
7621
+ expectAddressSet(
7622
+ "MultiAttestationVerifier.witnesses",
7623
+ results[1],
7624
+ manifest.attestationTrust.witnesses
7625
+ );
7626
+ }
7627
+ async readAuthorizationEvents(params) {
7628
+ if (params.fromBlock > params.toBlock) {
7629
+ throw new ReadinessMismatch("authorization event range is invalid");
7630
+ }
7631
+ let logs;
7632
+ try {
7633
+ logs = await this.readAuthorizationEventRange(params, params.fromBlock, params.toBlock);
7634
+ } catch (cause) {
7635
+ if (!isLogRangeLimitError(cause)) throw cause;
7636
+ const ranges = fallbackBlockRanges(params.fromBlock, params.toBlock);
7637
+ const batches = [];
7638
+ for (let index = 0; index < ranges.length; index += LOG_QUERY_CONCURRENCY) {
7639
+ const batch = await Promise.all(
7640
+ ranges.slice(index, index + LOG_QUERY_CONCURRENCY).map(
7641
+ ([fromBlock, toBlock]) => this.readAuthorizationEventRange(params, fromBlock, toBlock)
7642
+ )
7643
+ );
7644
+ batches.push(...batch);
7645
+ }
7646
+ logs = batches.flat();
7647
+ }
7648
+ return logs;
7649
+ }
7650
+ async readAuthorizationEventRange(params, fromBlock, toBlock) {
7651
+ const logs = await this.config.publicClient.getLogs({
7652
+ address: params.address,
7653
+ events: params.events,
7654
+ fromBlock,
7655
+ toBlock,
7656
+ strict: true
7657
+ });
7658
+ return logs.map((event) => ({
7659
+ eventName: event.eventName,
7660
+ blockNumber: event.blockNumber,
7661
+ transactionIndex: event.transactionIndex,
7662
+ logIndex: event.logIndex,
7663
+ args: event.args
7664
+ }));
7665
+ }
7666
+ async verifyExactAuthorizationSets(blockNumber, successorActive) {
7667
+ const { manifest, publicClient } = this.config;
7668
+ const identities = manifest.runtimeIdentities;
7669
+ const authorizations = manifest.exactAuthorizationSets;
7670
+ const [orchestratorEvents, lifecycleHookEvents, writers] = await Promise.all([
7671
+ this.readAuthorizationEvents({
7672
+ address: identities.OrchestratorRegistry.address,
7673
+ events: ORCHESTRATOR_AUTHORIZATION_EVENTS,
7674
+ fromBlock: BigInt(authorizations.orchestratorAuthorizationFromBlock),
7675
+ toBlock: blockNumber
7676
+ }),
7677
+ this.readAuthorizationEvents({
7678
+ address: identities.DisputeProtectionPolicy.address,
7679
+ events: LIFECYCLE_HOOK_AUTHORIZATION_EVENTS,
7680
+ fromBlock: BigInt(authorizations.lifecycleHookAuthorizationFromBlock),
7681
+ toBlock: blockNumber
7682
+ }),
7683
+ publicClient.readContract({
7684
+ address: identities.DisputeNullifierRegistry.address,
7685
+ abi: DisputeNullifierRegistry_default,
7686
+ functionName: "getWriters",
7687
+ blockNumber
7688
+ })
7689
+ ]);
7690
+ const orchestratorAuthorizationEvents = orchestratorEvents.map((event) => {
7691
+ if (event.eventName !== "OrchestratorAdded" && event.eventName !== "OrchestratorRemoved") {
7692
+ throw new ReadinessMismatch("OrchestratorRegistry authorization event is malformed");
7693
+ }
7694
+ return {
7695
+ ...event,
7696
+ args: {
7697
+ orchestrator: event.args?.orchestrator,
7698
+ enabled: event.eventName === "OrchestratorAdded"
7699
+ }
7700
+ };
7701
+ });
7702
+ const orchestrators = replayAddressAuthorizations(
7703
+ "OrchestratorRegistry authorization",
7704
+ orchestratorAuthorizationEvents,
7705
+ "orchestrator"
7706
+ );
7707
+ const lifecycleHooks = replayAddressAuthorizations(
7708
+ "DisputeProtectionPolicy lifecycle authorization",
7709
+ lifecycleHookEvents,
7710
+ "hook",
7711
+ "isAuthorized"
7712
+ );
7713
+ expectAddressSet(
7714
+ "OrchestratorRegistry authorized orchestrators",
7715
+ orchestrators,
7716
+ authorizations.authorizedOrchestrators
7717
+ );
7718
+ expectAddressSet(
7719
+ "DisputeProtectionPolicy authorized lifecycle hooks",
7720
+ lifecycleHooks,
7721
+ authorizations.authorizedLifecycleHooks
7722
+ );
7723
+ expectAddressSet(
7724
+ "DisputeNullifierRegistry writers",
7725
+ writers,
7726
+ successorActive ? authorizations.activeDisputeNullifierWriters : authorizations.passiveDisputeNullifierWriters
7727
+ );
7728
+ }
7729
+ async verifySuccessorState(blockNumber, successorActive) {
7730
+ const { manifest, publicClient } = this.config;
7731
+ const identities = manifest.runtimeIdentities;
7732
+ const relations = manifest.expectedRelations;
7733
+ const prerequisite = manifest.prerequisites;
7734
+ const policy = identities.DisputeProtectionPolicy.address;
7735
+ const riskWindows = Object.entries(manifest.riskWindowSecondsByPaymentMethod).sort(
7736
+ ([left], [right]) => left.localeCompare(right)
7737
+ );
7738
+ const contracts = [
7739
+ {
7740
+ address: identities.IntentLifecycleHookV1.address,
7741
+ abi: IntentLifecycleHookV1_default,
7742
+ functionName: "orchestratorRegistry"
7743
+ },
7744
+ {
7745
+ address: identities.IntentLifecycleHookV1.address,
7746
+ abi: IntentLifecycleHookV1_default,
7747
+ functionName: "whitelistPolicy"
7748
+ },
7749
+ {
7750
+ address: identities.IntentLifecycleHookV1.address,
7751
+ abi: IntentLifecycleHookV1_default,
7752
+ functionName: "disputeProtectionPolicy"
7753
+ },
7754
+ {
7755
+ address: identities.OrchestratorRegistry.address,
7756
+ abi: OrchestratorRegistry_default,
7757
+ functionName: "isOrchestrator",
7758
+ args: [relations.registeredOrchestrator]
7759
+ },
7760
+ {
7761
+ address: identities.WhitelistPolicy.address,
7762
+ abi: WhitelistPolicy_default,
7763
+ functionName: "groupRegistry"
7764
+ },
7765
+ {
7766
+ address: identities.WhitelistPolicy.address,
7767
+ abi: WhitelistPolicy_default,
7768
+ functionName: "escrowRegistry"
7769
+ },
7770
+ {
7771
+ address: identities.WhitelistPolicy.address,
7772
+ abi: WhitelistPolicy_default,
7773
+ functionName: "orchestratorRegistry"
7774
+ },
7775
+ { address: policy, abi: DisputeProtectionPolicy_default, functionName: "stakeVault" },
7776
+ { address: policy, abi: DisputeProtectionPolicy_default, functionName: "disputeVerifier" },
7777
+ {
7778
+ address: policy,
7779
+ abi: DisputeProtectionPolicy_default,
7780
+ functionName: "disputeNullifierRegistry"
7781
+ },
7782
+ {
7783
+ address: policy,
7784
+ abi: DisputeProtectionPolicy_default,
7785
+ functionName: "isLifecycleHookAuthorized",
7786
+ args: [relations.authorizedLifecycleHook]
7787
+ },
7788
+ { address: policy, abi: DisputeProtectionPolicy_default, functionName: "admissionsPaused" },
7789
+ {
7790
+ address: policy,
7791
+ abi: DisputeProtectionPolicy_default,
7792
+ functionName: "PENDING_COVERAGE_MATURITY"
7793
+ },
7794
+ {
7795
+ address: policy,
7796
+ abi: DisputeProtectionPolicy_default,
7797
+ functionName: "isDisputeProtectionEnabled",
7798
+ args: [manifest.sentinel.escrow, BigInt(manifest.sentinel.depositId)]
7799
+ },
7800
+ ...riskWindows.map(([paymentMethod]) => ({
7801
+ address: policy,
7802
+ abi: DisputeProtectionPolicy_default,
7803
+ functionName: "getRiskWindow",
7804
+ args: [paymentMethod]
7805
+ })),
7806
+ {
7807
+ address: identities.DisputeVerifier.address,
7808
+ abi: DisputeVerifier_default,
7809
+ functionName: "nullifierRegistry"
7810
+ },
7811
+ {
7812
+ address: identities.DisputeVerifier.address,
7813
+ abi: DisputeVerifier_default,
7814
+ functionName: "attestationVerifier"
7815
+ },
7816
+ { address: identities.StakeVault.address, abi: StakeVault_default, functionName: "controller" },
7817
+ { address: identities.StakeVault.address, abi: StakeVault_default, functionName: "stakeToken" },
7818
+ {
7819
+ address: identities.StakeVault.address,
7820
+ abi: StakeVault_default,
7821
+ functionName: "pendingController"
7822
+ },
7823
+ {
7824
+ address: identities.StakeVault.address,
7825
+ abi: StakeVault_default,
7826
+ functionName: "pendingControllerValidAt"
7827
+ }
7828
+ ];
7829
+ const result = await publicClient.multicall({
7830
+ allowFailure: false,
7831
+ blockNumber,
7832
+ // The dynamic risk-window suffix prevents viem from inferring one fixed
7833
+ // ABI tuple, while every entry remains assembled from packaged ABIs.
7834
+ contracts
7835
+ });
7836
+ expectAddress(
7837
+ "IntentLifecycleHookV1.orchestratorRegistry",
7838
+ result[0],
7839
+ relations.hookOrchestratorRegistry
7840
+ );
7841
+ expectAddress(
7842
+ "IntentLifecycleHookV1.whitelistPolicy",
7843
+ result[1],
7844
+ relations.hookWhitelistPolicy
7845
+ );
7846
+ expectAddress(
7847
+ "IntentLifecycleHookV1.disputeProtectionPolicy",
7848
+ result[2],
7849
+ relations.hookDisputeProtectionPolicy
7850
+ );
7851
+ expectBoolean(
7852
+ "OrchestratorRegistry.isOrchestrator",
7853
+ result[3],
7854
+ prerequisite.orchestratorRegistered
7855
+ );
7856
+ expectAddress("WhitelistPolicy.groupRegistry", result[4], relations.whitelistGroupRegistry);
7857
+ expectAddress("WhitelistPolicy.escrowRegistry", result[5], relations.whitelistEscrowRegistry);
7858
+ expectAddress(
7859
+ "WhitelistPolicy.orchestratorRegistry",
7860
+ result[6],
7861
+ relations.whitelistOrchestratorRegistry
7862
+ );
7863
+ expectAddress("DisputeProtectionPolicy.stakeVault", result[7], relations.policyStakeVault);
7864
+ expectAddress(
7865
+ "DisputeProtectionPolicy.disputeVerifier",
7866
+ result[8],
7867
+ relations.policyDisputeVerifier
7868
+ );
7869
+ expectAddress(
7870
+ "DisputeProtectionPolicy.disputeNullifierRegistry",
7871
+ result[9],
7872
+ relations.policyDisputeNullifierRegistry
7873
+ );
7874
+ expectBoolean(
7875
+ "DisputeProtectionPolicy.isLifecycleHookAuthorized",
7876
+ result[10],
7877
+ prerequisite.lifecycleHookAuthorized
7878
+ );
7879
+ if (typeof result[11] !== "boolean") {
7880
+ throw new ReadinessMismatch("DisputeProtectionPolicy.admissionsPaused is malformed");
7881
+ }
7882
+ const policyAdmissionsPaused = result[11];
7883
+ expectBigInt(
7884
+ "DisputeProtectionPolicy.PENDING_COVERAGE_MATURITY",
7885
+ result[12],
7886
+ BigInt(prerequisite.pendingCoverageMaturity)
7887
+ );
7888
+ expectBoolean("DisputeProtectionPolicy.sentinel", result[13], manifest.sentinel.expected);
7889
+ let index = 14;
7890
+ for (const [paymentMethod, seconds] of riskWindows) {
7891
+ expectBigInt(
7892
+ `DisputeProtectionPolicy.getRiskWindow(${paymentMethod})`,
7893
+ result[index],
7894
+ BigInt(seconds)
7895
+ );
7896
+ index += 1;
7897
+ }
7898
+ expectAddress(
7899
+ "DisputeVerifier.nullifierRegistry",
7900
+ result[index++],
7901
+ relations.disputeVerifierNullifierRegistry
7902
+ );
7903
+ expectAddress(
7904
+ "DisputeVerifier.attestationVerifier",
7905
+ result[index++],
7906
+ relations.disputeVerifierAttestationVerifier
7907
+ );
7908
+ expectAddress("StakeVault.controller", result[index++], relations.vaultController);
7909
+ expectAddress("StakeVault.stakeToken", result[index++], relations.vaultStakeToken);
7910
+ expectAddress("StakeVault.pendingController", result[index++], zeroAddress);
7911
+ expectBigInt("StakeVault.pendingControllerValidAt", result[index], 0n);
7912
+ await this.verifyGovernance(blockNumber);
7913
+ await this.verifyAttestationTrust(blockNumber);
7914
+ await this.verifyExactAuthorizationSets(blockNumber, successorActive);
7915
+ return policyAdmissionsPaused;
7916
+ }
7917
+ async read(options = {}) {
7918
+ const packageMismatch = validatePackagedIdentity(this.config);
7919
+ if (packageMismatch) {
7920
+ return {
7921
+ state: "mismatch",
7922
+ readyForDisputeProtection: false,
7923
+ asOfBlock: null,
7924
+ reason: packageMismatch
7925
+ };
7926
+ }
7927
+ let blockNumber = null;
7928
+ try {
7929
+ blockNumber = await this.config.publicClient.getBlockNumber();
7930
+ await this.verifyRuntimeIdentities(["OrchestratorV3"], blockNumber);
7931
+ const orchestrator = await this.readOrchestrator(blockNumber);
7932
+ const hook = orchestrator.lifecycleHook;
7933
+ const identities = this.config.manifest.runtimeIdentities;
7934
+ if (sameAddress(hook, zeroAddress)) {
7935
+ return knownResult(
7936
+ "verified_no_hook",
7937
+ false,
7938
+ blockNumber,
7939
+ this.config,
7940
+ hook,
7941
+ orchestrator.paused,
7942
+ orchestrator.allowMultipleIntents,
7943
+ null
7944
+ );
7945
+ }
7946
+ if (sameAddress(hook, identities.RecognizedPredecessorHook.address)) {
7947
+ await this.verifyRuntimeIdentities(
7948
+ ["RecognizedPredecessorHook", "RecognizedPredecessorPolicy"],
7949
+ blockNumber
7950
+ );
7951
+ if (!options.verifyPassiveSuccessor) {
7952
+ return knownResult(
7953
+ "recognized_predecessor",
7954
+ false,
7955
+ blockNumber,
7956
+ this.config,
7957
+ hook,
7958
+ orchestrator.paused,
7959
+ orchestrator.allowMultipleIntents,
7960
+ null
7961
+ );
7962
+ }
7963
+ await this.verifyRuntimeIdentities(SUCCESSOR_RUNTIME_IDENTITIES, blockNumber);
7964
+ const policyAdmissionsPaused2 = await this.verifySuccessorState(blockNumber, false);
7965
+ return knownResult(
7966
+ "passive_successor",
7967
+ false,
7968
+ blockNumber,
7969
+ this.config,
7970
+ hook,
7971
+ orchestrator.paused,
7972
+ orchestrator.allowMultipleIntents,
7973
+ policyAdmissionsPaused2
7974
+ );
7975
+ }
7976
+ if (!sameAddress(hook, identities.IntentLifecycleHookV1.address)) {
7977
+ throw new ReadinessMismatch("OrchestratorV3.lifecycleHook is not a recognized deployment");
7978
+ }
7979
+ await this.verifyRuntimeIdentities(SUCCESSOR_RUNTIME_IDENTITIES, blockNumber);
7980
+ const policyAdmissionsPaused = await this.verifySuccessorState(blockNumber, true);
7981
+ const readyForDisputeProtection = orchestrator.paused === this.config.manifest.prerequisites.orchestratorPaused && orchestrator.allowMultipleIntents === this.config.manifest.prerequisites.allowMultipleIntents && policyAdmissionsPaused === this.config.manifest.prerequisites.admissionsPaused;
7982
+ return knownResult(
7983
+ "active_successor_verified",
7984
+ readyForDisputeProtection,
7985
+ blockNumber,
7986
+ this.config,
7987
+ hook,
7988
+ orchestrator.paused,
7989
+ orchestrator.allowMultipleIntents,
7990
+ policyAdmissionsPaused
7991
+ );
7992
+ } catch (error) {
7993
+ return {
7994
+ state: "mismatch",
7995
+ readyForDisputeProtection: false,
7996
+ asOfBlock: blockNumber,
7997
+ reason: error instanceof ReadinessMismatch ? error.message : `dispute readiness RPC failed: ${error instanceof Error ? error.message : String(error)}`
7998
+ };
7999
+ }
8000
+ }
8001
+ };
8002
+ function createDisputeProtectionReadinessReader(params) {
8003
+ return new DisputeProtectionReadinessReader({
8004
+ publicClient: params.publicClient,
8005
+ chainId: params.chainId,
8006
+ manifest: manifestForEnvironment(params.environment),
8007
+ buildMetadata: SDK_BUILD_METADATA,
8008
+ contractsPackageVersion: version
8009
+ });
8010
+ }
8011
+
6504
8012
  // src/indexer/intentVerification.ts
6505
8013
  async function fetchFulfillmentAndPayment(client, intentHash) {
6506
8014
  return client.query({
@@ -6870,17 +8378,19 @@ var Zkp2pClient = class {
6870
8378
  "clearStakeOwner",
6871
8379
  () => []
6872
8380
  );
8381
+ /** Enable or disable dispute protection for one deposit. */
8382
+ this.setDisputeProtectionEnabled = this.buildDisputeProtectionPolicyMethod("setDisputeProtectionEnabled", (params) => [params.escrow, params.depositId, params.enabled]);
6873
8383
  /**
6874
- * Release one chargeback intent whose risk window matured, unlocking its
6875
- * stake cover. Permissionless once mature. Pass `chargebackPolicyAddress` to
8384
+ * Release one protected intent whose risk window matured, unlocking its
8385
+ * stake cover. Permissionless once mature. Pass `disputeProtectionPolicyAddress` to
6876
8386
  * pin the transaction to a snapshotted deployment.
6877
8387
  */
6878
- this.releaseMaturedChargebackIntent = this.buildChargebackPolicyMethod("releaseMaturedChargebackIntent", (params) => [params.intentHash]);
8388
+ this.releaseMaturedDisputeProtectionIntent = this.buildDisputeProtectionPolicyMethod("releaseMaturedDisputeProtectionIntent", (params) => [params.intentHash]);
6879
8389
  /**
6880
- * Release multiple matured chargeback intents in one transaction.
6881
- * Pass `chargebackPolicyAddress` to pin the transaction to a snapshotted deployment.
8390
+ * Release multiple matured protected intents in one transaction.
8391
+ * Pass `disputeProtectionPolicyAddress` to pin the transaction to a snapshotted deployment.
6882
8392
  */
6883
- this.releaseMaturedChargebackIntents = this.buildChargebackPolicyMethod("releaseMaturedChargebackIntents", (params) => [params.intentHashes]);
8393
+ this.releaseMaturedDisputeProtectionIntents = this.buildDisputeProtectionPolicyMethod("releaseMaturedDisputeProtectionIntents", (params) => [params.intentHashes]);
6884
8394
  // ╔═══════════════════════════════════════════════════════════════════════════╗
6885
8395
  // ║ CORE: DEPOSIT MANAGEMENT ║
6886
8396
  // ╚═══════════════════════════════════════════════════════════════════════════╝
@@ -7746,6 +9256,11 @@ var Zkp2pClient = class {
7746
9256
  chain: selectedChain,
7747
9257
  transport: opts.rpcTransport ?? http(rpc, { batch: false })
7748
9258
  });
9259
+ this._disputeProtectionReadinessReader = createDisputeProtectionReadinessReader({
9260
+ publicClient: this.publicClient,
9261
+ chainId: this.chainId,
9262
+ environment: this.runtimeEnv
9263
+ });
7749
9264
  const { addresses, abis } = getContracts(this.chainId, this.runtimeEnv);
7750
9265
  const toAddress = (value) => this.isValidHexAddress(value) ? value : void 0;
7751
9266
  const uniqAddresses = (values) => {
@@ -7813,8 +9328,8 @@ var Zkp2pClient = class {
7813
9328
  this.intentGuardianAbi = abis.intentGuardian;
7814
9329
  this.stakeVaultAddress = toAddress(addresses.stakeVault);
7815
9330
  this.stakeVaultAbi = abis.stakeVault;
7816
- this.chargebackPolicyAddress = toAddress(addresses.chargebackPolicy);
7817
- this.chargebackPolicyAbi = abis.chargebackPolicy;
9331
+ this.disputeProtectionPolicyAddress = toAddress(addresses.disputeProtectionPolicy);
9332
+ this.disputeProtectionPolicyAbi = abis.disputeProtectionPolicy;
7818
9333
  if (!this.rateManagerRegistryAddress || !this.rateManagerRegistryAbi) {
7819
9334
  try {
7820
9335
  const rateManagerContracts = getRateManagerContracts(this.chainId, this.runtimeEnv);
@@ -7904,8 +9419,8 @@ var Zkp2pClient = class {
7904
9419
  getStakeVaultAddress: () => this.stakeVaultAddress,
7905
9420
  getStakeVaultAbi: () => this.stakeVaultAbi,
7906
9421
  getStakeTokenAddress: () => this._usdcAddress,
7907
- getChargebackPolicyAddress: () => this.chargebackPolicyAddress,
7908
- getChargebackPolicyAbi: () => this.chargebackPolicyAbi
9422
+ getDisputeProtectionPolicyAddress: () => this.disputeProtectionPolicyAddress,
9423
+ getDisputeProtectionPolicyAbi: () => this.disputeProtectionPolicyAbi
7909
9424
  });
7910
9425
  this._intentGuardianOps = new IntentGuardianOperations({
7911
9426
  getPublicClient: () => this.publicClient,
@@ -8246,7 +9761,7 @@ var Zkp2pClient = class {
8246
9761
  const escrowAbi = opts.escrowAbi ?? this.escrowAbi;
8247
9762
  if (!escrowAddress || !escrowAbi) throw new Error("Escrow not available");
8248
9763
  const { referrer, value } = opts.txOverrides ?? {};
8249
- const data = encodeWithAttribution(
9764
+ const data3 = encodeWithAttribution(
8250
9765
  {
8251
9766
  abi: escrowAbi,
8252
9767
  functionName: opts.functionName,
@@ -8256,7 +9771,7 @@ var Zkp2pClient = class {
8256
9771
  );
8257
9772
  return {
8258
9773
  to: escrowAddress,
8259
- data,
9774
+ data: data3,
8260
9775
  value: opts.value ?? value ?? 0n,
8261
9776
  chainId: this.chainId,
8262
9777
  abi: escrowAbi,
@@ -8269,7 +9784,7 @@ var Zkp2pClient = class {
8269
9784
  const orchestratorAbi = opts.orchestratorAbi ?? this.orchestratorAbi;
8270
9785
  if (!orchestratorAddress || !orchestratorAbi) throw new Error("Orchestrator not available");
8271
9786
  const { referrer, value } = opts.txOverrides ?? {};
8272
- const data = encodeWithAttribution(
9787
+ const data3 = encodeWithAttribution(
8273
9788
  {
8274
9789
  abi: orchestratorAbi,
8275
9790
  functionName: opts.functionName,
@@ -8279,7 +9794,7 @@ var Zkp2pClient = class {
8279
9794
  );
8280
9795
  return {
8281
9796
  to: orchestratorAddress,
8282
- data,
9797
+ data: data3,
8283
9798
  value: opts.value ?? value ?? 0n,
8284
9799
  chainId: this.chainId,
8285
9800
  abi: orchestratorAbi,
@@ -8300,7 +9815,7 @@ var Zkp2pClient = class {
8300
9815
  }
8301
9816
  prepareContractTransaction(opts) {
8302
9817
  const { referrer, value } = opts.txOverrides ?? {};
8303
- const data = encodeWithAttribution(
9818
+ const data3 = encodeWithAttribution(
8304
9819
  {
8305
9820
  abi: opts.abi,
8306
9821
  functionName: opts.functionName,
@@ -8310,7 +9825,7 @@ var Zkp2pClient = class {
8310
9825
  );
8311
9826
  return {
8312
9827
  to: opts.address,
8313
- data,
9828
+ data: data3,
8314
9829
  value: opts.value ?? value ?? 0n,
8315
9830
  chainId: this.chainId,
8316
9831
  abi: opts.abi,
@@ -8370,12 +9885,12 @@ var Zkp2pClient = class {
8370
9885
  buildArgs
8371
9886
  );
8372
9887
  }
8373
- buildChargebackPolicyMethod(functionName, buildArgs) {
9888
+ buildDisputeProtectionPolicyMethod(functionName, buildArgs) {
8374
9889
  return this.buildContractMethod(
8375
9890
  (params) => ({
8376
- address: params.chargebackPolicyAddress ?? this.chargebackPolicyAddress,
8377
- abi: this.chargebackPolicyAbi,
8378
- label: "ChargebackPolicy"
9891
+ address: params.disputeProtectionPolicyAddress ?? this.disputeProtectionPolicyAddress,
9892
+ abi: this.disputeProtectionPolicyAbi,
9893
+ label: "DisputeProtectionPolicy"
8379
9894
  }),
8380
9895
  functionName,
8381
9896
  buildArgs
@@ -8778,6 +10293,20 @@ var Zkp2pClient = class {
8778
10293
  signal: options?.signal
8779
10294
  });
8780
10295
  },
10296
+ /** Pages stake-owner locks by immutable lock identity. */
10297
+ getStakeLocks: (params, options) => {
10298
+ return stakingService.fetchStakeLocks(params, { signal: options?.signal });
10299
+ },
10300
+ /** Pages append-only activity relevant to either side of a merchant's stake delegation. */
10301
+ getStakeActivity: (params, options) => {
10302
+ return stakingService.fetchStakeActivity(params, { signal: options?.signal });
10303
+ },
10304
+ /** Pages the exact active policy's finalized dispute stream. */
10305
+ getDisputeProtectionIntents: (params, options) => {
10306
+ return stakingService.fetchDisputeProtectionIntents(params, {
10307
+ signal: options?.signal
10308
+ });
10309
+ },
8781
10310
  /**
8782
10311
  * Fetches chronological fund activities for a specific deposit.
8783
10312
  */
@@ -8877,12 +10406,12 @@ var Zkp2pClient = class {
8877
10406
  }
8878
10407
  return { address: this.orchestratorV3Address, abi: this.orchestratorV3Abi };
8879
10408
  }
8880
- /** Return the resolved ChargebackPolicy coordinates for keeper integrations. */
8881
- getChargebackPolicyContract() {
8882
- if (!this.chargebackPolicyAddress || !this.chargebackPolicyAbi) {
8883
- throw new Error("ChargebackPolicy not available for this chain/environment");
10409
+ /** Return the resolved DisputeProtectionPolicy coordinates for keeper integrations. */
10410
+ getDisputeProtectionPolicyContract() {
10411
+ if (!this.disputeProtectionPolicyAddress || !this.disputeProtectionPolicyAbi) {
10412
+ throw new Error("DisputeProtectionPolicy not available for this chain/environment");
8884
10413
  }
8885
- return { address: this.chargebackPolicyAddress, abi: this.chargebackPolicyAbi };
10414
+ return { address: this.disputeProtectionPolicyAddress, abi: this.disputeProtectionPolicyAbi };
8886
10415
  }
8887
10416
  /**
8888
10417
  * Ensure the connected wallet has approved enough USDC for StakeVault.
@@ -8930,10 +10459,14 @@ var Zkp2pClient = class {
8930
10459
  getStakeVaultState(params) {
8931
10460
  return this._stakeOps.getStakeVaultState(params);
8932
10461
  }
8933
- /** Read whether the ChargebackPolicy is refusing new chargebackable admissions. */
10462
+ /** Read whether the DisputeProtectionPolicy is refusing new dispute-protected admissions. */
8934
10463
  getAdmissionsPaused() {
8935
10464
  return this._stakeOps.getAdmissionsPaused();
8936
10465
  }
10466
+ /** Prove the exact packaged dispute-protection deployment at one block. */
10467
+ getDisputeProtectionReadiness(options) {
10468
+ return this._disputeProtectionReadinessReader.read(options);
10469
+ }
8937
10470
  /**
8938
10471
  * Read a payment method's minimum collateral lock window in seconds. Zero
8939
10472
  * means the method admits unbonded — no stake is locked at admission.
@@ -8941,9 +10474,9 @@ var Zkp2pClient = class {
8941
10474
  getRiskWindow(paymentMethodHash) {
8942
10475
  return this._stakeOps.getRiskWindow(paymentMethodHash);
8943
10476
  }
8944
- /** Read whether an escrow deposit has opted into chargeback coverage. */
8945
- isChargebackEnabled(escrow, depositId) {
8946
- return this._stakeOps.isChargebackEnabled(escrow, depositId);
10477
+ /** Read whether an escrow deposit has opted into dispute protection. */
10478
+ isDisputeProtectionEnabled(escrow, depositId) {
10479
+ return this._stakeOps.isDisputeProtectionEnabled(escrow, depositId);
8947
10480
  }
8948
10481
  /**
8949
10482
  * Registers payee details with the curator API and returns hashed on-chain IDs.
@@ -9146,7 +10679,7 @@ var Zkp2pClient = class {
9146
10679
  }
9147
10680
  }
9148
10681
  });
9149
- const { mapConversionRatesToOnchainMinRate: mapConversionRatesToOnchainMinRate2 } = await import('./currency-MARF3D2J.mjs');
10682
+ const { mapConversionRatesToOnchainMinRate: mapConversionRatesToOnchainMinRate2 } = await import('./currency-XA62DCJH.mjs');
9150
10683
  currencies = mapConversionRatesToOnchainMinRate2(
9151
10684
  params.conversionRates,
9152
10685
  paymentMethods.length
@@ -9742,7 +11275,7 @@ var Zkp2pClient = class {
9742
11275
  rateManagerV1: this.rateManagerV1Address,
9743
11276
  orchestratorRegistry: this.orchestratorRegistryAddress,
9744
11277
  stakeVault: this.stakeVaultAddress,
9745
- chargebackPolicy: this.chargebackPolicyAddress,
11278
+ disputeProtectionPolicy: this.disputeProtectionPolicyAddress,
9746
11279
  usdc: this._usdcAddress
9747
11280
  };
9748
11281
  }
@@ -9832,17 +11365,17 @@ function integer(value, label) {
9832
11365
  if (parsed < 0n) throw new RangeError(`${label} must be non-negative`);
9833
11366
  return parsed;
9834
11367
  }
9835
- function calculateRequiredCoverage(amount, chargebackable) {
9836
- return chargebackable ? integer(amount, "amount") : 0n;
11368
+ function calculateRequiredCoverage(amount, disputeProtected) {
11369
+ return disputeProtected ? integer(amount, "amount") : 0n;
9837
11370
  }
9838
11371
  function calculateStakeBackedCapacity(freeStake) {
9839
11372
  return integer(freeStake, "freeStake");
9840
11373
  }
9841
- function selectRiskMode(amount, freeStake, chargebackable) {
9842
- const required = calculateRequiredCoverage(amount, chargebackable);
9843
- if (!chargebackable) return "UNBONDED";
11374
+ function selectRiskMode(amount, freeStake, disputeProtected) {
11375
+ const required = calculateRequiredCoverage(amount, disputeProtected);
11376
+ if (!disputeProtected) return "UNBONDED";
9844
11377
  if (integer(freeStake, "freeStake") >= required) return "STAKE_BACKED";
9845
- throw new RangeError("insufficient free stake for chargebackable admission");
11378
+ throw new RangeError("insufficient free stake for dispute-protected admission");
9846
11379
  }
9847
11380
 
9848
11381
  // src/client/accessPolicyPlan.ts
@@ -10001,6 +11534,6 @@ var planAccessPolicyUpdate = (persistedInput, draftInput) => {
10001
11534
  };
10002
11535
  };
10003
11536
 
10004
- export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, IndexerStakingService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, RISK_BPS_DENOMINATOR, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuote, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiSignIntentV3, apiSignIntentV3Raw, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, buildStakingEntityIds, calculateRequiredCoverage, calculateStakeBackedCapacity, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, selectRiskMode, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
11537
+ export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, IndexerStakingService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, RISK_BPS_DENOMINATOR, SDK_BUILD_METADATA, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuote, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiSignIntentV3, apiSignIntentV3Raw, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, buildStakingEntityIds, calculateRequiredCoverage, calculateStakeBackedCapacity, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, selectRiskMode, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
10005
11538
  //# sourceMappingURL=index.mjs.map
10006
11539
  //# sourceMappingURL=index.mjs.map