@zkp2p/sdk 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +42 -37
  2. package/dist/{Zkp2pClient-tpqzO2dc.d.mts → Zkp2pClient-BwGN8dWD.d.mts} +1 -1
  3. package/dist/{Zkp2pClient-tpqzO2dc.d.ts → Zkp2pClient-BwGN8dWD.d.ts} +1 -1
  4. package/dist/chunk-37HJPVJE.mjs +11 -0
  5. package/dist/chunk-37HJPVJE.mjs.map +1 -0
  6. package/dist/chunk-EIW43UIQ.mjs +231 -0
  7. package/dist/chunk-EIW43UIQ.mjs.map +1 -0
  8. package/dist/{chunk-PLKVLZVI.mjs → chunk-FHWDNBNQ.mjs} +4 -4
  9. package/dist/{chunk-PLKVLZVI.mjs.map → chunk-FHWDNBNQ.mjs.map} +1 -1
  10. package/dist/{chunk-GYYD6SSA.mjs → chunk-LUOIIWYO.mjs} +19 -3
  11. package/dist/chunk-LUOIIWYO.mjs.map +1 -0
  12. package/dist/{chunk-IXZY7BSF.mjs → chunk-MDLTLKWK.mjs} +3 -3
  13. package/dist/chunk-MDLTLKWK.mjs.map +1 -0
  14. package/dist/constants-65JLA7QO.mjs +5 -0
  15. package/dist/{constants-UPXDEQFF.mjs.map → constants-65JLA7QO.mjs.map} +1 -1
  16. package/dist/currency-P4HY7S34.mjs +4 -0
  17. package/dist/{currency-V2V6PKXO.mjs.map → currency-P4HY7S34.mjs.map} +1 -1
  18. package/dist/index.cjs +273 -173
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.mts +19 -4
  21. package/dist/index.d.ts +19 -4
  22. package/dist/index.mjs +52 -41
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/paymentResolution-4Z3TKEVB.mjs +4 -0
  25. package/dist/{paymentResolution-AZUVXTLV.mjs.map → paymentResolution-4Z3TKEVB.mjs.map} +1 -1
  26. package/dist/protocolViewerParsers-HFBHDBSJ.mjs +6 -0
  27. package/dist/{protocolViewerParsers-ZHJDHXTL.mjs.map → protocolViewerParsers-HFBHDBSJ.mjs.map} +1 -1
  28. package/dist/react.d.mts +1 -1
  29. package/dist/react.d.ts +1 -1
  30. package/dist/react.mjs +1 -1
  31. package/dist/{timeout-7HCFGU6P.mjs → timeout-QB7K5SOB.mjs} +2 -3
  32. package/dist/timeout-QB7K5SOB.mjs.map +1 -0
  33. package/package.json +16 -16
  34. package/dist/chunk-3QS3WKRC.mjs +0 -29
  35. package/dist/chunk-3QS3WKRC.mjs.map +0 -1
  36. package/dist/chunk-GNGQRV2U.mjs +0 -196
  37. package/dist/chunk-GNGQRV2U.mjs.map +0 -1
  38. package/dist/chunk-GYYD6SSA.mjs.map +0 -1
  39. package/dist/chunk-IXZY7BSF.mjs.map +0 -1
  40. package/dist/chunk-RMWIECY7.mjs +0 -75
  41. package/dist/chunk-RMWIECY7.mjs.map +0 -1
  42. package/dist/constants-UPXDEQFF.mjs +0 -6
  43. package/dist/currency-V2V6PKXO.mjs +0 -5
  44. package/dist/paymentResolution-AZUVXTLV.mjs +0 -5
  45. package/dist/protocolViewerParsers-ZHJDHXTL.mjs +0 -7
  46. package/dist/timeout-7HCFGU6P.mjs.map +0 -1
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  ## Who Is This For?
10
10
 
11
11
  This SDK is designed for **liquidity providers (peers)** who want to:
12
+
12
13
  - Create and manage USDC deposits that accept fiat payments
13
14
  - Configure payment methods, currencies, and conversion rates
14
15
  - Monitor deposit utilization and manage liquidity
@@ -26,15 +27,15 @@ Advanced historical queries (pagination, filtering, fulfillment records) are ava
26
27
 
27
28
  ## Core Features (Deposit Management)
28
29
 
29
- | Feature | Description |
30
- |---------|-------------|
31
- | **Create Deposits** | Lock USDC and define accepted payment methods |
32
- | **Configure Rates** | Set conversion rates per currency and payment platform |
33
- | **Manage Funds** | Add/remove funds, withdraw deposits |
30
+ | Feature | Description |
31
+ | ------------------- | ---------------------------------------------------------------- |
32
+ | **Create Deposits** | Lock USDC and define accepted payment methods |
33
+ | **Configure Rates** | Set conversion rates per currency and payment platform |
34
+ | **Manage Funds** | Add/remove funds, withdraw deposits |
34
35
  | **Payment Methods** | Wise, Venmo, Revolut, CashApp, PayPal, Zelle, Monzo, MercadoPago |
35
- | **Multi-Currency** | Support USD, EUR, GBP, and 25+ fiat currencies |
36
- | **Query Deposits** | Real-time on-chain queries via ProtocolViewer |
37
- | **React Hooks** | Full suite of React hooks for frontend integration |
36
+ | **Multi-Currency** | Support USD, EUR, GBP, and 25+ fiat currencies |
37
+ | **Query Deposits** | Real-time on-chain queries via ProtocolViewer |
38
+ | **React Hooks** | Full suite of React hooks for frontend integration |
38
39
 
39
40
  ## Supporting Features
40
41
 
@@ -155,11 +156,11 @@ await client.createDeposit({
155
156
  processorNames: ['wise', 'revolut'],
156
157
  depositData: [
157
158
  { email: 'maker@example.com' }, // Wise payment details
158
- { tag: '@maker' }, // Revolut payment details
159
+ { tag: '@maker' }, // Revolut payment details
159
160
  ],
160
161
  conversionRates: [
161
162
  [{ currency: Currency.USD, conversionRate: '1020000000000000000' }], // 1.02 (18 decimals)
162
- [{ currency: Currency.EUR, conversionRate: '950000000000000000' }], // 0.95 (18 decimals)
163
+ [{ currency: Currency.EUR, conversionRate: '950000000000000000' }], // 0.95 (18 decimals)
163
164
  ],
164
165
  onSuccess: ({ hash }) => console.log('Deposit created:', hash),
165
166
  });
@@ -235,14 +236,14 @@ For historical data, pagination, and advanced filtering:
235
236
  // Query with filters and pagination
236
237
  const deposits = await client.indexer.getDeposits(
237
238
  { status: 'ACTIVE', minLiquidity: '1000000', depositor: '0xYourAddress' }, // Note: use 'depositor', not 'owner'
238
- { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' }
239
+ { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' },
239
240
  );
240
241
 
241
242
  // Get deposits with related data
242
243
  const depositsWithRelations = await client.indexer.getDepositsWithRelations(
243
244
  { status: 'ACTIVE' },
244
245
  { limit: 50 },
245
- { includeIntents: true, intentStatuses: ['SIGNALED'] }
246
+ { includeIntents: true, intentStatuses: ['SIGNALED'] },
246
247
  );
247
248
 
248
249
  // Historical fulfillment records
@@ -353,16 +354,16 @@ function DepositManager({ client }) {
353
354
 
354
355
  Supported payment platforms:
355
356
 
356
- | Platform | Key | Currencies |
357
- |-------------|---------------|------------|
357
+ | Platform | Key | Currencies |
358
+ | ----------- | ------------- | ------------------- |
358
359
  | Wise | `wise` | USD, EUR, GBP, etc. |
359
- | Venmo | `venmo` | USD |
360
+ | Venmo | `venmo` | USD |
360
361
  | Revolut | `revolut` | USD, EUR, GBP, etc. |
361
- | CashApp | `cashapp` | USD |
362
- | PayPal | `paypal` | USD, EUR, etc. |
363
- | Zelle | `zelle` | USD |
364
- | Monzo | `monzo` | GBP |
365
- | MercadoPago | `mercadopago` | BRL, ARS, MXN |
362
+ | CashApp | `cashapp` | USD |
363
+ | PayPal | `paypal` | USD, EUR, etc. |
364
+ | Zelle | `zelle` | USD |
365
+ | Monzo | `monzo` | GBP |
366
+ | MercadoPago | `mercadopago` | BRL, ARS, MXN |
366
367
 
367
368
  ```typescript
368
369
  import { getPaymentMethodsCatalog, PLATFORM_METADATA, PAYMENT_PLATFORMS } from '@zkp2p/sdk';
@@ -386,7 +387,7 @@ import {
386
387
  Currency,
387
388
  currencyInfo,
388
389
  getCurrencyInfoFromHash,
389
- resolveFiatCurrencyBytes32
390
+ resolveFiatCurrencyBytes32,
390
391
  } from '@zkp2p/sdk';
391
392
 
392
393
  // Use currency constants
@@ -408,7 +409,7 @@ import { getContracts, getPaymentMethodsCatalog } from '@zkp2p/sdk';
408
409
 
409
410
  // Get contract addresses and ABIs
410
411
  const { addresses, abis } = getContracts(8453, 'production');
411
- console.log(addresses.escrow); // Contract addresses use camelCase
412
+ console.log(addresses.escrow); // Contract addresses use camelCase
412
413
  console.log(addresses.orchestrator);
413
414
 
414
415
  // Get payment methods catalog
@@ -417,41 +418,47 @@ const catalog = getPaymentMethodsCatalog(8453, 'production');
417
418
 
418
419
  ## Supported Networks
419
420
 
420
- | Network | Chain ID | Environment |
421
- |---------|----------|-------------|
422
- | Base Mainnet | 8453 | `production` |
423
- | Base Sepolia | 84532 | `staging` |
421
+ | Network | Chain ID | Environment |
422
+ | ------------ | -------- | ------------ |
423
+ | Base Mainnet | 8453 | `production` |
424
+ | Base Sepolia | 84532 | `staging` |
424
425
 
425
426
  ## API Reference
426
427
 
427
428
  ### Query Methods (RPC-first)
428
429
 
429
430
  **Deposits (instant on-chain reads):**
431
+
430
432
  - `getDeposits()` - Get connected wallet's deposits
431
433
  - `getAccountDeposits(owner)` - Get deposits for any address
432
434
  - `getDeposit(depositId)` - Get single deposit by ID
433
435
  - `getDepositsById(ids)` - Batch fetch deposits
434
436
 
435
437
  **Intents (instant on-chain reads):**
438
+
436
439
  - `getIntents()` - Get connected wallet's intents
437
440
  - `getAccountIntents(owner)` - Get intents for any address
438
441
  - `getIntent(intentHash)` - Get single intent by hash
439
442
 
440
443
  **Utilities:**
444
+
441
445
  - `resolvePayeeHash(depositId, paymentMethodHash)` - Get payee details hash
442
446
 
443
447
  **Token Allowance:**
448
+
444
449
  - `ensureAllowance(params)` - Check/set ERC20 allowance for deposits
445
450
 
446
451
  ### Core Methods (Deposit Management)
447
452
 
448
453
  **Creating & Managing Deposits:**
454
+
449
455
  - `createDeposit(params)` - Create a new liquidity deposit
450
456
  - `addFunds(params)` - Add funds to deposit
451
457
  - `removeFunds(params)` - Remove funds from deposit
452
458
  - `withdrawDeposit(params)` - Withdraw entire deposit
453
459
 
454
460
  **Configuring Deposits:**
461
+
455
462
  - `setAcceptingIntents(params)` - Toggle intent acceptance
456
463
  - `setIntentRange(params)` - Set min/max intent amounts
457
464
  - `setCurrencyMinRate(params)` - Set minimum conversion rate
@@ -476,6 +483,7 @@ For historical data, pagination, and advanced filtering:
476
483
  ### Supporting Methods
477
484
 
478
485
  **Intent Operations** (typically used by takers, not liquidity providers):
486
+
479
487
  - `signalIntent(params)` - Signal an intent to use a deposit
480
488
  - `fulfillIntent(params)` - Fulfill with attestation proof
481
489
  - `cancelIntent(params)` - Cancel an intent
@@ -483,6 +491,7 @@ For historical data, pagination, and advanced filtering:
483
491
  - `pruneExpiredIntents(params)` - Clean up expired intents
484
492
 
485
493
  **Quote API** (used by frontends):
494
+
486
495
  - `getQuote(params)` - Get available exchange quotes
487
496
 
488
497
  ## Token Allowance Management
@@ -514,15 +523,9 @@ For methods that interact directly with on-chain data, parameters use bytes32 he
514
523
  await client.addPaymentMethods({
515
524
  depositId: 1n,
516
525
  paymentMethods: ['0x...'], // bytes32 payment method hashes
517
- paymentMethodData: [
518
- { intentGatingService: '0x...', payeeDetails: '0x...', data: '0x' },
519
- ],
526
+ paymentMethodData: [{ intentGatingService: '0x...', payeeDetails: '0x...', data: '0x' }],
520
527
  // currencies is required and must align with paymentMethods by index
521
- currencies: [
522
- [
523
- { code: '0x...', minConversionRate: 1020000000000000000n },
524
- ],
525
- ],
528
+ currencies: [[{ code: '0x...', minConversionRate: 1020000000000000000n }]],
526
529
  });
527
530
 
528
531
  // addCurrencies - Add currencies to a payment method
@@ -538,7 +541,7 @@ await client.addCurrencies({
538
541
  await client.deactivateCurrency({
539
542
  depositId: 1n,
540
543
  paymentMethod: '0x...', // bytes32 payment method hash
541
- currencyCode: '0x...', // bytes32 currency code
544
+ currencyCode: '0x...', // bytes32 currency code
542
545
  });
543
546
 
544
547
  // setPaymentMethodActive - Enable/disable a payment method
@@ -552,7 +555,7 @@ await client.setPaymentMethodActive({
552
555
  await client.setCurrencyMinRate({
553
556
  depositId: 1n,
554
557
  paymentMethod: '0x...', // bytes32 payment method hash
555
- fiatCurrency: '0x...', // bytes32 currency code (not currencyCode)
558
+ fiatCurrency: '0x...', // bytes32 currency code (not currencyCode)
556
559
  minConversionRate: 1020000000000000000n, // 18 decimals
557
560
  });
558
561
  ```
@@ -563,7 +566,9 @@ await client.setCurrencyMinRate({
563
566
  import { ValidationError, NetworkError, ContractError } from '@zkp2p/sdk';
564
567
 
565
568
  try {
566
- await client.createDeposit({ /* ... */ });
569
+ await client.createDeposit({
570
+ /* ... */
571
+ });
567
572
  } catch (error) {
568
573
  if (error instanceof ValidationError) {
569
574
  console.error('Invalid parameters:', error.message);
@@ -1082,7 +1082,7 @@ type GetTakerTierResponse = {
1082
1082
  statusCode?: number;
1083
1083
  };
1084
1084
 
1085
- declare const PAYMENT_PLATFORMS: readonly ["wise", "venmo", "revolut", "cashapp", "mercadopago", "zelle", "paypal", "monzo"];
1085
+ declare const PAYMENT_PLATFORMS: readonly ["wise", "venmo", "revolut", "cashapp", "mercadopago", "zelle", "paypal", "monzo", "chime", "n26"];
1086
1086
  type PaymentPlatformType = (typeof PAYMENT_PLATFORMS)[number];
1087
1087
 
1088
1088
  /**
@@ -1082,7 +1082,7 @@ type GetTakerTierResponse = {
1082
1082
  statusCode?: number;
1083
1083
  };
1084
1084
 
1085
- declare const PAYMENT_PLATFORMS: readonly ["wise", "venmo", "revolut", "cashapp", "mercadopago", "zelle", "paypal", "monzo"];
1085
+ declare const PAYMENT_PLATFORMS: readonly ["wise", "venmo", "revolut", "cashapp", "mercadopago", "zelle", "paypal", "monzo", "chime", "n26"];
1086
1086
  type PaymentPlatformType = (typeof PAYMENT_PLATFORMS)[number];
1087
1087
 
1088
1088
  /**
@@ -0,0 +1,11 @@
1
+ import { keccak256 } from 'viem';
2
+
3
+ // src/utils/currencyKeccak256.ts
4
+ var currencyKeccak256 = (inputString) => {
5
+ const bytes = new TextEncoder().encode(inputString);
6
+ return keccak256(bytes);
7
+ };
8
+
9
+ export { currencyKeccak256 };
10
+ //# sourceMappingURL=chunk-37HJPVJE.mjs.map
11
+ //# sourceMappingURL=chunk-37HJPVJE.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/currencyKeccak256.ts"],"names":["viemKeccak256"],"mappings":";;;AAEO,IAAM,iBAAA,GAAoB,CAAC,WAAA,KAAgC;AAChE,EAAA,MAAM,KAAA,GAAQ,IAAI,WAAA,EAAY,CAAE,OAAO,WAAW,CAAA;AAClD,EAAA,OAAOA,UAAc,KAAK,CAAA;AAC5B","file":"chunk-37HJPVJE.mjs","sourcesContent":["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"]}
@@ -0,0 +1,231 @@
1
+ import { currencyKeccak256 } from './chunk-37HJPVJE.mjs';
2
+ import { keccak256, parseUnits, hexToBytes, toBytes, bytesToHex } from 'viem';
3
+ import 'ethers';
4
+ import baseSepoliaPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseSepolia';
5
+ import baseStagingPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseStaging';
6
+
7
+ function ensureBytes32(value, { hashIfAscii = false } = {}) {
8
+ if (value.startsWith("0x")) {
9
+ const bytes = hexToBytes(value);
10
+ if (bytes.length !== 32) throw new Error("Expected 32-byte hex value");
11
+ return value;
12
+ }
13
+ if (!hashIfAscii)
14
+ throw new Error("Expected 32-byte hex; received ascii string. Pass hashIfAscii=true to hash.");
15
+ const hashed = keccak256(toBytes(value));
16
+ return hashed;
17
+ }
18
+ function asciiToBytes32(value) {
19
+ const b = toBytes(value);
20
+ if (b.length > 32) throw new Error("ASCII input exceeds 32 bytes");
21
+ const padded = new Uint8Array(32);
22
+ padded.set(b);
23
+ return bytesToHex(padded);
24
+ }
25
+ var usdcUnits = (amount) => {
26
+ return parseUnits(amount.toString(), 6);
27
+ };
28
+ var currencyKeccak2562 = (inputString) => {
29
+ const bytes = new TextEncoder().encode(inputString);
30
+ return keccak256(bytes);
31
+ };
32
+ var Currency = {
33
+ AED: "AED",
34
+ ARS: "ARS",
35
+ AUD: "AUD",
36
+ CAD: "CAD",
37
+ CHF: "CHF",
38
+ CNY: "CNY",
39
+ CZK: "CZK",
40
+ DKK: "DKK",
41
+ EUR: "EUR",
42
+ GBP: "GBP",
43
+ HKD: "HKD",
44
+ HUF: "HUF",
45
+ IDR: "IDR",
46
+ ILS: "ILS",
47
+ INR: "INR",
48
+ JPY: "JPY",
49
+ KES: "KES",
50
+ NOK: "NOK",
51
+ MXN: "MXN",
52
+ MYR: "MYR",
53
+ NZD: "NZD",
54
+ PHP: "PHP",
55
+ PLN: "PLN",
56
+ RON: "RON",
57
+ SAR: "SAR",
58
+ SEK: "SEK",
59
+ SGD: "SGD",
60
+ THB: "THB",
61
+ TRY: "TRY",
62
+ UGX: "UGX",
63
+ USD: "USD",
64
+ VND: "VND",
65
+ ZAR: "ZAR"
66
+ };
67
+ ({
68
+ [Currency.AED]: {
69
+ currencyCodeHash: currencyKeccak2562("AED")},
70
+ [Currency.ARS]: {
71
+ currencyCodeHash: currencyKeccak2562("ARS")},
72
+ [Currency.AUD]: {
73
+ currencyCodeHash: currencyKeccak2562("AUD")},
74
+ [Currency.CAD]: {
75
+ currencyCodeHash: currencyKeccak2562("CAD")},
76
+ [Currency.CHF]: {
77
+ currencyCodeHash: currencyKeccak2562("CHF")},
78
+ [Currency.CNY]: {
79
+ currencyCodeHash: currencyKeccak2562("CNY")},
80
+ [Currency.CZK]: {
81
+ currencyCodeHash: currencyKeccak2562("CZK")},
82
+ [Currency.DKK]: {
83
+ currencyCodeHash: currencyKeccak2562("DKK")},
84
+ [Currency.EUR]: {
85
+ currencyCodeHash: currencyKeccak2562("EUR")},
86
+ [Currency.GBP]: {
87
+ currencyCodeHash: currencyKeccak2562("GBP")},
88
+ [Currency.HKD]: {
89
+ currencyCodeHash: currencyKeccak2562("HKD")},
90
+ [Currency.HUF]: {
91
+ currencyCodeHash: currencyKeccak2562("HUF")},
92
+ [Currency.IDR]: {
93
+ currencyCodeHash: currencyKeccak2562("IDR")},
94
+ [Currency.INR]: {
95
+ currencyCodeHash: currencyKeccak2562("INR")},
96
+ [Currency.ILS]: {
97
+ currencyCodeHash: currencyKeccak2562("ILS")},
98
+ [Currency.JPY]: {
99
+ currencyCodeHash: currencyKeccak2562("JPY")},
100
+ [Currency.KES]: {
101
+ currencyCodeHash: currencyKeccak2562("KES")},
102
+ [Currency.MXN]: {
103
+ currencyCodeHash: currencyKeccak2562("MXN")},
104
+ [Currency.MYR]: {
105
+ currencyCodeHash: currencyKeccak2562("MYR")},
106
+ [Currency.NOK]: {
107
+ currencyCodeHash: currencyKeccak2562("NOK")},
108
+ [Currency.NZD]: {
109
+ currencyCodeHash: currencyKeccak2562("NZD")},
110
+ [Currency.PHP]: {
111
+ currencyCodeHash: currencyKeccak2562("PHP")},
112
+ [Currency.PLN]: {
113
+ currencyCodeHash: currencyKeccak2562("PLN")},
114
+ [Currency.RON]: {
115
+ currencyCodeHash: currencyKeccak2562("RON")},
116
+ [Currency.SAR]: {
117
+ currencyCodeHash: currencyKeccak2562("SAR")},
118
+ [Currency.SEK]: {
119
+ currencyCodeHash: currencyKeccak2562("SEK")},
120
+ [Currency.SGD]: {
121
+ currencyCodeHash: currencyKeccak2562("SGD")},
122
+ [Currency.THB]: {
123
+ currencyCodeHash: currencyKeccak2562("THB")},
124
+ [Currency.TRY]: {
125
+ currencyCodeHash: currencyKeccak2562("TRY")},
126
+ [Currency.UGX]: {
127
+ currencyCodeHash: currencyKeccak2562("UGX")},
128
+ [Currency.USD]: {
129
+ currencyCodeHash: currencyKeccak2562("USD")},
130
+ [Currency.VND]: {
131
+ currencyCodeHash: currencyKeccak2562("VND")},
132
+ [Currency.ZAR]: {
133
+ currencyCodeHash: currencyKeccak2562("ZAR")}
134
+ });
135
+ var PaymentPlatform = {
136
+ VENMO: "venmo",
137
+ CASHAPP: "cashapp",
138
+ CHIME: "chime",
139
+ REVOLUT: "revolut",
140
+ WISE: "wise",
141
+ MERCADO_PAGO: "mercadopago",
142
+ ZELLE: "zelle",
143
+ PAYPAL: "paypal",
144
+ MONZO: "monzo",
145
+ N26: "n26",
146
+ ALIPAY: "alipay"
147
+ };
148
+ [...Object.values(PaymentPlatform)];
149
+ var METHOD_NAME_TO_HASH = {
150
+ venmo: "0x90262a3db0edd0be2369c6b28f9e8511ec0bac7136cefbada0880602f87e7268",
151
+ revolut: "0x617f88ab82b5c1b014c539f7e75121427f0bb50a4c58b187a238531e7d58605d",
152
+ cashapp: "0x10940ee67cfb3c6c064569ec92c0ee934cd7afa18dd2ca2d6a2254fcb009c17d",
153
+ chime: "0x5908bb0c9b87763ac6171d4104847667e7f02b4c47b574fe890c1f439ed128bb",
154
+ wise: "0x554a007c2217df766b977723b276671aee5ebb4adaea0edb6433c88b3e61dac5",
155
+ mercadopago: "0xa5418819c024239299ea32e09defae8ec412c03e58f5c75f1b2fe84c857f5483",
156
+ "zelle-citi": "0x817260692b75e93c7fbc51c71637d4075a975e221e1ebc1abeddfabd731fd90d",
157
+ "zelle-chase": "0x6aa1d1401e79ad0549dced8b1b96fb72c41cd02b32a7d9ea1fed54ba9e17152e",
158
+ "zelle-bofa": "0x4bc42b322a3ad413b91b2fde30549ca70d6ee900eded1681de91aaf32ffd7ab5",
159
+ paypal: "0x3ccc3d4d5e769b1f82dc4988485551dc0cd3c7a3926d7d8a4dde91507199490f",
160
+ monzo: "0x62c7ed738ad3e7618111348af32691b5767777fbaf46a2d8943237625552645c",
161
+ n26: "0xd9ff4fd6b39a3e3dd43c41d05662a5547de4a878bc97a65bcb352ade493cdc6b",
162
+ alipay: "0xcac9daea62d7b89d75ac73af4ee14dcf25721012ae82b568c2ea5c808eaa04ff"
163
+ };
164
+ Object.entries(
165
+ METHOD_NAME_TO_HASH
166
+ ).reduce(
167
+ (acc, [name, hash]) => {
168
+ acc[hash.toLowerCase()] = name;
169
+ return acc;
170
+ },
171
+ {}
172
+ );
173
+ BigInt(5e9);
174
+ BigInt(1e9);
175
+ BigInt(2e9);
176
+ usdcUnits(0.1);
177
+ function getPaymentMethodMap(env, network) {
178
+ if (env === "staging") {
179
+ const m = baseStagingPaymentMethods?.methods ?? {};
180
+ return m && Object.keys(m).length ? m : null;
181
+ }
182
+ if (network === "base_sepolia") {
183
+ const m = baseSepoliaPaymentMethods?.methods ?? {};
184
+ return m && Object.keys(m).length ? m : null;
185
+ }
186
+ return null;
187
+ }
188
+ function resolvePaymentMethodHash(nameOrBytes, opts = {}) {
189
+ const { env = "production", network = "base" } = opts;
190
+ if (nameOrBytes.startsWith("0x")) return ensureBytes32(nameOrBytes);
191
+ const mapping = getPaymentMethodMap(env, network);
192
+ if (mapping) {
193
+ const key = nameOrBytes.toLowerCase();
194
+ const entry = mapping[key];
195
+ if (entry?.paymentMethodHash) return entry.paymentMethodHash;
196
+ }
197
+ return ensureBytes32(nameOrBytes, { hashIfAscii: true });
198
+ }
199
+ function resolveFiatCurrencyBytes32(codeOrBytes) {
200
+ if (codeOrBytes.startsWith("0x")) return ensureBytes32(codeOrBytes);
201
+ return currencyKeccak256(codeOrBytes.toUpperCase());
202
+ }
203
+ function resolvePaymentMethodHashFromCatalog(processorName, catalog) {
204
+ if (!processorName) {
205
+ throw new Error("processorName is required to resolve paymentMethodHash");
206
+ }
207
+ if (processorName.startsWith("0x")) {
208
+ return ensureBytes32(processorName);
209
+ }
210
+ const key = processorName.toLowerCase();
211
+ const entry = catalog?.[key];
212
+ if (entry?.paymentMethodHash) return entry.paymentMethodHash;
213
+ const fallbackHash = METHOD_NAME_TO_HASH[key];
214
+ if (fallbackHash) return fallbackHash;
215
+ const available = Object.keys(catalog || {}).sort().join(", ");
216
+ throw new Error(
217
+ available ? `Unknown processorName: ${processorName}. Available: ${available}` : `Unknown processorName: ${processorName}. The payment methods catalog is empty or unavailable.`
218
+ );
219
+ }
220
+ function resolvePaymentMethodNameFromHash(hash, catalog) {
221
+ if (!hash) return void 0;
222
+ const target = ensureBytes32(hash);
223
+ for (const [name, entry] of Object.entries(catalog || {})) {
224
+ if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;
225
+ }
226
+ return void 0;
227
+ }
228
+
229
+ export { asciiToBytes32, ensureBytes32, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash };
230
+ //# sourceMappingURL=chunk-EIW43UIQ.mjs.map
231
+ //# sourceMappingURL=chunk-EIW43UIQ.mjs.map
@@ -0,0 +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,MAAA;AACT;AAKO,SAAS,eAAe,KAAA,EAA8B;AAC3D,EAAA,MAAM,CAAA,GAAI,QAAQ,KAAK,CAAA;AACvB,EAAA,IAAI,EAAE,MAAA,GAAS,EAAA,EAAI,MAAM,IAAI,MAAM,8BAA8B,CAAA;AACjE,EAAA,MAAM,MAAA,GAAS,IAAI,UAAA,CAAW,EAAE,CAAA;AAChC,EAAA,MAAA,CAAO,IAAI,CAAC,CAAA;AACZ,EAAA,OAAO,WAAW,MAAM,CAAA;AAC1B;AC3BO,IAAM,SAAA,GAAY,CAAC,MAAA,KAA6C;AACrE,EAAA,OAAO,UAAA,CAAW,MAAA,CAAO,QAA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IW43UIQ.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 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 ) => string;\n getFormattedSendLink: (\n recipientId: string,\n sendCurrency?: CurrencyType,\n amountFiatToSend?: 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 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 \"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// 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 baseSepoliaPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseSepolia';\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' | 'base_sepolia';\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 if (network === 'base_sepolia') {\n const m = (baseSepoliaPaymentMethods?.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' | 'base_sepolia')\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,5 +1,5 @@
1
- import { resolvePaymentMethodNameFromHash } from './chunk-RMWIECY7.mjs';
2
- import { getCurrencyInfoFromHash } from './chunk-IXZY7BSF.mjs';
1
+ import { resolvePaymentMethodNameFromHash } from './chunk-EIW43UIQ.mjs';
2
+ import { getCurrencyInfoFromHash } from './chunk-MDLTLKWK.mjs';
3
3
  import baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';
4
4
  import baseSepoliaAddressesRaw from '@zkp2p/contracts-v2/addresses/baseSepolia';
5
5
  import baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';
@@ -240,5 +240,5 @@ function enrichPvIntentView(view, chainId, env = "production") {
240
240
  }
241
241
 
242
242
  export { enrichPvDepositView, enrichPvIntentView, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, parseDepositView, parseIntentView };
243
- //# sourceMappingURL=chunk-PLKVLZVI.mjs.map
244
- //# sourceMappingURL=chunk-PLKVLZVI.mjs.map
243
+ //# sourceMappingURL=chunk-FHWDNBNQ.mjs.map
244
+ //# sourceMappingURL=chunk-FHWDNBNQ.mjs.map