@zkp2p/sdk 0.0.1 → 0.0.2
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.
- package/README.md +18 -18
- package/dist/{Zkp2pClient-CODjD_Kf.d.mts → Zkp2pClient-DcNWTyeG.d.mts} +5 -5
- package/dist/{Zkp2pClient-CODjD_Kf.d.ts → Zkp2pClient-DcNWTyeG.d.ts} +5 -5
- package/dist/{chunk-PBBMWRNE.mjs → chunk-BEZUO5YY.mjs} +2 -2
- package/dist/chunk-BEZUO5YY.mjs.map +1 -0
- package/dist/{chunk-M6S5FL2X.mjs → chunk-GDKCACWH.mjs} +2 -2
- package/dist/{chunk-M6S5FL2X.mjs.map → chunk-GDKCACWH.mjs.map} +1 -1
- package/dist/{chunk-O7DHVBCL.mjs → chunk-KLSZK5TR.mjs} +4 -4
- package/dist/{chunk-O7DHVBCL.mjs.map → chunk-KLSZK5TR.mjs.map} +1 -1
- package/dist/{chunk-JLEW4EOG.mjs → chunk-P3NOBRQB.mjs} +2 -2
- package/dist/{chunk-JLEW4EOG.mjs.map → chunk-P3NOBRQB.mjs.map} +1 -1
- package/dist/constants-CFOT2I4R.mjs +4 -0
- package/dist/{constants-DMJE2ALO.mjs.map → constants-CFOT2I4R.mjs.map} +1 -1
- package/dist/{currency-ULYH5HL2.mjs → currency-JIMAHIGJ.mjs} +3 -3
- package/dist/{currency-ULYH5HL2.mjs.map → currency-JIMAHIGJ.mjs.map} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +18 -18
- package/dist/index.mjs.map +1 -1
- package/dist/paymentResolution-4AAJVIIC.mjs +3 -0
- package/dist/{paymentResolution-S6GZR3OY.mjs.map → paymentResolution-4AAJVIIC.mjs.map} +1 -1
- package/dist/protocolViewerParsers-OYF64AE4.mjs +5 -0
- package/dist/{protocolViewerParsers-DTJLHUCH.mjs.map → protocolViewerParsers-OYF64AE4.mjs.map} +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-PBBMWRNE.mjs.map +0 -1
- package/dist/constants-DMJE2ALO.mjs +0 -4
- package/dist/paymentResolution-S6GZR3OY.mjs +0 -3
- package/dist/protocolViewerParsers-DTJLHUCH.mjs +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# @zkp2p/
|
|
1
|
+
# @zkp2p/sdk
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@zkp2p/sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
@@ -47,11 +47,11 @@ The SDK also includes supporting functionality for the broader ZKP2P ecosystem:
|
|
|
47
47
|
## Installation
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
npm install @zkp2p/
|
|
50
|
+
npm install @zkp2p/sdk viem
|
|
51
51
|
# or
|
|
52
|
-
yarn add @zkp2p/
|
|
52
|
+
yarn add @zkp2p/sdk viem
|
|
53
53
|
# or
|
|
54
|
-
pnpm add @zkp2p/
|
|
54
|
+
pnpm add @zkp2p/sdk viem
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
## Quick Start
|
|
@@ -59,7 +59,7 @@ pnpm add @zkp2p/client-sdk viem
|
|
|
59
59
|
### Initialize the Client
|
|
60
60
|
|
|
61
61
|
```typescript
|
|
62
|
-
import { OfframpClient } from '@zkp2p/
|
|
62
|
+
import { OfframpClient } from '@zkp2p/sdk';
|
|
63
63
|
import { createWalletClient, custom } from 'viem';
|
|
64
64
|
import { base } from 'viem/chains';
|
|
65
65
|
|
|
@@ -82,7 +82,7 @@ const client = new OfframpClient({
|
|
|
82
82
|
Provide liquidity by creating a deposit with your preferred payment methods and currencies:
|
|
83
83
|
|
|
84
84
|
```typescript
|
|
85
|
-
import { Currency } from '@zkp2p/
|
|
85
|
+
import { Currency } from '@zkp2p/sdk';
|
|
86
86
|
|
|
87
87
|
await client.createDeposit({
|
|
88
88
|
token: '0xUSDC_ADDRESS',
|
|
@@ -255,7 +255,7 @@ import {
|
|
|
255
255
|
usePruneExpiredIntents,
|
|
256
256
|
useSetDelegate,
|
|
257
257
|
useRemoveDelegate,
|
|
258
|
-
} from '@zkp2p/
|
|
258
|
+
} from '@zkp2p/sdk/react';
|
|
259
259
|
|
|
260
260
|
function DepositManager({ client }) {
|
|
261
261
|
const { createDeposit, isLoading, error } = useCreateDeposit({ client });
|
|
@@ -301,7 +301,7 @@ Supported payment platforms:
|
|
|
301
301
|
| MercadoPago | `mercadopago` | BRL, ARS, MXN |
|
|
302
302
|
|
|
303
303
|
```typescript
|
|
304
|
-
import { getPaymentMethodsCatalog, PLATFORM_METADATA, PAYMENT_PLATFORMS } from '@zkp2p/
|
|
304
|
+
import { getPaymentMethodsCatalog, PLATFORM_METADATA, PAYMENT_PLATFORMS } from '@zkp2p/sdk';
|
|
305
305
|
|
|
306
306
|
// Available payment platforms
|
|
307
307
|
console.log(PAYMENT_PLATFORMS); // ['wise', 'venmo', 'revolut', 'cashapp', 'mercadopago', 'zelle', 'paypal', 'monzo']
|
|
@@ -323,7 +323,7 @@ import {
|
|
|
323
323
|
currencyInfo,
|
|
324
324
|
getCurrencyInfoFromHash,
|
|
325
325
|
resolveFiatCurrencyBytes32
|
|
326
|
-
} from '@zkp2p/
|
|
326
|
+
} from '@zkp2p/sdk';
|
|
327
327
|
|
|
328
328
|
// Use currency constants
|
|
329
329
|
const usd = Currency.USD;
|
|
@@ -340,7 +340,7 @@ const usdBytes = resolveFiatCurrencyBytes32('USD');
|
|
|
340
340
|
## Contract Helpers
|
|
341
341
|
|
|
342
342
|
```typescript
|
|
343
|
-
import { getContracts, getPaymentMethodsCatalog } from '@zkp2p/
|
|
343
|
+
import { getContracts, getPaymentMethodsCatalog } from '@zkp2p/sdk';
|
|
344
344
|
|
|
345
345
|
// Get contract addresses and ABIs
|
|
346
346
|
const { addresses, abis } = getContracts(8453, 'production');
|
|
@@ -481,7 +481,7 @@ await client.setCurrencyMinRate({
|
|
|
481
481
|
## Error Handling
|
|
482
482
|
|
|
483
483
|
```typescript
|
|
484
|
-
import { ValidationError, NetworkError, ContractError } from '@zkp2p/
|
|
484
|
+
import { ValidationError, NetworkError, ContractError } from '@zkp2p/sdk';
|
|
485
485
|
|
|
486
486
|
try {
|
|
487
487
|
await client.createDeposit({ /* ... */ });
|
|
@@ -499,7 +499,7 @@ try {
|
|
|
499
499
|
## Logging
|
|
500
500
|
|
|
501
501
|
```typescript
|
|
502
|
-
import { setLogLevel } from '@zkp2p/
|
|
502
|
+
import { setLogLevel } from '@zkp2p/sdk';
|
|
503
503
|
|
|
504
504
|
// Set log level: 'debug' | 'info' | 'warn' | 'error' | 'none'
|
|
505
505
|
setLogLevel('debug');
|
|
@@ -518,13 +518,13 @@ import type {
|
|
|
518
518
|
IndexerIntent,
|
|
519
519
|
CurrencyType,
|
|
520
520
|
PaymentPlatformType,
|
|
521
|
-
} from '@zkp2p/
|
|
521
|
+
} from '@zkp2p/sdk';
|
|
522
522
|
```
|
|
523
523
|
|
|
524
524
|
## Contributing
|
|
525
525
|
|
|
526
526
|
```bash
|
|
527
|
-
cd packages/
|
|
527
|
+
cd packages/sdk
|
|
528
528
|
npm install
|
|
529
529
|
npm run build
|
|
530
530
|
npm run test
|
|
@@ -537,11 +537,11 @@ MIT License - see [LICENSE](LICENSE) for details.
|
|
|
537
537
|
|
|
538
538
|
## Links
|
|
539
539
|
|
|
540
|
-
- [NPM Package](https://www.npmjs.com/package/@zkp2p/
|
|
541
|
-
- [GitHub Repository](https://github.com/zkp2p/zkp2p-
|
|
540
|
+
- [NPM Package](https://www.npmjs.com/package/@zkp2p/sdk)
|
|
541
|
+
- [GitHub Repository](https://github.com/zkp2p/zkp2p-clients/tree/main/packages/sdk)
|
|
542
542
|
- [Documentation](https://docs.zkp2p.xyz)
|
|
543
543
|
|
|
544
544
|
## Support
|
|
545
545
|
|
|
546
|
-
- GitHub Issues: [Create an issue](https://github.com/zkp2p/zkp2p-
|
|
546
|
+
- GitHub Issues: [Create an issue](https://github.com/zkp2p/zkp2p-clients/issues)
|
|
547
547
|
- Email: support@zkp2p.xyz
|
|
@@ -8,7 +8,7 @@ import { Abi } from 'abitype';
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* import { Currency } from '@zkp2p/
|
|
11
|
+
* import { Currency } from '@zkp2p/sdk';
|
|
12
12
|
*
|
|
13
13
|
* const rates = [
|
|
14
14
|
* { currency: Currency.USD, conversionRate: '1020000000000000000' },
|
|
@@ -74,7 +74,7 @@ type CurrencyData = {
|
|
|
74
74
|
*
|
|
75
75
|
* @example
|
|
76
76
|
* ```typescript
|
|
77
|
-
* import { currencyInfo, Currency } from '@zkp2p/
|
|
77
|
+
* import { currencyInfo, Currency } from '@zkp2p/sdk';
|
|
78
78
|
*
|
|
79
79
|
* const usd = currencyInfo[Currency.USD];
|
|
80
80
|
* console.log(usd.currencyName); // "United States Dollar"
|
|
@@ -195,7 +195,7 @@ type RuntimeEnv = 'production' | 'staging';
|
|
|
195
195
|
*
|
|
196
196
|
* @example
|
|
197
197
|
* ```typescript
|
|
198
|
-
* import { getContracts } from '@zkp2p/
|
|
198
|
+
* import { getContracts } from '@zkp2p/sdk';
|
|
199
199
|
*
|
|
200
200
|
* const { addresses, abis } = getContracts(8453, 'production');
|
|
201
201
|
* console.log(addresses.escrow); // "0x..."
|
|
@@ -225,7 +225,7 @@ type PaymentMethodCatalog = Record<string, {
|
|
|
225
225
|
*
|
|
226
226
|
* @example
|
|
227
227
|
* ```typescript
|
|
228
|
-
* import { getPaymentMethodsCatalog } from '@zkp2p/
|
|
228
|
+
* import { getPaymentMethodsCatalog } from '@zkp2p/sdk';
|
|
229
229
|
*
|
|
230
230
|
* const catalog = getPaymentMethodsCatalog(8453, 'production');
|
|
231
231
|
* console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]
|
|
@@ -1114,7 +1114,7 @@ type Zkp2pNextOptions = {
|
|
|
1114
1114
|
* import { createWalletClient, http } from 'viem';
|
|
1115
1115
|
* import { base } from 'viem/chains';
|
|
1116
1116
|
* import { privateKeyToAccount } from 'viem/accounts';
|
|
1117
|
-
* import { Zkp2pClient } from '@zkp2p/
|
|
1117
|
+
* import { Zkp2pClient } from '@zkp2p/sdk';
|
|
1118
1118
|
*
|
|
1119
1119
|
* const walletClient = createWalletClient({
|
|
1120
1120
|
* account: privateKeyToAccount('0x...'),
|
|
@@ -8,7 +8,7 @@ import { Abi } from 'abitype';
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* import { Currency } from '@zkp2p/
|
|
11
|
+
* import { Currency } from '@zkp2p/sdk';
|
|
12
12
|
*
|
|
13
13
|
* const rates = [
|
|
14
14
|
* { currency: Currency.USD, conversionRate: '1020000000000000000' },
|
|
@@ -74,7 +74,7 @@ type CurrencyData = {
|
|
|
74
74
|
*
|
|
75
75
|
* @example
|
|
76
76
|
* ```typescript
|
|
77
|
-
* import { currencyInfo, Currency } from '@zkp2p/
|
|
77
|
+
* import { currencyInfo, Currency } from '@zkp2p/sdk';
|
|
78
78
|
*
|
|
79
79
|
* const usd = currencyInfo[Currency.USD];
|
|
80
80
|
* console.log(usd.currencyName); // "United States Dollar"
|
|
@@ -195,7 +195,7 @@ type RuntimeEnv = 'production' | 'staging';
|
|
|
195
195
|
*
|
|
196
196
|
* @example
|
|
197
197
|
* ```typescript
|
|
198
|
-
* import { getContracts } from '@zkp2p/
|
|
198
|
+
* import { getContracts } from '@zkp2p/sdk';
|
|
199
199
|
*
|
|
200
200
|
* const { addresses, abis } = getContracts(8453, 'production');
|
|
201
201
|
* console.log(addresses.escrow); // "0x..."
|
|
@@ -225,7 +225,7 @@ type PaymentMethodCatalog = Record<string, {
|
|
|
225
225
|
*
|
|
226
226
|
* @example
|
|
227
227
|
* ```typescript
|
|
228
|
-
* import { getPaymentMethodsCatalog } from '@zkp2p/
|
|
228
|
+
* import { getPaymentMethodsCatalog } from '@zkp2p/sdk';
|
|
229
229
|
*
|
|
230
230
|
* const catalog = getPaymentMethodsCatalog(8453, 'production');
|
|
231
231
|
* console.log(Object.keys(catalog)); // ['wise', 'venmo', 'revolut', ...]
|
|
@@ -1114,7 +1114,7 @@ type Zkp2pNextOptions = {
|
|
|
1114
1114
|
* import { createWalletClient, http } from 'viem';
|
|
1115
1115
|
* import { base } from 'viem/chains';
|
|
1116
1116
|
* import { privateKeyToAccount } from 'viem/accounts';
|
|
1117
|
-
* import { Zkp2pClient } from '@zkp2p/
|
|
1117
|
+
* import { Zkp2pClient } from '@zkp2p/sdk';
|
|
1118
1118
|
*
|
|
1119
1119
|
* const walletClient = createWalletClient({
|
|
1120
1120
|
* account: privateKeyToAccount('0x...'),
|
|
@@ -127,5 +127,5 @@ function isSupportedCurrencyHash(hash) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export { Currency, currencyInfo, currencyKeccak256, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchain, mapConversionRatesToOnchainMinRate };
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
131
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-BEZUO5YY.mjs.map
|
|
131
|
+
//# sourceMappingURL=chunk-BEZUO5YY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/keccak.ts","../src/utils/currency.ts"],"names":["_keccak256"],"mappings":";;;AAOO,IAAM,iBAAA,GAAoB,CAAC,WAAA,KAAgC;AAEhE,EAAA,OAAOA,SAAA,CAAW,WAAA,CAAY,WAAW,CAAC,CAAA;AAC5C;;;ACOO,IAAM,QAAA,GAAW;AAAA,EACtB,GAAA,EAAK,KAAA;AAAA,EACL,GAAA,EAAK,KAAA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CAAA,CAAE,cAAc,CAAA,EAAE;AAAA,IACnE,CAAC;AAAA,GACH;AACF;AAgBO,SAAS,wBAAwB,IAAA,EAAwC;AAC9E,EAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,EAAA,MAAM,CAAA,GAAI,KAAK,WAAA,EAAY;AAC3B,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,YAAY,CAAA,EAAuC;AAC/E,IAAA,MAAM,IAAA,GAAO,aAAa,GAAG,CAAA;AAC7B,IAAA,IAAI,IAAA,EAAM,gBAAA,EAAkB,WAAA,EAAY,KAAM,GAAG,OAAO,IAAA;AAAA,EAC1D;AACA,EAAA,OAAO,MAAA;AACT;AAQO,SAAS,+BAA+B,IAAA,EAAwC;AACrF,EAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,EAAA,MAAM,KAAA,GAAQ,KAAK,WAAA,EAAY;AAC/B,EAAA,OAAO,aAAa,KAAK,CAAA;AAC3B;AAcO,SAAS,wBAAwB,IAAA,EAAkC;AACxE,EAAA,OAAO,uBAAA,CAAwB,IAAI,CAAA,EAAG,YAAA;AACxC;AAQO,SAAS,wBAAwB,IAAA,EAAuB;AAC7D,EAAA,OAAO,OAAA,CAAQ,uBAAA,CAAwB,IAAI,CAAC,CAAA;AAC9C","file":"chunk-BEZUO5YY.mjs","sourcesContent":["import { keccak256 as _keccak256, sha256 as _sha256, encodePacked, stringToHex } from 'viem';\n\nexport const keccak256 = (inputString: string): string => {\n // Equivalent to solidityKeccak256(['string'], [inputString])\n return _keccak256(encodePacked(['string'], [inputString]));\n};\n\nexport const currencyKeccak256 = (inputString: string): string => {\n // Raw keccak of UTF-8 bytes\n return _keccak256(stringToHex(inputString));\n};\n\nexport const sha256 = (inputString: string): string => {\n // Equivalent to soliditySha256(['string'], [inputString])\n return _sha256(encodePacked(['string'], [inputString]));\n};\n","import { currencyKeccak256 } from './keccak';\n\n/**\n * Supported fiat currency codes.\n *\n * Use these constants when specifying currencies in conversion rates:\n *\n * @example\n * ```typescript\n * import { Currency } from '@zkp2p/sdk';\n *\n * const rates = [\n * { currency: Currency.USD, conversionRate: '1020000000000000000' },\n * { currency: Currency.EUR, conversionRate: '1100000000000000000' },\n * ];\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 MXN: 'MXN',\n MYR: 'MYR',\n NOK: 'NOK',\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} as const;\n\n/**\n * Union type of all supported currency codes.\n */\nexport type CurrencyType = (typeof Currency)[keyof typeof Currency];\n\n/**\n * Complete currency information including name, symbol, and hash.\n */\nexport type CurrencyData = {\n currency: CurrencyType;\n currencyCode: string;\n currencyName: string;\n currencySymbol: string;\n currencyCodeHash: string;\n countryCode: string;\n};\n\n/**\n * Lookup table containing metadata for all supported currencies.\n *\n * Includes currency name, symbol, keccak256 hash (for on-chain use),\n * and ISO country code for flag display.\n *\n * @example\n * ```typescript\n * import { currencyInfo, Currency } from '@zkp2p/sdk';\n *\n * const usd = currencyInfo[Currency.USD];\n * console.log(usd.currencyName); // \"United States Dollar\"\n * console.log(usd.currencySymbol); // \"$\"\n * console.log(usd.currencyCodeHash); // \"0x...\"\n * ```\n */\nexport const currencyInfo: Record<CurrencyType, CurrencyData> = {\n AED: { currency: 'AED', currencyCode: 'AED', currencyName: 'United Arab Emirates Dirham', currencyCodeHash: currencyKeccak256('AED'), currencySymbol: 'د.إ', countryCode: 'ae' },\n ARS: { currency: 'ARS', currencyCode: 'ARS', currencyName: 'Argentine Peso', currencyCodeHash: currencyKeccak256('ARS'), currencySymbol: '$', countryCode: 'ar' },\n AUD: { currency: 'AUD', currencyCode: 'AUD', currencyName: 'Australian Dollar', currencyCodeHash: currencyKeccak256('AUD'), currencySymbol: 'A$', countryCode: 'au' },\n CAD: { currency: 'CAD', currencyCode: 'CAD', currencyName: 'Canadian Dollar', currencyCodeHash: currencyKeccak256('CAD'), currencySymbol: 'C$', countryCode: 'ca' },\n CHF: { currency: 'CHF', currencyCode: 'CHF', currencyName: 'Swiss Franc', currencyCodeHash: currencyKeccak256('CHF'), currencySymbol: 'Fr', countryCode: 'ch' },\n CNY: { currency: 'CNY', currencyCode: 'CNY', currencyName: 'Chinese Yuan', currencyCodeHash: currencyKeccak256('CNY'), currencySymbol: '¥', countryCode: 'cn' },\n CZK: { currency: 'CZK', currencyCode: 'CZK', currencyName: 'Czech Koruna', currencyCodeHash: currencyKeccak256('CZK'), currencySymbol: 'Kč', countryCode: 'cz' },\n DKK: { currency: 'DKK', currencyCode: 'DKK', currencyName: 'Danish Krone', currencyCodeHash: currencyKeccak256('DKK'), currencySymbol: 'kr', countryCode: 'dk' },\n EUR: { currency: 'EUR', currencyCode: 'EUR', currencyName: 'Euro', currencyCodeHash: currencyKeccak256('EUR'), currencySymbol: '€', countryCode: 'eu' },\n GBP: { currency: 'GBP', currencyCode: 'GBP', currencyName: 'British Pound', currencyCodeHash: currencyKeccak256('GBP'), currencySymbol: '£', countryCode: 'gb' },\n HKD: { currency: 'HKD', currencyCode: 'HKD', currencyName: 'Hong Kong Dollar', currencyCodeHash: currencyKeccak256('HKD'), currencySymbol: 'HK$', countryCode: 'hk' },\n HUF: { currency: 'HUF', currencyCode: 'HUF', currencyName: 'Hungarian Forint', currencyCodeHash: currencyKeccak256('HUF'), currencySymbol: 'Ft', countryCode: 'hu' },\n IDR: { currency: 'IDR', currencyCode: 'IDR', currencyName: 'Indonesian Rupiah', currencyCodeHash: currencyKeccak256('IDR'), currencySymbol: 'Rp', countryCode: 'id' },\n ILS: { currency: 'ILS', currencyCode: 'ILS', currencyName: 'Israeli New Shekel', currencyCodeHash: currencyKeccak256('ILS'), currencySymbol: '₪', countryCode: 'il' },\n INR: { currency: 'INR', currencyCode: 'INR', currencyName: 'Indian Rupee', currencyCodeHash: currencyKeccak256('INR'), currencySymbol: '₹', countryCode: 'in' },\n JPY: { currency: 'JPY', currencyCode: 'JPY', currencyName: 'Japanese Yen', currencyCodeHash: currencyKeccak256('JPY'), currencySymbol: '¥', countryCode: 'jp' },\n KES: { currency: 'KES', currencyCode: 'KES', currencyName: 'Kenyan Shilling', currencyCodeHash: currencyKeccak256('KES'), currencySymbol: 'KSh', countryCode: 'ke' },\n MXN: { currency: 'MXN', currencyCode: 'MXN', currencyName: 'Mexican Peso', currencyCodeHash: currencyKeccak256('MXN'), currencySymbol: '$', countryCode: 'mx' },\n MYR: { currency: 'MYR', currencyCode: 'MYR', currencyName: 'Malaysian Ringgit', currencyCodeHash: currencyKeccak256('MYR'), currencySymbol: 'RM', countryCode: 'my' },\n NOK: { currency: 'NOK', currencyCode: 'NOK', currencyName: 'Norwegian Krone', currencyCodeHash: currencyKeccak256('NOK'), currencySymbol: 'kr', countryCode: 'no' },\n NZD: { currency: 'NZD', currencyCode: 'NZD', currencyName: 'New Zealand Dollar', currencyCodeHash: currencyKeccak256('NZD'), currencySymbol: 'NZ$', countryCode: 'nz' },\n PHP: { currency: 'PHP', currencyCode: 'PHP', currencyName: 'Philippine Peso', currencyCodeHash: currencyKeccak256('PHP'), currencySymbol: '₱', countryCode: 'ph' },\n PLN: { currency: 'PLN', currencyCode: 'PLN', currencyName: 'Polish Złoty', currencyCodeHash: currencyKeccak256('PLN'), currencySymbol: 'zł', countryCode: 'pl' },\n RON: { currency: 'RON', currencyCode: 'RON', currencyName: 'Romanian Leu', currencyCodeHash: currencyKeccak256('RON'), currencySymbol: 'lei', countryCode: 'ro' },\n SAR: { currency: 'SAR', currencyCode: 'SAR', currencyName: 'Saudi Riyal', currencyCodeHash: currencyKeccak256('SAR'), currencySymbol: '﷼', countryCode: 'sa' },\n SEK: { currency: 'SEK', currencyCode: 'SEK', currencyName: 'Swedish Krona', currencyCodeHash: currencyKeccak256('SEK'), currencySymbol: 'kr', countryCode: 'se' },\n SGD: { currency: 'SGD', currencyCode: 'SGD', currencyName: 'Singapore Dollar', currencyCodeHash: currencyKeccak256('SGD'), currencySymbol: 'S$', countryCode: 'sg' },\n THB: { currency: 'THB', currencyCode: 'THB', currencyName: 'Thai Baht', currencyCodeHash: currencyKeccak256('THB'), currencySymbol: '฿', countryCode: 'th' },\n TRY: { currency: 'TRY', currencyCode: 'TRY', currencyName: 'Turkish Lira', currencyCodeHash: currencyKeccak256('TRY'), currencySymbol: '₺', countryCode: 'tr' },\n UGX: { currency: 'UGX', currencyCode: 'UGX', currencyName: 'Ugandan Shilling', currencyCodeHash: currencyKeccak256('UGX'), currencySymbol: 'USh', countryCode: 'ug' },\n USD: { currency: 'USD', currencyCode: 'USD', currencyName: 'United States Dollar', currencyCodeHash: currencyKeccak256('USD'), currencySymbol: '$', countryCode: 'us' },\n VND: { currency: 'VND', currencyCode: 'VND', currencyName: 'Vietnamese Dong', currencyCodeHash: currencyKeccak256('VND'), currencySymbol: '₫', countryCode: 'vn' },\n ZAR: { currency: 'ZAR', currencyCode: 'ZAR', currencyName: 'South African Rand', currencyCodeHash: currencyKeccak256('ZAR'), currencySymbol: 'R', countryCode: 'za' },\n} as unknown as Record<CurrencyType, CurrencyData>;\n\n/**\n * UI-friendly currency rate structure used in SDK methods.\n */\nexport type UICurrencyRate = { currency: CurrencyType; conversionRate: string };\n\n/**\n * On-chain currency structure with bytes32 code and bigint rate.\n */\nexport type OnchainCurrency = { code: `0x${string}`; conversionRate: bigint };\n\n/**\n * Maps UI currency rates to on-chain format.\n *\n * @param groups - Nested array of currency rates per payment method\n * @param expectedGroups - Expected number of groups (for validation)\n * @returns On-chain formatted currency arrays\n * @throws Error if groups structure is invalid or lengths don't match\n *\n * @internal Used by createDeposit internally\n */\nexport function mapConversionRatesToOnchain(\n groups: UICurrencyRate[][],\n expectedGroups?: number\n): OnchainCurrency[][] {\n if (!Array.isArray(groups) || !Array.isArray(groups[0])) {\n throw new Error('conversionRates must be a nested array per processor');\n }\n if (typeof expectedGroups === 'number' && groups.length !== expectedGroups) {\n throw new Error(`conversionRates length (${groups.length}) must match processorNames length (${expectedGroups})`);\n }\n return groups.map((group) => group.map((r) => {\n const info = currencyInfo[r.currency as CurrencyType];\n if (!info?.currencyCodeHash) throw new Error('Invalid currency');\n return { code: info.currencyCodeHash as `0x${string}`, conversionRate: BigInt(r.conversionRate) };\n }));\n}\n\n/**\n * On-chain currency structure with minimum conversion rate (V3 escrow format).\n */\nexport type OnchainCurrencyMinRate = { code: `0x${string}`; minConversionRate: bigint };\n\n/**\n * Maps UI currency rates to on-chain V3 escrow format with minConversionRate.\n *\n * @param groups - Nested array of currency rates per payment method\n * @param expectedGroups - Expected number of groups (for validation)\n * @returns On-chain formatted currency arrays for V3 escrow\n * @throws Error if groups structure is invalid or lengths don't match\n */\nexport function mapConversionRatesToOnchainMinRate(\n groups: UICurrencyRate[][],\n expectedGroups?: number\n): OnchainCurrencyMinRate[][] {\n if (!Array.isArray(groups) || !Array.isArray(groups[0])) {\n throw new Error('conversionRates must be a nested array per payment method');\n }\n if (typeof expectedGroups === 'number' && groups.length !== expectedGroups) {\n throw new Error(`conversionRates length (${groups.length}) must match processorNames length (${expectedGroups})`);\n }\n return groups.map((group) =>\n group.map((r) => {\n const info = currencyInfo[r.currency as CurrencyType];\n const hash = info?.currencyCodeHash as `0x${string}` | undefined;\n if (!hash) throw new Error(`Invalid currency: ${r.currency}`);\n return { code: hash, minConversionRate: BigInt(r.conversionRate) };\n })\n );\n}\n\n/**\n * Looks up currency info by its keccak256 hash.\n *\n * @param hash - The currency code hash (0x-prefixed)\n * @returns Currency data if found, undefined otherwise\n *\n * @example\n * ```typescript\n * const info = getCurrencyInfoFromHash('0x...');\n * if (info) {\n * console.log(info.currencyCode); // \"USD\"\n * }\n * ```\n */\nexport function getCurrencyInfoFromHash(hash: string): CurrencyData | undefined {\n if (!hash) return undefined;\n const h = hash.toLowerCase();\n for (const key of Object.keys(currencyInfo) as Array<keyof typeof currencyInfo>) {\n const info = currencyInfo[key];\n if (info?.currencyCodeHash?.toLowerCase() === h) return info;\n }\n return undefined;\n}\n\n/**\n * Looks up currency info by ISO country code.\n *\n * @param code - The ISO country code (e.g., 'US', 'GB')\n * @returns Currency data if found, undefined otherwise\n */\nexport function getCurrencyInfoFromCountryCode(code: string): CurrencyData | undefined {\n if (!code) return undefined;\n const upper = code.toUpperCase() as CurrencyType;\n return currencyInfo[upper];\n}\n\n/**\n * Converts a currency hash to its ISO currency code.\n *\n * @param hash - The currency code hash (0x-prefixed)\n * @returns Currency code string (e.g., 'USD') or undefined if not found\n *\n * @example\n * ```typescript\n * const code = getCurrencyCodeFromHash('0x...');\n * console.log(code); // \"USD\"\n * ```\n */\nexport function getCurrencyCodeFromHash(hash: string): string | undefined {\n return getCurrencyInfoFromHash(hash)?.currencyCode;\n}\n\n/**\n * Checks if a currency hash is recognized by the SDK.\n *\n * @param hash - The currency code hash to check\n * @returns true if the hash corresponds to a supported currency\n */\nexport function isSupportedCurrencyHash(hash: string): boolean {\n return Boolean(getCurrencyInfoFromHash(hash));\n}\n"]}
|
|
@@ -71,5 +71,5 @@ function resolvePaymentMethodNameFromHash(hash, catalog) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export { asciiToBytes32, ensureBytes32, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash };
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-GDKCACWH.mjs.map
|
|
75
|
+
//# sourceMappingURL=chun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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-GDKCACWH.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(value: string, { hashIfAscii = false }: { hashIfAscii?: boolean } = {}): `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) 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 (`0x${bytesToHex(padded)}`) as `0x${string}`;\n}\n\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, asciiToBytes32 } from './bytes32';\nimport type { PaymentMethodCatalog } from '../contracts';\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(env: RuntimeEnv, network: NetworkKey): Record<string, { paymentMethodHash: `0x${string}` }> | null {\n if (env === 'staging') {\n const m = (baseStagingPaymentMethods?.methods ?? {}) as Record<string, { paymentMethodHash: `0x${string}` }>;\n return m && Object.keys(m).length ? m : null;\n }\n if (network === 'base_sepolia') {\n const m = (baseSepoliaPaymentMethods?.methods ?? {}) as Record<string, { paymentMethodHash: `0x${string}` }>;\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 (ASCII right-padded).\n *\n * If the input is already a hex string (0x-prefixed), it's normalized to bytes32.\n * Otherwise, the currency code is converted to uppercase ASCII bytes32.\n *\n * @param codeOrBytes - Currency code ('USD') or existing bytes32 hash\n * @returns bytes32 encoded currency\n *\n * @example\n * ```typescript\n * const bytes = resolveFiatCurrencyBytes32('USD');\n * // Returns: 0x5553440000000000000000000000000000000000000000000000000000000000\n * ```\n */\nexport function resolveFiatCurrencyBytes32(codeOrBytes: string): `0x${string}` {\n if (codeOrBytes.startsWith('0x')) return ensureBytes32(codeOrBytes) as `0x${string}`;\n return asciiToBytes32(codeOrBytes.toUpperCase());\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 * @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\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 const available = Object.keys(catalog || {}).sort().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-
|
|
2
|
-
import { getCurrencyInfoFromHash } from './chunk-
|
|
1
|
+
import { resolvePaymentMethodNameFromHash } from './chunk-GDKCACWH.mjs';
|
|
2
|
+
import { getCurrencyInfoFromHash } from './chunk-BEZUO5YY.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-
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-KLSZK5TR.mjs.map
|
|
244
|
+
//# sourceMappingURL=chunk-KLSZK5TR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contracts.ts","../src/utils/protocolViewerParsers.ts"],"names":[],"mappings":";;;;;;;;;;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AA,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-O7DHVBCL.mjs","sourcesContent":["/**\n * Contract resolution utilities for the SDK.\n *\n * Provides access to deployed contract addresses and ABIs for different\n * networks (Base, Base Sepolia) and environments (production, staging).\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 baseSepoliaAddressesRaw from '@zkp2p/contracts-v2/addresses/baseSepolia';\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 EscrowBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Escrow.json';\nimport OrchestratorBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Orchestrator.json';\nimport ProtocolViewerBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/ProtocolViewer.json';\nimport UnifiedPaymentVerifierBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/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 baseSepoliaPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseSepolia.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): { name?: string; chainId?: number; contracts?: Record<string, `0x${string}`> } {\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) 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): { methods?: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }> } {\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) 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 baseSepoliaAddresses = unwrapAddresses(baseSepoliaAddressesRaw);\nconst baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);\nconst basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);\nconst baseSepoliaPaymentMethods = unwrapMethods(baseSepoliaPaymentMethodsRaw);\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' | 'base_sepolia' {\n if (chainId === 84532) return 'base_sepolia';\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, 84532 for Base Sepolia)\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/client-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(chainId: number, env: RuntimeEnv = 'production'): { addresses: V2ContractAddresses; abis: V2ContractAbis } {\n const key = networkKeyFromChainId(chainId);\n\n const addressesByKey: Record<'base' | 'base_sepolia', V2ContractAddresses> = {\n base: {\n escrow: (baseAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseAddresses.contracts?.UnifiedPaymentVerifier ?? '') as `0x${string}`,\n protocolViewer: (baseAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseConstants as any).USDC,\n },\n base_sepolia: {\n escrow: (baseSepoliaAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseSepoliaAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseSepoliaAddresses.contracts?.UnifiedPaymentVerifier ?? '') as `0x${string}`,\n protocolViewer: (baseSepoliaAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n // Prefer mock USDC when available on testnet\n usdc: (baseSepoliaAddresses.contracts as any)?.USDCMock as `0x${string}` | undefined,\n },\n };\n\n const abisByKey: Record<'base' | 'base_sepolia', V2ContractAbis> = {\n base: {\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 base_sepolia: {\n escrow: EscrowBaseSepolia as unknown as Abi,\n orchestrator: OrchestratorBaseSepolia as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBaseSepolia as unknown as Abi,\n protocolViewer: ProtocolViewerBaseSepolia as unknown as Abi,\n },\n };\n\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 ?? '') 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 { addresses: addressesByKey[key], abis: abisByKey[key] };\n}\n\n/**\n * Catalog of payment methods with their hashes and supported currencies.\n */\nexport type PaymentMethodCatalog = Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>;\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/client-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(chainId: number, env: RuntimeEnv = 'production'): PaymentMethodCatalog {\n const isBaseSepolia = networkKeyFromChainId(chainId) === 'base_sepolia';\n const src = env === 'staging'\n ? (baseStagingPaymentMethods as any)\n : (isBaseSepolia ? (baseSepoliaPaymentMethods 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(chainId: number, env: RuntimeEnv = 'production'): `0x${string}` {\n // Base Staging & Production share the same gating service in current deployments\n if (env === 'staging') {\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n }\n // Testnets / Base Sepolia often use a dev signer (Hardhat 0)\n if (networkKeyFromChainId(chainId) === 'base_sepolia') {\n return '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' as `0x${string}`;\n }\n // Base mainnet (production)\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":";;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAS,gBAAgB,GAAA,EAA8F;AACrH,EAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,EAAA,MAAM,CAAA,GAAI,GAAA;AAEV,EAAA,IAAI,CAAA,CAAE,WAAW,OAAO,CAAA;AAExB,EAAA,IAAK,CAAA,CAAE,OAAA,EAAqC,SAAA,EAAW,OAAO,CAAA,CAAE,OAAA;AAEhE,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AAA,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-KLSZK5TR.mjs","sourcesContent":["/**\n * Contract resolution utilities for the SDK.\n *\n * Provides access to deployed contract addresses and ABIs for different\n * networks (Base, Base Sepolia) and environments (production, staging).\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 baseSepoliaAddressesRaw from '@zkp2p/contracts-v2/addresses/baseSepolia';\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 EscrowBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Escrow.json';\nimport OrchestratorBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Orchestrator.json';\nimport ProtocolViewerBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/ProtocolViewer.json';\nimport UnifiedPaymentVerifierBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/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 baseSepoliaPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseSepolia.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): { name?: string; chainId?: number; contracts?: Record<string, `0x${string}`> } {\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) 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): { methods?: Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }> } {\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) 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 baseSepoliaAddresses = unwrapAddresses(baseSepoliaAddressesRaw);\nconst baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);\nconst basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);\nconst baseSepoliaPaymentMethods = unwrapMethods(baseSepoliaPaymentMethodsRaw);\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' | 'base_sepolia' {\n if (chainId === 84532) return 'base_sepolia';\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, 84532 for Base Sepolia)\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(chainId: number, env: RuntimeEnv = 'production'): { addresses: V2ContractAddresses; abis: V2ContractAbis } {\n const key = networkKeyFromChainId(chainId);\n\n const addressesByKey: Record<'base' | 'base_sepolia', V2ContractAddresses> = {\n base: {\n escrow: (baseAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseAddresses.contracts?.UnifiedPaymentVerifier ?? '') as `0x${string}`,\n protocolViewer: (baseAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n usdc: (baseConstants as any).USDC,\n },\n base_sepolia: {\n escrow: (baseSepoliaAddresses.contracts?.Escrow ?? '') as `0x${string}`,\n orchestrator: (baseSepoliaAddresses.contracts?.Orchestrator ?? '') as `0x${string}`,\n unifiedPaymentVerifier: (baseSepoliaAddresses.contracts?.UnifiedPaymentVerifier ?? '') as `0x${string}`,\n protocolViewer: (baseSepoliaAddresses.contracts?.ProtocolViewer ?? '') as `0x${string}`,\n // Prefer mock USDC when available on testnet\n usdc: (baseSepoliaAddresses.contracts as any)?.USDCMock as `0x${string}` | undefined,\n },\n };\n\n const abisByKey: Record<'base' | 'base_sepolia', V2ContractAbis> = {\n base: {\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 base_sepolia: {\n escrow: EscrowBaseSepolia as unknown as Abi,\n orchestrator: OrchestratorBaseSepolia as unknown as Abi,\n unifiedPaymentVerifier: UnifiedPaymentVerifierBaseSepolia as unknown as Abi,\n protocolViewer: ProtocolViewerBaseSepolia as unknown as Abi,\n },\n };\n\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 ?? '') 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 { addresses: addressesByKey[key], abis: abisByKey[key] };\n}\n\n/**\n * Catalog of payment methods with their hashes and supported currencies.\n */\nexport type PaymentMethodCatalog = Record<string, { paymentMethodHash: `0x${string}`; currencies?: `0x${string}`[] }>;\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(chainId: number, env: RuntimeEnv = 'production'): PaymentMethodCatalog {\n const isBaseSepolia = networkKeyFromChainId(chainId) === 'base_sepolia';\n const src = env === 'staging'\n ? (baseStagingPaymentMethods as any)\n : (isBaseSepolia ? (baseSepoliaPaymentMethods 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(chainId: number, env: RuntimeEnv = 'production'): `0x${string}` {\n // Base Staging & Production share the same gating service in current deployments\n if (env === 'staging') {\n return '0x396D31055Db28C0C6f36e8b36f18FE7227248a97' as `0x${string}`;\n }\n // Testnets / Base Sepolia often use a dev signer (Hardhat 0)\n if (networkKeyFromChainId(chainId) === 'base_sepolia') {\n return '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' as `0x${string}`;\n }\n // Base mainnet (production)\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"]}
|
|
@@ -174,5 +174,5 @@ function resolvePlatformAttestationConfig(platformName) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
export { DEFAULT_BASE_API_URL, DEFAULT_WITNESS_URL, DEPLOYED_ADDRESSES, PAYMENT_PLATFORMS, PLATFORM_ATTESTATION_CONFIG, PLATFORM_METADATA, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, resolvePlatformAttestationConfig };
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-P3NOBRQB.mjs.map
|
|
178
|
+
//# sourceMappingURL=chunk-P3NOBRQB.mjs.map
|