@zkp2p/sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,47 @@
1
+ // src/errors/index.ts
2
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
3
+ ErrorCode2["VALIDATION"] = "VALIDATION";
4
+ ErrorCode2["NETWORK"] = "NETWORK";
5
+ ErrorCode2["API"] = "API";
6
+ ErrorCode2["CONTRACT"] = "CONTRACT";
7
+ ErrorCode2["UNKNOWN"] = "UNKNOWN";
8
+ return ErrorCode2;
9
+ })(ErrorCode || {});
10
+ var ZKP2PError = class extends Error {
11
+ constructor(message, code = "UNKNOWN" /* UNKNOWN */, details, field) {
12
+ super(message);
13
+ this.name = "ZKP2PError";
14
+ this.code = code;
15
+ this.details = details;
16
+ this.field = field;
17
+ }
18
+ };
19
+ var ValidationError = class extends ZKP2PError {
20
+ constructor(message, field, details) {
21
+ super(message, "VALIDATION" /* VALIDATION */, details, field);
22
+ this.name = "ValidationError";
23
+ }
24
+ };
25
+ var NetworkError = class extends ZKP2PError {
26
+ constructor(message, details) {
27
+ super(message, "NETWORK" /* NETWORK */, details);
28
+ this.name = "NetworkError";
29
+ }
30
+ };
31
+ var APIError = class extends ZKP2PError {
32
+ constructor(message, status, details) {
33
+ super(message, "API" /* API */, details);
34
+ this.status = status;
35
+ this.name = "APIError";
36
+ }
37
+ };
38
+ var ContractError = class extends ZKP2PError {
39
+ constructor(message, details) {
40
+ super(message, "CONTRACT" /* CONTRACT */, details);
41
+ this.name = "ContractError";
42
+ }
43
+ };
44
+
45
+ export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError };
46
+ //# sourceMappingURL=chunk-GHQK65J2.mjs.map
47
+ //# sourceMappingURL=chunk-GHQK65J2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors/index.ts"],"names":["ErrorCode"],"mappings":";AAGO,IAAK,SAAA,qBAAAA,UA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,iBAAe,OAAO,CAAA;AACrC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,IAAA,GAAO,UAAA;AAAA,EACd;AACF;AAOO,IAAM,aAAA,GAAN,cAA4B,UAAA,CAAW;AAAA,EAC5C,WAAA,CAAY,SAAiB,OAAA,EAAmB;AAC9C,IAAA,KAAA,CAAM,OAAA,EAAS,2BAAoB,OAAO,CAAA;AAC1C,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF","file":"chunk-GHQK65J2.mjs","sourcesContent":["/**\n * Error codes for categorizing SDK errors.\n */\nexport enum ErrorCode {\n /** Input validation failed */\n VALIDATION = 'VALIDATION',\n /** Network/RPC error */\n NETWORK = 'NETWORK',\n /** API request failed */\n API = 'API',\n /** Smart contract error */\n CONTRACT = 'CONTRACT',\n /** Unknown/uncategorized error */\n UNKNOWN = 'UNKNOWN'\n}\n\n/**\n * Base error class for all SDK errors.\n *\n * All SDK-specific errors extend this class, making it easy to catch\n * and handle SDK errors uniformly.\n *\n * @example\n * ```typescript\n * try {\n * await client.createDeposit(...);\n * } catch (error) {\n * if (error instanceof ZKP2PError) {\n * console.log('SDK Error:', error.code, error.message);\n * console.log('Details:', error.details);\n * }\n * }\n * ```\n */\nexport class ZKP2PError extends Error {\n /** Error category code */\n code: ErrorCode;\n /** Additional error details (varies by error type) */\n details?: unknown;\n /** Field that caused the error (for validation errors) */\n field?: string;\n\n constructor(message: string, code: ErrorCode = ErrorCode.UNKNOWN, details?: unknown, field?: string) {\n super(message);\n this.name = 'ZKP2PError';\n this.code = code;\n this.details = details;\n this.field = field;\n }\n}\n\n/**\n * Thrown when input validation fails.\n *\n * @example\n * ```typescript\n * throw new ValidationError('Amount must be positive', 'amount');\n * ```\n */\nexport class ValidationError extends ZKP2PError {\n constructor(message: string, field?: string, details?: unknown) {\n super(message, ErrorCode.VALIDATION, details, field);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Thrown when a network or RPC request fails.\n */\nexport class NetworkError extends ZKP2PError {\n constructor(message: string, details?: unknown) {\n super(message, ErrorCode.NETWORK, details);\n this.name = 'NetworkError';\n }\n}\n\n/**\n * Thrown when an API request fails.\n *\n * @example\n * ```typescript\n * catch (error) {\n * if (error instanceof APIError) {\n * console.log('HTTP Status:', error.status);\n * }\n * }\n * ```\n */\nexport class APIError extends ZKP2PError {\n /** HTTP status code (if applicable) */\n status?: number;\n\n constructor(message: string, status?: number, details?: unknown) {\n super(message, ErrorCode.API, details);\n this.status = status;\n this.name = 'APIError';\n }\n}\n\n/**\n * Thrown when a smart contract call fails.\n *\n * Check the `details` property for the underlying viem error.\n */\nexport class ContractError extends ZKP2PError {\n constructor(message: string, details?: unknown) {\n super(message, ErrorCode.CONTRACT, details);\n this.name = 'ContractError';\n }\n}\n\n"]}
@@ -0,0 +1,178 @@
1
+ // src/types/index.ts
2
+ var PAYMENT_PLATFORMS = [
3
+ "wise",
4
+ "venmo",
5
+ "revolut",
6
+ "cashapp",
7
+ "mercadopago",
8
+ "zelle",
9
+ "paypal",
10
+ "monzo"
11
+ ];
12
+
13
+ // src/utils/constants.ts
14
+ var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
15
+ var DEFAULT_WITNESS_URL = "https://witness-proxy.zkp2p.xyz";
16
+ var DEPLOYED_ADDRESSES = {
17
+ 8453: {
18
+ production: {
19
+ // external contracts
20
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
21
+ // escrow + verifiers
22
+ escrow: "0xCA38607D85E8F6294Dc10728669605E6664C2D70",
23
+ // Processor names to deployed addresses
24
+ venmo: "0x9a733B55a875D0DB4915c6B36350b24F8AB99dF5",
25
+ revolut: "0xAA5A1B62B01781E789C900d616300717CD9A41aB",
26
+ cashapp: "0x76D33A33068D86016B806dF02376dDBb23Dd3703",
27
+ wise: "0xFF0149799631D7A5bdE2e7eA9b306c42b3d9a9ca",
28
+ mercadopago: "0xf2AC5be14F32Cbe6A613CFF8931d95460D6c33A3",
29
+ zelle: "0x431a078A5029146aAB239c768A615CD484519aF7",
30
+ paypal: "0x03d17E9371C858072E171276979f6B44571C5DeA",
31
+ monzo: "0x0dE46433bD251027f73eD8f28E01eF05DA36a2E0",
32
+ // offchain services
33
+ gatingService: "0x396D31055Db28C0C6f36e8b36f18FE7227248a97",
34
+ zkp2pWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3"
35
+ },
36
+ staging: {
37
+ // external contracts
38
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
39
+ // escrow + verifiers
40
+ escrow: "0xC8cd114C6274Ef1066840337E7678BC9731BEa68",
41
+ // Processor names to deployed addresses
42
+ venmo: "0xCE6454f272127ba69e8C8128B92F2388Ca343257",
43
+ revolut: "0xb941e69B6C1A23A88cf9DA7D243bAE1D2Cb8eb6b",
44
+ cashapp: "0xdDB9d452180398F456Fe89A43Df9C65B19756CEa",
45
+ wise: "0x79F35E2f65ff917BE35686d34932C8Ef5a30631f",
46
+ mercadopago: "0xA2d54F983B8201c7b276C9705641C49C2FBD1A36",
47
+ zelle: "0x0Ed3c3DB9CF8458e5D9991712552539675D2C896",
48
+ paypal: "0xB07764999679a9136d6853a5D4c70449afbfc2f8",
49
+ monzo: "0x179792F99C0eFBFa06c3F6747989a96c58544f6F",
50
+ // offchain services
51
+ gatingService: "0x396D31055Db28C0C6f36e8b36f18FE7227248a97",
52
+ zkp2pWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3"
53
+ }
54
+ },
55
+ 84532: {
56
+ usdc: "0x17463cb89A62c7b4A5ecD949aFDEDBD0Aa047ad1",
57
+ escrow: "0x15EF83EBB422B4AC8e3b8393d016Ed076dc50CB7",
58
+ venmo: "0x8499f2e7c4496Acfe0D7Ca5C7b6522514877b33F",
59
+ revolut: "0x7E34909A1C1b2a4D2FAbA61c17a0F59ECAce6F29",
60
+ cashapp: "0xe4148B108Fe4D7421853FE8cFfd35bDc2c0d95Ec",
61
+ wise: "0x54c92a8828A393C5A6D1DfbB71d0e9e97329b39C",
62
+ mercadopago: "0x4367155Fe7BAA99d9AE99fE4F6aC1b8E87012e6b",
63
+ zelle: "0xbeeC239145b3c461422BC2fC45B78E5fd70862F1",
64
+ paypal: "0xC8cd114C6274Ef1066840337E7678BC9731BEa68",
65
+ monzo: "0xe2B378D9181046c84dB1156B0F90cF3108e25E9D",
66
+ gatingService: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
67
+ zkp2pWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3"
68
+ },
69
+ 31337: {
70
+ usdc: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
71
+ escrow: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
72
+ venmo: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
73
+ revolut: "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
74
+ cashapp: "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
75
+ wise: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
76
+ mercadopago: "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
77
+ zelle: "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
78
+ paypal: "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
79
+ monzo: "0x9E545E3C0baAB3E08CdfD552C960A1050f373042",
80
+ // offchain services
81
+ gatingService: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
82
+ // Hardhat 0
83
+ zkp2pWitnessSigner: "0x0636c417755E3ae25C6c166D181c0607F4C572A3"
84
+ }
85
+ };
86
+
87
+ // src/constants.ts
88
+ var SUPPORTED_CHAIN_IDS = {
89
+ /** Base mainnet (8453) */
90
+ BASE_MAINNET: 8453,
91
+ /** Base Sepolia testnet (84532) */
92
+ BASE_SEPOLIA: 84532,
93
+ /** Scroll mainnet (534352) */
94
+ SCROLL_MAINNET: 534352,
95
+ /** Local Hardhat network (31337) */
96
+ HARDHAT: 31337
97
+ };
98
+ var PLATFORM_METADATA = {
99
+ venmo: {
100
+ name: "Venmo",
101
+ displayName: "Venmo",
102
+ logo: "\u{1F4B5}",
103
+ requiredProofs: 1
104
+ },
105
+ revolut: {
106
+ name: "Revolut",
107
+ displayName: "Revolut",
108
+ logo: "\u{1F4B3}",
109
+ requiredProofs: 1
110
+ },
111
+ cashapp: {
112
+ name: "CashApp",
113
+ displayName: "Cash App",
114
+ logo: "\u{1F4B8}",
115
+ requiredProofs: 1
116
+ },
117
+ wise: {
118
+ name: "Wise",
119
+ displayName: "Wise",
120
+ logo: "\u{1F30D}",
121
+ requiredProofs: 2
122
+ },
123
+ mercadopago: {
124
+ name: "MercadoPago",
125
+ displayName: "Mercado Pago",
126
+ logo: "\u{1F4B0}",
127
+ requiredProofs: 1
128
+ },
129
+ zelle: {
130
+ name: "Zelle",
131
+ displayName: "Zelle",
132
+ logo: "\u{1F4B2}",
133
+ requiredProofs: 1
134
+ },
135
+ paypal: {
136
+ name: "PayPal",
137
+ displayName: "PayPal",
138
+ logo: "\u{1F499}",
139
+ requiredProofs: 1
140
+ },
141
+ monzo: {
142
+ name: "Monzo",
143
+ displayName: "Monzo",
144
+ logo: "\u{1F3E6}",
145
+ requiredProofs: 1
146
+ }
147
+ };
148
+ var TOKEN_METADATA = {
149
+ USDC: {
150
+ symbol: "USDC",
151
+ decimals: 6,
152
+ name: "USD Coin"
153
+ }
154
+ };
155
+ var PLATFORM_ATTESTATION_CONFIG = {
156
+ wise: { actionType: "transfer_wise", actionPlatform: "wise" },
157
+ venmo: { actionType: "transfer_venmo", actionPlatform: "venmo" },
158
+ revolut: { actionType: "transfer_revolut", actionPlatform: "revolut" },
159
+ cashapp: { actionType: "transfer_cashapp", actionPlatform: "cashapp" },
160
+ mercadopago: { actionType: "transfer_mercadopago", actionPlatform: "mercadopago" },
161
+ paypal: { actionType: "transfer_paypal", actionPlatform: "paypal" },
162
+ monzo: { actionType: "transfer_monzo", actionPlatform: "monzo" },
163
+ "zelle-chase": { actionType: "transfer_zelle", actionPlatform: "chase" },
164
+ "zelle-bofa": { actionType: "transfer_zelle", actionPlatform: "bankofamerica" },
165
+ "zelle-citi": { actionType: "transfer_zelle", actionPlatform: "citi" }
166
+ };
167
+ function resolvePlatformAttestationConfig(platformName) {
168
+ const normalized = platformName.toLowerCase();
169
+ const config = PLATFORM_ATTESTATION_CONFIG[normalized];
170
+ if (!config) {
171
+ throw new Error(`Unknown payment platform: ${platformName}`);
172
+ }
173
+ return config;
174
+ }
175
+
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-JLEW4EOG.mjs.map
178
+ //# sourceMappingURL=chunk-JLEW4EOG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/index.ts","../src/utils/constants.ts","../src/constants.ts"],"names":[],"mappings":";AAwmBO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;;;AC9mBO,IAAM,oBAAA,GAAuB;AAC7B,IAAM,mBAAA,GAAsB;AAkC5B,IAAM,kBAAA,GAAgC;AAAA,EAC3C,IAAA,EAAM;AAAA,IACJ,UAAA,EAAY;AAAA;AAAA,MAEV,IAAA,EAAM,4CAAA;AAAA;AAAA,MAGN,MAAA,EAAQ,4CAAA;AAAA;AAAA,MAGR,KAAA,EAAO,4CAAA;AAAA,MACP,OAAA,EAAS,4CAAA;AAAA,MACT,OAAA,EAAS,4CAAA;AAAA,MACT,IAAA,EAAM,4CAAA;AAAA,MACN,WAAA,EAAa,4CAAA;AAAA,MACb,KAAA,EAAO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E;AAWO,SAAS,iCAAiC,YAAA,EAAsE;AACrH,EAAA,MAAM,UAAA,GAAa,aAAa,WAAA,EAAY;AAC5C,EAAA,MAAM,MAAA,GAAS,4BAA4B,UAAU,CAAA;AACrD,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,0BAAA,EAA6B,YAAY,CAAA,CAAE,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,MAAA;AACT","file":"chunk-JLEW4EOG.mjs","sourcesContent":["// Minimal initial type surface for Offramp SDK\nimport type { AccessList, Address, AuthorizationList, Hash, WalletClient } from 'viem';\nimport type { CurrencyType } from '../utils/currency';\n\n/**\n * Timeout configuration for different operation types\n */\nexport type TimeoutConfig = {\n /** API call timeout in milliseconds (default: 30000) */\n api?: number;\n /** Transaction timeout in milliseconds (default: 60000) */\n transaction?: number;\n};\n\nexport type Zkp2pClientOptions = {\n walletClient: WalletClient;\n apiKey: string;\n chainId: number;\n environment?: 'production' | 'staging';\n baseApiUrl?: string;\n witnessUrl?: string;\n rpcUrl?: string;\n /** Optional bearer token for hybrid auth */\n authorizationToken?: string;\n /** Optional timeout configuration */\n timeouts?: TimeoutConfig;\n};\n\n/**\n * Callback function for transaction actions\n * @param params - Transaction callback parameters\n * @param params.hash - Transaction hash\n * @param params.data - Optional additional data from the transaction\n */\nexport type ActionCallback = (params: { hash: Hash; data?: unknown }) => void;\n\n/**\n * Safe transaction overrides including ERC-8021 referrers.\n * Referrer codes are prepended before the Base builder code (bc_nbn6qkni).\n */\nexport type TxOverrides = {\n gas?: bigint;\n gasPrice?: bigint;\n maxFeePerGas?: bigint;\n maxPriorityFeePerGas?: bigint;\n nonce?: number;\n value?: bigint;\n accessList?: AccessList;\n authorizationList?: AuthorizationList;\n /**\n * ERC-8021 referrer code(s) to prepend before the Base builder code.\n * Accepts a single code or multiple (e.g., ['zkp2p-bot', 'merchant-id']).\n */\n referrer?: string | string[];\n};\n\n/**\n * Parameters for fulfilling an intent with payment attestation\n */\nexport type FulfillIntentParams = {\n /** Hash of the intent to fulfill */\n intentHash: Hash;\n /** Attestation proof - object or stringified JSON from attestation service */\n proof: Record<string, unknown> | string;\n /** Optional attestation timestamp buffer override in milliseconds */\n timestampBufferMs?: number | string;\n /** Override the attestation service base URL */\n attestationServiceUrl?: string;\n /** Override the verifying contract (defaults to UnifiedPaymentVerifier) */\n verifyingContract?: Address;\n /** Optional hook payload passed to orchestrator */\n postIntentHookData?: `0x${string}`;\n /** Optional viem transaction overrides */\n txOverrides?: TxOverrides;\n /** Optional lifecycle callbacks */\n callbacks?: {\n onAttestationStart?: () => void;\n onTxSent?: (hash: Hash) => void;\n onTxMined?: (hash: Hash) => void;\n };\n};\n\n/**\n * Parameters for releasing funds back to the payer\n */\nexport type ReleaseFundsToPayerParams = {\n /** Hash of the intent to release funds for */\n intentHash: Hash;\n /** Callback when transaction is successfully sent */\n onSuccess?: ActionCallback;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n /** Callback when transaction is mined */\n onMined?: ActionCallback;\n};\n\n/**\n * Parameters for signaling an intent to use a deposit\n */\nexport type SignalIntentParams = {\n /** Payment processor name (e.g., 'wise', 'revolut') */\n processorName: string;\n /** ID of the deposit to use */\n depositId: string;\n /** Amount of tokens to transfer */\n tokenAmount: string;\n /** Payee details for the payment */\n payeeDetails: string;\n /** Recipient blockchain address */\n toAddress: string;\n /** Currency type for the payment */\n currency: CurrencyType;\n /** Callback when transaction is successfully sent */\n onSuccess?: ActionCallback;\n /** Callback when an error occurs */\n onError?: (error: Error) => void;\n /** Callback when transaction is mined */\n onMined?: ActionCallback;\n};\n\n// (removed placeholder Create/Withdraw/Cancel types; see refined forms below)\n\n/**\n * Request structure for signaling an intent via the API\n */\nexport type IntentSignalRequest = {\n /** Payment processor name */\n processorName: string;\n /** ID of the deposit */\n depositId: string;\n /** Amount of tokens */\n tokenAmount: string;\n /** Payee details */\n payeeDetails: string;\n /** Recipient address */\n toAddress: string;\n /** Fiat currency code */\n fiatCurrencyCode: string;\n /** Chain ID as string */\n chainId: string;\n};\n\n/**\n * Response from signaling an intent via the API\n */\nexport type SignalIntentResponse = {\n /** Whether the request was successful */\n success: boolean;\n /** Response message */\n message: string;\n /** Response object containing intent details */\n responseObject: {\n /** Deposit data associated with the intent */\n depositData: Record<string, string | number | boolean>;\n /** Signed intent string */\n signedIntent: string;\n /** Intent data details */\n intentData: {\n /** Deposit ID */\n depositId: string;\n /** Token amount */\n tokenAmount: string;\n /** Recipient address */\n recipientAddress: string;\n /** Verifier contract address */\n verifierAddress: string;\n /** Hash of the currency code */\n currencyCodeHash: string;\n /** Signature from the gating service */\n gatingServiceSignature: string;\n };\n };\n /** HTTP status code */\n statusCode: number;\n};\n\n/**\n * Request structure for posting deposit details\n */\nexport type PostDepositDetailsRequest = {\n /** Deposit data key-value pairs */\n depositData: { [key: string]: string };\n /** Payment processor name */\n processorName: string;\n};\n\n/**\n * Response from posting deposit details\n */\nexport type PostDepositDetailsResponse = {\n /** Whether the request was successful */\n success: boolean;\n message: string;\n responseObject: {\n id: number;\n processorName: string;\n depositData: { [key: string]: string };\n hashedOnchainId: string;\n createdAt: string;\n };\n statusCode: number;\n};\n\n/**\n * Alias types for clarity when registering payee details (makers/create)\n */\nexport type RegisterPayeeDetailsRequest = PostDepositDetailsRequest;\nexport type RegisterPayeeDetailsResponse = PostDepositDetailsResponse;\n\nexport type QuoteRequest = {\n paymentPlatforms: string[];\n fiatCurrency: string;\n user: string;\n recipient: string;\n destinationChainId: number;\n destinationToken: string;\n referrer?: string;\n useMultihop?: boolean;\n quotesToReturn?: number;\n amount: string;\n isExactFiat?: boolean;\n /** Optional filter: limit quotes to these escrow contracts */\n escrowAddresses?: string[];\n /** Enable nearby quote discovery when exact match unavailable */\n includeNearbyQuotes?: boolean;\n /** Max % deviation to search for nearby quotes (e.g., 10 = ±10%) */\n nearbySearchRange?: number;\n /** Max suggestions per direction (1-10, default: 3) */\n nearbyQuotesCount?: number;\n};\n\nexport type FiatResponse = { currencyCode: string; currencyName: string; currencySymbol: string; countryCode: string };\nexport type TokenResponse = { token: string; decimals: number; name: string; symbol: string; chainId: number };\n/**\n * Intent details within a quote response\n */\nexport type QuoteIntentResponse = {\n /** Deposit ID */\n depositId: string;\n /** Payment processor name */\n processorName: string;\n /** Amount to transfer */\n amount: string;\n /** Recipient address */\n toAddress: string;\n /** Payee details */\n payeeDetails: string;\n /** Processor-specific intent data */\n processorIntentData: Record<string, unknown>;\n /** Fiat currency code */\n fiatCurrencyCode: string;\n /** Chain ID */\n chainId: string;\n};\nexport type QuoteSingleResponse = {\n fiatAmount: string;\n fiatAmountFormatted: string;\n tokenAmount: string;\n tokenAmountFormatted: string;\n paymentMethod: string;\n payeeAddress: string;\n conversionRate: string;\n intent: QuoteIntentResponse;\n payeeData?: Record<string, string>;\n};\nexport type QuoteFeesResponse = { zkp2pFee: string; zkp2pFeeFormatted: string; swapFee: string; swapFeeFormatted: string };\n\n/**\n * A nearby quote suggestion returned when no exact match is available.\n * Fields vary based on whether request was exact-token or exact-fiat mode.\n */\nexport type NearbyQuote = {\n /** For exact-token mode: suggested token amount */\n suggestedTokenAmount?: string;\n /** For exact-token mode: formatted suggested token amount */\n suggestedTokenAmountFormatted?: string;\n /** For exact-token mode: percentage difference from requested (e.g., \"-5.0%\" or \"+10.0%\") */\n tokenPercentDifference?: string;\n /** For exact-fiat mode: suggested fiat amount */\n suggestedFiatAmount?: string;\n /** For exact-fiat mode: formatted suggested fiat amount */\n suggestedFiatAmountFormatted?: string;\n /** For exact-fiat mode: percentage difference from requested */\n fiatPercentDifference?: string;\n /** The full quote at this suggested amount */\n quote: QuoteSingleResponse;\n};\n\n/**\n * Nearby quote suggestions when no exact match is available.\n * Only present in response when includeNearbyQuotes=true and no exact quotes found.\n */\nexport type NearbySuggestions = {\n /** Quotes at amounts below the requested amount (sorted by closest first) */\n below: NearbyQuote[];\n /** Quotes at amounts above the requested amount (sorted by closest first) */\n above: NearbyQuote[];\n};\n\nexport type QuoteResponseObject = {\n fiat: FiatResponse;\n token: TokenResponse;\n quotes: QuoteSingleResponse[];\n fees: QuoteFeesResponse;\n /** Nearby suggestions when no exact quotes available (only present with includeNearbyQuotes=true) */\n nearbySuggestions?: NearbySuggestions;\n};\n\nexport type QuoteResponse = {\n message: string;\n success: boolean;\n responseObject: QuoteResponseObject;\n statusCode: number;\n};\n\n/**\n * Request to fetch payee details\n * Prefer `processorName`; `platform` kept for backward compatibility.\n */\nexport type GetPayeeDetailsRequest = { hashedOnchainId: string; processorName: string };\nexport type GetPayeeDetailsResponse = {\n success: boolean;\n message: string;\n responseObject: {\n id: number;\n processorName: string;\n depositData: { [key: string]: string };\n hashedOnchainId: string;\n createdAt: string;\n};\n statusCode: number;\n};\n\n// Makers list (presented)\nexport type ListPayeesRequest = { processorName?: string };\nexport type PresentedMaker = { id?: number; processorName: string; hashedOnchainId: string; createdAt: string };\nexport type ListPayeesResponse = { success: boolean; message: string; responseObject: PresentedMaker[]; statusCode: number };\n\nexport type ValidatePayeeDetailsRequest = {\n processorName: string;\n depositData: { [key: string]: string };\n};\n\nexport type ValidatePayeeDetailsResponse = {\n success: boolean;\n message: string;\n responseObject: { isValid: boolean; errors?: string[] };\n statusCode: number;\n};\n\n// Onchain currency and deposit verifier types used in createDeposit action\nexport type OnchainCurrency = { code: `0x${string}`; conversionRate: bigint };\nexport type DepositVerifierData = {\n intentGatingService: `0x${string}`;\n payeeDetails: string;\n data: `0x${string}`;\n};\n\n// CreateDeposit refined inputs\nexport type Range = { min: bigint; max: bigint };\nexport type CreateDepositConversionRate = { currency: CurrencyType; conversionRate: string };\nexport type CreateDepositParams = {\n token: Address;\n amount: bigint;\n intentAmountRange: Range;\n conversionRates: CreateDepositConversionRate[][];\n processorNames: string[];\n depositData: { [key: string]: string }[];\n onSuccess?: ActionCallback;\n onError?: (error: Error) => void;\n onMined?: ActionCallback;\n};\n\nexport type WithdrawDepositParams = {\n depositId: string | number | bigint;\n onSuccess?: ActionCallback;\n onError?: (error: Error) => void;\n onMined?: ActionCallback;\n};\n\nexport type CancelIntentParams = {\n intentHash: Hash;\n onSuccess?: ActionCallback;\n onError?: (error: Error) => void;\n onMined?: ActionCallback;\n};\n\n\n// Historical Event Types (for deposits and intents)\nexport type DepositStatus = 'ACTIVE' | 'WITHDRAWN' | 'CLOSED';\n\nexport type Deposit = {\n id: string;\n owner: string;\n amount: string;\n minimumIntent: string;\n maximumIntent: string;\n status: DepositStatus;\n updatedAt: Date;\n createdAt: Date;\n processorPaymentData: Array<{\n processor: string;\n paymentDetailsHash: string;\n isHashed: boolean;\n paymentDetails: string;\n updatedAt: Date;\n createdAt: Date;\n }>;\n};\n\n// API Intent status per v1 Orders API\n// Note: MANUALLY_RELEASED can occur when maker releases funds without payment verification\nexport type ApiIntentStatus = 'SIGNALED' | 'FULFILLED' | 'PRUNED' | 'MANUALLY_RELEASED';\n\nexport type Intent = {\n id: number;\n intentHash: string;\n depositId: string;\n verifier: string;\n owner: string;\n toAddress: string;\n amount: string;\n fiatCurrency: string;\n conversionRate: string;\n sustainabilityFee: string | null;\n verifierFee: string | null;\n status: ApiIntentStatus;\n signalTxHash: string;\n signalTimestamp: Date;\n fulfillTxHash: string | null;\n fulfillTimestamp: Date | null;\n pruneTxHash: string | null;\n prunedTimestamp: Date | null;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type GetOwnerIntentsRequest = {\n ownerAddress: string;\n status?: ApiIntentStatus | ApiIntentStatus[];\n};\n\nexport type GetOwnerIntentsResponse = {\n success: boolean;\n message: string;\n responseObject: Intent[];\n statusCode: number;\n};\n\n// Orders API types\nexport type GetIntentsByDepositRequest = {\n depositId: string;\n status?: ApiIntentStatus | ApiIntentStatus[];\n};\n\nexport type GetIntentsByDepositResponse = {\n success: boolean;\n message: string;\n responseObject: Intent[];\n statusCode: number;\n};\n\nexport type GetIntentsByTakerRequest = {\n takerAddress: string;\n status?: ApiIntentStatus | ApiIntentStatus[];\n};\n\nexport type GetIntentsByTakerResponse = {\n success: boolean;\n message: string;\n responseObject: Intent[];\n statusCode: number;\n};\n\nexport type GetIntentsByRecipientRequest = {\n recipientAddress: string;\n status?: ApiIntentStatus | ApiIntentStatus[];\n};\n\nexport type GetIntentsByRecipientResponse = {\n success: boolean;\n message: string;\n responseObject: Intent[];\n statusCode: number;\n};\n\nexport type GetIntentByHashRequest = {\n intentHash: string;\n};\n\nexport type GetIntentByHashResponse = {\n success: boolean;\n message: string;\n responseObject: Intent;\n statusCode: number;\n};\n\n// Deposits API types aligned with v1\nexport type DepositVerifierCurrency = { id?: number; depositVerifierId?: number; currencyCode: string; conversionRate: string; createdAt?: Date; updatedAt?: Date };\nexport type DepositVerifier = { id?: number; depositId: number; verifier: string; intentGatingService: string; payeeDetailsHash: string; data: string; createdAt?: Date; updatedAt?: Date; currencies: DepositVerifierCurrency[] };\nexport type ApiDeposit = {\n id: number;\n depositor: string;\n token: string;\n amount: string;\n remainingDeposits: string;\n intentAmountMin: string;\n intentAmountMax: string;\n acceptingIntents: boolean;\n outstandingIntentAmount: string;\n availableLiquidity: string;\n status: 'ACTIVE' | 'WITHDRAWN' | 'CLOSED';\n totalIntents: number;\n signaledIntents: number;\n fulfilledIntents: number;\n prunedIntents: number;\n createdAt?: Date;\n updatedAt?: Date;\n verifiers: DepositVerifier[];\n};\n\nexport type GetOwnerDepositsRequest = {\n ownerAddress: string;\n /** Optional status filter: 'ACTIVE' | 'WITHDRAWN' | 'CLOSED' */\n status?: DepositStatus;\n};\n\nexport type GetOwnerDepositsResponse = {\n success: boolean;\n message: string;\n responseObject: ApiDeposit[];\n statusCode: number;\n};\n\nexport type GetDepositByIdRequest = { depositId: string };\nexport type GetDepositByIdResponse = { success: boolean; message: string; responseObject: ApiDeposit; statusCode: number };\n\n// Intent/order statistics returned by `/deposits/order-stats`\nexport type OrderStats = {\n id: number;\n totalIntents: number;\n signaledIntents: number;\n fulfilledIntents: number;\n prunedIntents: number;\n};\n\n// Kept for backward compatibility\nexport type DepositIntentStatistics = OrderStats;\nexport type GetDepositsOrderStatsRequest = { depositIds: number[] };\nexport type GetDepositsOrderStatsResponse = { success: boolean; message: string; responseObject: OrderStats[]; statusCode: number };\n\n// Taker tier API types\nexport type TakerTierStats = {\n lifetimeSignaledCount: number;\n lifetimeFulfilledCount: number;\n lifetimeManualReleaseCount: number;\n lifetimePruneCount: number;\n totalCancelledVolume: string;\n totalFulfilledVolume: string;\n lockScore: string;\n lockScoreDiluted: string;\n firstSeenAt: string;\n lastIntentAt: string;\n updatedAt: string;\n};\n\nexport type TakerTierLevel = 'PEASANT' | 'PEER' | 'PLUS' | 'PRO' | 'PLATINUM' | 'PEER_PRESIDENT';\nexport type PlatformRiskLevel = 'LOW' | 'MEDIUM_HIGH' | 'HIGH' | 'HIGHEST';\n\nexport type PlatformLimit = {\n paymentMethodHash: string;\n platformName: string;\n riskLevel: PlatformRiskLevel;\n capMultiplier: number;\n effectiveCap: string;\n effectiveCapDisplay: string;\n hasCooldown: boolean;\n cooldownHours: number;\n isLocked: boolean;\n minTierRequired: TakerTierLevel | null;\n};\n\nexport type TakerTier = {\n owner: string;\n chainId: number;\n tier: TakerTierLevel;\n perIntentCapBaseUnits: string;\n perIntentCapDisplay: string;\n lastUpdated: string;\n source: 'computed' | 'fallback';\n stats: TakerTierStats | null;\n cooldownHours: number;\n cooldownSeconds: number;\n cooldownActive: boolean;\n cooldownRemainingSeconds: number;\n nextIntentAvailableAt: string | null;\n platformLimits?: PlatformLimit[];\n};\n\nexport type GetTakerTierRequest = {\n owner: string;\n chainId: number;\n};\n\nexport type GetTakerTierResponse = {\n success: boolean;\n message: string;\n responseObject: TakerTier;\n statusCode?: number;\n};\n\n// Currency domain (ISO) and on-chain currency mapping\nexport { Currency } from '../utils/currency';\nexport type { CurrencyType } from '../utils/currency';\n\n// Payment platforms (derived as a closed union for safety)\nexport const PAYMENT_PLATFORMS = [\n 'wise',\n 'venmo',\n 'revolut',\n 'cashapp',\n 'mercadopago',\n 'zelle',\n 'paypal',\n 'monzo',\n] as const;\nexport type PaymentPlatformType = typeof PAYMENT_PLATFORMS[number];\n\n\n// On-chain views\nexport type { EscrowDepositView, EscrowIntentView } from './escrowViews';\n","import type { Address } from 'viem';\n\n// Unversioned base; callers/providers must append /v1 or /v2 in adapters\nexport const DEFAULT_BASE_API_URL = 'https://api.zkp2p.xyz';\nexport const DEFAULT_WITNESS_URL = 'https://witness-proxy.zkp2p.xyz';\n\n// Enabled payment platforms (verifiers) for enrichment and platform-aware logic\nexport const ENABLED_PLATFORMS = [\n 'venmo',\n 'revolut',\n 'cashapp',\n 'wise',\n 'mercadopago',\n 'zelle',\n 'paypal',\n 'monzo',\n] as const;\n\nexport type EnabledPlatform = (typeof ENABLED_PLATFORMS)[number];\n\ntype PlatformAddresses = { [P in EnabledPlatform]: Address };\n\nexport type ContractSet = PlatformAddresses & {\n usdc: Address;\n escrow: Address;\n gatingService: Address;\n zkp2pWitnessSigner: Address;\n};\n\ntype Contracts = {\n [chainId: number]:\n | ContractSet\n | {\n production: ContractSet;\n staging: ContractSet;\n };\n};\n\nexport const DEPLOYED_ADDRESSES: Contracts = {\n 8453: {\n production: {\n // external contracts\n usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n \n // escrow + verifiers\n escrow: '0xCA38607D85E8F6294Dc10728669605E6664C2D70',\n \n // Processor names to deployed addresses\n venmo: '0x9a733B55a875D0DB4915c6B36350b24F8AB99dF5',\n revolut: '0xAA5A1B62B01781E789C900d616300717CD9A41aB',\n cashapp: '0x76D33A33068D86016B806dF02376dDBb23Dd3703',\n wise: '0xFF0149799631D7A5bdE2e7eA9b306c42b3d9a9ca',\n mercadopago: '0xf2AC5be14F32Cbe6A613CFF8931d95460D6c33A3',\n zelle: '0x431a078A5029146aAB239c768A615CD484519aF7',\n paypal: '0x03d17E9371C858072E171276979f6B44571C5DeA',\n monzo: '0x0dE46433bD251027f73eD8f28E01eF05DA36a2E0',\n \n // offchain services\n gatingService: '0x396D31055Db28C0C6f36e8b36f18FE7227248a97',\n zkp2pWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',\n },\n staging: {\n // external contracts\n usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n \n // escrow + verifiers\n escrow: '0xC8cd114C6274Ef1066840337E7678BC9731BEa68',\n \n // Processor names to deployed addresses\n venmo: '0xCE6454f272127ba69e8C8128B92F2388Ca343257',\n revolut: '0xb941e69B6C1A23A88cf9DA7D243bAE1D2Cb8eb6b',\n cashapp: '0xdDB9d452180398F456Fe89A43Df9C65B19756CEa',\n wise: '0x79F35E2f65ff917BE35686d34932C8Ef5a30631f',\n mercadopago: '0xA2d54F983B8201c7b276C9705641C49C2FBD1A36',\n zelle: '0x0Ed3c3DB9CF8458e5D9991712552539675D2C896',\n paypal: '0xB07764999679a9136d6853a5D4c70449afbfc2f8',\n monzo: '0x179792F99C0eFBFa06c3F6747989a96c58544f6F',\n \n // offchain services\n gatingService: '0x396D31055Db28C0C6f36e8b36f18FE7227248a97',\n zkp2pWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',\n },\n },\n 84532: {\n usdc: '0x17463cb89A62c7b4A5ecD949aFDEDBD0Aa047ad1',\n escrow: '0x15EF83EBB422B4AC8e3b8393d016Ed076dc50CB7',\n venmo: '0x8499f2e7c4496Acfe0D7Ca5C7b6522514877b33F',\n revolut: '0x7E34909A1C1b2a4D2FAbA61c17a0F59ECAce6F29',\n cashapp: '0xe4148B108Fe4D7421853FE8cFfd35bDc2c0d95Ec',\n wise: '0x54c92a8828A393C5A6D1DfbB71d0e9e97329b39C',\n mercadopago: '0x4367155Fe7BAA99d9AE99fE4F6aC1b8E87012e6b',\n zelle: '0xbeeC239145b3c461422BC2fC45B78E5fd70862F1',\n paypal: '0xC8cd114C6274Ef1066840337E7678BC9731BEa68',\n monzo: '0xe2B378D9181046c84dB1156B0F90cF3108e25E9D',\n \n gatingService: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',\n zkp2pWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',\n },\n 31337: {\n usdc: '0x5FbDB2315678afecb367f032d93F642f64180aa3',\n escrow: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',\n venmo: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',\n revolut: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',\n cashapp: '0x610178dA211FEF7D417bC0e6FeD39F05609AD788',\n wise: '0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82',\n mercadopago: '0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1',\n zelle: '0x3Aa5ebB10DC797CAC828524e59A333d0A371443c',\n paypal: '0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E',\n monzo: '0x9E545E3C0baAB3E08CdfD552C960A1050f373042',\n \n // offchain services\n gatingService: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', // Hardhat 0\n zkp2pWitnessSigner: '0x0636c417755E3ae25C6c166D181c0607F4C572A3',\n },\n};\n\nexport function getPlatformAddressMap(\n addresses: ContractSet\n): Record<EnabledPlatform, Address> {\n const entries = ENABLED_PLATFORMS.map((p) => [p, addresses[p]] as const);\n return Object.fromEntries(entries) as Record<EnabledPlatform, Address>;\n}\n\nexport function platformFromVerifierAddress(\n addresses: ContractSet,\n verifierAddress: string\n): EnabledPlatform | null {\n if (!verifierAddress) return null;\n const target = verifierAddress.toLowerCase();\n for (const p of ENABLED_PLATFORMS) {\n const addr = addresses[p]?.toLowerCase?.();\n if (addr && addr === target) return p;\n }\n return null;\n}\n","/**\n * SDK Constants\n *\n * This module exports all public constants for the SDK including:\n * - Payment platforms (Wise, Venmo, Revolut, etc.)\n * - Currencies (USD, EUR, GBP, etc.)\n * - Chain IDs and network configuration\n * - Token metadata\n *\n * @module constants\n */\n\n// Payment platforms\nexport { PAYMENT_PLATFORMS, type PaymentPlatformType } from './types';\n\n// Currencies\nexport { Currency, currencyInfo } from './utils/currency';\nexport type { CurrencyType, CurrencyData } from './utils/currency';\n\n// Contract addresses and deployment info\nexport { DEPLOYED_ADDRESSES } from './utils/constants';\n\n// API URLs\nexport { DEFAULT_BASE_API_URL, DEFAULT_WITNESS_URL } from './utils/constants';\n\n/**\n * Supported blockchain chain IDs.\n *\n * @example\n * ```typescript\n * import { SUPPORTED_CHAIN_IDS } from '@zkp2p/client-sdk';\n *\n * const client = new Zkp2pClient({\n * chainId: SUPPORTED_CHAIN_IDS.BASE_MAINNET,\n * // ...\n * });\n * ```\n */\nexport const SUPPORTED_CHAIN_IDS = {\n /** Base mainnet (8453) */\n BASE_MAINNET: 8453,\n /** Base Sepolia testnet (84532) */\n BASE_SEPOLIA: 84532,\n /** Scroll mainnet (534352) */\n SCROLL_MAINNET: 534352,\n /** Local Hardhat network (31337) */\n HARDHAT: 31337,\n} as const;\n\n/**\n * Union type of supported chain IDs.\n */\nexport type SupportedChainId = typeof SUPPORTED_CHAIN_IDS[keyof typeof SUPPORTED_CHAIN_IDS];\n\n/**\n * Metadata for each supported payment platform.\n *\n * Includes display names, logos, and the number of proofs required\n * for payment verification.\n */\nexport const PLATFORM_METADATA = {\n venmo: {\n name: 'Venmo',\n displayName: 'Venmo',\n logo: '💵',\n requiredProofs: 1,\n },\n revolut: {\n name: 'Revolut',\n displayName: 'Revolut',\n logo: '💳',\n requiredProofs: 1,\n },\n cashapp: {\n name: 'CashApp',\n displayName: 'Cash App',\n logo: '💸',\n requiredProofs: 1,\n },\n wise: {\n name: 'Wise',\n displayName: 'Wise',\n logo: '🌍',\n requiredProofs: 2,\n },\n mercadopago: {\n name: 'MercadoPago',\n displayName: 'Mercado Pago',\n logo: '💰',\n requiredProofs: 1,\n },\n zelle: {\n name: 'Zelle',\n displayName: 'Zelle',\n logo: '💲',\n requiredProofs: 1,\n },\n paypal: {\n name: 'PayPal',\n displayName: 'PayPal',\n logo: '💙',\n requiredProofs: 1,\n },\n monzo: {\n name: 'Monzo',\n displayName: 'Monzo',\n logo: '🏦',\n requiredProofs: 1,\n },\n} as const;\n\n/**\n * Token metadata for supported tokens.\n */\nexport const TOKEN_METADATA = {\n USDC: {\n symbol: 'USDC',\n decimals: 6,\n name: 'USD Coin',\n },\n} as const;\n\n/**\n * Attestation service configuration for each payment platform.\n *\n * Maps platform names to their corresponding action types for the\n * attestation service endpoints.\n *\n * @internal Used internally by fulfillIntent\n */\nexport const PLATFORM_ATTESTATION_CONFIG: Record<string, { actionType: string; actionPlatform: string }> = {\n wise: { actionType: 'transfer_wise', actionPlatform: 'wise' },\n venmo: { actionType: 'transfer_venmo', actionPlatform: 'venmo' },\n revolut: { actionType: 'transfer_revolut', actionPlatform: 'revolut' },\n cashapp: { actionType: 'transfer_cashapp', actionPlatform: 'cashapp' },\n mercadopago: { actionType: 'transfer_mercadopago', actionPlatform: 'mercadopago' },\n paypal: { actionType: 'transfer_paypal', actionPlatform: 'paypal' },\n monzo: { actionType: 'transfer_monzo', actionPlatform: 'monzo' },\n 'zelle-chase': { actionType: 'transfer_zelle', actionPlatform: 'chase' },\n 'zelle-bofa': { actionType: 'transfer_zelle', actionPlatform: 'bankofamerica' },\n 'zelle-citi': { actionType: 'transfer_zelle', actionPlatform: 'citi' },\n} as const;\n\n/**\n * Resolves attestation platform configuration for a given payment platform.\n *\n * @param platformName - The payment platform name (e.g., 'wise', 'venmo', 'zelle-citi')\n * @returns Attestation configuration with actionType and actionPlatform\n * @throws Error if the platform is not supported\n *\n * @internal Used internally by fulfillIntent\n */\nexport function resolvePlatformAttestationConfig(platformName: string): { actionType: string; actionPlatform: string } {\n const normalized = platformName.toLowerCase();\n const config = PLATFORM_ATTESTATION_CONFIG[normalized];\n if (!config) {\n throw new Error(`Unknown payment platform: ${platformName}`);\n }\n return config;\n}\n"]}
@@ -0,0 +1,75 @@
1
+ import { hexToBytes, keccak256, toBytes, bytesToHex } from 'viem';
2
+ import baseSepoliaPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseSepolia';
3
+ import baseStagingPaymentMethods from '@zkp2p/contracts-v2/paymentMethods/baseStaging';
4
+
5
+ // src/utils/bytes32.ts
6
+ function ensureBytes32(value, { hashIfAscii = false } = {}) {
7
+ if (value.startsWith("0x")) {
8
+ const bytes = hexToBytes(value);
9
+ if (bytes.length !== 32) throw new Error("Expected 32-byte hex value");
10
+ return value;
11
+ }
12
+ if (!hashIfAscii) throw new Error("Expected 32-byte hex; received ascii string. Pass hashIfAscii=true to hash.");
13
+ const hashed = keccak256(toBytes(value));
14
+ return hashed;
15
+ }
16
+ function asciiToBytes32(value) {
17
+ const b = toBytes(value);
18
+ if (b.length > 32) throw new Error("ASCII input exceeds 32 bytes");
19
+ const padded = new Uint8Array(32);
20
+ padded.set(b);
21
+ return `0x${bytesToHex(padded)}`;
22
+ }
23
+ function getPaymentMethodMap(env, network) {
24
+ if (env === "staging") {
25
+ const m = baseStagingPaymentMethods?.methods ?? {};
26
+ return m && Object.keys(m).length ? m : null;
27
+ }
28
+ if (network === "base_sepolia") {
29
+ const m = baseSepoliaPaymentMethods?.methods ?? {};
30
+ return m && Object.keys(m).length ? m : null;
31
+ }
32
+ return null;
33
+ }
34
+ function resolvePaymentMethodHash(nameOrBytes, opts = {}) {
35
+ const { env = "production", network = "base" } = opts;
36
+ if (nameOrBytes.startsWith("0x")) return ensureBytes32(nameOrBytes);
37
+ const mapping = getPaymentMethodMap(env, network);
38
+ if (mapping) {
39
+ const key = nameOrBytes.toLowerCase();
40
+ const entry = mapping[key];
41
+ if (entry?.paymentMethodHash) return entry.paymentMethodHash;
42
+ }
43
+ return ensureBytes32(nameOrBytes, { hashIfAscii: true });
44
+ }
45
+ function resolveFiatCurrencyBytes32(codeOrBytes) {
46
+ if (codeOrBytes.startsWith("0x")) return ensureBytes32(codeOrBytes);
47
+ return asciiToBytes32(codeOrBytes.toUpperCase());
48
+ }
49
+ function resolvePaymentMethodHashFromCatalog(processorName, catalog) {
50
+ if (!processorName) {
51
+ throw new Error("processorName is required to resolve paymentMethodHash");
52
+ }
53
+ if (processorName.startsWith("0x")) {
54
+ return ensureBytes32(processorName);
55
+ }
56
+ const key = processorName.toLowerCase();
57
+ const entry = catalog?.[key];
58
+ if (entry?.paymentMethodHash) return entry.paymentMethodHash;
59
+ const available = Object.keys(catalog || {}).sort().join(", ");
60
+ throw new Error(
61
+ available ? `Unknown processorName: ${processorName}. Available: ${available}` : `Unknown processorName: ${processorName}. The payment methods catalog is empty or unavailable.`
62
+ );
63
+ }
64
+ function resolvePaymentMethodNameFromHash(hash, catalog) {
65
+ if (!hash) return void 0;
66
+ const target = ensureBytes32(hash);
67
+ for (const [name, entry] of Object.entries(catalog || {})) {
68
+ if (entry?.paymentMethodHash?.toLowerCase() === target.toLowerCase()) return name;
69
+ }
70
+ return void 0;
71
+ }
72
+
73
+ export { asciiToBytes32, ensureBytes32, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash };
74
+ //# sourceMappingURL=chunk-M6S5FL2X.mjs.map
75
+ //# sourceMappingURL=chunk-M6S5FL2X.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/bytes32.ts","../src/utils/paymentResolution.ts"],"names":[],"mappings":";;;;;AAKO,SAAS,cAAc,KAAA,EAAe,EAAE,cAAc,KAAA,EAAM,GAA+B,EAAC,EAAkB;AACnH,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,EAAa,MAAM,IAAI,MAAM,6EAA6E,CAAA;AAC/G,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,OAAA,CAAQ,KAAK,CAAC,CAAA;AACvC,EAAA,OAAO,MAAA;AACT;AAKO,SAAS,eAAe,KAAA,EAA8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AA,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-M6S5FL2X.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/client-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"]}
@@ -0,0 +1,244 @@
1
+ import { resolvePaymentMethodNameFromHash } from './chunk-M6S5FL2X.mjs';
2
+ import { getCurrencyInfoFromHash } from './chunk-PBBMWRNE.mjs';
3
+ import baseAddressesRaw from '@zkp2p/contracts-v2/addresses/base';
4
+ import baseSepoliaAddressesRaw from '@zkp2p/contracts-v2/addresses/baseSepolia';
5
+ import baseStagingAddressesRaw from '@zkp2p/contracts-v2/addresses/baseStaging';
6
+ import EscrowBase from '@zkp2p/contracts-v2/abis/base/Escrow.json';
7
+ import OrchestratorBase from '@zkp2p/contracts-v2/abis/base/Orchestrator.json';
8
+ import ProtocolViewerBase from '@zkp2p/contracts-v2/abis/base/ProtocolViewer.json';
9
+ import UnifiedPaymentVerifierBase from '@zkp2p/contracts-v2/abis/base/UnifiedPaymentVerifier.json';
10
+ import EscrowBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Escrow.json';
11
+ import OrchestratorBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/Orchestrator.json';
12
+ import ProtocolViewerBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/ProtocolViewer.json';
13
+ import UnifiedPaymentVerifierBaseSepolia from '@zkp2p/contracts-v2/abis/baseSepolia/UnifiedPaymentVerifier.json';
14
+ import EscrowBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Escrow.json';
15
+ import OrchestratorBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/Orchestrator.json';
16
+ import UnifiedPaymentVerifierBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/UnifiedPaymentVerifier.json';
17
+ import ProtocolViewerBaseStaging from '@zkp2p/contracts-v2/abis/baseStaging/ProtocolViewer.json';
18
+ import baseConstantsRaw from '@zkp2p/contracts-v2/constants/base';
19
+ import baseStagingConstantsRaw from '@zkp2p/contracts-v2/constants/baseStaging';
20
+ import basePaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/base.json';
21
+ import baseSepoliaPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseSepolia.json';
22
+ import baseStagingPaymentMethodsRaw from '@zkp2p/contracts-v2/paymentMethods/baseStaging.json';
23
+
24
+ function unwrapAddresses(mod) {
25
+ if (!mod) return {};
26
+ const m = mod;
27
+ if (m.contracts) return m;
28
+ if (m.default?.contracts) return m.default;
29
+ try {
30
+ const d = typeof m.default === "function" ? m.default() : m.default;
31
+ if (d?.contracts) return d;
32
+ } catch {
33
+ }
34
+ return m;
35
+ }
36
+ function unwrapMethods(mod) {
37
+ if (!mod) return {};
38
+ const m = mod;
39
+ if (m.methods) return m;
40
+ if (m.default?.methods) return m.default;
41
+ try {
42
+ const d = typeof m.default === "function" ? m.default() : m.default;
43
+ if (d?.methods) return d;
44
+ } catch {
45
+ }
46
+ return m;
47
+ }
48
+ function unwrapConstants(mod) {
49
+ if (!mod) return {};
50
+ const m = mod;
51
+ if (m.USDC) return m;
52
+ if (m.default?.USDC) return m.default;
53
+ try {
54
+ const d = typeof m.default === "function" ? m.default() : m.default;
55
+ if (d?.USDC) return d;
56
+ } catch {
57
+ }
58
+ return m;
59
+ }
60
+ var baseAddresses = unwrapAddresses(baseAddressesRaw);
61
+ var baseSepoliaAddresses = unwrapAddresses(baseSepoliaAddressesRaw);
62
+ var baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw);
63
+ var basePaymentMethods = unwrapMethods(basePaymentMethodsRaw);
64
+ var baseSepoliaPaymentMethods = unwrapMethods(baseSepoliaPaymentMethodsRaw);
65
+ var baseStagingPaymentMethods = unwrapMethods(baseStagingPaymentMethodsRaw);
66
+ var baseConstants = unwrapConstants(baseConstantsRaw);
67
+ var baseStagingConstants = unwrapConstants(baseStagingConstantsRaw);
68
+ function networkKeyFromChainId(chainId) {
69
+ if (chainId === 84532) return "base_sepolia";
70
+ return "base";
71
+ }
72
+ function getContracts(chainId, env = "production") {
73
+ const key = networkKeyFromChainId(chainId);
74
+ const addressesByKey = {
75
+ base: {
76
+ escrow: baseAddresses.contracts?.Escrow ?? "",
77
+ orchestrator: baseAddresses.contracts?.Orchestrator ?? "",
78
+ unifiedPaymentVerifier: baseAddresses.contracts?.UnifiedPaymentVerifier ?? "",
79
+ protocolViewer: baseAddresses.contracts?.ProtocolViewer ?? "",
80
+ usdc: baseConstants.USDC
81
+ },
82
+ base_sepolia: {
83
+ escrow: baseSepoliaAddresses.contracts?.Escrow ?? "",
84
+ orchestrator: baseSepoliaAddresses.contracts?.Orchestrator ?? "",
85
+ unifiedPaymentVerifier: baseSepoliaAddresses.contracts?.UnifiedPaymentVerifier ?? "",
86
+ protocolViewer: baseSepoliaAddresses.contracts?.ProtocolViewer ?? "",
87
+ // Prefer mock USDC when available on testnet
88
+ usdc: baseSepoliaAddresses.contracts?.USDCMock
89
+ }
90
+ };
91
+ const abisByKey = {
92
+ base: {
93
+ escrow: EscrowBase,
94
+ orchestrator: OrchestratorBase,
95
+ unifiedPaymentVerifier: UnifiedPaymentVerifierBase,
96
+ protocolViewer: ProtocolViewerBase
97
+ },
98
+ base_sepolia: {
99
+ escrow: EscrowBaseSepolia,
100
+ orchestrator: OrchestratorBaseSepolia,
101
+ unifiedPaymentVerifier: UnifiedPaymentVerifierBaseSepolia,
102
+ protocolViewer: ProtocolViewerBaseSepolia
103
+ }
104
+ };
105
+ if (env === "staging") {
106
+ return {
107
+ addresses: {
108
+ escrow: baseStagingAddresses.contracts?.Escrow ?? "",
109
+ orchestrator: baseStagingAddresses.contracts?.Orchestrator ?? "",
110
+ unifiedPaymentVerifier: baseStagingAddresses.contracts?.UnifiedPaymentVerifier ?? "",
111
+ protocolViewer: baseStagingAddresses.contracts?.ProtocolViewer ?? "",
112
+ usdc: baseStagingConstants.USDC
113
+ },
114
+ abis: {
115
+ escrow: EscrowBaseStaging,
116
+ orchestrator: OrchestratorBaseStaging,
117
+ unifiedPaymentVerifier: UnifiedPaymentVerifierBaseStaging,
118
+ protocolViewer: ProtocolViewerBaseStaging
119
+ }
120
+ };
121
+ }
122
+ return { addresses: addressesByKey[key], abis: abisByKey[key] };
123
+ }
124
+ function getPaymentMethodsCatalog(chainId, env = "production") {
125
+ const isBaseSepolia = networkKeyFromChainId(chainId) === "base_sepolia";
126
+ const src = env === "staging" ? baseStagingPaymentMethods : isBaseSepolia ? baseSepoliaPaymentMethods : basePaymentMethods;
127
+ const methods = src?.methods ?? src?.default?.methods ?? {};
128
+ return methods;
129
+ }
130
+ function getGatingServiceAddress(chainId, env = "production") {
131
+ if (env === "staging") {
132
+ return "0x396D31055Db28C0C6f36e8b36f18FE7227248a97";
133
+ }
134
+ if (networkKeyFromChainId(chainId) === "base_sepolia") {
135
+ return "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
136
+ }
137
+ return "0x396D31055Db28C0C6f36e8b36f18FE7227248a97";
138
+ }
139
+
140
+ // src/utils/protocolViewerParsers.ts
141
+ function toBigInt(v) {
142
+ if (typeof v === "bigint") return v;
143
+ if (typeof v === "number") return BigInt(v);
144
+ if (typeof v === "string") return BigInt(v);
145
+ if (v && typeof v.toString === "function") return BigInt(v.toString());
146
+ throw new Error("Unsupported numeric type for bigint conversion");
147
+ }
148
+ function parseDepositView(raw) {
149
+ return {
150
+ depositId: toBigInt(raw.depositId),
151
+ deposit: {
152
+ depositor: raw.deposit.depositor,
153
+ delegate: raw.deposit.delegate,
154
+ token: raw.deposit.token,
155
+ amount: toBigInt(raw.deposit.amount),
156
+ intentAmountRange: {
157
+ min: toBigInt(raw.deposit.intentAmountRange.min),
158
+ max: toBigInt(raw.deposit.intentAmountRange.max)
159
+ },
160
+ acceptingIntents: raw.deposit.acceptingIntents,
161
+ remainingDeposits: toBigInt(raw.deposit.remainingDeposits),
162
+ outstandingIntentAmount: toBigInt(raw.deposit.outstandingIntentAmount),
163
+ makerProtocolFee: toBigInt(raw.deposit.makerProtocolFee ?? 0),
164
+ reservedMakerFees: toBigInt(raw.deposit.reservedMakerFees ?? 0),
165
+ accruedMakerFees: toBigInt(raw.deposit.accruedMakerFees ?? 0),
166
+ accruedReferrerFees: toBigInt(raw.deposit.accruedReferrerFees ?? 0),
167
+ intentGuardian: raw.deposit.intentGuardian,
168
+ referrer: raw.deposit.referrer,
169
+ referrerFee: toBigInt(raw.deposit.referrerFee ?? 0)
170
+ },
171
+ availableLiquidity: toBigInt(raw.availableLiquidity),
172
+ paymentMethods: (raw.paymentMethods || []).map((pm) => ({
173
+ paymentMethod: pm.paymentMethod,
174
+ verificationData: {
175
+ intentGatingService: pm.verificationData.intentGatingService,
176
+ payeeDetails: pm.verificationData.payeeDetails,
177
+ data: pm.verificationData.data
178
+ },
179
+ currencies: (pm.currencies || []).map((c) => ({
180
+ code: c.code,
181
+ minConversionRate: toBigInt(c.minConversionRate)
182
+ }))
183
+ })),
184
+ intentHashes: raw.intentHashes || []
185
+ };
186
+ }
187
+ function parseIntentView(raw) {
188
+ const parsedDeposit = parseDepositView(raw.deposit);
189
+ const deposit = {
190
+ depositId: parsedDeposit.depositId,
191
+ deposit: parsedDeposit.deposit,
192
+ availableLiquidity: parsedDeposit.availableLiquidity,
193
+ paymentMethods: parsedDeposit.paymentMethods
194
+ };
195
+ return {
196
+ intentHash: raw.intentHash,
197
+ intent: {
198
+ owner: raw.intent.owner,
199
+ to: raw.intent.to,
200
+ escrow: raw.intent.escrow,
201
+ depositId: toBigInt(raw.intent.depositId),
202
+ amount: toBigInt(raw.intent.amount),
203
+ timestamp: toBigInt(raw.intent.timestamp),
204
+ paymentMethod: raw.intent.paymentMethod,
205
+ fiatCurrency: raw.intent.fiatCurrency,
206
+ conversionRate: toBigInt(raw.intent.conversionRate),
207
+ referrer: raw.intent.referrer,
208
+ referrerFee: toBigInt(raw.intent.referrerFee ?? 0),
209
+ postIntentHook: raw.intent.postIntentHook,
210
+ data: raw.intent.data
211
+ },
212
+ deposit
213
+ };
214
+ }
215
+ function enrichPvDepositView(view, chainId, env = "production") {
216
+ const catalog = getPaymentMethodsCatalog(chainId, env);
217
+ return {
218
+ ...view,
219
+ paymentMethods: view.paymentMethods.map((pm) => ({
220
+ ...pm,
221
+ processorName: resolvePaymentMethodNameFromHash(pm.paymentMethod, catalog),
222
+ currencies: pm.currencies.map((c) => ({
223
+ ...c,
224
+ currencyInfo: getCurrencyInfoFromHash(c.code)
225
+ }))
226
+ }))
227
+ };
228
+ }
229
+ function enrichPvIntentView(view, chainId, env = "production") {
230
+ const catalog = getPaymentMethodsCatalog(chainId, env);
231
+ return {
232
+ ...view,
233
+ intent: {
234
+ ...view.intent,
235
+ processorName: resolvePaymentMethodNameFromHash(view.intent.paymentMethod, catalog),
236
+ currencyInfo: getCurrencyInfoFromHash(view.intent.fiatCurrency)
237
+ },
238
+ deposit: enrichPvDepositView(view.deposit, chainId, env)
239
+ };
240
+ }
241
+
242
+ export { enrichPvDepositView, enrichPvIntentView, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, parseDepositView, parseIntentView };
243
+ //# sourceMappingURL=chunk-O7DHVBCL.mjs.map
244
+ //# sourceMappingURL=chunk-O7DHVBCL.mjs.map