@zkp2p/sdk 0.0.14 → 0.0.15

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.
@@ -451,6 +451,11 @@ interface IntentFulfilledEntity {
451
451
  isManualRelease: boolean;
452
452
  fundsTransferredTo?: string | null;
453
453
  }
454
+ interface IntentFulfillmentAmountsEntity {
455
+ intentHash: string;
456
+ releasedAmount?: string | null;
457
+ takerAmountNetFees?: string | null;
458
+ }
454
459
 
455
460
  type DepositOrderField = 'remainingDeposits' | 'outstandingIntentAmount' | 'totalAmountTaken' | 'totalWithdrawn' | 'updatedAt' | 'timestamp';
456
461
  type OrderDirection = 'asc' | 'desc';
@@ -502,6 +507,7 @@ declare class IndexerDepositService {
502
507
  limit?: number;
503
508
  }): Promise<IntentEntity[]>;
504
509
  fetchFulfilledIntentEvents(intentHashes: string[]): Promise<IntentFulfilledEntity[]>;
510
+ fetchIntentFulfillmentAmounts(intentHash: string): Promise<IntentFulfillmentAmountsEntity | null>;
505
511
  resolvePayeeHash(params: {
506
512
  escrowAddress?: string | null;
507
513
  depositId?: string | number | bigint | null;
@@ -1499,6 +1505,10 @@ declare class Zkp2pClient {
1499
1505
  * Fetches fulfillment events for completed intents.
1500
1506
  */
1501
1507
  getFulfilledIntentEvents: (intentHashes: string[]) => Promise<IntentFulfilledEntity[]>;
1508
+ /**
1509
+ * Fetches gross and net fulfillment amounts for an intent.
1510
+ */
1511
+ getIntentFulfillmentAmounts: (intentHash: string) => Promise<IntentFulfillmentAmountsEntity | null>;
1502
1512
  /**
1503
1513
  * Fetches both the fulfillment record and payment verification for an intent.
1504
1514
  */
@@ -2258,4 +2268,4 @@ declare class Zkp2pClient {
2258
2268
  }>;
2259
2269
  }
2260
2270
 
2261
- export { type GetIntentByHashResponse as $, type AuthorizationTokenProvider as A, type DepositVerifier as B, type CancelIntentMethodParams as C, type DepositWithRelations as D, type DepositVerifierCurrency as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type DepositStatus as H, type IntentEntity as I, type GetDepositByIdRequest as J, type GetDepositByIdResponse as K, type Intent as L, type ApiIntentStatus as M, type NearbyQuote as N, type GetOwnerIntentsRequest as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type Range as R, type SignalIntentMethodParams as S, type TxOverrides as T, type GetOwnerIntentsResponse as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type GetIntentsByDepositRequest as X, type GetIntentsByDepositResponse as Y, Zkp2pClient as Z, type GetIntentByHashRequest as _, type ValidatePayeeDetailsResponse as a, type RegisterPayeeDetailsRequest as a0, type RegisterPayeeDetailsResponse as a1, type OnchainCurrency as a2, type DepositVerifierData as a3, type PreparedTransaction as a4, type OrderStats as a5, type DepositIntentStatistics as a6, type TakerTier as a7, type TakerTierStats as a8, type TakerTierLevel as a9, isSupportedCurrencyHash as aA, mapConversionRatesToOnchainMinRate as aB, type CurrencyType as aC, type CurrencyData as aD, getContracts as aE, getPaymentMethodsCatalog as aF, getGatingServiceAddress as aG, type RuntimeEnv as aH, parseDepositView as aI, parseIntentView as aJ, enrichPvDepositView as aK, enrichPvIntentView as aL, type PV_DepositView as aM, type PV_Deposit as aN, type PV_PaymentMethodData as aO, type PV_Currency as aP, type PV_IntentView as aQ, type PV_Intent as aR, type PlatformLimit as aa, type PlatformRiskLevel as ab, IndexerClient as ac, defaultIndexerEndpoint as ad, IndexerDepositService as ae, fetchFulfillmentAndPayment as af, type DepositEntity as ag, type IntentFulfilledEntity as ah, type DepositPaymentMethodEntity as ai, type MethodCurrencyEntity as aj, type IntentStatus as ak, type DepositFilter as al, type PaginationOptions as am, type DepositOrderField as an, type OrderDirection as ao, type DeploymentEnv as ap, type FulfillmentRecord as aq, type PaymentVerifiedRecord as ar, type FulfillmentAndPaymentResponse as as, PAYMENT_PLATFORMS as at, type PaymentPlatformType as au, Currency as av, currencyInfo as aw, getCurrencyInfoFromHash as ax, getCurrencyInfoFromCountryCode as ay, getCurrencyCodeFromHash as az, type PostDepositDetailsResponse as b, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type Zkp2pClientOptions as i, type TimeoutConfig as j, type ActionCallback as k, type CreateDepositParams as l, type CreateDepositConversionRate as m, type SignalIntentParams as n, type FulfillIntentParams as o, type ReleaseFundsToPayerParams as p, type CancelIntentParams as q, type QuoteResponse as r, type QuoteResponseObject as s, type QuoteSingleResponse as t, type QuoteIntentResponse as u, type QuoteFeesResponse as v, type FiatResponse as w, type TokenResponse as x, type NearbySuggestions as y, type ApiDeposit as z };
2271
+ export { type GetIntentByHashResponse as $, type AuthorizationTokenProvider as A, type DepositVerifier as B, type CancelIntentMethodParams as C, type DepositWithRelations as D, type DepositVerifierCurrency as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type DepositStatus as H, type IntentEntity as I, type GetDepositByIdRequest as J, type GetDepositByIdResponse as K, type Intent as L, type ApiIntentStatus as M, type NearbyQuote as N, type GetOwnerIntentsRequest as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type Range as R, type SignalIntentMethodParams as S, type TxOverrides as T, type GetOwnerIntentsResponse as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type GetIntentsByDepositRequest as X, type GetIntentsByDepositResponse as Y, Zkp2pClient as Z, type GetIntentByHashRequest as _, type ValidatePayeeDetailsResponse as a, type RegisterPayeeDetailsRequest as a0, type RegisterPayeeDetailsResponse as a1, type OnchainCurrency as a2, type DepositVerifierData as a3, type PreparedTransaction as a4, type OrderStats as a5, type DepositIntentStatistics as a6, type TakerTier as a7, type TakerTierStats as a8, type TakerTierLevel as a9, getCurrencyCodeFromHash as aA, isSupportedCurrencyHash as aB, mapConversionRatesToOnchainMinRate as aC, type CurrencyType as aD, type CurrencyData as aE, getContracts as aF, getPaymentMethodsCatalog as aG, getGatingServiceAddress as aH, type RuntimeEnv as aI, parseDepositView as aJ, parseIntentView as aK, enrichPvDepositView as aL, enrichPvIntentView as aM, type PV_DepositView as aN, type PV_Deposit as aO, type PV_PaymentMethodData as aP, type PV_Currency as aQ, type PV_IntentView as aR, type PV_Intent as aS, type PlatformLimit as aa, type PlatformRiskLevel as ab, IndexerClient as ac, defaultIndexerEndpoint as ad, IndexerDepositService as ae, fetchFulfillmentAndPayment as af, type DepositEntity as ag, type IntentFulfilledEntity as ah, type IntentFulfillmentAmountsEntity as ai, type DepositPaymentMethodEntity as aj, type MethodCurrencyEntity as ak, type IntentStatus as al, type DepositFilter as am, type PaginationOptions as an, type DepositOrderField as ao, type OrderDirection as ap, type DeploymentEnv as aq, type FulfillmentRecord as ar, type PaymentVerifiedRecord as as, type FulfillmentAndPaymentResponse as at, PAYMENT_PLATFORMS as au, type PaymentPlatformType as av, Currency as aw, currencyInfo as ax, getCurrencyInfoFromHash as ay, getCurrencyInfoFromCountryCode as az, type PostDepositDetailsResponse as b, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type Zkp2pClientOptions as i, type TimeoutConfig as j, type ActionCallback as k, type CreateDepositParams as l, type CreateDepositConversionRate as m, type SignalIntentParams as n, type FulfillIntentParams as o, type ReleaseFundsToPayerParams as p, type CancelIntentParams as q, type QuoteResponse as r, type QuoteResponseObject as s, type QuoteSingleResponse as t, type QuoteIntentResponse as u, type QuoteFeesResponse as v, type FiatResponse as w, type TokenResponse as x, type NearbySuggestions as y, type ApiDeposit as z };
@@ -451,6 +451,11 @@ interface IntentFulfilledEntity {
451
451
  isManualRelease: boolean;
452
452
  fundsTransferredTo?: string | null;
453
453
  }
454
+ interface IntentFulfillmentAmountsEntity {
455
+ intentHash: string;
456
+ releasedAmount?: string | null;
457
+ takerAmountNetFees?: string | null;
458
+ }
454
459
 
455
460
  type DepositOrderField = 'remainingDeposits' | 'outstandingIntentAmount' | 'totalAmountTaken' | 'totalWithdrawn' | 'updatedAt' | 'timestamp';
456
461
  type OrderDirection = 'asc' | 'desc';
@@ -502,6 +507,7 @@ declare class IndexerDepositService {
502
507
  limit?: number;
503
508
  }): Promise<IntentEntity[]>;
504
509
  fetchFulfilledIntentEvents(intentHashes: string[]): Promise<IntentFulfilledEntity[]>;
510
+ fetchIntentFulfillmentAmounts(intentHash: string): Promise<IntentFulfillmentAmountsEntity | null>;
505
511
  resolvePayeeHash(params: {
506
512
  escrowAddress?: string | null;
507
513
  depositId?: string | number | bigint | null;
@@ -1499,6 +1505,10 @@ declare class Zkp2pClient {
1499
1505
  * Fetches fulfillment events for completed intents.
1500
1506
  */
1501
1507
  getFulfilledIntentEvents: (intentHashes: string[]) => Promise<IntentFulfilledEntity[]>;
1508
+ /**
1509
+ * Fetches gross and net fulfillment amounts for an intent.
1510
+ */
1511
+ getIntentFulfillmentAmounts: (intentHash: string) => Promise<IntentFulfillmentAmountsEntity | null>;
1502
1512
  /**
1503
1513
  * Fetches both the fulfillment record and payment verification for an intent.
1504
1514
  */
@@ -2258,4 +2268,4 @@ declare class Zkp2pClient {
2258
2268
  }>;
2259
2269
  }
2260
2270
 
2261
- export { type GetIntentByHashResponse as $, type AuthorizationTokenProvider as A, type DepositVerifier as B, type CancelIntentMethodParams as C, type DepositWithRelations as D, type DepositVerifierCurrency as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type DepositStatus as H, type IntentEntity as I, type GetDepositByIdRequest as J, type GetDepositByIdResponse as K, type Intent as L, type ApiIntentStatus as M, type NearbyQuote as N, type GetOwnerIntentsRequest as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type Range as R, type SignalIntentMethodParams as S, type TxOverrides as T, type GetOwnerIntentsResponse as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type GetIntentsByDepositRequest as X, type GetIntentsByDepositResponse as Y, Zkp2pClient as Z, type GetIntentByHashRequest as _, type ValidatePayeeDetailsResponse as a, type RegisterPayeeDetailsRequest as a0, type RegisterPayeeDetailsResponse as a1, type OnchainCurrency as a2, type DepositVerifierData as a3, type PreparedTransaction as a4, type OrderStats as a5, type DepositIntentStatistics as a6, type TakerTier as a7, type TakerTierStats as a8, type TakerTierLevel as a9, isSupportedCurrencyHash as aA, mapConversionRatesToOnchainMinRate as aB, type CurrencyType as aC, type CurrencyData as aD, getContracts as aE, getPaymentMethodsCatalog as aF, getGatingServiceAddress as aG, type RuntimeEnv as aH, parseDepositView as aI, parseIntentView as aJ, enrichPvDepositView as aK, enrichPvIntentView as aL, type PV_DepositView as aM, type PV_Deposit as aN, type PV_PaymentMethodData as aO, type PV_Currency as aP, type PV_IntentView as aQ, type PV_Intent as aR, type PlatformLimit as aa, type PlatformRiskLevel as ab, IndexerClient as ac, defaultIndexerEndpoint as ad, IndexerDepositService as ae, fetchFulfillmentAndPayment as af, type DepositEntity as ag, type IntentFulfilledEntity as ah, type DepositPaymentMethodEntity as ai, type MethodCurrencyEntity as aj, type IntentStatus as ak, type DepositFilter as al, type PaginationOptions as am, type DepositOrderField as an, type OrderDirection as ao, type DeploymentEnv as ap, type FulfillmentRecord as aq, type PaymentVerifiedRecord as ar, type FulfillmentAndPaymentResponse as as, PAYMENT_PLATFORMS as at, type PaymentPlatformType as au, Currency as av, currencyInfo as aw, getCurrencyInfoFromHash as ax, getCurrencyInfoFromCountryCode as ay, getCurrencyCodeFromHash as az, type PostDepositDetailsResponse as b, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type Zkp2pClientOptions as i, type TimeoutConfig as j, type ActionCallback as k, type CreateDepositParams as l, type CreateDepositConversionRate as m, type SignalIntentParams as n, type FulfillIntentParams as o, type ReleaseFundsToPayerParams as p, type CancelIntentParams as q, type QuoteResponse as r, type QuoteResponseObject as s, type QuoteSingleResponse as t, type QuoteIntentResponse as u, type QuoteFeesResponse as v, type FiatResponse as w, type TokenResponse as x, type NearbySuggestions as y, type ApiDeposit as z };
2271
+ export { type GetIntentByHashResponse as $, type AuthorizationTokenProvider as A, type DepositVerifier as B, type CancelIntentMethodParams as C, type DepositWithRelations as D, type DepositVerifierCurrency as E, type FulfillIntentMethodParams as F, type GetPayeeDetailsRequest as G, type DepositStatus as H, type IntentEntity as I, type GetDepositByIdRequest as J, type GetDepositByIdResponse as K, type Intent as L, type ApiIntentStatus as M, type NearbyQuote as N, type GetOwnerIntentsRequest as O, type PostDepositDetailsRequest as P, type QuoteRequest as Q, type Range as R, type SignalIntentMethodParams as S, type TxOverrides as T, type GetOwnerIntentsResponse as U, type ValidatePayeeDetailsRequest as V, type WithdrawDepositParams as W, type GetIntentsByDepositRequest as X, type GetIntentsByDepositResponse as Y, Zkp2pClient as Z, type GetIntentByHashRequest as _, type ValidatePayeeDetailsResponse as a, type RegisterPayeeDetailsRequest as a0, type RegisterPayeeDetailsResponse as a1, type OnchainCurrency as a2, type DepositVerifierData as a3, type PreparedTransaction as a4, type OrderStats as a5, type DepositIntentStatistics as a6, type TakerTier as a7, type TakerTierStats as a8, type TakerTierLevel as a9, getCurrencyCodeFromHash as aA, isSupportedCurrencyHash as aB, mapConversionRatesToOnchainMinRate as aC, type CurrencyType as aD, type CurrencyData as aE, getContracts as aF, getPaymentMethodsCatalog as aG, getGatingServiceAddress as aH, type RuntimeEnv as aI, parseDepositView as aJ, parseIntentView as aK, enrichPvDepositView as aL, enrichPvIntentView as aM, type PV_DepositView as aN, type PV_Deposit as aO, type PV_PaymentMethodData as aP, type PV_Currency as aQ, type PV_IntentView as aR, type PV_Intent as aS, type PlatformLimit as aa, type PlatformRiskLevel as ab, IndexerClient as ac, defaultIndexerEndpoint as ad, IndexerDepositService as ae, fetchFulfillmentAndPayment as af, type DepositEntity as ag, type IntentFulfilledEntity as ah, type IntentFulfillmentAmountsEntity as ai, type DepositPaymentMethodEntity as aj, type MethodCurrencyEntity as ak, type IntentStatus as al, type DepositFilter as am, type PaginationOptions as an, type DepositOrderField as ao, type OrderDirection as ap, type DeploymentEnv as aq, type FulfillmentRecord as ar, type PaymentVerifiedRecord as as, type FulfillmentAndPaymentResponse as at, PAYMENT_PLATFORMS as au, type PaymentPlatformType as av, Currency as aw, currencyInfo as ax, getCurrencyInfoFromHash as ay, getCurrencyInfoFromCountryCode as az, type PostDepositDetailsResponse as b, type GetPayeeDetailsResponse as c, type GetOwnerDepositsRequest as d, type GetOwnerDepositsResponse as e, type GetTakerTierRequest as f, type GetTakerTierResponse as g, type PaymentMethodCatalog as h, type Zkp2pClientOptions as i, type TimeoutConfig as j, type ActionCallback as k, type CreateDepositParams as l, type CreateDepositConversionRate as m, type SignalIntentParams as n, type FulfillIntentParams as o, type ReleaseFundsToPayerParams as p, type CancelIntentParams as q, type QuoteResponse as r, type QuoteResponseObject as s, type QuoteSingleResponse as t, type QuoteIntentResponse as u, type QuoteFeesResponse as v, type FiatResponse as w, type TokenResponse as x, type NearbySuggestions as y, type ApiDeposit as z };
@@ -1,4 +1,4 @@
1
- import { resolvePaymentMethodNameFromHash } from './chunk-DZ2TBIN7.mjs';
1
+ import { resolvePaymentMethodNameFromHash } from './chunk-RNJWFEXN.mjs';
2
2
  import { getCurrencyInfoFromHash } from './chunk-MDLTLKWK.mjs';
3
3
  import baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';
4
4
  import baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';
@@ -205,5 +205,5 @@ function enrichPvIntentView(view, chainId, env = "production") {
205
205
  }
206
206
 
207
207
  export { enrichPvDepositView, enrichPvIntentView, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, parseDepositView, parseIntentView };
208
- //# sourceMappingURL=chunk-MIPASRUG.mjs.map
209
- //# sourceMappingURL=chunk-MIPASRUG.mjs.map
208
+ //# sourceMappingURL=chunk-MMPINPEZ.mjs.map
209
+ //# sourceMappingURL=chunk-MMPINPEZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,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AE;AAAA,KACJ,CAAE;AAAA,GACJ;AACF;AAEO,SAAS,kBAAA,CAAmB,IAAA,EAAqB,OAAA,EAAiB,GAAA,GAAkB,YAAA,EAAc;AACvG,EAAA,MAAM,OAAA,GAAU,wBAAA,CAAyB,OAAA,EAAS,GAAG,CAAA;AACrD,EAAA,OAAO;AAAA,IACL,GAAG,IAAA;AAAA,IACH,MAAA,EAAQ;AAAA,MACN,GAAG,IAAA,CAAK,MAAA;AAAA,MACR,aAAA,EAAe,gCAAA,CAAiC,IAAA,CAAK,MAAA,CAAO,eAAe,OAAO,CAAA;AAAA,MAClF,YAAA,EAAc,uBAAA,CAAwB,IAAA,CAAK,MAAA,CAAO,YAAY;AAAA,KAChE;AAAA,IACA,OAAA,EAAS,mBAAA,CAAoB,IAAA,CAAK,OAAA,EAAgB,SAAS,GAAG;AAAA,GAChE;AACF","file":"chunk-MIPASRUG.mjs","sourcesContent":["/**\n * Contract resolution utilities for the SDK.\n *\n * Provides access to deployed contract addresses and ABIs for different\n * environments (production, staging) on Base.\n *\n * @module contracts\n */\n\nimport type { Abi } from 'abitype';\n\n// Typed imports from @zkp2p/contracts-v2 (module declarations provided in src/@types)\n// Use *Raw suffix for imports that need runtime normalization (addresses, constants)\nimport baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';\nimport baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';\n\nimport EscrowBase from '@zkp2p/contracts-v2/abis/base/Escrow.json';\nimport OrchestratorBase from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';\nimport ProtocolViewerBase from '@zkp2p/contracts-v2/abis/base/ProtocolViewer.json';\nimport UnifiedPaymentVerifierBase from '@zkp2p/contracts-v2/abis/base/UnifiedPaymentVerifier.json';\n\nimport EscrowBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Escrow.json';\nimport OrchestratorBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Orchestrator.json';\nimport UnifiedPaymentVerifierBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/UnifiedPaymentVerifier.json';\nimport ProtocolViewerBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/ProtocolViewer.json';\n\nimport baseConstantsRaw from '@zkp2p/contracts-v2/constants/base';\nimport baseStagingConstantsRaw from '@zkp2p/contracts-v2/constants/baseStaging';\n// Payment methods catalogs (JSON). Import statically so ESM bundlers include the data.\n// These modules are present in @zkp2p/contracts-v2; tsconfig sets resolveJsonModule: true\nimport basePaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/base.json';\nimport baseStagingPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseStaging.json';\n\n// ---------------------------------------------------------------------------\n// Runtime normalization helpers for ESM/CJS interoperability\n// ---------------------------------------------------------------------------\n// In certain runtimes (tsx, Node ESM), deep imports from @zkp2p/contracts-v2\n// resolve as { default: [Getter] } or { default: { contracts: {...} } } instead\n// of the expected shape. These helpers unwrap the actual data regardless of shape.\n\n/**\n * Normalize address module shape. Handles:\n * - { contracts: {...} } (direct)\n * - { default: { contracts: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapAddresses(mod: unknown): {\n name?: string;\n chainId?: number;\n contracts?: Record<string, `0x${string}`>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapAddresses>;\n const m = mod as Record<string, unknown>;\n // Direct shape\n if (m.contracts) return m as ReturnType<typeof unwrapAddresses>;\n // Wrapped shape\n if ((m.default as Record<string, unknown>)?.contracts)\n return m.default as ReturnType<typeof unwrapAddresses>;\n // Lazy getter shape\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.contracts) return d as ReturnType<typeof unwrapAddresses>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapAddresses>;\n}\n\n/**\n * Normalize payment methods module shape. Handles:\n * - { methods: {...} } (direct)\n * - { default: { methods: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapMethods(mod: unknown): {\n methods?: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapMethods>;\n const m = mod as Record<string, unknown>;\n if (m.methods) return m as ReturnType<typeof unwrapMethods>;\n if ((m.default as Record<string, unknown>)?.methods)\n return m.default as ReturnType<typeof unwrapMethods>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.methods) return d as ReturnType<typeof unwrapMethods>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapMethods>;\n}\n\n/**\n * Normalize constants module shape (for USDC address, etc.)\n */\nfunction unwrapConstants(mod: unknown): Record<string, unknown> {\n if (!mod) return {};\n const m = mod as Record<string, unknown>;\n if (m.USDC) return m;\n if ((m.default as Record<string, unknown>)?.USDC) return m.default as Record<string, unknown>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.USDC) return d as Record<string, unknown>;\n } catch {\n // ignore\n }\n return m;\n}\n\n// Apply runtime normalization to all imports\nconst baseAddresses = unwrapAddresses(baseAddressesRaw);\nconst baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);\nconst basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);\nconst baseStagingPaymentMethods = unwrapMethods(baseStagingPaymentMethodsRaw);\nconst baseConstants = unwrapConstants(baseConstantsRaw);\nconst baseStagingConstants = unwrapConstants(baseStagingConstantsRaw);\n\n/**\n * Contract addresses for a specific deployment.\n */\nexport type V2ContractAddresses = {\n /** Escrow contract (holds deposits and manages intents) */\n escrow: `0x${string}`;\n /** Orchestrator contract (handles intent signaling and fulfillment) */\n orchestrator?: `0x${string}`;\n /** UnifiedPaymentVerifier contract (verifies payment proofs) */\n unifiedPaymentVerifier?: `0x${string}`;\n /** ProtocolViewer contract (batch read operations) */\n protocolViewer?: `0x${string}`;\n /** USDC token address */\n usdc?: `0x${string}`;\n};\n\n/**\n * Contract ABIs for a specific deployment.\n */\nexport type V2ContractAbis = {\n escrow: Abi;\n orchestrator?: Abi;\n unifiedPaymentVerifier?: Abi;\n protocolViewer?: Abi;\n};\n\n/**\n * Runtime environment: 'production' for mainnet, 'staging' for testnet/dev.\n */\nexport type RuntimeEnv = 'production' | 'staging';\n\n/**\n * Converts a chain ID to its network key.\n * @internal\n */\nexport function networkKeyFromChainId(chainId: number): 'base' {\n return 'base';\n}\n\n/**\n * Retrieves deployed contract addresses and ABIs for a given chain and environment.\n *\n * @param chainId - The chain ID (8453 for Base)\n * @param env - Runtime environment ('production' or 'staging')\n * @returns Object containing addresses and ABIs\n *\n * @example\n * ```typescript\n * import { getContracts } from '@zkp2p/sdk';\n *\n * const { addresses, abis } = getContracts(8453, 'production');\n * console.log(addresses.escrow); // \"0x...\"\n * console.log(addresses.usdc); // \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\"\n * ```\n */\nexport function getContracts(\n chainId: number,\n env: RuntimeEnv = 'production',\n): { addresses: V2ContractAddresses; abis: V2ContractAbis } {\n // Staging overrides (custom addresses/abis)\n if (env === 'staging') {\n return {\n addresses: {\n escrow: (baseStagingAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseStagingAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseStagingAddresses.contracts?.UnifiedPaymentVerifier ??\n '') as `0x${string}`,\n protocolViewer: (baseStagingAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseStagingConstants as any).USDC,\n },\n abis: {\n escrow: EscrowBaseStaging as unknown as Abi,\n orchestrator: OrchestratorBaseStaging as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBaseStaging as unknown as Abi,\n protocolViewer: ProtocolViewerBaseStaging as unknown as Abi,\n },\n };\n }\n\n return {\n addresses: {\n escrow: (baseAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseAddresses.contracts?.UnifiedPaymentVerifier ??\n '') as `0x${string}`,\n protocolViewer: (baseAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseConstants as any).USDC,\n },\n abis: {\n escrow: EscrowBase as unknown as Abi,\n orchestrator: OrchestratorBase as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBase as unknown as Abi,\n protocolViewer: ProtocolViewerBase as unknown as Abi,\n },\n };\n}\n\n/**\n * Catalog of payment methods with their hashes and supported currencies.\n */\nexport type PaymentMethodCatalog = Record<\n string,\n { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }\n>;\n\n/**\n * Retrieves the payment methods catalog for a given chain and environment.\n *\n * The catalog maps payment platform names (e.g., 'wise', 'revolut') to their\n * on-chain hashes and supported currency hashes.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Payment method catalog keyed by platform name\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]\n * console.log(catalog.wise.paymentMethodHash); // \"0x...\"\n * console.log(catalog.wise.currencies); // [\"0x...\", \"0x...\"] (currency hashes)\n * ```\n */\nexport function getPaymentMethodsCatalog(\n chainId: number,\n env: RuntimeEnv = 'production',\n): PaymentMethodCatalog {\n const src = env === 'staging' ? (baseStagingPaymentMethods as any) : (basePaymentMethods as any);\n const methods = (src?.methods ?? src?.default?.methods ?? {}) as PaymentMethodCatalog;\n return methods;\n}\n\n/**\n * Returns the gating service address for a given chain and environment.\n *\n * The gating service signs intent parameters before they can be submitted\n * on-chain, providing an additional validation layer.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Gating service signer address\n */\nexport function getGatingServiceAddress(\n chainId: number,\n env: RuntimeEnv = 'production',\n): `0x${string}` {\n // Base Staging & Production share the same gating service in current deployments\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n}\n","function toBigInt(v: any): bigint {\n if (typeof v === 'bigint') return v;\n if (typeof v === 'number') return BigInt(v);\n if (typeof v === 'string') return BigInt(v);\n if (v && typeof v.toString === 'function') return BigInt(v.toString());\n throw new Error('Unsupported numeric type for bigint conversion');\n}\n\nexport type PV_Deposit = {\n depositor: string;\n delegate: string;\n token: string;\n amount: bigint;\n intentAmountRange: { min: bigint; max: bigint };\n acceptingIntents: boolean;\n remainingDeposits: bigint;\n outstandingIntentAmount: bigint;\n makerProtocolFee: bigint;\n reservedMakerFees: bigint;\n accruedMakerFees: bigint;\n accruedReferrerFees: bigint;\n intentGuardian: string;\n referrer: string;\n referrerFee: bigint;\n};\n\nexport type PV_Currency = { code: string; minConversionRate: bigint };\nexport type PV_PaymentMethodData = {\n paymentMethod: string; // bytes32\n verificationData: {\n intentGatingService: string;\n payeeDetails: string; // bytes32\n data: string; // bytes\n };\n currencies: PV_Currency[];\n};\n\nexport type PV_DepositView = {\n depositId: bigint;\n deposit: PV_Deposit;\n availableLiquidity: bigint;\n paymentMethods: PV_PaymentMethodData[];\n intentHashes: string[];\n};\n\nexport type PV_Intent = {\n owner: string;\n to: string;\n escrow: string;\n depositId: bigint;\n amount: bigint;\n timestamp: bigint;\n paymentMethod: string; // bytes32\n fiatCurrency: string; // bytes32\n conversionRate: bigint;\n referrer: string;\n referrerFee: bigint;\n postIntentHook: string;\n data: string;\n};\n\nexport type PV_IntentView = {\n intentHash: string;\n intent: PV_Intent;\n deposit: Omit<PV_DepositView, 'intentHashes'>;\n};\n\nexport function parseDepositView(raw: any): PV_DepositView {\n return {\n depositId: toBigInt(raw.depositId),\n deposit: {\n depositor: raw.deposit.depositor,\n delegate: raw.deposit.delegate,\n token: raw.deposit.token,\n amount: toBigInt(raw.deposit.amount),\n intentAmountRange: {\n min: toBigInt(raw.deposit.intentAmountRange.min),\n max: toBigInt(raw.deposit.intentAmountRange.max),\n },\n acceptingIntents: raw.deposit.acceptingIntents,\n remainingDeposits: toBigInt(raw.deposit.remainingDeposits),\n outstandingIntentAmount: toBigInt(raw.deposit.outstandingIntentAmount),\n makerProtocolFee: toBigInt(raw.deposit.makerProtocolFee ?? 0),\n reservedMakerFees: toBigInt(raw.deposit.reservedMakerFees ?? 0),\n accruedMakerFees: toBigInt(raw.deposit.accruedMakerFees ?? 0),\n accruedReferrerFees: toBigInt(raw.deposit.accruedReferrerFees ?? 0),\n intentGuardian: raw.deposit.intentGuardian,\n referrer: raw.deposit.referrer,\n referrerFee: toBigInt(raw.deposit.referrerFee ?? 0),\n },\n availableLiquidity: toBigInt(raw.availableLiquidity),\n paymentMethods: (raw.paymentMethods || []).map((pm: any) => ({\n paymentMethod: pm.paymentMethod,\n verificationData: {\n intentGatingService: pm.verificationData.intentGatingService,\n payeeDetails: pm.verificationData.payeeDetails,\n data: pm.verificationData.data,\n },\n currencies: (pm.currencies || []).map((c: any) => ({\n code: c.code,\n minConversionRate: toBigInt(c.minConversionRate),\n })),\n })),\n intentHashes: raw.intentHashes || [],\n };\n}\n\nexport function parseIntentView(raw: any): PV_IntentView {\n const parsedDeposit = parseDepositView(raw.deposit);\n const deposit: Omit<PV_DepositView, 'intentHashes'> = {\n depositId: parsedDeposit.depositId,\n deposit: parsedDeposit.deposit,\n availableLiquidity: parsedDeposit.availableLiquidity,\n paymentMethods: parsedDeposit.paymentMethods,\n };\n return {\n intentHash: raw.intentHash,\n intent: {\n owner: raw.intent.owner,\n to: raw.intent.to,\n escrow: raw.intent.escrow,\n depositId: toBigInt(raw.intent.depositId),\n amount: toBigInt(raw.intent.amount),\n timestamp: toBigInt(raw.intent.timestamp),\n paymentMethod: raw.intent.paymentMethod,\n fiatCurrency: raw.intent.fiatCurrency,\n conversionRate: toBigInt(raw.intent.conversionRate),\n referrer: raw.intent.referrer,\n referrerFee: toBigInt(raw.intent.referrerFee ?? 0),\n postIntentHook: raw.intent.postIntentHook,\n data: raw.intent.data,\n },\n deposit,\n };\n}\n\n// Enrichment helpers for dashboards/explorers\nimport { getPaymentMethodsCatalog, type RuntimeEnv } from '../contracts';\nimport { resolvePaymentMethodNameFromHash } from './paymentResolution';\nimport { getCurrencyInfoFromHash } from './currency';\n\nexport function enrichPvDepositView(view: PV_DepositView, chainId: number, env: RuntimeEnv = 'production') {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n paymentMethods: view.paymentMethods.map((pm) => ({\n ...pm,\n processorName: resolvePaymentMethodNameFromHash(pm.paymentMethod, catalog),\n currencies: pm.currencies.map((c) => ({\n ...c,\n currencyInfo: getCurrencyInfoFromHash(c.code),\n })),\n })),\n };\n}\n\nexport function enrichPvIntentView(view: PV_IntentView, chainId: number, env: RuntimeEnv = 'production') {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n intent: {\n ...view.intent,\n processorName: resolvePaymentMethodNameFromHash(view.intent.paymentMethod, catalog),\n currencyInfo: getCurrencyInfoFromHash(view.intent.fiatCurrency),\n },\n deposit: enrichPvDepositView(view.deposit as any, chainId, env),\n } as any;\n}\n"]}
1
+ {"version":3,"sources":["../src/contracts.ts","../src/utils/protocolViewerParsers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8CA,SAAS,gBAAgB,GAAA,EAIvB;AACA,EAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,EAAA,MAAM,CAAA,GAAI,GAAA;AAEV,EAAA,IAAI,CAAA,CAAE,WAAW,OAAO,CAAA;AAExB,EAAA,IAAK,EAAE,OAAA,EAAqC,SAAA;AAC1C,IAAA,OAAO,CAAA,CAAE,OAAA;AAEX,EAAA,IAAI;AACF,IAAA,MAAM,CAAA,GAAI,OAAO,CAAA,CAAE,OAAA,KAAY,aAAc,CAAA,CAAE,OAAA,KAA8B,CAAA,CAAE,OAAA;AAC/E,IAAA,IAAK,CAAA,EAA+B,WAAW,OAAO,CAAA;AAAA,EACxD,CAAA,CAAA,M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A,GAChE;AACF","file":"chunk-MMPINPEZ.mjs","sourcesContent":["/**\n * Contract resolution utilities for the SDK.\n *\n * Provides access to deployed contract addresses and ABIs for different\n * environments (production, staging) on Base.\n *\n * @module contracts\n */\n\nimport type { Abi } from 'abitype';\n\n// Typed imports from @zkp2p/contracts-v2 (module declarations provided in src/@types)\n// Use *Raw suffix for imports that need runtime normalization (addresses, constants)\nimport baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';\nimport baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';\n\nimport EscrowBase from '@zkp2p/contracts-v2/abis/base/Escrow.json';\nimport OrchestratorBase from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';\nimport ProtocolViewerBase from '@zkp2p/contracts-v2/abis/base/ProtocolViewer.json';\nimport UnifiedPaymentVerifierBase from '@zkp2p/contracts-v2/abis/base/UnifiedPaymentVerifier.json';\n\nimport EscrowBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Escrow.json';\nimport OrchestratorBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Orchestrator.json';\nimport UnifiedPaymentVerifierBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/UnifiedPaymentVerifier.json';\nimport ProtocolViewerBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/ProtocolViewer.json';\n\nimport baseConstantsRaw from '@zkp2p/contracts-v2/constants/base';\nimport baseStagingConstantsRaw from '@zkp2p/contracts-v2/constants/baseStaging';\n// Payment methods catalogs (JSON). Import statically so ESM bundlers include the data.\n// These modules are present in @zkp2p/contracts-v2; tsconfig sets resolveJsonModule: true\nimport basePaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/base.json';\nimport baseStagingPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseStaging.json';\n\n// ---------------------------------------------------------------------------\n// Runtime normalization helpers for ESM/CJS interoperability\n// ---------------------------------------------------------------------------\n// In certain runtimes (tsx, Node ESM), deep imports from @zkp2p/contracts-v2\n// resolve as { default: [Getter] } or { default: { contracts: {...} } } instead\n// of the expected shape. These helpers unwrap the actual data regardless of shape.\n\n/**\n * Normalize address module shape. Handles:\n * - { contracts: {...} } (direct)\n * - { default: { contracts: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapAddresses(mod: unknown): {\n name?: string;\n chainId?: number;\n contracts?: Record<string, `0x${string}`>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapAddresses>;\n const m = mod as Record<string, unknown>;\n // Direct shape\n if (m.contracts) return m as ReturnType<typeof unwrapAddresses>;\n // Wrapped shape\n if ((m.default as Record<string, unknown>)?.contracts)\n return m.default as ReturnType<typeof unwrapAddresses>;\n // Lazy getter shape\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.contracts) return d as ReturnType<typeof unwrapAddresses>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapAddresses>;\n}\n\n/**\n * Normalize payment methods module shape. Handles:\n * - { methods: {...} } (direct)\n * - { default: { methods: {...} } } (wrapped)\n * - { default: [Getter] } (lazy)\n */\nfunction unwrapMethods(mod: unknown): {\n methods?: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>;\n} {\n if (!mod) return {} as ReturnType<typeof unwrapMethods>;\n const m = mod as Record<string, unknown>;\n if (m.methods) return m as ReturnType<typeof unwrapMethods>;\n if ((m.default as Record<string, unknown>)?.methods)\n return m.default as ReturnType<typeof unwrapMethods>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.methods) return d as ReturnType<typeof unwrapMethods>;\n } catch {\n // ignore\n }\n return m as ReturnType<typeof unwrapMethods>;\n}\n\n/**\n * Normalize constants module shape (for USDC address, etc.)\n */\nfunction unwrapConstants(mod: unknown): Record<string, unknown> {\n if (!mod) return {};\n const m = mod as Record<string, unknown>;\n if (m.USDC) return m;\n if ((m.default as Record<string, unknown>)?.USDC) return m.default as Record<string, unknown>;\n try {\n const d = typeof m.default === 'function' ? (m.default as () => unknown)() : m.default;\n if ((d as Record<string, unknown>)?.USDC) return d as Record<string, unknown>;\n } catch {\n // ignore\n }\n return m;\n}\n\n// Apply runtime normalization to all imports\nconst baseAddresses = unwrapAddresses(baseAddressesRaw);\nconst baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);\nconst basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);\nconst baseStagingPaymentMethods = unwrapMethods(baseStagingPaymentMethodsRaw);\nconst baseConstants = unwrapConstants(baseConstantsRaw);\nconst baseStagingConstants = unwrapConstants(baseStagingConstantsRaw);\n\n/**\n * Contract addresses for a specific deployment.\n */\nexport type V2ContractAddresses = {\n /** Escrow contract (holds deposits and manages intents) */\n escrow: `0x${string}`;\n /** Orchestrator contract (handles intent signaling and fulfillment) */\n orchestrator?: `0x${string}`;\n /** UnifiedPaymentVerifier contract (verifies payment proofs) */\n unifiedPaymentVerifier?: `0x${string}`;\n /** ProtocolViewer contract (batch read operations) */\n protocolViewer?: `0x${string}`;\n /** USDC token address */\n usdc?: `0x${string}`;\n};\n\n/**\n * Contract ABIs for a specific deployment.\n */\nexport type V2ContractAbis = {\n escrow: Abi;\n orchestrator?: Abi;\n unifiedPaymentVerifier?: Abi;\n protocolViewer?: Abi;\n};\n\n/**\n * Runtime environment: 'production' for mainnet, 'staging' for testnet/dev.\n */\nexport type RuntimeEnv = 'production' | 'staging';\n\n/**\n * Converts a chain ID to its network key.\n * @internal\n */\nexport function networkKeyFromChainId(chainId: number): 'base' {\n return 'base';\n}\n\n/**\n * Retrieves deployed contract addresses and ABIs for a given chain and environment.\n *\n * @param chainId - The chain ID (8453 for Base)\n * @param env - Runtime environment ('production' or 'staging')\n * @returns Object containing addresses and ABIs\n *\n * @example\n * ```typescript\n * import { getContracts } from '@zkp2p/sdk';\n *\n * const { addresses, abis } = getContracts(8453, 'production');\n * console.log(addresses.escrow); // \"0x...\"\n * console.log(addresses.usdc); // \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\"\n * ```\n */\nexport function getContracts(\n chainId: number,\n env: RuntimeEnv = 'production',\n): { addresses: V2ContractAddresses; abis: V2ContractAbis } {\n // Staging overrides (custom addresses/abis)\n if (env === 'staging') {\n return {\n addresses: {\n escrow: (baseStagingAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseStagingAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseStagingAddresses.contracts?.UnifiedPaymentVerifier ??\n '') as `0x${string}`,\n protocolViewer: (baseStagingAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseStagingConstants as any).USDC,\n },\n abis: {\n escrow: EscrowBaseStaging as unknown as Abi,\n orchestrator: OrchestratorBaseStaging as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBaseStaging as unknown as Abi,\n protocolViewer: ProtocolViewerBaseStaging as unknown as Abi,\n },\n };\n }\n\n return {\n addresses: {\n escrow: (baseAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseAddresses.contracts?.UnifiedPaymentVerifier ??\n '') as `0x${string}`,\n protocolViewer: (baseAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseConstants as any).USDC,\n },\n abis: {\n escrow: EscrowBase as unknown as Abi,\n orchestrator: OrchestratorBase as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBase as unknown as Abi,\n protocolViewer: ProtocolViewerBase as unknown as Abi,\n },\n };\n}\n\n/**\n * Catalog of payment methods with their hashes and supported currencies.\n */\nexport type PaymentMethodCatalog = Record<\n string,\n { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }\n>;\n\n/**\n * Retrieves the payment methods catalog for a given chain and environment.\n *\n * The catalog maps payment platform names (e.g., 'wise', 'revolut') to their\n * on-chain hashes and supported currency hashes.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Payment method catalog keyed by platform name\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]\n * console.log(catalog.wise.paymentMethodHash); // \"0x...\"\n * console.log(catalog.wise.currencies); // [\"0x...\", \"0x...\"] (currency hashes)\n * ```\n */\nexport function getPaymentMethodsCatalog(\n chainId: number,\n env: RuntimeEnv = 'production',\n): PaymentMethodCatalog {\n const src = env === 'staging' ? (baseStagingPaymentMethods as any) : (basePaymentMethods as any);\n const methods = (src?.methods ?? src?.default?.methods ?? {}) as PaymentMethodCatalog;\n return methods;\n}\n\n/**\n * Returns the gating service address for a given chain and environment.\n *\n * The gating service signs intent parameters before they can be submitted\n * on-chain, providing an additional validation layer.\n *\n * @param chainId - The chain ID\n * @param env - Runtime environment\n * @returns Gating service signer address\n */\nexport function getGatingServiceAddress(\n chainId: number,\n env: RuntimeEnv = 'production',\n): `0x${string}` {\n // Base Staging & Production share the same gating service in current deployments\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n}\n","function toBigInt(v: any): bigint {\n if (typeof v === 'bigint') return v;\n if (typeof v === 'number') return BigInt(v);\n if (typeof v === 'string') return BigInt(v);\n if (v && typeof v.toString === 'function') return BigInt(v.toString());\n throw new Error('Unsupported numeric type for bigint conversion');\n}\n\nexport type PV_Deposit = {\n depositor: string;\n delegate: string;\n token: string;\n amount: bigint;\n intentAmountRange: { min: bigint; max: bigint };\n acceptingIntents: boolean;\n remainingDeposits: bigint;\n outstandingIntentAmount: bigint;\n makerProtocolFee: bigint;\n reservedMakerFees: bigint;\n accruedMakerFees: bigint;\n accruedReferrerFees: bigint;\n intentGuardian: string;\n referrer: string;\n referrerFee: bigint;\n};\n\nexport type PV_Currency = { code: string; minConversionRate: bigint };\nexport type PV_PaymentMethodData = {\n paymentMethod: string; // bytes32\n verificationData: {\n intentGatingService: string;\n payeeDetails: string; // bytes32\n data: string; // bytes\n };\n currencies: PV_Currency[];\n};\n\nexport type PV_DepositView = {\n depositId: bigint;\n deposit: PV_Deposit;\n availableLiquidity: bigint;\n paymentMethods: PV_PaymentMethodData[];\n intentHashes: string[];\n};\n\nexport type PV_Intent = {\n owner: string;\n to: string;\n escrow: string;\n depositId: bigint;\n amount: bigint;\n timestamp: bigint;\n paymentMethod: string; // bytes32\n fiatCurrency: string; // bytes32\n conversionRate: bigint;\n referrer: string;\n referrerFee: bigint;\n postIntentHook: string;\n data: string;\n};\n\nexport type PV_IntentView = {\n intentHash: string;\n intent: PV_Intent;\n deposit: Omit<PV_DepositView, 'intentHashes'>;\n};\n\nexport function parseDepositView(raw: any): PV_DepositView {\n return {\n depositId: toBigInt(raw.depositId),\n deposit: {\n depositor: raw.deposit.depositor,\n delegate: raw.deposit.delegate,\n token: raw.deposit.token,\n amount: toBigInt(raw.deposit.amount),\n intentAmountRange: {\n min: toBigInt(raw.deposit.intentAmountRange.min),\n max: toBigInt(raw.deposit.intentAmountRange.max),\n },\n acceptingIntents: raw.deposit.acceptingIntents,\n remainingDeposits: toBigInt(raw.deposit.remainingDeposits),\n outstandingIntentAmount: toBigInt(raw.deposit.outstandingIntentAmount),\n makerProtocolFee: toBigInt(raw.deposit.makerProtocolFee ?? 0),\n reservedMakerFees: toBigInt(raw.deposit.reservedMakerFees ?? 0),\n accruedMakerFees: toBigInt(raw.deposit.accruedMakerFees ?? 0),\n accruedReferrerFees: toBigInt(raw.deposit.accruedReferrerFees ?? 0),\n intentGuardian: raw.deposit.intentGuardian,\n referrer: raw.deposit.referrer,\n referrerFee: toBigInt(raw.deposit.referrerFee ?? 0),\n },\n availableLiquidity: toBigInt(raw.availableLiquidity),\n paymentMethods: (raw.paymentMethods || []).map((pm: any) => ({\n paymentMethod: pm.paymentMethod,\n verificationData: {\n intentGatingService: pm.verificationData.intentGatingService,\n payeeDetails: pm.verificationData.payeeDetails,\n data: pm.verificationData.data,\n },\n currencies: (pm.currencies || []).map((c: any) => ({\n code: c.code,\n minConversionRate: toBigInt(c.minConversionRate),\n })),\n })),\n intentHashes: raw.intentHashes || [],\n };\n}\n\nexport function parseIntentView(raw: any): PV_IntentView {\n const parsedDeposit = parseDepositView(raw.deposit);\n const deposit: Omit<PV_DepositView, 'intentHashes'> = {\n depositId: parsedDeposit.depositId,\n deposit: parsedDeposit.deposit,\n availableLiquidity: parsedDeposit.availableLiquidity,\n paymentMethods: parsedDeposit.paymentMethods,\n };\n return {\n intentHash: raw.intentHash,\n intent: {\n owner: raw.intent.owner,\n to: raw.intent.to,\n escrow: raw.intent.escrow,\n depositId: toBigInt(raw.intent.depositId),\n amount: toBigInt(raw.intent.amount),\n timestamp: toBigInt(raw.intent.timestamp),\n paymentMethod: raw.intent.paymentMethod,\n fiatCurrency: raw.intent.fiatCurrency,\n conversionRate: toBigInt(raw.intent.conversionRate),\n referrer: raw.intent.referrer,\n referrerFee: toBigInt(raw.intent.referrerFee ?? 0),\n postIntentHook: raw.intent.postIntentHook,\n data: raw.intent.data,\n },\n deposit,\n };\n}\n\n// Enrichment helpers for dashboards/explorers\nimport { getPaymentMethodsCatalog, type RuntimeEnv } from '../contracts';\nimport { resolvePaymentMethodNameFromHash } from './paymentResolution';\nimport { getCurrencyInfoFromHash } from './currency';\n\nexport function enrichPvDepositView(view: PV_DepositView, chainId: number, env: RuntimeEnv = 'production') {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n paymentMethods: view.paymentMethods.map((pm) => ({\n ...pm,\n processorName: resolvePaymentMethodNameFromHash(pm.paymentMethod, catalog),\n currencies: pm.currencies.map((c) => ({\n ...c,\n currencyInfo: getCurrencyInfoFromHash(c.code),\n })),\n })),\n };\n}\n\nexport function enrichPvIntentView(view: PV_IntentView, chainId: number, env: RuntimeEnv = 'production') {\n const catalog = getPaymentMethodsCatalog(chainId, env);\n return {\n ...view,\n intent: {\n ...view.intent,\n processorName: resolvePaymentMethodNameFromHash(view.intent.paymentMethod, catalog),\n currencyInfo: getCurrencyInfoFromHash(view.intent.fiatCurrency),\n },\n deposit: enrichPvDepositView(view.deposit as any, chainId, env),\n } as any;\n}\n"]}
@@ -224,5 +224,5 @@ function resolvePaymentMethodNameFromHash(hash, catalog) {
224
224
  }
225
225
 
226
226
  export { asciiToBytes32, ensureBytes32, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash };
227
- //# sourceMappingURL=chunk-DZ2TBIN7.mjs.map
228
- //# sourceMappingURL=chunk-DZ2TBIN7.mjs.map
227
+ //# sourceMappingURL=chunk-RNJWFEXN.mjs.map
228
+ //# sourceMappingURL=chunk-RNJWFEXN.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/bytes32.ts","../../core/src/utils/usdcUnits.ts","../../core/src/utils/currencyKeccak256.ts","../../core/src/types/currency.ts","../../core/src/platforms/types.ts","../../core/src/utils/paymentMethodHashes.ts","../../core/src/utils/gas.ts","../../core/src/constants/index.ts","../src/utils/paymentResolution.ts"],"names":["currencyKeccak256","viemKeccak256"],"mappings":";;;;;AAKO,SAAS,cACd,KAAA,EACA,EAAE,cAAc,KAAA,EAAM,GAA+B,EAAC,EACvC;AACf,EAAA,IAAI,KAAA,CAAM,UAAA,CAAW,IAAI,CAAA,EAAG;AAC1B,IAAA,MAAM,KAAA,GAAQ,WAAW,KAAsB,CAAA;AAC/C,IAAA,IAAI,MAAM,MAAA,KAAW,EAAA,EAAI,MAAM,IAAI,MAAM,4BAA4B,CAAA;AACrE,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,WAAA;AACH,IAAA,MAAM,IAAI,MAAM,6EAA6E,CAAA;AAC/F,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,OAAA,CAAQ,KAAK,CAAC,CAAA;AACvC,EAAA,OAAO,MAA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EAAA,KAAA,MAAW,CAAC,MAAM,KAAK,CAAA,IAAK,OAAO,OAAA,CAAQ,OAAA,IAAW,EAAE,CAAA,EAAG;AACzD,IAAA,IAAI,OAAO,iBAAA,EAAmB,WAAA,OAAkB,MAAA,CAAO,WAAA,IAAe,OAAO,IAAA;AAAA,EAC/E;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-DZ2TBIN7.mjs","sourcesContent":["import { keccak256, toBytes, hexToBytes, bytesToHex } from 'viem';\n\n/**\n * Ensure a value is 32 bytes hex (0x + 64 nibbles). If ascii, keccak256 by default when hash=true.\n */\nexport function ensureBytes32(\n value: string,\n { hashIfAscii = false }: { hashIfAscii?: boolean } = {},\n): `0x${string}` {\n if (value.startsWith('0x')) {\n const bytes = hexToBytes(value as `0x${string}`);\n if (bytes.length !== 32) throw new Error('Expected 32-byte hex value');\n return value as `0x${string}`;\n }\n if (!hashIfAscii)\n throw new Error('Expected 32-byte hex; received ascii string. Pass hashIfAscii=true to hash.');\n const hashed = keccak256(toBytes(value));\n return hashed as `0x${string}`;\n}\n\n/**\n * Encode ASCII (<=32 chars) left-aligned, right-padded with zeros to 32 bytes.\n */\nexport function asciiToBytes32(value: string): `0x${string}` {\n const b = toBytes(value);\n if (b.length > 32) throw new Error('ASCII input exceeds 32 bytes');\n const padded = new Uint8Array(32);\n padded.set(b);\n return bytesToHex(padded);\n}\n","import { parseUnits } from \"viem\";\n\nexport const usdcUnits = (amount: number | string | bigint): bigint => {\n return parseUnits(amount.toString(), 6);\n};\n","import { keccak256 as viemKeccak256 } from \"viem\";\n\nexport const currencyKeccak256 = (inputString: string): string => {\n const bytes = new TextEncoder().encode(inputString);\n return viemKeccak256(bytes);\n};\n","import { currencyKeccak256 } from '../utils/currencyKeccak256';\n\n\nexport const Currency = {\n AED: \"AED\",\n ARS: \"ARS\",\n AUD: \"AUD\",\n CAD: \"CAD\",\n CHF: \"CHF\",\n CNY: \"CNY\",\n CZK: \"CZK\",\n DKK: \"DKK\",\n EUR: \"EUR\",\n GBP: \"GBP\",\n HKD: \"HKD\",\n HUF: \"HUF\",\n IDR: \"IDR\",\n ILS: \"ILS\",\n INR: \"INR\",\n JPY: \"JPY\",\n KES: \"KES\",\n NOK: \"NOK\",\n MXN: \"MXN\",\n MYR: \"MYR\",\n NZD: \"NZD\",\n PHP: \"PHP\",\n PLN: \"PLN\",\n RON: \"RON\",\n SAR: \"SAR\",\n SEK: \"SEK\",\n SGD: \"SGD\",\n THB: \"THB\",\n TRY: \"TRY\",\n UGX: \"UGX\",\n USD: \"USD\",\n VND: \"VND\",\n ZAR: \"ZAR\",\n};\n\nexport type CurrencyType = typeof Currency[keyof typeof Currency];\n\nfunction getCurrencies(): string[] {\n return Object.values(Currency);\n}\n\nexport function getCurrencyInfoFromHash(currencyCodeHash: string): CurrencyData | null {\n return Object.values(currencyInfo).find(\n (currency) => currency.currencyCodeHash === currencyCodeHash\n ) ?? null;\n}\n\nexport function getCurrencyInfoFromCountryCode(countryCode: string): CurrencyData | null {\n return Object.values(currencyInfo).find(\n (currency) => currency.countryCode === countryCode\n ) ?? null;\n}\n\nexport function isSupportedCurrency(currencyCode: string): boolean {\n return Object.values(currencyInfo).some(\n (currency) => currency.currencyCode === currencyCode\n );\n}\n\nexport const currencies = getCurrencies();\n\ninterface CurrencyData {\n currency: CurrencyType;\n currencyCode: string;\n currencyName: string;\n currencySymbol: string;\n currencyCodeHash: string;\n countryCode: string;\n}\n\nexport const currencyInfo: Record<CurrencyType, CurrencyData> = {\n [Currency.AED]: {\n currency: Currency.AED,\n currencyCode: \"AED\",\n currencyName: \"United Arab Emirates Dirham\",\n currencyCodeHash: currencyKeccak256(\"AED\"),\n currencySymbol: \"د.إ\",\n countryCode: \"ae\",\n },\n [Currency.ARS]: {\n currency: Currency.ARS,\n currencyCode: \"ARS\",\n currencyName: \"Argentine Peso\",\n currencyCodeHash: currencyKeccak256(\"ARS\"),\n currencySymbol: \"$\",\n countryCode: \"ar\"\n },\n [Currency.AUD]: {\n currency: Currency.AUD,\n currencyCode: \"AUD\",\n currencyName: \"Australian Dollar\",\n currencyCodeHash: currencyKeccak256(\"AUD\"),\n currencySymbol: \"A$\",\n countryCode: \"au\",\n },\n [Currency.CAD]: {\n currency: Currency.CAD,\n currencyCode: \"CAD\",\n currencyName: \"Canadian Dollar\",\n currencyCodeHash: currencyKeccak256(\"CAD\"),\n currencySymbol: \"C$\",\n countryCode: \"ca\",\n },\n [Currency.CHF]: {\n currency: Currency.CHF,\n currencyCode: \"CHF\",\n currencyName: \"Swiss Franc\",\n currencyCodeHash: currencyKeccak256(\"CHF\"),\n currencySymbol: \"Fr\",\n countryCode: \"ch\",\n },\n [Currency.CNY]: {\n currency: Currency.CNY,\n currencyCode: \"CNY\",\n currencyName: \"Chinese Yuan\",\n currencyCodeHash: currencyKeccak256(\"CNY\"),\n currencySymbol: \"¥\",\n countryCode: \"cn\",\n },\n [Currency.CZK]: {\n currency: Currency.CZK,\n currencyCode: \"CZK\",\n currencyName: \"Czech Koruna\",\n currencyCodeHash: currencyKeccak256(\"CZK\"),\n currencySymbol: \"Kč\",\n countryCode: \"cz\",\n },\n [Currency.DKK]: {\n currency: Currency.DKK,\n currencyCode: \"DKK\",\n currencyName: \"Danish Krone\",\n currencyCodeHash: currencyKeccak256(\"DKK\"),\n currencySymbol: \"kr\",\n countryCode: \"dk\",\n },\n [Currency.EUR]: {\n currency: Currency.EUR,\n currencyCode: \"EUR\",\n currencyName: \"Euro\",\n currencyCodeHash: currencyKeccak256(\"EUR\"),\n currencySymbol: \"€\",\n countryCode: \"eu\",\n },\n [Currency.GBP]: {\n currency: Currency.GBP,\n currencyCode: \"GBP\",\n currencyName: \"British Pound\",\n currencyCodeHash: currencyKeccak256(\"GBP\"),\n currencySymbol: \"£\",\n countryCode: \"gb\",\n },\n [Currency.HKD]: {\n currency: Currency.HKD,\n currencyCode: \"HKD\",\n currencyName: \"Hong Kong Dollar\",\n currencyCodeHash: currencyKeccak256(\"HKD\"),\n currencySymbol: \"HK$\",\n countryCode: \"hk\",\n },\n [Currency.HUF]: {\n currency: Currency.HUF,\n currencyCode: \"HUF\",\n currencyName: \"Hungarian Forint\",\n currencyCodeHash: currencyKeccak256(\"HUF\"),\n currencySymbol: \"Ft\",\n countryCode: \"hu\",\n },\n [Currency.IDR]: {\n currency: Currency.IDR,\n currencyCode: \"IDR\",\n currencyName: \"Indonesian Rupiah\",\n currencyCodeHash: currencyKeccak256(\"IDR\"),\n currencySymbol: \"Rp\",\n countryCode: \"id\",\n },\n [Currency.INR]: {\n currency: Currency.INR,\n currencyCode: \"INR\",\n currencyName: \"Indian Rupee\",\n currencyCodeHash: currencyKeccak256(\"INR\"),\n currencySymbol: \"₹\",\n countryCode: \"in\",\n },\n [Currency.ILS]: {\n currency: Currency.ILS,\n currencyCode: \"ILS\",\n currencyName: \"Israeli New Shekel\",\n currencyCodeHash: currencyKeccak256(\"ILS\"),\n currencySymbol: \"₪\",\n countryCode: \"il\",\n },\n [Currency.JPY]: {\n currency: Currency.JPY,\n currencyCode: \"JPY\",\n currencyName: \"Japanese Yen\",\n currencyCodeHash: currencyKeccak256(\"JPY\"),\n currencySymbol: \"¥\",\n countryCode: \"jp\",\n },\n [Currency.KES]: {\n currency: Currency.KES,\n currencyCode: \"KES\",\n currencyName: \"Kenyan Shilling\",\n currencyCodeHash: currencyKeccak256(\"KES\"),\n currencySymbol: \"KSh\",\n countryCode: \"ke\",\n },\n [Currency.MXN]: {\n currency: Currency.MXN,\n currencyCode: \"MXN\",\n currencyName: \"Mexican Peso\",\n currencyCodeHash: currencyKeccak256(\"MXN\"),\n currencySymbol: \"$\",\n countryCode: \"mx\",\n },\n [Currency.MYR]: {\n currency: Currency.MYR,\n currencyCode: \"MYR\",\n currencyName: \"Malaysian Ringgit\",\n currencyCodeHash: currencyKeccak256(\"MYR\"),\n currencySymbol: \"RM\",\n countryCode: \"my\",\n },\n [Currency.NOK]: {\n currency: Currency.NOK,\n currencyCode: \"NOK\",\n currencyName: \"Norwegian Krone\",\n currencyCodeHash: currencyKeccak256(\"NOK\"),\n currencySymbol: \"kr\",\n countryCode: \"no\",\n },\n [Currency.NZD]: {\n currency: Currency.NZD,\n currencyCode: \"NZD\",\n currencyName: \"New Zealand Dollar\",\n currencyCodeHash: currencyKeccak256(\"NZD\"),\n currencySymbol: \"NZ$\",\n countryCode: \"nz\",\n },\n [Currency.PHP]: {\n currency: Currency.PHP,\n currencyCode: \"PHP\",\n currencyName: \"Philippine Peso\",\n currencyCodeHash: currencyKeccak256(\"PHP\"),\n currencySymbol: \"₱\",\n countryCode: \"ph\",\n },\n [Currency.PLN]: {\n currency: Currency.PLN,\n currencyCode: \"PLN\",\n currencyName: \"Polish Złoty\",\n currencyCodeHash: currencyKeccak256(\"PLN\"),\n currencySymbol: \"zł\",\n countryCode: \"pl\",\n },\n [Currency.RON]: {\n currency: Currency.RON,\n currencyCode: \"RON\",\n currencyName: \"Romanian Leu\",\n currencyCodeHash: currencyKeccak256(\"RON\"),\n currencySymbol: \"lei\",\n countryCode: \"ro\",\n },\n [Currency.SAR]: {\n currency: Currency.SAR,\n currencyCode: \"SAR\",\n currencyName: \"Saudi Riyal\",\n currencyCodeHash: currencyKeccak256(\"SAR\"),\n currencySymbol: \"﷼\",\n countryCode: \"sa\",\n },\n [Currency.SEK]: {\n currency: Currency.SEK,\n currencyCode: \"SEK\",\n currencyName: \"Swedish Krona\",\n currencyCodeHash: currencyKeccak256(\"SEK\"),\n currencySymbol: \"kr\",\n countryCode: \"se\",\n },\n [Currency.SGD]: {\n currency: Currency.SGD,\n currencyCode: \"SGD\",\n currencyName: \"Singapore Dollar\",\n currencyCodeHash: currencyKeccak256(\"SGD\"),\n currencySymbol: \"S$\",\n countryCode: \"sg\",\n },\n [Currency.THB]: {\n currency: Currency.THB,\n currencyCode: \"THB\",\n currencyName: \"Thai Baht\",\n currencyCodeHash: currencyKeccak256(\"THB\"),\n currencySymbol: \"฿\",\n countryCode: \"th\",\n },\n [Currency.TRY]: {\n currency: Currency.TRY,\n currencyCode: \"TRY\",\n currencyName: \"Turkish Lira\",\n currencyCodeHash: currencyKeccak256(\"TRY\"),\n currencySymbol: \"₺\",\n countryCode: \"tr\",\n },\n [Currency.UGX]: {\n currency: Currency.UGX,\n currencyCode: \"UGX\",\n currencyName: \"Ugandan Shilling\",\n currencyCodeHash: currencyKeccak256(\"UGX\"),\n currencySymbol: \"USh\",\n countryCode: \"ug\",\n },\n [Currency.USD]: {\n currency: Currency.USD,\n currencyCode: \"USD\",\n currencyName: \"United States Dollar\",\n currencyCodeHash: currencyKeccak256(\"USD\"),\n currencySymbol: \"$\",\n countryCode: \"us\",\n },\n [Currency.VND]: {\n currency: Currency.VND,\n currencyCode: \"VND\",\n currencyName: \"Vietnamese Dong\",\n currencyCodeHash: currencyKeccak256(\"VND\"),\n currencySymbol: \"₫\",\n countryCode: \"vn\",\n },\n [Currency.ZAR]: {\n currency: Currency.ZAR,\n currencyCode: \"ZAR\",\n currencyName: \"South African Rand\",\n currencyCodeHash: currencyKeccak256(\"ZAR\"),\n currencySymbol: \"R\",\n countryCode: \"za\",\n },\n};\n\n// Utility helpers to safely resolve currency values at runtime\nexport function resolveCurrency(currencyCode?: string | null): CurrencyType {\n const code = (currencyCode || '').toUpperCase();\n return isSupportedCurrency(code) ? (code as CurrencyType) : Currency.USD;\n}\n\n// Note: intentionally not exporting a \"safeCurrencyInfo\" wrapper to\n// keep the public surface area minimal; use resolveCurrency + currencyInfo instead.\n","import { CurrencyType } from \"../types/currency\";\nimport { ExtensionRequestMetadata } from \"../types/browserExtension\";\n\n// Platforms that can be used to send payments\nexport const PaymentPlatform = {\n VENMO: \"venmo\",\n CASHAPP: \"cashapp\",\n CHIME: \"chime\",\n LUXON: \"luxon\",\n REVOLUT: \"revolut\",\n WISE: \"wise\",\n MERCADO_PAGO: \"mercadopago\",\n ZELLE: \"zelle\",\n PAYPAL: \"paypal\",\n MONZO: \"monzo\",\n N26: \"n26\",\n ALIPAY: \"alipay\",\n};\n\nexport const paymentPlatforms = [...Object.values(PaymentPlatform)];\nexport type PaymentPlatformType =\n (typeof PaymentPlatform)[keyof typeof PaymentPlatform];\n\n// Payment platform enums and interfaces\nexport enum PaymentPlatformDefaultPaymentMode {\n QR_CODE = \"QR_CODE\",\n WEB_PAYMENT = \"WEB_PAYMENT\",\n}\n\nexport interface ParsedPaymentDetails {\n amount: string;\n parsedAmount: boolean; // whether the amount was successfully parsed\n date: string;\n parsedDate: boolean; // whether the date was successfully parsed\n recipientId: string;\n parsedRecipientId: boolean; // whether the recipientId was successfully parsed\n currency: string;\n parsedCurrency: boolean; // whether the currency was successfully parsed\n}\n\nexport interface ProofExtractedParameters {\n amount: string;\n recipient: string;\n currency: string;\n paymentPlatform: string;\n date: string;\n paymentId: string;\n intentHash: string;\n providerHash: string;\n}\n\nexport interface SendPaymentConfig {\n paymentMethodName?: string;\n paymentMethodIcon?: string;\n defaultPaymentMode: PaymentPlatformDefaultPaymentMode;\n useCustomQRCode?: boolean;\n payeeDetailPrefix?: string;\n troubleScanningQRCodeLink: (\n recipientId: string,\n sendCurrency?: CurrencyType,\n amountFiatToSend?: string,\n memo?: string,\n ) => string;\n getFormattedSendLink: (\n recipientId: string,\n sendCurrency?: CurrencyType,\n amountFiatToSend?: string,\n memo?: string,\n ) => string;\n supportsSendingPaymentOnWeb: boolean;\n showTroubleScanningQRCodeLink: boolean;\n sendPaymentWarning?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => string;\n sendPaymentInfo?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => string;\n // Optional structured guidance for clearer bullets and emphasis\n sendPaymentDos?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => Array<{ text: string; emphasize?: string[] }>;\n sendPaymentDonts?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => Array<{ text: string; emphasize?: string[] }>;\n}\n\nexport interface PaymentVerificationConfig {\n authLink: string;\n actionType: string;\n actionPlatform: string;\n numPaymentsFetched: number;\n minExtensionVersion: string;\n supportsAppclip: boolean;\n parseExtractedParameters: (parameters: string) => ProofExtractedParameters;\n parseMetadata: (metadata: ExtensionRequestMetadata) => ParsedPaymentDetails;\n reverseTransactionHistoryOrder?: boolean;\n getSubjectText: (metadata: ExtensionRequestMetadata) => string;\n totalProofs: number;\n}\n\nexport interface PlatformDepositConfig {\n depositRequiresApproval: boolean;\n payeeDetailInputPlaceholder: string;\n payeeDetailInputHelperText: string;\n payeeDetailValidationFailureMessage: string;\n getDepositData: (\n payeeDetails: string,\n telegramUsername?: string,\n ) => { [key: string]: string };\n getPayeeDetail: (data: { [key: string]: string }) => string;\n}\n\nexport interface PaymentPlatformConfig {\n platformId: PaymentPlatformType;\n platformLogo?: string;\n platformName: string;\n platformCurrencies: CurrencyType[];\n minFiatAmount: string;\n localeTimeString: string;\n platformIcon?: string;\n platformColor?: string; // Platform's brand color for fallback logo background\n // Optional client-side caps for better pre-validation UX\n maxUsdcPerIntent?: string; // e.g., '5000' means 5000 USDC cap\n\n // One deposit config per platform\n depositConfig: PlatformDepositConfig;\n\n hasMultiplePaymentMethods: boolean;\n // Multiple payment methods per platform\n paymentMethods: Array<{\n sendConfig: SendPaymentConfig;\n verifyConfig: PaymentVerificationConfig;\n }>;\n}\n","import { PaymentPlatform, PaymentPlatformType } from \"../platforms\";\n\n// Optional convenience mapping from method name -> hash (for reference)\nexport const METHOD_NAME_TO_HASH = {\n venmo: \"0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268\",\n revolut: \"0x617f88ab82b5c1b014c539f7e75121427f0bb50a4c58b187a238531e7d58605d\",\n cashapp: \"0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d\",\n chime: \"0x5908bb0c9b87763ac6171d4104847667e7f02b4c47b574fe890c1f439ed128bb\",\n luxon: \"0xaea63ef983458674f54ee50cdaa7b09d80a5c6c03ed505f51c90b0f2b54abb01\",\n wise: \"0x554a007c2217df766b977723b276671aee5ebb4adaea0edb6433c88b3e61dac5\",\n mercadopago:\n \"0xa5418819c024239299ea32e09defae8ec412c03e58f5c75f1b2fe84c857f5483\",\n \"zelle-citi\":\n \"0x817260692b75e93c7fbc51c71637d4075a975e221e1ebc1abeddfabd731fd90d\",\n \"zelle-chase\":\n \"0x6aa1d1401e79ad0549dced8b1b96fb72c41cd02b32a7d9ea1fed54ba9e17152e\",\n \"zelle-bofa\":\n \"0x4bc42b322a3ad413b91b2fde30549ca70d6ee900eded1681de91aaf32ffd7ab5\",\n paypal: \"0x3ccc3d4d5e769b1f82dc4988485551dc0cd3c7a3926d7d8a4dde91507199490f\",\n monzo: \"0x62c7ed738ad3e7618111348af32691b5767777fbaf46a2d8943237625552645c\",\n n26: \"0xd9ff4fd6b39a3e3dd43c41d05662a5547de4a878bc97a65bcb352ade493cdc6b\",\n alipay: \"0xcac9daea62d7b89d75ac73af4ee14dcf25721012ae82b568c2ea5c808eaa04ff\",\n} as const;\n\ntype MethodName = keyof typeof METHOD_NAME_TO_HASH;\n\nexport const HASH_TO_METHOD_NAME: Record<string, MethodName> = Object.entries(\n METHOD_NAME_TO_HASH,\n).reduce(\n (acc, [name, hash]) => {\n acc[hash.toLowerCase()] = name as MethodName;\n return acc;\n },\n {} as Record<string, MethodName>,\n);\n\n// Legacy V2 method hash for Zelle (ASCII 'zelle' padded to 32 bytes)\n// Some historical deposits may use this selector. Map it to Zelle.\nconst LEGACY_ZELLE_V2_HASH =\n \"0x7a656c6c650000000000000000000000000000000000000000000000000000\".toLowerCase();\n\nfunction methodNameToPlatform(\n method: MethodName,\n): PaymentPlatformType | undefined {\n switch (method) {\n case \"venmo\":\n return PaymentPlatform.VENMO;\n case \"revolut\":\n return PaymentPlatform.REVOLUT;\n case \"cashapp\":\n return PaymentPlatform.CASHAPP;\n case \"chime\":\n return PaymentPlatform.CHIME;\n case \"luxon\":\n return PaymentPlatform.LUXON;\n case \"wise\":\n return PaymentPlatform.WISE;\n case \"mercadopago\":\n return PaymentPlatform.MERCADO_PAGO;\n case \"paypal\":\n return PaymentPlatform.PAYPAL;\n case \"monzo\":\n return PaymentPlatform.MONZO;\n case \"n26\":\n return PaymentPlatform.N26;\n case \"alipay\":\n return PaymentPlatform.ALIPAY;\n case \"zelle-citi\":\n case \"zelle-chase\":\n case \"zelle-bofa\":\n return PaymentPlatform.ZELLE;\n default:\n return undefined;\n }\n}\n\n/**\n * Resolve a platform id from a payment method hash.\n * Returns undefined when the hash is unknown.\n */\nexport function resolvePlatformFromMethodHash(\n hash?: string | null,\n): PaymentPlatformType | undefined {\n if (!hash) return undefined;\n const normalized = hash.toLowerCase();\n\n // Handle legacy V2 Zelle deposits that use the ASCII 'zelle' 32-byte selector\n if (normalized === LEGACY_ZELLE_V2_HASH) {\n return PaymentPlatform.ZELLE;\n }\n\n const method = HASH_TO_METHOD_NAME[normalized];\n if (!method) return undefined;\n return methodNameToPlatform(method);\n}\n\nconst METHOD_VARIANT_LABEL_MAP: Record<string, string> = {\n \"zelle-chase\": \"Chase\",\n \"zelle-bofa\": \"Bank of America\",\n \"zelle-citi\": \"Citi\",\n};\n\nexport function getMethodVariantLabel(\n methodName?: string | null,\n): string | null {\n if (!methodName) return null;\n const normalized = methodName.toLowerCase();\n const mapped = METHOD_VARIANT_LABEL_MAP[normalized];\n if (mapped) return mapped;\n if (normalized.includes(\"-\")) {\n return normalized\n .split(\"-\")\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join(\" \");\n }\n return null;\n}\n\nexport function getMethodVariantLabelFromHash(\n hash?: string | null,\n): string | null {\n if (!hash) return null;\n const method = HASH_TO_METHOD_NAME[hash.toLowerCase()];\n if (!method) return null;\n return getMethodVariantLabel(method);\n}\n","import type { PublicClient } from 'viem';\n\nexport interface GasPricing {\n priority: bigint;\n max: bigint;\n baseFee: bigint;\n isCongested: boolean;\n}\n\nexport interface GasEstimationParams {\n estimated: bigint;\n baseFee: bigint;\n isCongested: boolean;\n}\n\n/**\n * Congestion threshold - base fee above this level triggers higher gas fees\n */\nexport const CONGESTION_THRESHOLD = BigInt(5000000000); // 5 gwei\n\n/**\n * Minimum gas fees required for account abstraction bundlers\n */\nexport const MIN_PRIORITY_FEE = BigInt(1000000000); // 1 gwei\nexport const MIN_MAX_FEE = BigInt(2000000000); // 2 gwei\n\n/**\n * Get dynamic gas pricing based on current network conditions\n * Applies congestion multiplier when base fee > 5 gwei\n */\nexport async function getDynamicGasPricing(publicClient: PublicClient | null): Promise<GasPricing> {\n try {\n if (!publicClient) {\n console.warn('[Gas] Public client not available, using fallback gas prices');\n return {\n priority: BigInt(2000000000), // 2 gwei fallback\n max: BigInt(4000000000), // 4 gwei fallback\n baseFee: BigInt(1000000000), // 1 gwei fallback\n isCongested: false\n };\n }\n\n // Get current base fee from latest block\n const block = await publicClient.getBlock({ blockTag: 'latest' });\n const baseFee = block.baseFeePerGas || BigInt(1000000000); // 1 gwei fallback\n \n // Check if network is congested\n const isCongested = baseFee > CONGESTION_THRESHOLD;\n \n // Apply congestion multiplier when network is congested\n const congestionMultiplier = isCongested ? 2n : 1n;\n \n // Calculate priority and max fees with congestion adjustment\n const priorityFee = (baseFee * congestionMultiplier) / 10n; // 10% of adjusted base fee\n const maxFee = (baseFee * congestionMultiplier * 12n) / 10n; // 120% of adjusted base fee\n \n // Ensure minimum values for account abstraction bundlers\n const finalPriorityFee = priorityFee > MIN_PRIORITY_FEE ? priorityFee : MIN_PRIORITY_FEE;\n const finalMaxFee = maxFee > MIN_MAX_FEE ? maxFee : MIN_MAX_FEE;\n\n return {\n priority: finalPriorityFee,\n max: finalMaxFee,\n baseFee,\n isCongested\n };\n } catch (error) {\n console.error('[Gas] Failed to fetch dynamic gas price:', error);\n // Return conservative fallback values\n return {\n priority: BigInt(2000000000), // 2 gwei\n max: BigInt(4000000000), // 4 gwei\n baseFee: BigInt(1000000000), // 1 gwei\n isCongested: false\n };\n }\n}\n\n/**\n * Calculate gas estimation with adaptive buffer based on network conditions\n * Uses 30% buffer during congestion, 20% during normal conditions\n */\nexport function calculateGasWithBuffer(params: GasEstimationParams): bigint {\n const { estimated, isCongested } = params;\n \n // Apply 30% buffer during congestion, 20% during normal conditions\n const bufferMultiplier = isCongested ? 130n : 120n;\n const gasWithBuffer = (estimated * bufferMultiplier) / 100n;\n \n return gasWithBuffer;\n}\n\n/**\n * Get network conditions for gas optimization decisions\n */\nexport async function getNetworkConditions(publicClient: PublicClient | null): Promise<{\n baseFee: bigint;\n isCongested: boolean;\n recommendedBuffer: number;\n}> {\n try {\n if (!publicClient) {\n return {\n baseFee: BigInt(1000000000),\n isCongested: false,\n recommendedBuffer: 20\n };\n }\n\n const block = await publicClient.getBlock({ blockTag: 'latest' });\n const baseFee = block.baseFeePerGas || BigInt(1000000000);\n const isCongested = baseFee > CONGESTION_THRESHOLD;\n \n return {\n baseFee,\n isCongested,\n recommendedBuffer: isCongested ? 30 : 20\n };\n } catch (error) {\n console.error('[Gas] Failed to get network conditions:', error);\n return {\n baseFee: BigInt(1000000000),\n isCongested: false,\n recommendedBuffer: 25 // Conservative fallback\n };\n }\n}","import { usdcUnits } from \"../utils/usdcUnits\";\n\n// Re-export time constants\nexport * from \"./time\";\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt\nexport const ZERO = 0n;\nexport const SECONDS_IN_DAY = 86400n;\n\n// =============================================================================\n// QUERY & POLLING CONFIGURATION\n// =============================================================================\n// Centralized configuration for all data fetching, polling intervals, and cache times.\n// Rule: staleTime should be slightly LESS than polling interval to prevent unnecessary\n// refetches on remount/focus while still allowing polling to work correctly.\n// =============================================================================\n\n// --- Base Network Timing ---\n// Base has 2 second block times - this affects how quickly on-chain data propagates\nexport const BASE_BLOCK_TIME_MS = 2000;\n// Delay after transaction to allow RPC nodes to sync (block time + propagation margin)\nexport const RPC_PROPAGATION_DELAY_MS = 2000;\n\n// --- RPC Direct Reads (ProtocolViewer) ---\n// Used for instant on-chain data after transactions\nexport const RPC_STALE_TIME_MS = 3000; // Block time + 1s margin\nexport const RPC_GC_TIME_MS = 30000; // Keep in cache for quick re-access\n\n// --- Intent Polling (Active Swap Flow) ---\n// Fast polling for responsive UX during active order, pauses when tab hidden\nexport const INTENT_POLLING_INTERVAL_MS = 3000;\nexport const INTENT_STALE_TIME_MS = 2500; // < polling interval to prevent double-fetch on remount\n\n// --- Balance Polling ---\n// Background refresh for wallet balances, not critical path\nexport const BALANCE_POLLING_INTERVAL_MS = 30000;\nexport const BALANCE_STALE_TIME_MS = 25000; // < polling interval\n\n// --- Deposit List Polling ---\n// Slower polling for deposit management pages\nexport const DEPOSIT_REFETCH_INTERVAL = 300000; // 5 minutes\nexport const DEPOSIT_STALE_TIME_MS = 290000; // 4:50 - slightly less than polling\n\n// --- Liquidity Table Polling ---\n// Medium-frequency polling for orderbook/liquidity views\nexport const LIQUIDITY_POLLING_INTERVAL_MS = 60000; // 1 minute\nexport const LIQUIDITY_STALE_TIME_MS = 55000; // 55s - slightly less than polling\n\n// --- Backend API Queries ---\n// Longer stale times since RPC provides real-time data for critical flows\nexport const BACKEND_DEPOSITS_STALE_TIME_MS = 30000;\nexport const BACKEND_DEPOSITS_GC_TIME_MS = 120000; // 2 minutes\nexport const BACKEND_INTENTS_STALE_TIME_MS = 30000;\nexport const BACKEND_INTENTS_GC_TIME_MS = 60000; // 1 minute\nexport const BACKEND_DEPOSIT_ORDERS_STALE_TIME_MS = 30000;\nexport const BACKEND_DEPOSIT_ORDERS_GC_TIME_MS = 120000;\n\n// --- Proof Polling (Order Completion Flow) ---\n// Fast polling while waiting for proof generation\nexport const PROOF_POLL_INTERVAL_MS = 3000;\n\n// --- ENS Resolution ---\n// Long cache time since ENS names rarely change\nexport const ENS_STALE_TIME_MS = 900000; // 15 minutes\nexport const ENS_GC_TIME_MS = 1800000; // 30 minutes\n\n// --- Past Deposits (No Polling) ---\n// Historical data that only updates on explicit invalidation\nexport const PAST_DEPOSITS_STALE_TIME_MS = Infinity;\nexport const PAST_DEPOSITS_GC_TIME_MS = 60000;\n\n// =============================================================================\n// END QUERY & POLLING CONFIGURATION\n// =============================================================================\n\n// =============================================================================\n// SESSION STORAGE KEYS\n// =============================================================================\n// Namespaced keys for cross-component communication via sessionStorage.\n// These enable data-aware UI updates (e.g., skeleton clearing after deposits).\n//\n// Usage pattern:\n// 1. Component A sets a key before navigation/action\n// 2. Component B reads and clears the key on mount/update\n// 3. Component B uses the value to determine UI behavior\n//\n// All keys are namespaced with 'zkp2p:' to avoid collisions with other storage.\n// =============================================================================\n\n/**\n * Signals that the deposit list needs refreshing with skeleton loading.\n * Set by DepositDetailsView when closing a deposit before navigating back.\n * Cleared by Deposits/index.tsx after initiating refresh.\n */\nexport const DEPOSIT_REFRESH_PENDING_KEY = \"zkp2p:deposit:refreshPending\";\n\n/**\n * Stores the deposit ID that was just closed.\n * Used for data-aware skeleton clearing - skeleton clears when this ID\n * is no longer present in the deposit list.\n * Set by DepositDetailsView, cleared by Deposits/index.tsx.\n */\nexport const DEPOSIT_CLOSED_ID_KEY = \"zkp2p:deposit:closedId\";\n\n/**\n * Stores the expected deposit count after creating a new deposit.\n * Used for data-aware skeleton clearing - skeleton clears when the\n * actual count matches or exceeds the expected count.\n * Set by NewDeposit flow, cleared by Deposits/index.tsx.\n */\nexport const DEPOSIT_EXPECTED_COUNT_KEY = \"zkp2p:deposit:expectedCount\";\n\n// =============================================================================\n// END SESSION STORAGE KEYS\n// =============================================================================\n\n// =============================================================================\n// UI TIMING CONSTANTS\n// =============================================================================\n// Constants for skeleton loading states, animations, and visual feedback timing.\n// These ensure consistent UX across the application.\n// =============================================================================\n\n/**\n * Minimum time to show skeleton loading state for visual feedback.\n * Prevents jarring flash if data loads very quickly.\n */\nexport const MIN_REFRESH_SKELETON_MS = 1500;\n\n/**\n * Maximum time to show skeleton loading state before giving up.\n * Safety timeout if data change detection fails.\n */\nexport const MAX_REFRESH_SKELETON_MS = 6000;\n\n// =============================================================================\n// END UI TIMING CONSTANTS\n// =============================================================================\n\n// Chain IDs\nconst BASE_MAINNET_CHAIN_ID = 8453;\nexport const BASE_SEPOLIA_CHAIN_ID = 84532;\nexport const SOLANA_CHAIN_ID = 792703809;\nexport const TRON_CHAIN_ID = 728126428;\nexport const HYPEREVM_CHAIN_ID = 999;\nexport const HYPERLIQUID_CHAIN_ID = 1337;\nexport const PLASMA_CHAIN_ID = 9745;\nexport const BITCOIN_CHAIN_ID = 8253038;\nexport const SUI_CHAIN_ID = 103665049;\nexport const TAIKO_CHAIN_ID = 167000;\n\n// Hyperliquid uses a special USDC token with different decimals\nexport const HYPERLIQUID_USDC_ADDRESS = \"0x00000000000000000000000000000000\";\n\n// Bitcoin uses a special address format for BTC\nexport const BITCOIN_BTC_ADDRESS = \"bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8\";\n\n// Both STAGING and PRODUCTION use Base mainnet\nexport const BASE_CHAIN_ID = BASE_MAINNET_CHAIN_ID;\n\n// USDC addresses\nconst BASE_MAINNET_USDC_ADDRESS = \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\";\nexport const BASE_USDC_ADDRESS = BASE_MAINNET_USDC_ADDRESS;\n\n// Excluded origin chains for Relay deposit-address flow (keep in sync with provider checks)\nexport const RELAY_DEPOSIT_ORIGIN_EXCLUDED_CHAIN_IDS: number[] = [\n BASE_MAINNET_CHAIN_ID, // Base mainnet\n BASE_SEPOLIA_CHAIN_ID, // Base Sepolia\n 43114, // Avalanche\n 1301, // Unichain\n 80084, // Berachain (testnet)\n 1088, // Metis\n 21000000, // Corn\n];\n\nexport const MINIMUM_DEPOSIT_AMOUNT = usdcUnits(0.1);\n\n// Order limit constants\nexport const MIN_ORDER_FLOOR = 5; // Minimum allowed order amount in USDC\nexport const MIN_ORDER_CAP = 50; // Maximum value for minimum order amount in USDC\nexport const MAX_ORDER_ADVISORY_THRESHOLD = 3000; // Advisory threshold for high per-order amounts in USDC\nexport const MIN_ORDER_DEPOSIT_THRESHOLD = 5; // Deposits below this amount are not subject to formula enforcement\nexport const DEFAULT_MAX_ORDER_CAP = 3000; // Default per-order cap applied when auto-filling max\n\n// Dust filtering threshold - hide liquidity entries below this USD value\nexport const DUST_THRESHOLD_USD = 5;\n\n// Extreme spread filtering threshold - hide orders with spread above this percentage\nexport const EXTREME_SPREAD_THRESHOLD_PERCENT = 100; // +100% spread\n\n// Success-rate and order-threshold configuration\nexport const MIN_ORDERS_FOR_SUCCESS_METRIC = 10; // minimum finalized intents before surfacing stats\nexport const LOW_SUCCESS_RATE_FILTER_PERCENT = 20; // Deposits below this hidden by default\nexport const LOW_SUCCESS_RATE_WARNING_PERCENT = 50; // Warn users below this completion rate\nexport const EXTREMELY_LOW_SUCCESS_RATE_PERCENT = 10; // Stronger warning badge threshold\n\n// Intent expiration fallback when indexer expiryTime unavailable.\n// On-chain: Production = 6 hours, Staging = 1 hour.\n// This is only used as a fallback; prefer expiryTime from indexer which reads the real on-chain value.\n// Note: In production, use the 6-hour default. Consuming apps can override this based on their environment.\nexport const INTENT_EXPIRATION_PERIOD_IN_SECONDS = 3600 * 6; // 6 hours (production default)\nexport const INTENT_EXPIRATION_PERIOD_STAGING_IN_SECONDS = 3600; // 1 hour (staging)\n\nexport const PRECISION = 1000000000000000000n; // 18\n\nexport const QUOTE_DEFAULT_ADDRESS =\n \"0x18Cc6F90512C6D95ACA0d57F98C727D61873c06a\";\nexport const QUOTE_DEFAULT_BTC_ADDRESS = \"34FzWazeBFL1mWF8tn36635hPsnJEzTrMR\"; // Default Bitcoin address for quotes\nexport const QUOTE_DEFAULT_SOL_ADDRESS =\n \"8pHKRNF3u8tndkUJ4euAddNWM9EAMWbUiK5GVmtaGY5U\";\nexport const QUOTE_DEFAULT_TRON_ADDRESS = \"TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N\"; // justin's tron address\nexport const QUOTE_DEFAULT_SUI_ADDRESS =\n \"0x2dad0710678565a0045073af0327a945e93c9c3bff31169ee689739558ed8b6b\";\n\n// the numeric form of the payload1 passed into the primitive\n// corresponds to the openssh signature produced by the following command:\n// echo \"E PLURIBUS UNUM; DO NOT SHARE\" | ssh-keygen -Y sign -n double-blind.xyz -f ~/.ssh/id_rsa | pbcopy\n\nexport const CLIENT_VERSION = \"3.0.0\";\n\n// circom constants from main.circom / https://zkrepl.dev/?gist=30d21c7a7285b1b14f608325f172417b\n// template RSAGroupSigVerify(n, k, levels) {\n// component main { public [ modulus ] } = RSAVerify(121, 17);\n// component main { public [ root, payload1 ] } = RSAGroupSigVerify(121, 17, 30);\n\n// Misc smart contract values\n\nexport const ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n// Default intent guardian for V3 deposits\nexport const DEFAULT_INTENT_GUARDIAN_ADDRESS =\n \"0xe29a5BD4D0CEbA6C125A0361E7D20ab4eA275C2f\";\nexport const CALLER_ACCOUNT = \"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\";\nexport const DEFAULT_NETWORK = \"base\";\n\n// Relay bridge app fee configuration\nexport const RELAY_APP_FEE_RECIPIENT =\n \"0x0bC26FF515411396DD588Abd6Ef6846E04470227\";\nexport const RELAY_APP_FEE_BPS = \"50\"; // 50 basis points = 0.5%\n\n/**\n * Destination chains where ALL tokens are eligible for zero app fees.\n *\n * Hyperliquid chains (HyperEVM and L1) are whitelisted to incentivize user\n * adoption and liquidity flow to the Hyperliquid ecosystem. This strategic\n * partnership benefits both platforms by reducing friction for users bridging\n * funds to trade on Hyperliquid's perpetuals and spot markets.\n */\nexport const RELAY_ZERO_FEE_DESTINATION_CHAINS: number[] = [\n HYPEREVM_CHAIN_ID, // HyperEVM (999)\n HYPERLIQUID_CHAIN_ID, // Hyperliquid L1 (1337)\n];\n\n// Cross-chain destination token addresses eligible for zero app fees when bridging from Base\nexport const RELAY_ZERO_FEE_TOKEN_ADDRESSES: Record<number, string[]> = {\n 1: [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\", // USDC\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\", // USDT\n ],\n 10: [\n \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\", // USDC\n \"0x01bFf41798a0bcF287b996046cA68B395dbc1071\", // USDT\n ],\n 137: [\"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"], // Polygon PoS (USDC)\n 42161: [\n \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\", // USDC\n \"0xfd086BC7CD5C481DCC9C85ebe478A1C0b69FCbb9\", // USDT\n ],\n 43114: [\"0x9702230A8Ea53601F5cD2dc00fDBC13D4dF4A8c7\"], // Avalanche (USDT)\n 480: [\"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"], // World Chain (USDC)\n [HYPEREVM_CHAIN_ID]: [\n \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\", // USDC\n \"0xb8cE59fC3717AdA4C02EAdf9682A9e934F625ebb\", // USDT\n ],\n [PLASMA_CHAIN_ID]: [\n \"0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb\", // USDT0\n ],\n 1301: [\n \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\", // USDC\n \"0x9151434b16b9763660705744891Fa906f660EcC5\", // USDT\n ],\n 1329: [\n \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\", // USDC\n \"0x9151434b16b9763660705744891Fa906f660EcC5\", // USDT\n ],\n [HYPERLIQUID_CHAIN_ID]: [\n HYPERLIQUID_USDC_ADDRESS,\n \"0x25faEdc3F054130DBB4e4203AcA63567\",\n ],\n 146: [\"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"], // Sonic (USDC)\n [SOLANA_CHAIN_ID]: [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\", // USDC\n \"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB\", // USDT\n ],\n [TRON_CHAIN_ID]: [\"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\"],\n 80084: [\"0x779dED0C9E1022225F8E0630B35a9B54Be713736\"], // Berachain (USDT)\n};\n\n// Proving key paths\n","/**\n * Payment method resolution utilities.\n *\n * These functions convert between human-readable payment platform names\n * (e.g., 'wise', 'revolut') and their on-chain bytes32 hashes.\n *\n * @module paymentResolution\n */\n\nimport { ensureBytes32 } from './bytes32';\nimport { currencyKeccak256 } from './currencyKeccak256';\nimport type { PaymentMethodCatalog } from '../contracts';\nimport { METHOD_NAME_TO_HASH } from '@zkp2p/core/utils';\n\n// Optional JSON maps from @zkp2p/contracts-v2 (only provided on some envs)\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport baseStagingPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseStaging';\n\ntype NetworkKey = 'base';\ntype RuntimeEnv = 'production' | 'staging';\n\nfunction getPaymentMethodMap(\n env: RuntimeEnv,\n network: NetworkKey,\n): Record<string, { paymentMethodHash: `0x${string}` }> | null {\n if (env === 'staging') {\n const m = (baseStagingPaymentMethods?.methods ?? {}) as Record<\n string,\n { paymentMethodHash: `0x${string}` }\n >;\n return m && Object.keys(m).length ? m : null;\n }\n return null;\n}\n\n/**\n * Resolves a payment method hash from a human-readable name.\n *\n * First attempts to look up the hash from contracts-v2 payment method maps.\n * Falls back to keccak256(name) when maps are unavailable.\n *\n * **Warning**: The fallback may not match on-chain mappings. Prefer using\n * `resolvePaymentMethodHashFromCatalog` with an explicit catalog.\n *\n * @param nameOrBytes - Payment method name ('wise') or existing bytes32 hash\n * @param opts.env - Runtime environment ('production' | 'staging')\n * @param opts.network - Network key ('base')\n * @returns bytes32 payment method hash\n *\n * @example\n * ```typescript\n * const hash = resolvePaymentMethodHash('wise', { env: 'production' });\n * ```\n */\nexport function resolvePaymentMethodHash(\n nameOrBytes: string,\n opts: { env?: RuntimeEnv; network?: NetworkKey } = {},\n): `0x${string}` {\n const { env = 'production', network = 'base' } = opts;\n if (nameOrBytes.startsWith('0x')) return ensureBytes32(nameOrBytes) as `0x${string}`;\n const mapping = getPaymentMethodMap(env, network);\n if (mapping) {\n const key = nameOrBytes.toLowerCase();\n const entry = mapping[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n }\n // Fallback: hash ascii name to bytes32\n return ensureBytes32(nameOrBytes, { hashIfAscii: true });\n}\n\n/**\n * Encodes a fiat currency code into bytes32 format (keccak256 hash).\n *\n * If the input is already a hex string (0x-prefixed), it's normalized to bytes32.\n * Otherwise, the currency code is hashed using keccak256.\n *\n * @param codeOrBytes - Currency code ('USD') or existing bytes32 hash\n * @returns bytes32 keccak256 hash of the currency code\n *\n * @example\n * ```typescript\n * const bytes = resolveFiatCurrencyBytes32('USD');\n * // Returns: 0xc4ae21aac0c6549d71dd96035b7e0bdb6c79ebdba8891b666115bc976d16a29e\n * ```\n */\nexport function resolveFiatCurrencyBytes32(codeOrBytes: string): `0x${string}` {\n if (codeOrBytes.startsWith('0x')) return ensureBytes32(codeOrBytes) as `0x${string}`;\n return currencyKeccak256(codeOrBytes.toUpperCase()) as `0x${string}`;\n}\n\n/**\n * Resolves a payment method hash from a provided catalog.\n *\n * This is the recommended method for resolving payment methods as it uses\n * the exact catalog from `getPaymentMethodsCatalog()`, ensuring consistency\n * with on-chain registrations.\n *\n * If the processor is not found in the catalog, falls back to the known\n * payment method hashes from @zkp2p/core before throwing an error.\n *\n * @param processorName - Payment platform name ('wise', 'revolut', etc.)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns bytes32 payment method hash\n * @throws Error with available processors if not found in catalog or fallback\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * const hash = resolvePaymentMethodHashFromCatalog('wise', catalog);\n * ```\n */\nexport function resolvePaymentMethodHashFromCatalog(\n processorName: string,\n catalog: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>,\n): `0x${string}` {\n if (!processorName) {\n throw new Error('processorName is required to resolve paymentMethodHash');\n }\n if (processorName.startsWith('0x')) {\n return ensureBytes32(processorName) as `0x${string}`;\n }\n const key = processorName.toLowerCase();\n const entry = catalog?.[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n\n // Fallback to core's known payment method hashes when catalog is missing the entry\n const fallbackHash = METHOD_NAME_TO_HASH[key as keyof typeof METHOD_NAME_TO_HASH];\n if (fallbackHash) return fallbackHash as `0x${string}`;\n\n const available = Object.keys(catalog || {})\n .sort()\n .join(', ');\n throw new Error(\n available\n ? `Unknown processorName: ${processorName}. Available: ${available}`\n : `Unknown processorName: ${processorName}. The payment methods catalog is empty or unavailable.`,\n );\n}\n\n/**\n * Reverse-lookup: converts a payment method hash back to its name.\n *\n * @param hash - The payment method hash (bytes32)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns Payment platform name (e.g., 'wise') or undefined if not found\n *\n * @example\n * ```typescript\n * const name = resolvePaymentMethodNameFromHash('0x...', catalog);\n * console.log(name); // \"wise\"\n * ```\n */\nexport function resolvePaymentMethodNameFromHash(\n hash: string,\n catalog: PaymentMethodCatalog,\n): string | undefined {\n if (!hash) return undefined;\n const target = ensureBytes32(hash) as `0x${string}`;\n for (const [name, entry] of Object.entries(catalog || {})) {\n if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/bytes32.ts","../../core/src/utils/usdcUnits.ts","../../core/src/utils/currencyKeccak256.ts","../../core/src/types/currency.ts","../../core/src/platforms/types.ts","../../core/src/utils/paymentMethodHashes.ts","../../core/src/utils/gas.ts","../../core/src/constants/index.ts","../src/utils/paymentResolution.ts"],"names":["currencyKeccak256","viemKeccak256"],"mappings":";;;;;AAKO,SAAS,cACd,KAAA,EACA,EAAE,cAAc,KAAA,EAAM,GAA+B,EAAC,EACvC;AACf,EAAA,IAAI,KAAA,CAAM,UAAA,CAAW,IAAI,CAAA,EAAG;AAC1B,IAAA,MAAM,KAAA,GAAQ,WAAW,KAAsB,CAAA;AAC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EAAA,MAAM,IAAI,KAAA;AAAA,IACR,YACI,CAAA,uBAAA,EAA0B,aAAa,gBAAgB,SAAS,CAAA,CAAA,GAChE,0BAA0B,aAAa,CAAA,sDAAA;AAAA,GAC7C;AACF;AAeO,SAAS,gCAAA,CACd,MACA,OAAA,EACoB;AACpB,EAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,EAAA,MAAM,MAAA,GAAS,cAAc,IAAI,CAAA;AACjC,EAAA,KAAA,MAAW,CAAC,MAAM,KAAK,CAAA,IAAK,OAAO,OAAA,CAAQ,OAAA,IAAW,EAAE,CAAA,EAAG;AACzD,IAAA,IAAI,OAAO,iBAAA,EAAmB,WAAA,OAAkB,MAAA,CAAO,WAAA,IAAe,OAAO,IAAA;AAAA,EAC/E;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-RNJWFEXN.mjs","sourcesContent":["import { keccak256, toBytes, hexToBytes, bytesToHex } from 'viem';\n\n/**\n * Ensure a value is 32 bytes hex (0x + 64 nibbles). If ascii, keccak256 by default when hash=true.\n */\nexport function ensureBytes32(\n value: string,\n { hashIfAscii = false }: { hashIfAscii?: boolean } = {},\n): `0x${string}` {\n if (value.startsWith('0x')) {\n const bytes = hexToBytes(value as `0x${string}`);\n if (bytes.length !== 32) throw new Error('Expected 32-byte hex value');\n return value as `0x${string}`;\n }\n if (!hashIfAscii)\n throw new Error('Expected 32-byte hex; received ascii string. Pass hashIfAscii=true to hash.');\n const hashed = keccak256(toBytes(value));\n return hashed as `0x${string}`;\n}\n\n/**\n * Encode ASCII (<=32 chars) left-aligned, right-padded with zeros to 32 bytes.\n */\nexport function asciiToBytes32(value: string): `0x${string}` {\n const b = toBytes(value);\n if (b.length > 32) throw new Error('ASCII input exceeds 32 bytes');\n const padded = new Uint8Array(32);\n padded.set(b);\n return bytesToHex(padded);\n}\n","import { parseUnits } from \"viem\";\n\nexport const usdcUnits = (amount: number | string | bigint): bigint => {\n return parseUnits(amount.toString(), 6);\n};\n","import { keccak256 as viemKeccak256 } from \"viem\";\n\nexport const currencyKeccak256 = (inputString: string): string => {\n const bytes = new TextEncoder().encode(inputString);\n return viemKeccak256(bytes);\n};\n","import { currencyKeccak256 } from '../utils/currencyKeccak256';\n\n\nexport const Currency = {\n AED: \"AED\",\n ARS: \"ARS\",\n AUD: \"AUD\",\n CAD: \"CAD\",\n CHF: \"CHF\",\n CNY: \"CNY\",\n CZK: \"CZK\",\n DKK: \"DKK\",\n EUR: \"EUR\",\n GBP: \"GBP\",\n HKD: \"HKD\",\n HUF: \"HUF\",\n IDR: \"IDR\",\n ILS: \"ILS\",\n INR: \"INR\",\n JPY: \"JPY\",\n KES: \"KES\",\n NOK: \"NOK\",\n MXN: \"MXN\",\n MYR: \"MYR\",\n NZD: \"NZD\",\n PHP: \"PHP\",\n PLN: \"PLN\",\n RON: \"RON\",\n SAR: \"SAR\",\n SEK: \"SEK\",\n SGD: \"SGD\",\n THB: \"THB\",\n TRY: \"TRY\",\n UGX: \"UGX\",\n USD: \"USD\",\n VND: \"VND\",\n ZAR: \"ZAR\",\n};\n\nexport type CurrencyType = typeof Currency[keyof typeof Currency];\n\nfunction getCurrencies(): string[] {\n return Object.values(Currency);\n}\n\nexport function getCurrencyInfoFromHash(currencyCodeHash: string): CurrencyData | null {\n return Object.values(currencyInfo).find(\n (currency) => currency.currencyCodeHash === currencyCodeHash\n ) ?? null;\n}\n\nexport function getCurrencyInfoFromCountryCode(countryCode: string): CurrencyData | null {\n return Object.values(currencyInfo).find(\n (currency) => currency.countryCode === countryCode\n ) ?? null;\n}\n\nexport function isSupportedCurrency(currencyCode: string): boolean {\n return Object.values(currencyInfo).some(\n (currency) => currency.currencyCode === currencyCode\n );\n}\n\nexport const currencies = getCurrencies();\n\ninterface CurrencyData {\n currency: CurrencyType;\n currencyCode: string;\n currencyName: string;\n currencySymbol: string;\n currencyCodeHash: string;\n countryCode: string;\n}\n\nexport const currencyInfo: Record<CurrencyType, CurrencyData> = {\n [Currency.AED]: {\n currency: Currency.AED,\n currencyCode: \"AED\",\n currencyName: \"United Arab Emirates Dirham\",\n currencyCodeHash: currencyKeccak256(\"AED\"),\n currencySymbol: \"د.إ\",\n countryCode: \"ae\",\n },\n [Currency.ARS]: {\n currency: Currency.ARS,\n currencyCode: \"ARS\",\n currencyName: \"Argentine Peso\",\n currencyCodeHash: currencyKeccak256(\"ARS\"),\n currencySymbol: \"$\",\n countryCode: \"ar\"\n },\n [Currency.AUD]: {\n currency: Currency.AUD,\n currencyCode: \"AUD\",\n currencyName: \"Australian Dollar\",\n currencyCodeHash: currencyKeccak256(\"AUD\"),\n currencySymbol: \"A$\",\n countryCode: \"au\",\n },\n [Currency.CAD]: {\n currency: Currency.CAD,\n currencyCode: \"CAD\",\n currencyName: \"Canadian Dollar\",\n currencyCodeHash: currencyKeccak256(\"CAD\"),\n currencySymbol: \"C$\",\n countryCode: \"ca\",\n },\n [Currency.CHF]: {\n currency: Currency.CHF,\n currencyCode: \"CHF\",\n currencyName: \"Swiss Franc\",\n currencyCodeHash: currencyKeccak256(\"CHF\"),\n currencySymbol: \"Fr\",\n countryCode: \"ch\",\n },\n [Currency.CNY]: {\n currency: Currency.CNY,\n currencyCode: \"CNY\",\n currencyName: \"Chinese Yuan\",\n currencyCodeHash: currencyKeccak256(\"CNY\"),\n currencySymbol: \"¥\",\n countryCode: \"cn\",\n },\n [Currency.CZK]: {\n currency: Currency.CZK,\n currencyCode: \"CZK\",\n currencyName: \"Czech Koruna\",\n currencyCodeHash: currencyKeccak256(\"CZK\"),\n currencySymbol: \"Kč\",\n countryCode: \"cz\",\n },\n [Currency.DKK]: {\n currency: Currency.DKK,\n currencyCode: \"DKK\",\n currencyName: \"Danish Krone\",\n currencyCodeHash: currencyKeccak256(\"DKK\"),\n currencySymbol: \"kr\",\n countryCode: \"dk\",\n },\n [Currency.EUR]: {\n currency: Currency.EUR,\n currencyCode: \"EUR\",\n currencyName: \"Euro\",\n currencyCodeHash: currencyKeccak256(\"EUR\"),\n currencySymbol: \"€\",\n countryCode: \"eu\",\n },\n [Currency.GBP]: {\n currency: Currency.GBP,\n currencyCode: \"GBP\",\n currencyName: \"British Pound\",\n currencyCodeHash: currencyKeccak256(\"GBP\"),\n currencySymbol: \"£\",\n countryCode: \"gb\",\n },\n [Currency.HKD]: {\n currency: Currency.HKD,\n currencyCode: \"HKD\",\n currencyName: \"Hong Kong Dollar\",\n currencyCodeHash: currencyKeccak256(\"HKD\"),\n currencySymbol: \"HK$\",\n countryCode: \"hk\",\n },\n [Currency.HUF]: {\n currency: Currency.HUF,\n currencyCode: \"HUF\",\n currencyName: \"Hungarian Forint\",\n currencyCodeHash: currencyKeccak256(\"HUF\"),\n currencySymbol: \"Ft\",\n countryCode: \"hu\",\n },\n [Currency.IDR]: {\n currency: Currency.IDR,\n currencyCode: \"IDR\",\n currencyName: \"Indonesian Rupiah\",\n currencyCodeHash: currencyKeccak256(\"IDR\"),\n currencySymbol: \"Rp\",\n countryCode: \"id\",\n },\n [Currency.INR]: {\n currency: Currency.INR,\n currencyCode: \"INR\",\n currencyName: \"Indian Rupee\",\n currencyCodeHash: currencyKeccak256(\"INR\"),\n currencySymbol: \"₹\",\n countryCode: \"in\",\n },\n [Currency.ILS]: {\n currency: Currency.ILS,\n currencyCode: \"ILS\",\n currencyName: \"Israeli New Shekel\",\n currencyCodeHash: currencyKeccak256(\"ILS\"),\n currencySymbol: \"₪\",\n countryCode: \"il\",\n },\n [Currency.JPY]: {\n currency: Currency.JPY,\n currencyCode: \"JPY\",\n currencyName: \"Japanese Yen\",\n currencyCodeHash: currencyKeccak256(\"JPY\"),\n currencySymbol: \"¥\",\n countryCode: \"jp\",\n },\n [Currency.KES]: {\n currency: Currency.KES,\n currencyCode: \"KES\",\n currencyName: \"Kenyan Shilling\",\n currencyCodeHash: currencyKeccak256(\"KES\"),\n currencySymbol: \"KSh\",\n countryCode: \"ke\",\n },\n [Currency.MXN]: {\n currency: Currency.MXN,\n currencyCode: \"MXN\",\n currencyName: \"Mexican Peso\",\n currencyCodeHash: currencyKeccak256(\"MXN\"),\n currencySymbol: \"$\",\n countryCode: \"mx\",\n },\n [Currency.MYR]: {\n currency: Currency.MYR,\n currencyCode: \"MYR\",\n currencyName: \"Malaysian Ringgit\",\n currencyCodeHash: currencyKeccak256(\"MYR\"),\n currencySymbol: \"RM\",\n countryCode: \"my\",\n },\n [Currency.NOK]: {\n currency: Currency.NOK,\n currencyCode: \"NOK\",\n currencyName: \"Norwegian Krone\",\n currencyCodeHash: currencyKeccak256(\"NOK\"),\n currencySymbol: \"kr\",\n countryCode: \"no\",\n },\n [Currency.NZD]: {\n currency: Currency.NZD,\n currencyCode: \"NZD\",\n currencyName: \"New Zealand Dollar\",\n currencyCodeHash: currencyKeccak256(\"NZD\"),\n currencySymbol: \"NZ$\",\n countryCode: \"nz\",\n },\n [Currency.PHP]: {\n currency: Currency.PHP,\n currencyCode: \"PHP\",\n currencyName: \"Philippine Peso\",\n currencyCodeHash: currencyKeccak256(\"PHP\"),\n currencySymbol: \"₱\",\n countryCode: \"ph\",\n },\n [Currency.PLN]: {\n currency: Currency.PLN,\n currencyCode: \"PLN\",\n currencyName: \"Polish Złoty\",\n currencyCodeHash: currencyKeccak256(\"PLN\"),\n currencySymbol: \"zł\",\n countryCode: \"pl\",\n },\n [Currency.RON]: {\n currency: Currency.RON,\n currencyCode: \"RON\",\n currencyName: \"Romanian Leu\",\n currencyCodeHash: currencyKeccak256(\"RON\"),\n currencySymbol: \"lei\",\n countryCode: \"ro\",\n },\n [Currency.SAR]: {\n currency: Currency.SAR,\n currencyCode: \"SAR\",\n currencyName: \"Saudi Riyal\",\n currencyCodeHash: currencyKeccak256(\"SAR\"),\n currencySymbol: \"﷼\",\n countryCode: \"sa\",\n },\n [Currency.SEK]: {\n currency: Currency.SEK,\n currencyCode: \"SEK\",\n currencyName: \"Swedish Krona\",\n currencyCodeHash: currencyKeccak256(\"SEK\"),\n currencySymbol: \"kr\",\n countryCode: \"se\",\n },\n [Currency.SGD]: {\n currency: Currency.SGD,\n currencyCode: \"SGD\",\n currencyName: \"Singapore Dollar\",\n currencyCodeHash: currencyKeccak256(\"SGD\"),\n currencySymbol: \"S$\",\n countryCode: \"sg\",\n },\n [Currency.THB]: {\n currency: Currency.THB,\n currencyCode: \"THB\",\n currencyName: \"Thai Baht\",\n currencyCodeHash: currencyKeccak256(\"THB\"),\n currencySymbol: \"฿\",\n countryCode: \"th\",\n },\n [Currency.TRY]: {\n currency: Currency.TRY,\n currencyCode: \"TRY\",\n currencyName: \"Turkish Lira\",\n currencyCodeHash: currencyKeccak256(\"TRY\"),\n currencySymbol: \"₺\",\n countryCode: \"tr\",\n },\n [Currency.UGX]: {\n currency: Currency.UGX,\n currencyCode: \"UGX\",\n currencyName: \"Ugandan Shilling\",\n currencyCodeHash: currencyKeccak256(\"UGX\"),\n currencySymbol: \"USh\",\n countryCode: \"ug\",\n },\n [Currency.USD]: {\n currency: Currency.USD,\n currencyCode: \"USD\",\n currencyName: \"United States Dollar\",\n currencyCodeHash: currencyKeccak256(\"USD\"),\n currencySymbol: \"$\",\n countryCode: \"us\",\n },\n [Currency.VND]: {\n currency: Currency.VND,\n currencyCode: \"VND\",\n currencyName: \"Vietnamese Dong\",\n currencyCodeHash: currencyKeccak256(\"VND\"),\n currencySymbol: \"₫\",\n countryCode: \"vn\",\n },\n [Currency.ZAR]: {\n currency: Currency.ZAR,\n currencyCode: \"ZAR\",\n currencyName: \"South African Rand\",\n currencyCodeHash: currencyKeccak256(\"ZAR\"),\n currencySymbol: \"R\",\n countryCode: \"za\",\n },\n};\n\n// Utility helpers to safely resolve currency values at runtime\nexport function resolveCurrency(currencyCode?: string | null): CurrencyType {\n const code = (currencyCode || '').toUpperCase();\n return isSupportedCurrency(code) ? (code as CurrencyType) : Currency.USD;\n}\n\n// Note: intentionally not exporting a \"safeCurrencyInfo\" wrapper to\n// keep the public surface area minimal; use resolveCurrency + currencyInfo instead.\n","import { CurrencyType } from \"../types/currency\";\nimport { ExtensionRequestMetadata } from \"../types/browserExtension\";\n\n// Platforms that can be used to send payments\nexport const PaymentPlatform = {\n VENMO: \"venmo\",\n CASHAPP: \"cashapp\",\n CHIME: \"chime\",\n LUXON: \"luxon\",\n REVOLUT: \"revolut\",\n WISE: \"wise\",\n MERCADO_PAGO: \"mercadopago\",\n ZELLE: \"zelle\",\n PAYPAL: \"paypal\",\n MONZO: \"monzo\",\n N26: \"n26\",\n ALIPAY: \"alipay\",\n};\n\nexport const paymentPlatforms = [...Object.values(PaymentPlatform)];\nexport type PaymentPlatformType =\n (typeof PaymentPlatform)[keyof typeof PaymentPlatform];\n\n// Payment platform enums and interfaces\nexport enum PaymentPlatformDefaultPaymentMode {\n QR_CODE = \"QR_CODE\",\n WEB_PAYMENT = \"WEB_PAYMENT\",\n}\n\nexport interface ParsedPaymentDetails {\n amount: string;\n parsedAmount: boolean; // whether the amount was successfully parsed\n date: string;\n parsedDate: boolean; // whether the date was successfully parsed\n recipientId: string;\n parsedRecipientId: boolean; // whether the recipientId was successfully parsed\n currency: string;\n parsedCurrency: boolean; // whether the currency was successfully parsed\n}\n\nexport interface ProofExtractedParameters {\n amount: string;\n recipient: string;\n currency: string;\n paymentPlatform: string;\n date: string;\n paymentId: string;\n intentHash: string;\n providerHash: string;\n}\n\nexport interface SendPaymentConfig {\n paymentMethodName?: string;\n paymentMethodIcon?: string;\n defaultPaymentMode: PaymentPlatformDefaultPaymentMode;\n useCustomQRCode?: boolean;\n payeeDetailPrefix?: string;\n troubleScanningQRCodeLink: (\n recipientId: string,\n sendCurrency?: CurrencyType,\n amountFiatToSend?: string,\n memo?: string,\n ) => string;\n getFormattedSendLink: (\n recipientId: string,\n sendCurrency?: CurrencyType,\n amountFiatToSend?: string,\n memo?: string,\n ) => string;\n supportsSendingPaymentOnWeb: boolean;\n showTroubleScanningQRCodeLink: boolean;\n sendPaymentWarning?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => string;\n sendPaymentInfo?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => string;\n // Optional structured guidance for clearer bullets and emphasis\n sendPaymentDos?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => Array<{ text: string; emphasize?: string[] }>;\n sendPaymentDonts?: (\n sendCurrency: CurrencyType,\n amountFiatToSend: string,\n ) => Array<{ text: string; emphasize?: string[] }>;\n}\n\nexport interface PaymentVerificationConfig {\n authLink: string;\n actionType: string;\n actionPlatform: string;\n numPaymentsFetched: number;\n minExtensionVersion: string;\n supportsAppclip: boolean;\n parseExtractedParameters: (parameters: string) => ProofExtractedParameters;\n parseMetadata: (metadata: ExtensionRequestMetadata) => ParsedPaymentDetails;\n reverseTransactionHistoryOrder?: boolean;\n getSubjectText: (metadata: ExtensionRequestMetadata) => string;\n totalProofs: number;\n}\n\nexport interface PlatformDepositConfig {\n depositRequiresApproval: boolean;\n payeeDetailInputPlaceholder: string;\n payeeDetailInputHelperText: string;\n payeeDetailValidationFailureMessage: string;\n getDepositData: (\n payeeDetails: string,\n telegramUsername?: string,\n ) => { [key: string]: string };\n getPayeeDetail: (data: { [key: string]: string }) => string;\n}\n\nexport interface PaymentPlatformConfig {\n platformId: PaymentPlatformType;\n platformLogo?: string;\n platformName: string;\n platformCurrencies: CurrencyType[];\n minFiatAmount: string;\n localeTimeString: string;\n platformIcon?: string;\n platformColor?: string; // Platform's brand color for fallback logo background\n // Optional client-side caps for better pre-validation UX\n maxUsdcPerIntent?: string; // e.g., '5000' means 5000 USDC cap\n\n // One deposit config per platform\n depositConfig: PlatformDepositConfig;\n\n hasMultiplePaymentMethods: boolean;\n // Multiple payment methods per platform\n paymentMethods: Array<{\n sendConfig: SendPaymentConfig;\n verifyConfig: PaymentVerificationConfig;\n }>;\n}\n","import { PaymentPlatform, PaymentPlatformType } from \"../platforms\";\n\n// Optional convenience mapping from method name -> hash (for reference)\nexport const METHOD_NAME_TO_HASH = {\n venmo: \"0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268\",\n revolut: \"0x617f88ab82b5c1b014c539f7e75121427f0bb50a4c58b187a238531e7d58605d\",\n cashapp: \"0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d\",\n chime: \"0x5908bb0c9b87763ac6171d4104847667e7f02b4c47b574fe890c1f439ed128bb\",\n luxon: \"0xaea63ef983458674f54ee50cdaa7b09d80a5c6c03ed505f51c90b0f2b54abb01\",\n wise: \"0x554a007c2217df766b977723b276671aee5ebb4adaea0edb6433c88b3e61dac5\",\n mercadopago:\n \"0xa5418819c024239299ea32e09defae8ec412c03e58f5c75f1b2fe84c857f5483\",\n \"zelle-citi\":\n \"0x817260692b75e93c7fbc51c71637d4075a975e221e1ebc1abeddfabd731fd90d\",\n \"zelle-chase\":\n \"0x6aa1d1401e79ad0549dced8b1b96fb72c41cd02b32a7d9ea1fed54ba9e17152e\",\n \"zelle-bofa\":\n \"0x4bc42b322a3ad413b91b2fde30549ca70d6ee900eded1681de91aaf32ffd7ab5\",\n paypal: \"0x3ccc3d4d5e769b1f82dc4988485551dc0cd3c7a3926d7d8a4dde91507199490f\",\n monzo: \"0x62c7ed738ad3e7618111348af32691b5767777fbaf46a2d8943237625552645c\",\n n26: \"0xd9ff4fd6b39a3e3dd43c41d05662a5547de4a878bc97a65bcb352ade493cdc6b\",\n alipay: \"0xcac9daea62d7b89d75ac73af4ee14dcf25721012ae82b568c2ea5c808eaa04ff\",\n} as const;\n\ntype MethodName = keyof typeof METHOD_NAME_TO_HASH;\n\nexport const HASH_TO_METHOD_NAME: Record<string, MethodName> = Object.entries(\n METHOD_NAME_TO_HASH,\n).reduce(\n (acc, [name, hash]) => {\n acc[hash.toLowerCase()] = name as MethodName;\n return acc;\n },\n {} as Record<string, MethodName>,\n);\n\n// Legacy V2 method hash for Zelle (ASCII 'zelle' padded to 32 bytes)\n// Some historical deposits may use this selector. Map it to Zelle.\nconst LEGACY_ZELLE_V2_HASH =\n \"0x7a656c6c650000000000000000000000000000000000000000000000000000\".toLowerCase();\n\nfunction methodNameToPlatform(\n method: MethodName,\n): PaymentPlatformType | undefined {\n switch (method) {\n case \"venmo\":\n return PaymentPlatform.VENMO;\n case \"revolut\":\n return PaymentPlatform.REVOLUT;\n case \"cashapp\":\n return PaymentPlatform.CASHAPP;\n case \"chime\":\n return PaymentPlatform.CHIME;\n case \"luxon\":\n return PaymentPlatform.LUXON;\n case \"wise\":\n return PaymentPlatform.WISE;\n case \"mercadopago\":\n return PaymentPlatform.MERCADO_PAGO;\n case \"paypal\":\n return PaymentPlatform.PAYPAL;\n case \"monzo\":\n return PaymentPlatform.MONZO;\n case \"n26\":\n return PaymentPlatform.N26;\n case \"alipay\":\n return PaymentPlatform.ALIPAY;\n case \"zelle-citi\":\n case \"zelle-chase\":\n case \"zelle-bofa\":\n return PaymentPlatform.ZELLE;\n default:\n return undefined;\n }\n}\n\n/**\n * Resolve a platform id from a payment method hash.\n * Returns undefined when the hash is unknown.\n */\nexport function resolvePlatformFromMethodHash(\n hash?: string | null,\n): PaymentPlatformType | undefined {\n if (!hash) return undefined;\n const normalized = hash.toLowerCase();\n\n // Handle legacy V2 Zelle deposits that use the ASCII 'zelle' 32-byte selector\n if (normalized === LEGACY_ZELLE_V2_HASH) {\n return PaymentPlatform.ZELLE;\n }\n\n const method = HASH_TO_METHOD_NAME[normalized];\n if (!method) return undefined;\n return methodNameToPlatform(method);\n}\n\nconst METHOD_VARIANT_LABEL_MAP: Record<string, string> = {\n \"zelle-chase\": \"Chase\",\n \"zelle-bofa\": \"Bank of America\",\n \"zelle-citi\": \"Citi\",\n};\n\nexport function getMethodVariantLabel(\n methodName?: string | null,\n): string | null {\n if (!methodName) return null;\n const normalized = methodName.toLowerCase();\n const mapped = METHOD_VARIANT_LABEL_MAP[normalized];\n if (mapped) return mapped;\n if (normalized.includes(\"-\")) {\n return normalized\n .split(\"-\")\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join(\" \");\n }\n return null;\n}\n\nexport function getMethodVariantLabelFromHash(\n hash?: string | null,\n): string | null {\n if (!hash) return null;\n const method = HASH_TO_METHOD_NAME[hash.toLowerCase()];\n if (!method) return null;\n return getMethodVariantLabel(method);\n}\n","import type { PublicClient } from 'viem';\n\nexport interface GasPricing {\n priority: bigint;\n max: bigint;\n baseFee: bigint;\n isCongested: boolean;\n}\n\nexport interface GasEstimationParams {\n estimated: bigint;\n baseFee: bigint;\n isCongested: boolean;\n}\n\n/**\n * Congestion threshold - base fee above this level triggers higher gas fees\n */\nexport const CONGESTION_THRESHOLD = BigInt(5000000000); // 5 gwei\n\n/**\n * Minimum gas fees required for account abstraction bundlers\n */\nexport const MIN_PRIORITY_FEE = BigInt(1000000000); // 1 gwei\nexport const MIN_MAX_FEE = BigInt(2000000000); // 2 gwei\n\n/**\n * Get dynamic gas pricing based on current network conditions\n * Applies congestion multiplier when base fee > 5 gwei\n */\nexport async function getDynamicGasPricing(publicClient: PublicClient | null): Promise<GasPricing> {\n try {\n if (!publicClient) {\n console.warn('[Gas] Public client not available, using fallback gas prices');\n return {\n priority: BigInt(2000000000), // 2 gwei fallback\n max: BigInt(4000000000), // 4 gwei fallback\n baseFee: BigInt(1000000000), // 1 gwei fallback\n isCongested: false\n };\n }\n\n // Get current base fee from latest block\n const block = await publicClient.getBlock({ blockTag: 'latest' });\n const baseFee = block.baseFeePerGas || BigInt(1000000000); // 1 gwei fallback\n \n // Check if network is congested\n const isCongested = baseFee > CONGESTION_THRESHOLD;\n \n // Apply congestion multiplier when network is congested\n const congestionMultiplier = isCongested ? 2n : 1n;\n \n // Calculate priority and max fees with congestion adjustment\n const priorityFee = (baseFee * congestionMultiplier) / 10n; // 10% of adjusted base fee\n const maxFee = (baseFee * congestionMultiplier * 12n) / 10n; // 120% of adjusted base fee\n \n // Ensure minimum values for account abstraction bundlers\n const finalPriorityFee = priorityFee > MIN_PRIORITY_FEE ? priorityFee : MIN_PRIORITY_FEE;\n const finalMaxFee = maxFee > MIN_MAX_FEE ? maxFee : MIN_MAX_FEE;\n\n return {\n priority: finalPriorityFee,\n max: finalMaxFee,\n baseFee,\n isCongested\n };\n } catch (error) {\n console.error('[Gas] Failed to fetch dynamic gas price:', error);\n // Return conservative fallback values\n return {\n priority: BigInt(2000000000), // 2 gwei\n max: BigInt(4000000000), // 4 gwei\n baseFee: BigInt(1000000000), // 1 gwei\n isCongested: false\n };\n }\n}\n\n/**\n * Calculate gas estimation with adaptive buffer based on network conditions\n * Uses 30% buffer during congestion, 20% during normal conditions\n */\nexport function calculateGasWithBuffer(params: GasEstimationParams): bigint {\n const { estimated, isCongested } = params;\n \n // Apply 30% buffer during congestion, 20% during normal conditions\n const bufferMultiplier = isCongested ? 130n : 120n;\n const gasWithBuffer = (estimated * bufferMultiplier) / 100n;\n \n return gasWithBuffer;\n}\n\n/**\n * Get network conditions for gas optimization decisions\n */\nexport async function getNetworkConditions(publicClient: PublicClient | null): Promise<{\n baseFee: bigint;\n isCongested: boolean;\n recommendedBuffer: number;\n}> {\n try {\n if (!publicClient) {\n return {\n baseFee: BigInt(1000000000),\n isCongested: false,\n recommendedBuffer: 20\n };\n }\n\n const block = await publicClient.getBlock({ blockTag: 'latest' });\n const baseFee = block.baseFeePerGas || BigInt(1000000000);\n const isCongested = baseFee > CONGESTION_THRESHOLD;\n \n return {\n baseFee,\n isCongested,\n recommendedBuffer: isCongested ? 30 : 20\n };\n } catch (error) {\n console.error('[Gas] Failed to get network conditions:', error);\n return {\n baseFee: BigInt(1000000000),\n isCongested: false,\n recommendedBuffer: 25 // Conservative fallback\n };\n }\n}","import { usdcUnits } from \"../utils/usdcUnits\";\n\n// Re-export time constants\nexport * from \"./time\";\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt\nexport const ZERO = 0n;\nexport const SECONDS_IN_DAY = 86400n;\n\n// =============================================================================\n// QUERY & POLLING CONFIGURATION\n// =============================================================================\n// Centralized configuration for all data fetching, polling intervals, and cache times.\n// Rule: staleTime should be slightly LESS than polling interval to prevent unnecessary\n// refetches on remount/focus while still allowing polling to work correctly.\n// =============================================================================\n\n// --- Base Network Timing ---\n// Base has 2 second block times - this affects how quickly on-chain data propagates\nexport const BASE_BLOCK_TIME_MS = 2000;\n// Delay after transaction to allow RPC nodes to sync (block time + propagation margin)\nexport const RPC_PROPAGATION_DELAY_MS = 2000;\n\n// --- RPC Direct Reads (ProtocolViewer) ---\n// Used for instant on-chain data after transactions\nexport const RPC_STALE_TIME_MS = 3000; // Block time + 1s margin\nexport const RPC_GC_TIME_MS = 30000; // Keep in cache for quick re-access\n\n// --- Intent Polling (Active Swap Flow) ---\n// Fast polling for responsive UX during active order, pauses when tab hidden\nexport const INTENT_POLLING_INTERVAL_MS = 3000;\nexport const INTENT_STALE_TIME_MS = 2500; // < polling interval to prevent double-fetch on remount\n\n// --- Balance Polling ---\n// Background refresh for wallet balances, not critical path\nexport const BALANCE_POLLING_INTERVAL_MS = 30000;\nexport const BALANCE_STALE_TIME_MS = 25000; // < polling interval\n\n// --- Deposit List Polling ---\n// Slower polling for deposit management pages\nexport const DEPOSIT_REFETCH_INTERVAL = 300000; // 5 minutes\nexport const DEPOSIT_STALE_TIME_MS = 290000; // 4:50 - slightly less than polling\n\n// --- Liquidity Table Polling ---\n// Medium-frequency polling for orderbook/liquidity views\nexport const LIQUIDITY_POLLING_INTERVAL_MS = 60000; // 1 minute\nexport const LIQUIDITY_STALE_TIME_MS = 55000; // 55s - slightly less than polling\n\n// --- Backend API Queries ---\n// Longer stale times since RPC provides real-time data for critical flows\nexport const BACKEND_DEPOSITS_STALE_TIME_MS = 30000;\nexport const BACKEND_DEPOSITS_GC_TIME_MS = 120000; // 2 minutes\nexport const BACKEND_INTENTS_STALE_TIME_MS = 30000;\nexport const BACKEND_INTENTS_GC_TIME_MS = 60000; // 1 minute\nexport const BACKEND_DEPOSIT_ORDERS_STALE_TIME_MS = 30000;\nexport const BACKEND_DEPOSIT_ORDERS_GC_TIME_MS = 120000;\n\n// --- Proof Polling (Order Completion Flow) ---\n// Fast polling while waiting for proof generation\nexport const PROOF_POLL_INTERVAL_MS = 3000;\n\n// --- ENS Resolution ---\n// Long cache time since ENS names rarely change\nexport const ENS_STALE_TIME_MS = 900000; // 15 minutes\nexport const ENS_GC_TIME_MS = 1800000; // 30 minutes\n\n// --- Past Deposits (No Polling) ---\n// Historical data that only updates on explicit invalidation\nexport const PAST_DEPOSITS_STALE_TIME_MS = Infinity;\nexport const PAST_DEPOSITS_GC_TIME_MS = 60000;\n\n// =============================================================================\n// END QUERY & POLLING CONFIGURATION\n// =============================================================================\n\n// =============================================================================\n// SESSION STORAGE KEYS\n// =============================================================================\n// Namespaced keys for cross-component communication via sessionStorage.\n// These enable data-aware UI updates (e.g., skeleton clearing after deposits).\n//\n// Usage pattern:\n// 1. Component A sets a key before navigation/action\n// 2. Component B reads and clears the key on mount/update\n// 3. Component B uses the value to determine UI behavior\n//\n// All keys are namespaced with 'zkp2p:' to avoid collisions with other storage.\n// =============================================================================\n\n/**\n * Signals that the deposit list needs refreshing with skeleton loading.\n * Set by DepositDetailsView when closing a deposit before navigating back.\n * Cleared by Deposits/index.tsx after initiating refresh.\n */\nexport const DEPOSIT_REFRESH_PENDING_KEY = \"zkp2p:deposit:refreshPending\";\n\n/**\n * Stores the deposit ID that was just closed.\n * Used for data-aware skeleton clearing - skeleton clears when this ID\n * is no longer present in the deposit list.\n * Set by DepositDetailsView, cleared by Deposits/index.tsx.\n */\nexport const DEPOSIT_CLOSED_ID_KEY = \"zkp2p:deposit:closedId\";\n\n/**\n * Stores the expected deposit count after creating a new deposit.\n * Used for data-aware skeleton clearing - skeleton clears when the\n * actual count matches or exceeds the expected count.\n * Set by NewDeposit flow, cleared by Deposits/index.tsx.\n */\nexport const DEPOSIT_EXPECTED_COUNT_KEY = \"zkp2p:deposit:expectedCount\";\n\n// =============================================================================\n// END SESSION STORAGE KEYS\n// =============================================================================\n\n// =============================================================================\n// UI TIMING CONSTANTS\n// =============================================================================\n// Constants for skeleton loading states, animations, and visual feedback timing.\n// These ensure consistent UX across the application.\n// =============================================================================\n\n/**\n * Minimum time to show skeleton loading state for visual feedback.\n * Prevents jarring flash if data loads very quickly.\n */\nexport const MIN_REFRESH_SKELETON_MS = 1500;\n\n/**\n * Maximum time to show skeleton loading state before giving up.\n * Safety timeout if data change detection fails.\n */\nexport const MAX_REFRESH_SKELETON_MS = 6000;\n\n// =============================================================================\n// END UI TIMING CONSTANTS\n// =============================================================================\n\n// Chain IDs\nconst BASE_MAINNET_CHAIN_ID = 8453;\nexport const SOLANA_CHAIN_ID = 792703809;\nexport const TRON_CHAIN_ID = 728126428;\nexport const HYPEREVM_CHAIN_ID = 999;\nexport const HYPERLIQUID_CHAIN_ID = 1337;\nexport const PLASMA_CHAIN_ID = 9745;\nexport const BITCOIN_CHAIN_ID = 8253038;\nexport const SUI_CHAIN_ID = 103665049;\nexport const TAIKO_CHAIN_ID = 167000;\n\n// Hyperliquid uses a special USDC token with different decimals\nexport const HYPERLIQUID_USDC_ADDRESS = \"0x00000000000000000000000000000000\";\n\n// Bitcoin uses a special address format for BTC\nexport const BITCOIN_BTC_ADDRESS = \"bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8\";\n\n// Both STAGING and PRODUCTION use Base mainnet\nexport const BASE_CHAIN_ID = BASE_MAINNET_CHAIN_ID;\n\n// USDC addresses\nconst BASE_MAINNET_USDC_ADDRESS = \"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913\";\nexport const BASE_USDC_ADDRESS = BASE_MAINNET_USDC_ADDRESS;\n\n// Excluded origin chains for Relay deposit-address flow (keep in sync with provider checks)\nexport const RELAY_DEPOSIT_ORIGIN_EXCLUDED_CHAIN_IDS: number[] = [\n BASE_MAINNET_CHAIN_ID, // Base mainnet\n 43114, // Avalanche\n 1301, // Unichain\n 80084, // Berachain (testnet)\n 1088, // Metis\n 21000000, // Corn\n];\n\nexport const MINIMUM_DEPOSIT_AMOUNT = usdcUnits(0.1);\n\n// Order limit constants\nexport const MIN_ORDER_FLOOR = 5; // Minimum allowed order amount in USDC\nexport const MIN_ORDER_CAP = 50; // Maximum value for minimum order amount in USDC\nexport const MAX_ORDER_ADVISORY_THRESHOLD = 3000; // Advisory threshold for high per-order amounts in USDC\nexport const MIN_ORDER_DEPOSIT_THRESHOLD = 5; // Deposits below this amount are not subject to formula enforcement\nexport const DEFAULT_MAX_ORDER_CAP = 3000; // Default per-order cap applied when auto-filling max\n\n// Dust filtering threshold - hide liquidity entries below this USD value\nexport const DUST_THRESHOLD_USD = 5;\n\n// Extreme spread filtering threshold - hide orders with spread above this percentage\nexport const EXTREME_SPREAD_THRESHOLD_PERCENT = 100; // +100% spread\n\n// Success-rate and order-threshold configuration\nexport const MIN_ORDERS_FOR_SUCCESS_METRIC = 10; // minimum finalized intents before surfacing stats\nexport const LOW_SUCCESS_RATE_FILTER_PERCENT = 20; // Deposits below this hidden by default\nexport const LOW_SUCCESS_RATE_WARNING_PERCENT = 50; // Warn users below this completion rate\nexport const EXTREMELY_LOW_SUCCESS_RATE_PERCENT = 10; // Stronger warning badge threshold\n\n// Intent expiration fallback when indexer expiryTime unavailable.\n// On-chain: Production = 6 hours, Staging = 1 hour.\n// This is only used as a fallback; prefer expiryTime from indexer which reads the real on-chain value.\n// Note: In production, use the 6-hour default. Consuming apps can override this based on their environment.\nexport const INTENT_EXPIRATION_PERIOD_IN_SECONDS = 3600 * 6; // 6 hours (production default)\nexport const INTENT_EXPIRATION_PERIOD_STAGING_IN_SECONDS = 3600; // 1 hour (staging)\n\nexport const PRECISION = 1000000000000000000n; // 18\n\nexport const QUOTE_DEFAULT_ADDRESS =\n \"0x18Cc6F90512C6D95ACA0d57F98C727D61873c06a\";\nexport const QUOTE_DEFAULT_BTC_ADDRESS = \"34FzWazeBFL1mWF8tn36635hPsnJEzTrMR\"; // Default Bitcoin address for quotes\nexport const QUOTE_DEFAULT_SOL_ADDRESS =\n \"8pHKRNF3u8tndkUJ4euAddNWM9EAMWbUiK5GVmtaGY5U\";\nexport const QUOTE_DEFAULT_TRON_ADDRESS = \"TT2T17KZhoDu47i2E4FWxfG79zdkEWkU9N\"; // justin's tron address\nexport const QUOTE_DEFAULT_SUI_ADDRESS =\n \"0x2dad0710678565a0045073af0327a945e93c9c3bff31169ee689739558ed8b6b\";\n\n// the numeric form of the payload1 passed into the primitive\n// corresponds to the openssh signature produced by the following command:\n// echo \"E PLURIBUS UNUM; DO NOT SHARE\" | ssh-keygen -Y sign -n double-blind.xyz -f ~/.ssh/id_rsa | pbcopy\n\nexport const CLIENT_VERSION = \"3.0.0\";\n\n// circom constants from main.circom / https://zkrepl.dev/?gist=30d21c7a7285b1b14f608325f172417b\n// template RSAGroupSigVerify(n, k, levels) {\n// component main { public [ modulus ] } = RSAVerify(121, 17);\n// component main { public [ root, payload1 ] } = RSAGroupSigVerify(121, 17, 30);\n\n// Misc smart contract values\n\nexport const ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n// Default intent guardian for V3 deposits\nexport const DEFAULT_INTENT_GUARDIAN_ADDRESS =\n \"0xe29a5BD4D0CEbA6C125A0361E7D20ab4eA275C2f\";\nexport const CALLER_ACCOUNT = \"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\";\nexport const DEFAULT_NETWORK = \"base\";\n\n// Relay bridge app fee configuration\nexport const RELAY_APP_FEE_RECIPIENT =\n \"0x0bC26FF515411396DD588Abd6Ef6846E04470227\";\nexport const RELAY_APP_FEE_BPS = \"50\"; // 50 basis points = 0.5%\n\n/**\n * Destination chains where ALL tokens are eligible for zero app fees.\n *\n * Hyperliquid chains (HyperEVM and L1) are whitelisted to incentivize user\n * adoption and liquidity flow to the Hyperliquid ecosystem. This strategic\n * partnership benefits both platforms by reducing friction for users bridging\n * funds to trade on Hyperliquid's perpetuals and spot markets.\n */\nexport const RELAY_ZERO_FEE_DESTINATION_CHAINS: number[] = [\n HYPEREVM_CHAIN_ID, // HyperEVM (999)\n HYPERLIQUID_CHAIN_ID, // Hyperliquid L1 (1337)\n];\n\n// Cross-chain destination token addresses eligible for zero app fees when bridging from Base\nexport const RELAY_ZERO_FEE_TOKEN_ADDRESSES: Record<number, string[]> = {\n 1: [\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\", // USDC\n \"0xdAC17F958D2ee523a2206206994597C13D831ec7\", // USDT\n ],\n 10: [\n \"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85\", // USDC\n \"0x01bFf41798a0bcF287b996046cA68B395dbc1071\", // USDT\n ],\n 137: [\"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359\"], // Polygon PoS (USDC)\n 42161: [\n \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\", // USDC\n \"0xfd086BC7CD5C481DCC9C85ebe478A1C0b69FCbb9\", // USDT\n ],\n 43114: [\"0x9702230A8Ea53601F5cD2dc00fDBC13D4dF4A8c7\"], // Avalanche (USDT)\n 480: [\"0x79A02482A880bCe3F13E09da970dC34dB4cD24D1\"], // World Chain (USDC)\n [HYPEREVM_CHAIN_ID]: [\n \"0xb88339CB7199b77E23DB6E890353E22632Ba630f\", // USDC\n \"0xb8cE59fC3717AdA4C02EAdf9682A9e934F625ebb\", // USDT\n ],\n [PLASMA_CHAIN_ID]: [\n \"0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb\", // USDT0\n ],\n 1301: [\n \"0x078D782b760474a361dDA0AF3839290b0EF57AD6\", // USDC\n \"0x9151434b16b9763660705744891Fa906f660EcC5\", // USDT\n ],\n 1329: [\n \"0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392\", // USDC\n \"0x9151434b16b9763660705744891Fa906f660EcC5\", // USDT\n ],\n [HYPERLIQUID_CHAIN_ID]: [\n HYPERLIQUID_USDC_ADDRESS,\n \"0x25faEdc3F054130DBB4e4203AcA63567\",\n ],\n 146: [\"0x29219dd400f2Bf60E5a23d13Be72B486D4038894\"], // Sonic (USDC)\n [SOLANA_CHAIN_ID]: [\n \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\", // USDC\n \"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB\", // USDT\n ],\n [TRON_CHAIN_ID]: [\"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\"],\n 80084: [\"0x779dED0C9E1022225F8E0630B35a9B54Be713736\"], // Berachain (USDT)\n};\n\n// Proving key paths\n","/**\n * Payment method resolution utilities.\n *\n * These functions convert between human-readable payment platform names\n * (e.g., 'wise', 'revolut') and their on-chain bytes32 hashes.\n *\n * @module paymentResolution\n */\n\nimport { ensureBytes32 } from './bytes32';\nimport { currencyKeccak256 } from './currencyKeccak256';\nimport type { PaymentMethodCatalog } from '../contracts';\nimport { METHOD_NAME_TO_HASH } from '@zkp2p/core/utils';\n\n// Optional JSON maps from @zkp2p/contracts-v2 (only provided on some envs)\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport baseStagingPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseStaging';\n\ntype NetworkKey = 'base';\ntype RuntimeEnv = 'production' | 'staging';\n\nfunction getPaymentMethodMap(\n env: RuntimeEnv,\n network: NetworkKey,\n): Record<string, { paymentMethodHash: `0x${string}` }> | null {\n if (env === 'staging') {\n const m = (baseStagingPaymentMethods?.methods ?? {}) as Record<\n string,\n { paymentMethodHash: `0x${string}` }\n >;\n return m && Object.keys(m).length ? m : null;\n }\n return null;\n}\n\n/**\n * Resolves a payment method hash from a human-readable name.\n *\n * First attempts to look up the hash from contracts-v2 payment method maps.\n * Falls back to keccak256(name) when maps are unavailable.\n *\n * **Warning**: The fallback may not match on-chain mappings. Prefer using\n * `resolvePaymentMethodHashFromCatalog` with an explicit catalog.\n *\n * @param nameOrBytes - Payment method name ('wise') or existing bytes32 hash\n * @param opts.env - Runtime environment ('production' | 'staging')\n * @param opts.network - Network key ('base')\n * @returns bytes32 payment method hash\n *\n * @example\n * ```typescript\n * const hash = resolvePaymentMethodHash('wise', { env: 'production' });\n * ```\n */\nexport function resolvePaymentMethodHash(\n nameOrBytes: string,\n opts: { env?: RuntimeEnv; network?: NetworkKey } = {},\n): `0x${string}` {\n const { env = 'production', network = 'base' } = opts;\n if (nameOrBytes.startsWith('0x')) return ensureBytes32(nameOrBytes) as `0x${string}`;\n const mapping = getPaymentMethodMap(env, network);\n if (mapping) {\n const key = nameOrBytes.toLowerCase();\n const entry = mapping[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n }\n // Fallback: hash ascii name to bytes32\n return ensureBytes32(nameOrBytes, { hashIfAscii: true });\n}\n\n/**\n * Encodes a fiat currency code into bytes32 format (keccak256 hash).\n *\n * If the input is already a hex string (0x-prefixed), it's normalized to bytes32.\n * Otherwise, the currency code is hashed using keccak256.\n *\n * @param codeOrBytes - Currency code ('USD') or existing bytes32 hash\n * @returns bytes32 keccak256 hash of the currency code\n *\n * @example\n * ```typescript\n * const bytes = resolveFiatCurrencyBytes32('USD');\n * // Returns: 0xc4ae21aac0c6549d71dd96035b7e0bdb6c79ebdba8891b666115bc976d16a29e\n * ```\n */\nexport function resolveFiatCurrencyBytes32(codeOrBytes: string): `0x${string}` {\n if (codeOrBytes.startsWith('0x')) return ensureBytes32(codeOrBytes) as `0x${string}`;\n return currencyKeccak256(codeOrBytes.toUpperCase()) as `0x${string}`;\n}\n\n/**\n * Resolves a payment method hash from a provided catalog.\n *\n * This is the recommended method for resolving payment methods as it uses\n * the exact catalog from `getPaymentMethodsCatalog()`, ensuring consistency\n * with on-chain registrations.\n *\n * If the processor is not found in the catalog, falls back to the known\n * payment method hashes from @zkp2p/core before throwing an error.\n *\n * @param processorName - Payment platform name ('wise', 'revolut', etc.)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns bytes32 payment method hash\n * @throws Error with available processors if not found in catalog or fallback\n *\n * @example\n * ```typescript\n * import { getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog } from '@zkp2p/sdk';\n *\n * const catalog = getPaymentMethodsCatalog(8453, 'production');\n * const hash = resolvePaymentMethodHashFromCatalog('wise', catalog);\n * ```\n */\nexport function resolvePaymentMethodHashFromCatalog(\n processorName: string,\n catalog: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>,\n): `0x${string}` {\n if (!processorName) {\n throw new Error('processorName is required to resolve paymentMethodHash');\n }\n if (processorName.startsWith('0x')) {\n return ensureBytes32(processorName) as `0x${string}`;\n }\n const key = processorName.toLowerCase();\n const entry = catalog?.[key];\n if (entry?.paymentMethodHash) return entry.paymentMethodHash;\n\n // Fallback to core's known payment method hashes when catalog is missing the entry\n const fallbackHash = METHOD_NAME_TO_HASH[key as keyof typeof METHOD_NAME_TO_HASH];\n if (fallbackHash) return fallbackHash as `0x${string}`;\n\n const available = Object.keys(catalog || {})\n .sort()\n .join(', ');\n throw new Error(\n available\n ? `Unknown processorName: ${processorName}. Available: ${available}`\n : `Unknown processorName: ${processorName}. The payment methods catalog is empty or unavailable.`,\n );\n}\n\n/**\n * Reverse-lookup: converts a payment method hash back to its name.\n *\n * @param hash - The payment method hash (bytes32)\n * @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`\n * @returns Payment platform name (e.g., 'wise') or undefined if not found\n *\n * @example\n * ```typescript\n * const name = resolvePaymentMethodNameFromHash('0x...', catalog);\n * console.log(name); // \"wise\"\n * ```\n */\nexport function resolvePaymentMethodNameFromHash(\n hash: string,\n catalog: PaymentMethodCatalog,\n): string | undefined {\n if (!hash) return undefined;\n const target = ensureBytes32(hash) as `0x${string}`;\n for (const [name, entry] of Object.entries(catalog || {})) {\n if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;\n }\n return undefined;\n}\n"]}