@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.
- package/LICENSE +22 -0
- package/README.md +547 -0
- package/dist/Zkp2pClient-CODjD_Kf.d.mts +1962 -0
- package/dist/Zkp2pClient-CODjD_Kf.d.ts +1962 -0
- package/dist/chunk-GHQK65J2.mjs +47 -0
- package/dist/chunk-GHQK65J2.mjs.map +1 -0
- package/dist/chunk-JLEW4EOG.mjs +178 -0
- package/dist/chunk-JLEW4EOG.mjs.map +1 -0
- package/dist/chunk-M6S5FL2X.mjs +75 -0
- package/dist/chunk-M6S5FL2X.mjs.map +1 -0
- package/dist/chunk-O7DHVBCL.mjs +244 -0
- package/dist/chunk-O7DHVBCL.mjs.map +1 -0
- package/dist/chunk-PBBMWRNE.mjs +131 -0
- package/dist/chunk-PBBMWRNE.mjs.map +1 -0
- package/dist/constants-DMJE2ALO.mjs +4 -0
- package/dist/constants-DMJE2ALO.mjs.map +1 -0
- package/dist/currency-ULYH5HL2.mjs +3 -0
- package/dist/currency-ULYH5HL2.mjs.map +1 -0
- package/dist/index.cjs +3080 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +435 -0
- package/dist/index.d.ts +435 -0
- package/dist/index.mjs +2205 -0
- package/dist/index.mjs.map +1 -0
- package/dist/paymentResolution-S6GZR3OY.mjs +3 -0
- package/dist/paymentResolution-S6GZR3OY.mjs.map +1 -0
- package/dist/protocolViewerParsers-DTJLHUCH.mjs +5 -0
- package/dist/protocolViewerParsers-DTJLHUCH.mjs.map +1 -0
- package/dist/react.cjs +798 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.mts +277 -0
- package/dist/react.d.ts +277 -0
- package/dist/react.mjs +774 -0
- package/dist/react.mjs.map +1 -0
- package/dist/timeout-QB7K5SOB.mjs +33 -0
- package/dist/timeout-QB7K5SOB.mjs.map +1 -0
- package/package.json +120 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { D as DepositWithRelations, I as IntentEntity, V as ValidatePayeeDetailsRequest, a as ValidatePayeeDetailsResponse, P as PostDepositDetailsRequest, b as PostDepositDetailsResponse, G as GetPayeeDetailsRequest, c as GetPayeeDetailsResponse, d as GetTakerTierRequest, e as GetTakerTierResponse, f as PaymentMethodCatalog, T as TxOverrides } from './Zkp2pClient-CODjD_Kf.mjs';
|
|
2
|
+
export { A as ActionCallback, t as ApiDeposit, H as ApiIntentStatus, k as CancelIntentParams, i as CreateDepositConversionRate, C as CreateDepositParams, aq as Currency, ay as CurrencyData, ax as CurrencyType, aI as Deposit, aK as DepositCurrency, a1 as DepositIntentStatistics, w as DepositStatus, u as DepositVerifier, v as DepositVerifierCurrency, $ as DepositVerifierData, aH as DepositView, q as FiatResponse, F as FulfillIntentParams, z as GetDepositByIdRequest, B as GetDepositByIdResponse, O as GetIntentByHashRequest, U as GetIntentByHashResponse, L as GetIntentsByDepositRequest, M as GetIntentsByDepositResponse, x as GetOwnerDepositsRequest, y as GetOwnerDepositsResponse, J as GetOwnerIntentsRequest, K as GetOwnerIntentsResponse, a7 as IndexerClient, ak as IndexerDeploymentEnv, ab as IndexerDeposit, ag as IndexerDepositFilter, aj as IndexerDepositOrderDirection, ai as IndexerDepositOrderField, ah as IndexerDepositPagination, ad as IndexerDepositPaymentMethod, a9 as IndexerDepositService, an as IndexerFulfillmentAndPaymentResponse, al as IndexerFulfillmentRecord, ac as IndexerIntentFulfilled, af as IndexerIntentStatus, ae as IndexerMethodCurrency, am as IndexerPaymentVerifiedRecord, E as Intent, aL as IntentView, N as NearbyQuote, s as NearbySuggestions, Z as OfframpClient, _ as OnchainCurrency, aM as OnchainIntent, a0 as OrderStats, ao as PAYMENT_PLATFORMS, aJ as PaymentMethodData, ap as PaymentPlatformType, a5 as PlatformLimit, a6 as PlatformRiskLevel, p as QuoteFeesResponse, o as QuoteIntentResponse, Q as QuoteRequest, l as QuoteResponse, m as QuoteResponseObject, n as QuoteSingleResponse, R as Range, X as RegisterPayeeDetailsRequest, Y as RegisterPayeeDetailsResponse, j as ReleaseFundsToPayerParams, aC as RuntimeEnv, S as SignalIntentParams, a2 as TakerTier, a4 as TakerTierLevel, a3 as TakerTierStats, h as TimeoutConfig, r as TokenResponse, W as WithdrawDepositParams, Z as Zkp2pClient, g as Zkp2pClientOptions, ar as currencyInfo, a8 as defaultIndexerEndpoint, aF as enrichPvDepositView, aG as enrichPvIntentView, aa as fetchIndexerFulfillmentAndPayment, az as getContracts, au as getCurrencyCodeFromHash, at as getCurrencyInfoFromCountryCode, as as getCurrencyInfoFromHash, aB as getGatingServiceAddress, aA as getPaymentMethodsCatalog, av as isSupportedCurrencyHash, aw as mapConversionRatesToOnchainMinRate, aD as parseDepositView, aE as parseIntentView } from './Zkp2pClient-CODjD_Kf.mjs';
|
|
3
|
+
import { Abi } from 'abitype';
|
|
4
|
+
import { Hex, WalletClient, Hash } from 'viem';
|
|
5
|
+
|
|
6
|
+
interface EscrowRange {
|
|
7
|
+
min: bigint;
|
|
8
|
+
max: bigint;
|
|
9
|
+
}
|
|
10
|
+
interface EscrowDeposit {
|
|
11
|
+
depositor: string;
|
|
12
|
+
token: string;
|
|
13
|
+
depositAmount: bigint;
|
|
14
|
+
intentAmountRange: EscrowRange;
|
|
15
|
+
acceptingIntents: boolean;
|
|
16
|
+
remainingDepositAmount: bigint;
|
|
17
|
+
outstandingIntentAmount: bigint;
|
|
18
|
+
intentHashes: string[];
|
|
19
|
+
}
|
|
20
|
+
interface EscrowCurrency {
|
|
21
|
+
code: string;
|
|
22
|
+
conversionRate: bigint;
|
|
23
|
+
}
|
|
24
|
+
interface EscrowDepositVerifierData {
|
|
25
|
+
intentGatingService: string;
|
|
26
|
+
payeeDetails: string;
|
|
27
|
+
data: string;
|
|
28
|
+
paymentData?: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
};
|
|
31
|
+
paymentMethod?: string;
|
|
32
|
+
}
|
|
33
|
+
interface EscrowVerifierDataView {
|
|
34
|
+
verifier: string;
|
|
35
|
+
verificationData: EscrowDepositVerifierData;
|
|
36
|
+
currencies: EscrowCurrency[];
|
|
37
|
+
}
|
|
38
|
+
interface EscrowDepositView {
|
|
39
|
+
depositId: bigint;
|
|
40
|
+
deposit: EscrowDeposit;
|
|
41
|
+
verifiers: EscrowVerifierDataView[];
|
|
42
|
+
}
|
|
43
|
+
interface EscrowIntent {
|
|
44
|
+
owner: string;
|
|
45
|
+
to: string;
|
|
46
|
+
depositId: bigint;
|
|
47
|
+
amount: bigint;
|
|
48
|
+
timestamp: bigint;
|
|
49
|
+
paymentVerifier: string;
|
|
50
|
+
fiatCurrency: string;
|
|
51
|
+
conversionRate: bigint;
|
|
52
|
+
paymentData?: {
|
|
53
|
+
[key: string]: string;
|
|
54
|
+
};
|
|
55
|
+
paymentMethod?: string;
|
|
56
|
+
}
|
|
57
|
+
interface EscrowIntentView {
|
|
58
|
+
intentHash: string;
|
|
59
|
+
intent: EscrowIntent;
|
|
60
|
+
deposit: EscrowDepositView;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare function createCompositeDepositId(escrowAddress: string, depositId: string | bigint): string;
|
|
64
|
+
declare function convertIndexerDepositToEscrowView(deposit: DepositWithRelations, _chainId: number, _escrowAddress: string): EscrowDepositView;
|
|
65
|
+
declare function convertDepositsForLiquidity(deposits: DepositWithRelations[], chainId: number, escrowAddress: string): EscrowDepositView[];
|
|
66
|
+
declare function convertIndexerIntentsToEscrowViews(intents: IntentEntity[], depositViewsById: Map<string, EscrowDepositView>): EscrowIntentView[];
|
|
67
|
+
|
|
68
|
+
declare function apiPostDepositDetails(req: PostDepositDetailsRequest, baseApiUrl: string, timeoutMs?: number): Promise<PostDepositDetailsResponse>;
|
|
69
|
+
declare function apiGetPayeeDetails(req: GetPayeeDetailsRequest, apiKey: string, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetPayeeDetailsResponse>;
|
|
70
|
+
declare function apiValidatePayeeDetails(req: ValidatePayeeDetailsRequest, baseApiUrl: string, timeoutMs?: number): Promise<ValidatePayeeDetailsResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Get taker tier information for a specific address.
|
|
73
|
+
*/
|
|
74
|
+
declare function apiGetTakerTier(req: GetTakerTierRequest, apiKey: string | undefined, baseApiUrl: string, authToken?: string, timeoutMs?: number): Promise<GetTakerTierResponse>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* SDK Constants
|
|
78
|
+
*
|
|
79
|
+
* This module exports all public constants for the SDK including:
|
|
80
|
+
* - Payment platforms (Wise, Venmo, Revolut, etc.)
|
|
81
|
+
* - Currencies (USD, EUR, GBP, etc.)
|
|
82
|
+
* - Chain IDs and network configuration
|
|
83
|
+
* - Token metadata
|
|
84
|
+
*
|
|
85
|
+
* @module constants
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Supported blockchain chain IDs.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { SUPPORTED_CHAIN_IDS } from '@zkp2p/client-sdk';
|
|
94
|
+
*
|
|
95
|
+
* const client = new Zkp2pClient({
|
|
96
|
+
* chainId: SUPPORTED_CHAIN_IDS.BASE_MAINNET,
|
|
97
|
+
* // ...
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare const SUPPORTED_CHAIN_IDS: {
|
|
102
|
+
/** Base mainnet (8453) */
|
|
103
|
+
readonly BASE_MAINNET: 8453;
|
|
104
|
+
/** Base Sepolia testnet (84532) */
|
|
105
|
+
readonly BASE_SEPOLIA: 84532;
|
|
106
|
+
/** Scroll mainnet (534352) */
|
|
107
|
+
readonly SCROLL_MAINNET: 534352;
|
|
108
|
+
/** Local Hardhat network (31337) */
|
|
109
|
+
readonly HARDHAT: 31337;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Union type of supported chain IDs.
|
|
113
|
+
*/
|
|
114
|
+
type SupportedChainId = typeof SUPPORTED_CHAIN_IDS[keyof typeof SUPPORTED_CHAIN_IDS];
|
|
115
|
+
/**
|
|
116
|
+
* Metadata for each supported payment platform.
|
|
117
|
+
*
|
|
118
|
+
* Includes display names, logos, and the number of proofs required
|
|
119
|
+
* for payment verification.
|
|
120
|
+
*/
|
|
121
|
+
declare const PLATFORM_METADATA: {
|
|
122
|
+
readonly venmo: {
|
|
123
|
+
readonly name: "Venmo";
|
|
124
|
+
readonly displayName: "Venmo";
|
|
125
|
+
readonly logo: "💵";
|
|
126
|
+
readonly requiredProofs: 1;
|
|
127
|
+
};
|
|
128
|
+
readonly revolut: {
|
|
129
|
+
readonly name: "Revolut";
|
|
130
|
+
readonly displayName: "Revolut";
|
|
131
|
+
readonly logo: "💳";
|
|
132
|
+
readonly requiredProofs: 1;
|
|
133
|
+
};
|
|
134
|
+
readonly cashapp: {
|
|
135
|
+
readonly name: "CashApp";
|
|
136
|
+
readonly displayName: "Cash App";
|
|
137
|
+
readonly logo: "💸";
|
|
138
|
+
readonly requiredProofs: 1;
|
|
139
|
+
};
|
|
140
|
+
readonly wise: {
|
|
141
|
+
readonly name: "Wise";
|
|
142
|
+
readonly displayName: "Wise";
|
|
143
|
+
readonly logo: "🌍";
|
|
144
|
+
readonly requiredProofs: 2;
|
|
145
|
+
};
|
|
146
|
+
readonly mercadopago: {
|
|
147
|
+
readonly name: "MercadoPago";
|
|
148
|
+
readonly displayName: "Mercado Pago";
|
|
149
|
+
readonly logo: "💰";
|
|
150
|
+
readonly requiredProofs: 1;
|
|
151
|
+
};
|
|
152
|
+
readonly zelle: {
|
|
153
|
+
readonly name: "Zelle";
|
|
154
|
+
readonly displayName: "Zelle";
|
|
155
|
+
readonly logo: "💲";
|
|
156
|
+
readonly requiredProofs: 1;
|
|
157
|
+
};
|
|
158
|
+
readonly paypal: {
|
|
159
|
+
readonly name: "PayPal";
|
|
160
|
+
readonly displayName: "PayPal";
|
|
161
|
+
readonly logo: "💙";
|
|
162
|
+
readonly requiredProofs: 1;
|
|
163
|
+
};
|
|
164
|
+
readonly monzo: {
|
|
165
|
+
readonly name: "Monzo";
|
|
166
|
+
readonly displayName: "Monzo";
|
|
167
|
+
readonly logo: "🏦";
|
|
168
|
+
readonly requiredProofs: 1;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Token metadata for supported tokens.
|
|
173
|
+
*/
|
|
174
|
+
declare const TOKEN_METADATA: {
|
|
175
|
+
readonly USDC: {
|
|
176
|
+
readonly symbol: "USDC";
|
|
177
|
+
readonly decimals: 6;
|
|
178
|
+
readonly name: "USD Coin";
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Payment method resolution utilities.
|
|
184
|
+
*
|
|
185
|
+
* These functions convert between human-readable payment platform names
|
|
186
|
+
* (e.g., 'wise', 'revolut') and their on-chain bytes32 hashes.
|
|
187
|
+
*
|
|
188
|
+
* @module paymentResolution
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
type NetworkKey = 'base' | 'base_sepolia';
|
|
192
|
+
type RuntimeEnv = 'production' | 'staging';
|
|
193
|
+
/**
|
|
194
|
+
* Resolves a payment method hash from a human-readable name.
|
|
195
|
+
*
|
|
196
|
+
* First attempts to look up the hash from contracts-v2 payment method maps.
|
|
197
|
+
* Falls back to keccak256(name) when maps are unavailable.
|
|
198
|
+
*
|
|
199
|
+
* **Warning**: The fallback may not match on-chain mappings. Prefer using
|
|
200
|
+
* `resolvePaymentMethodHashFromCatalog` with an explicit catalog.
|
|
201
|
+
*
|
|
202
|
+
* @param nameOrBytes - Payment method name ('wise') or existing bytes32 hash
|
|
203
|
+
* @param opts.env - Runtime environment ('production' | 'staging')
|
|
204
|
+
* @param opts.network - Network key ('base' | 'base_sepolia')
|
|
205
|
+
* @returns bytes32 payment method hash
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* const hash = resolvePaymentMethodHash('wise', { env: 'production' });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function resolvePaymentMethodHash(nameOrBytes: string, opts?: {
|
|
213
|
+
env?: RuntimeEnv;
|
|
214
|
+
network?: NetworkKey;
|
|
215
|
+
}): `0x${string}`;
|
|
216
|
+
/**
|
|
217
|
+
* Encodes a fiat currency code into bytes32 format (ASCII right-padded).
|
|
218
|
+
*
|
|
219
|
+
* If the input is already a hex string (0x-prefixed), it's normalized to bytes32.
|
|
220
|
+
* Otherwise, the currency code is converted to uppercase ASCII bytes32.
|
|
221
|
+
*
|
|
222
|
+
* @param codeOrBytes - Currency code ('USD') or existing bytes32 hash
|
|
223
|
+
* @returns bytes32 encoded currency
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const bytes = resolveFiatCurrencyBytes32('USD');
|
|
228
|
+
* // Returns: 0x5553440000000000000000000000000000000000000000000000000000000000
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare function resolveFiatCurrencyBytes32(codeOrBytes: string): `0x${string}`;
|
|
232
|
+
/**
|
|
233
|
+
* Resolves a payment method hash from a provided catalog.
|
|
234
|
+
*
|
|
235
|
+
* This is the recommended method for resolving payment methods as it uses
|
|
236
|
+
* the exact catalog from `getPaymentMethodsCatalog()`, ensuring consistency
|
|
237
|
+
* with on-chain registrations.
|
|
238
|
+
*
|
|
239
|
+
* @param processorName - Payment platform name ('wise', 'revolut', etc.)
|
|
240
|
+
* @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`
|
|
241
|
+
* @returns bytes32 payment method hash
|
|
242
|
+
* @throws Error with available processors if not found
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* import { getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog } from '@zkp2p/client-sdk';
|
|
247
|
+
*
|
|
248
|
+
* const catalog = getPaymentMethodsCatalog(8453, 'production');
|
|
249
|
+
* const hash = resolvePaymentMethodHashFromCatalog('wise', catalog);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function resolvePaymentMethodHashFromCatalog(processorName: string, catalog: Record<string, {
|
|
253
|
+
paymentMethodHash: `0x${string}`;
|
|
254
|
+
currencies?: `0x${string}`[];
|
|
255
|
+
}>): `0x${string}`;
|
|
256
|
+
/**
|
|
257
|
+
* Reverse-lookup: converts a payment method hash back to its name.
|
|
258
|
+
*
|
|
259
|
+
* @param hash - The payment method hash (bytes32)
|
|
260
|
+
* @param catalog - Payment method catalog from `getPaymentMethodsCatalog()`
|
|
261
|
+
* @returns Payment platform name (e.g., 'wise') or undefined if not found
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const name = resolvePaymentMethodNameFromHash('0x...', catalog);
|
|
266
|
+
* console.log(name); // "wise"
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare function resolvePaymentMethodNameFromHash(hash: string, catalog: PaymentMethodCatalog): string | undefined;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Ensure a value is 32 bytes hex (0x + 64 nibbles). If ascii, keccak256 by default when hash=true.
|
|
273
|
+
*/
|
|
274
|
+
declare function ensureBytes32(value: string, { hashIfAscii }?: {
|
|
275
|
+
hashIfAscii?: boolean;
|
|
276
|
+
}): `0x${string}`;
|
|
277
|
+
/**
|
|
278
|
+
* Encode ASCII (<=32 chars) left-aligned, right-padded with zeros to 32 bytes.
|
|
279
|
+
*/
|
|
280
|
+
declare function asciiToBytes32(value: string): `0x${string}`;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Base Builder Code for ZKP2P app (registered with Base).
|
|
284
|
+
* This is ALWAYS included as the last code in attribution and cannot be overridden.
|
|
285
|
+
*/
|
|
286
|
+
declare const BASE_BUILDER_CODE = "bc_nbn6qkni";
|
|
287
|
+
/**
|
|
288
|
+
* ZKP2P iOS app referrer code - pass via txOverrides.referrer
|
|
289
|
+
*/
|
|
290
|
+
declare const ZKP2P_IOS_REFERRER = "zkp2p-ios";
|
|
291
|
+
/**
|
|
292
|
+
* ZKP2P Android app referrer code - pass via txOverrides.referrer
|
|
293
|
+
*/
|
|
294
|
+
declare const ZKP2P_ANDROID_REFERRER = "zkp2p-android";
|
|
295
|
+
/**
|
|
296
|
+
* Generate the ERC-8021 attribution data suffix for transactions.
|
|
297
|
+
*
|
|
298
|
+
* The Base builder code (bc_nbn6qkni) is ALWAYS appended last and cannot be overridden.
|
|
299
|
+
* Custom referrer codes are prepended before the base builder code.
|
|
300
|
+
*
|
|
301
|
+
* @param referrer - Optional referrer code(s) to prepend before the base builder code.
|
|
302
|
+
* Can be a single string or array of strings.
|
|
303
|
+
* These will appear BEFORE the base builder code in the attribution.
|
|
304
|
+
* @returns Hex-encoded attribution suffix
|
|
305
|
+
*/
|
|
306
|
+
declare function getAttributionDataSuffix(referrer?: string | string[]): Hex;
|
|
307
|
+
/**
|
|
308
|
+
* Append attribution data suffix to existing calldata
|
|
309
|
+
*
|
|
310
|
+
* @param calldata - Original transaction calldata
|
|
311
|
+
* @param referrer - Optional referrer code(s) to prepend before the base builder code
|
|
312
|
+
* @returns Calldata with attribution suffix appended
|
|
313
|
+
*/
|
|
314
|
+
declare function appendAttributionToCalldata(calldata: Hex, referrer?: string | string[]): Hex;
|
|
315
|
+
/**
|
|
316
|
+
* Request parameters for sendTransactionWithAttribution
|
|
317
|
+
*/
|
|
318
|
+
interface AttributionRequest {
|
|
319
|
+
address: `0x${string}`;
|
|
320
|
+
abi: Abi;
|
|
321
|
+
functionName: string;
|
|
322
|
+
args?: readonly unknown[];
|
|
323
|
+
value?: bigint;
|
|
324
|
+
}
|
|
325
|
+
type OverrideFields = Omit<TxOverrides, 'referrer'>;
|
|
326
|
+
/**
|
|
327
|
+
* Send a contract transaction with ERC-8021 attribution.
|
|
328
|
+
*
|
|
329
|
+
* 1. Encodes the function call data using encodeFunctionData
|
|
330
|
+
* 2. Appends the attribution suffix
|
|
331
|
+
* 3. Sends via sendTransaction (wallet estimates gas automatically)
|
|
332
|
+
*
|
|
333
|
+
* @param walletClient - The viem wallet client
|
|
334
|
+
* @param request - The request with abi, functionName, args, address, value
|
|
335
|
+
* @param referrer - Optional referrer code(s) from txOverrides.referrer
|
|
336
|
+
* @param overrides - Optional transaction overrides (gas, nonce, etc.)
|
|
337
|
+
* @returns Transaction hash
|
|
338
|
+
*/
|
|
339
|
+
declare function sendTransactionWithAttribution(walletClient: WalletClient, request: AttributionRequest, referrer?: string | string[], overrides?: OverrideFields): Promise<Hash>;
|
|
340
|
+
|
|
341
|
+
type LogLevel = 'error' | 'info' | 'debug';
|
|
342
|
+
declare function setLogLevel(level: LogLevel): void;
|
|
343
|
+
declare const logger: {
|
|
344
|
+
debug: (...args: any[]) => void;
|
|
345
|
+
info: (...args: any[]) => void;
|
|
346
|
+
warn: (...args: any[]) => void;
|
|
347
|
+
error: (...args: any[]) => void;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Error codes for categorizing SDK errors.
|
|
352
|
+
*/
|
|
353
|
+
declare enum ErrorCode {
|
|
354
|
+
/** Input validation failed */
|
|
355
|
+
VALIDATION = "VALIDATION",
|
|
356
|
+
/** Network/RPC error */
|
|
357
|
+
NETWORK = "NETWORK",
|
|
358
|
+
/** API request failed */
|
|
359
|
+
API = "API",
|
|
360
|
+
/** Smart contract error */
|
|
361
|
+
CONTRACT = "CONTRACT",
|
|
362
|
+
/** Unknown/uncategorized error */
|
|
363
|
+
UNKNOWN = "UNKNOWN"
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Base error class for all SDK errors.
|
|
367
|
+
*
|
|
368
|
+
* All SDK-specific errors extend this class, making it easy to catch
|
|
369
|
+
* and handle SDK errors uniformly.
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* try {
|
|
374
|
+
* await client.createDeposit(...);
|
|
375
|
+
* } catch (error) {
|
|
376
|
+
* if (error instanceof ZKP2PError) {
|
|
377
|
+
* console.log('SDK Error:', error.code, error.message);
|
|
378
|
+
* console.log('Details:', error.details);
|
|
379
|
+
* }
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
declare class ZKP2PError extends Error {
|
|
384
|
+
/** Error category code */
|
|
385
|
+
code: ErrorCode;
|
|
386
|
+
/** Additional error details (varies by error type) */
|
|
387
|
+
details?: unknown;
|
|
388
|
+
/** Field that caused the error (for validation errors) */
|
|
389
|
+
field?: string;
|
|
390
|
+
constructor(message: string, code?: ErrorCode, details?: unknown, field?: string);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Thrown when input validation fails.
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* throw new ValidationError('Amount must be positive', 'amount');
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
declare class ValidationError extends ZKP2PError {
|
|
401
|
+
constructor(message: string, field?: string, details?: unknown);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Thrown when a network or RPC request fails.
|
|
405
|
+
*/
|
|
406
|
+
declare class NetworkError extends ZKP2PError {
|
|
407
|
+
constructor(message: string, details?: unknown);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Thrown when an API request fails.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* catch (error) {
|
|
415
|
+
* if (error instanceof APIError) {
|
|
416
|
+
* console.log('HTTP Status:', error.status);
|
|
417
|
+
* }
|
|
418
|
+
* }
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare class APIError extends ZKP2PError {
|
|
422
|
+
/** HTTP status code (if applicable) */
|
|
423
|
+
status?: number;
|
|
424
|
+
constructor(message: string, status?: number, details?: unknown);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Thrown when a smart contract call fails.
|
|
428
|
+
*
|
|
429
|
+
* Check the `details` property for the underlying viem error.
|
|
430
|
+
*/
|
|
431
|
+
declare class ContractError extends ZKP2PError {
|
|
432
|
+
constructor(message: string, details?: unknown);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export { APIError, BASE_BUILDER_CODE, ContractError, ErrorCode, type EscrowDepositView, type EscrowIntentView, GetPayeeDetailsRequest, GetPayeeDetailsResponse, GetTakerTierRequest, GetTakerTierResponse, DepositWithRelations as IndexerDepositWithRelations, IntentEntity as IndexerIntent, type LogLevel, NetworkError, PLATFORM_METADATA, PaymentMethodCatalog, PostDepositDetailsRequest, PostDepositDetailsResponse, SUPPORTED_CHAIN_IDS, type SupportedChainId, TOKEN_METADATA, TxOverrides, ValidatePayeeDetailsRequest, ValidatePayeeDetailsResponse, ValidationError, ZKP2PError, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, asciiToBytes32, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, ensureBytes32, getAttributionDataSuffix, logger, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash, sendTransactionWithAttribution, setLogLevel };
|