@t402/vue 2.0.0
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/dist/cjs/index.cjs +746 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +600 -0
- package/dist/esm/index.d.ts +600 -0
- package/dist/esm/index.js +720 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { PropType, Ref, ComputedRef } from 'vue';
|
|
3
|
+
import { PaymentRequired, PaymentRequirements } from '@t402/core/types';
|
|
4
|
+
export { PaymentRequired, PaymentRequirements } from '@t402/core/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A simple loading spinner component.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```vue
|
|
11
|
+
* <template>
|
|
12
|
+
* <Spinner size="md" />
|
|
13
|
+
* </template>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare const Spinner: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
17
|
+
size: {
|
|
18
|
+
type: PropType<"sm" | "md" | "lg">;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
+
size: {
|
|
25
|
+
type: PropType<"sm" | "md" | "lg">;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
}>> & Readonly<{}>, {
|
|
29
|
+
size: "sm" | "md" | "lg";
|
|
30
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
31
|
+
declare const spinnerStyles = "\n@keyframes t402-spin {\n to { transform: rotate(360deg); }\n}\n";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A payment button component with loading state support.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```vue
|
|
38
|
+
* <template>
|
|
39
|
+
* <PaymentButton
|
|
40
|
+
* @click="handlePayment"
|
|
41
|
+
* :loading="isProcessing"
|
|
42
|
+
* variant="primary"
|
|
43
|
+
* size="lg"
|
|
44
|
+
* >
|
|
45
|
+
* Pay $10.00
|
|
46
|
+
* </PaymentButton>
|
|
47
|
+
* </template>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare const PaymentButton: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
51
|
+
disabled: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
loading: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
variant: {
|
|
60
|
+
type: PropType<"primary" | "secondary" | "outline">;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
size: {
|
|
64
|
+
type: PropType<"sm" | "md" | "lg">;
|
|
65
|
+
default: string;
|
|
66
|
+
};
|
|
67
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "click"[], "click", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
70
|
+
disabled: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
loading: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: boolean;
|
|
77
|
+
};
|
|
78
|
+
variant: {
|
|
79
|
+
type: PropType<"primary" | "secondary" | "outline">;
|
|
80
|
+
default: string;
|
|
81
|
+
};
|
|
82
|
+
size: {
|
|
83
|
+
type: PropType<"sm" | "md" | "lg">;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
}>> & Readonly<{
|
|
87
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
88
|
+
}>, {
|
|
89
|
+
size: "sm" | "md" | "lg";
|
|
90
|
+
disabled: boolean;
|
|
91
|
+
loading: boolean;
|
|
92
|
+
variant: "primary" | "secondary" | "outline";
|
|
93
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Payment status states
|
|
97
|
+
*/
|
|
98
|
+
type PaymentStatus = "idle" | "loading" | "success" | "error";
|
|
99
|
+
/**
|
|
100
|
+
* Payment state for composables
|
|
101
|
+
*/
|
|
102
|
+
interface PaymentState {
|
|
103
|
+
/** Current payment status */
|
|
104
|
+
status: Ref<PaymentStatus>;
|
|
105
|
+
/** Error message if status is 'error' */
|
|
106
|
+
error: Ref<string | null>;
|
|
107
|
+
/** The payment required response from server */
|
|
108
|
+
paymentRequired: Ref<PaymentRequired | null>;
|
|
109
|
+
/** Currently selected payment requirement */
|
|
110
|
+
selectedRequirement: Ref<PaymentRequirements | null>;
|
|
111
|
+
/** Whether we're in testnet mode */
|
|
112
|
+
isTestnet: ComputedRef<boolean>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Props for PaymentButton component
|
|
116
|
+
*/
|
|
117
|
+
interface PaymentButtonProps {
|
|
118
|
+
/** Whether the button is disabled */
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
/** Whether the button is in loading state */
|
|
121
|
+
loading?: boolean;
|
|
122
|
+
/** Button variant */
|
|
123
|
+
variant?: "primary" | "secondary" | "outline";
|
|
124
|
+
/** Button size */
|
|
125
|
+
size?: "sm" | "md" | "lg";
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Props for PaymentStatusDisplay component
|
|
129
|
+
*/
|
|
130
|
+
interface PaymentStatusDisplayProps {
|
|
131
|
+
/** Current status */
|
|
132
|
+
status: PaymentStatus;
|
|
133
|
+
/** Message to display */
|
|
134
|
+
message?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Props for PaymentDetails component
|
|
138
|
+
*/
|
|
139
|
+
interface PaymentDetailsProps {
|
|
140
|
+
/** Payment requirements to display */
|
|
141
|
+
requirement: PaymentRequirements;
|
|
142
|
+
/** Whether to show the network name */
|
|
143
|
+
showNetwork?: boolean;
|
|
144
|
+
/** Whether to show the asset */
|
|
145
|
+
showAsset?: boolean;
|
|
146
|
+
/** Whether to show the recipient address */
|
|
147
|
+
showRecipient?: boolean;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Props for Spinner component
|
|
151
|
+
*/
|
|
152
|
+
interface SpinnerProps {
|
|
153
|
+
/** Spinner size */
|
|
154
|
+
size?: "sm" | "md" | "lg";
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Props for AddressDisplay component
|
|
158
|
+
*/
|
|
159
|
+
interface AddressDisplayProps {
|
|
160
|
+
/** The address to display */
|
|
161
|
+
address: string;
|
|
162
|
+
/** Number of characters to show at start */
|
|
163
|
+
startChars?: number;
|
|
164
|
+
/** Number of characters to show at end */
|
|
165
|
+
endChars?: number;
|
|
166
|
+
/** Whether to show copy button */
|
|
167
|
+
copyable?: boolean;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* A component to display payment status with appropriate styling.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```vue
|
|
175
|
+
* <template>
|
|
176
|
+
* <PaymentStatusDisplay
|
|
177
|
+
* :status="status"
|
|
178
|
+
* message="Processing payment..."
|
|
179
|
+
* />
|
|
180
|
+
* </template>
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
declare const PaymentStatusDisplay: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
184
|
+
status: {
|
|
185
|
+
type: PropType<PaymentStatus>;
|
|
186
|
+
required: true;
|
|
187
|
+
};
|
|
188
|
+
message: {
|
|
189
|
+
type: StringConstructor;
|
|
190
|
+
default: undefined;
|
|
191
|
+
};
|
|
192
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
193
|
+
[key: string]: any;
|
|
194
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
195
|
+
status: {
|
|
196
|
+
type: PropType<PaymentStatus>;
|
|
197
|
+
required: true;
|
|
198
|
+
};
|
|
199
|
+
message: {
|
|
200
|
+
type: StringConstructor;
|
|
201
|
+
default: undefined;
|
|
202
|
+
};
|
|
203
|
+
}>> & Readonly<{}>, {
|
|
204
|
+
message: string;
|
|
205
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A component to display payment requirement details.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```vue
|
|
212
|
+
* <template>
|
|
213
|
+
* <PaymentDetails
|
|
214
|
+
* :requirement="requirement"
|
|
215
|
+
* show-network
|
|
216
|
+
* show-asset
|
|
217
|
+
* show-recipient
|
|
218
|
+
* />
|
|
219
|
+
* </template>
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare const PaymentDetails: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
223
|
+
requirement: {
|
|
224
|
+
type: PropType<PaymentRequirements>;
|
|
225
|
+
required: true;
|
|
226
|
+
};
|
|
227
|
+
showNetwork: {
|
|
228
|
+
type: BooleanConstructor;
|
|
229
|
+
default: boolean;
|
|
230
|
+
};
|
|
231
|
+
showAsset: {
|
|
232
|
+
type: BooleanConstructor;
|
|
233
|
+
default: boolean;
|
|
234
|
+
};
|
|
235
|
+
showRecipient: {
|
|
236
|
+
type: BooleanConstructor;
|
|
237
|
+
default: boolean;
|
|
238
|
+
};
|
|
239
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
240
|
+
[key: string]: any;
|
|
241
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
242
|
+
requirement: {
|
|
243
|
+
type: PropType<PaymentRequirements>;
|
|
244
|
+
required: true;
|
|
245
|
+
};
|
|
246
|
+
showNetwork: {
|
|
247
|
+
type: BooleanConstructor;
|
|
248
|
+
default: boolean;
|
|
249
|
+
};
|
|
250
|
+
showAsset: {
|
|
251
|
+
type: BooleanConstructor;
|
|
252
|
+
default: boolean;
|
|
253
|
+
};
|
|
254
|
+
showRecipient: {
|
|
255
|
+
type: BooleanConstructor;
|
|
256
|
+
default: boolean;
|
|
257
|
+
};
|
|
258
|
+
}>> & Readonly<{}>, {
|
|
259
|
+
showNetwork: boolean;
|
|
260
|
+
showAsset: boolean;
|
|
261
|
+
showRecipient: boolean;
|
|
262
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* A component to display blockchain addresses with optional copy functionality.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```vue
|
|
269
|
+
* <template>
|
|
270
|
+
* <AddressDisplay
|
|
271
|
+
* address="0x1234567890abcdef1234567890abcdef12345678"
|
|
272
|
+
* copyable
|
|
273
|
+
* :start-chars="6"
|
|
274
|
+
* :end-chars="4"
|
|
275
|
+
* />
|
|
276
|
+
* </template>
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
declare const AddressDisplay: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
280
|
+
address: {
|
|
281
|
+
type: StringConstructor;
|
|
282
|
+
required: true;
|
|
283
|
+
};
|
|
284
|
+
startChars: {
|
|
285
|
+
type: NumberConstructor;
|
|
286
|
+
default: number;
|
|
287
|
+
};
|
|
288
|
+
endChars: {
|
|
289
|
+
type: NumberConstructor;
|
|
290
|
+
default: number;
|
|
291
|
+
};
|
|
292
|
+
copyable: {
|
|
293
|
+
type: BooleanConstructor;
|
|
294
|
+
default: boolean;
|
|
295
|
+
};
|
|
296
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
297
|
+
[key: string]: any;
|
|
298
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
299
|
+
address: {
|
|
300
|
+
type: StringConstructor;
|
|
301
|
+
required: true;
|
|
302
|
+
};
|
|
303
|
+
startChars: {
|
|
304
|
+
type: NumberConstructor;
|
|
305
|
+
default: number;
|
|
306
|
+
};
|
|
307
|
+
endChars: {
|
|
308
|
+
type: NumberConstructor;
|
|
309
|
+
default: number;
|
|
310
|
+
};
|
|
311
|
+
copyable: {
|
|
312
|
+
type: BooleanConstructor;
|
|
313
|
+
default: boolean;
|
|
314
|
+
};
|
|
315
|
+
}>> & Readonly<{}>, {
|
|
316
|
+
startChars: number;
|
|
317
|
+
endChars: number;
|
|
318
|
+
copyable: boolean;
|
|
319
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
320
|
+
|
|
321
|
+
interface UsePaymentRequiredOptions {
|
|
322
|
+
/** Callback when payment is successful */
|
|
323
|
+
onSuccess?: (response: Response) => void;
|
|
324
|
+
/** Callback when payment fails */
|
|
325
|
+
onError?: (error: Error) => void;
|
|
326
|
+
}
|
|
327
|
+
interface UsePaymentRequiredReturn {
|
|
328
|
+
/** The payment required data from a 402 response */
|
|
329
|
+
paymentRequired: Ref<PaymentRequired | null>;
|
|
330
|
+
/** Current status of the fetch operation */
|
|
331
|
+
status: Ref<PaymentStatus>;
|
|
332
|
+
/** Error message if status is 'error' */
|
|
333
|
+
error: Ref<string | null>;
|
|
334
|
+
/** Fetch a resource and capture 402 response */
|
|
335
|
+
fetchResource: (url: string, options?: RequestInit) => Promise<Response | null>;
|
|
336
|
+
/** Reset the state */
|
|
337
|
+
reset: () => void;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Composable to fetch a resource and capture 402 Payment Required responses.
|
|
341
|
+
*
|
|
342
|
+
* @param options - Configuration options.
|
|
343
|
+
* @returns State and methods for handling 402 responses.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```vue
|
|
347
|
+
* <script setup>
|
|
348
|
+
* import { usePaymentRequired } from "@t402/vue";
|
|
349
|
+
*
|
|
350
|
+
* const { paymentRequired, status, fetchResource } = usePaymentRequired({
|
|
351
|
+
* onSuccess: (response) => console.log("Access granted!"),
|
|
352
|
+
* });
|
|
353
|
+
*
|
|
354
|
+
* const handleFetch = async () => {
|
|
355
|
+
* const response = await fetchResource("/api/protected");
|
|
356
|
+
* if (response?.ok) {
|
|
357
|
+
* const data = await response.json();
|
|
358
|
+
* // Handle successful response
|
|
359
|
+
* }
|
|
360
|
+
* };
|
|
361
|
+
* </script>
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
declare function usePaymentRequired(options?: UsePaymentRequiredOptions): UsePaymentRequiredReturn;
|
|
365
|
+
|
|
366
|
+
interface StatusMessage {
|
|
367
|
+
/** Message text */
|
|
368
|
+
text: string;
|
|
369
|
+
/** Message type */
|
|
370
|
+
type: "info" | "success" | "error" | "warning";
|
|
371
|
+
/** Optional auto-dismiss timeout in ms */
|
|
372
|
+
timeout?: number;
|
|
373
|
+
}
|
|
374
|
+
interface UsePaymentStatusReturn {
|
|
375
|
+
/** Current payment status */
|
|
376
|
+
status: Ref<PaymentStatus>;
|
|
377
|
+
/** Current status message */
|
|
378
|
+
message: Ref<StatusMessage | null>;
|
|
379
|
+
/** Set the status */
|
|
380
|
+
setStatus: (status: PaymentStatus, message?: string) => void;
|
|
381
|
+
/** Set a success message */
|
|
382
|
+
setSuccess: (message: string, timeout?: number) => void;
|
|
383
|
+
/** Set an error message */
|
|
384
|
+
setError: (message: string) => void;
|
|
385
|
+
/** Set an info message */
|
|
386
|
+
setInfo: (message: string, timeout?: number) => void;
|
|
387
|
+
/** Set a warning message */
|
|
388
|
+
setWarning: (message: string, timeout?: number) => void;
|
|
389
|
+
/** Clear the current message */
|
|
390
|
+
clearMessage: () => void;
|
|
391
|
+
/** Reset to idle state */
|
|
392
|
+
reset: () => void;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Composable for managing payment status and status messages.
|
|
396
|
+
*
|
|
397
|
+
* @returns State and methods for status management.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```vue
|
|
401
|
+
* <script setup>
|
|
402
|
+
* import { usePaymentStatus } from "@t402/vue";
|
|
403
|
+
*
|
|
404
|
+
* const {
|
|
405
|
+
* status,
|
|
406
|
+
* message,
|
|
407
|
+
* setStatus,
|
|
408
|
+
* setSuccess,
|
|
409
|
+
* setError,
|
|
410
|
+
* } = usePaymentStatus();
|
|
411
|
+
*
|
|
412
|
+
* const handlePayment = async () => {
|
|
413
|
+
* setStatus("loading", "Processing payment...");
|
|
414
|
+
* try {
|
|
415
|
+
* await processPayment();
|
|
416
|
+
* setSuccess("Payment successful!", 3000);
|
|
417
|
+
* } catch (err) {
|
|
418
|
+
* setError("Payment failed. Please try again.");
|
|
419
|
+
* }
|
|
420
|
+
* };
|
|
421
|
+
* </script>
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
declare function usePaymentStatus(): UsePaymentStatusReturn;
|
|
425
|
+
|
|
426
|
+
interface UseAsyncPaymentOptions<T> {
|
|
427
|
+
/** The async payment function to execute */
|
|
428
|
+
paymentFn: () => Promise<T>;
|
|
429
|
+
/** Callback on successful payment */
|
|
430
|
+
onSuccess?: (result: T) => void;
|
|
431
|
+
/** Callback on payment error */
|
|
432
|
+
onError?: (error: Error) => void;
|
|
433
|
+
/** Callback when payment starts */
|
|
434
|
+
onStart?: () => void;
|
|
435
|
+
}
|
|
436
|
+
interface UseAsyncPaymentReturn<T> {
|
|
437
|
+
/** Execute the payment */
|
|
438
|
+
execute: () => Promise<T | null>;
|
|
439
|
+
/** Current payment status */
|
|
440
|
+
status: Ref<PaymentStatus>;
|
|
441
|
+
/** Result of successful payment */
|
|
442
|
+
result: Ref<T | null>;
|
|
443
|
+
/** Error message if payment failed */
|
|
444
|
+
error: Ref<string | null>;
|
|
445
|
+
/** Whether payment is in progress */
|
|
446
|
+
isLoading: ComputedRef<boolean>;
|
|
447
|
+
/** Whether payment succeeded */
|
|
448
|
+
isSuccess: ComputedRef<boolean>;
|
|
449
|
+
/** Whether payment failed */
|
|
450
|
+
isError: ComputedRef<boolean>;
|
|
451
|
+
/** Reset the state */
|
|
452
|
+
reset: () => void;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Composable for managing async payment operations with loading states.
|
|
456
|
+
*
|
|
457
|
+
* @param options - Configuration including the payment function and callbacks.
|
|
458
|
+
* @returns State and methods for managing the async payment.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```vue
|
|
462
|
+
* <script setup>
|
|
463
|
+
* import { useAsyncPayment } from "@t402/vue";
|
|
464
|
+
*
|
|
465
|
+
* const { execute, isLoading, isSuccess, error } = useAsyncPayment({
|
|
466
|
+
* paymentFn: async () => {
|
|
467
|
+
* const response = await fetch("/api/protected", {
|
|
468
|
+
* headers: { "X-Payment": paymentPayload },
|
|
469
|
+
* });
|
|
470
|
+
* return response.json();
|
|
471
|
+
* },
|
|
472
|
+
* onSuccess: (data) => console.log("Payment succeeded:", data),
|
|
473
|
+
* onError: (err) => console.error("Payment failed:", err),
|
|
474
|
+
* });
|
|
475
|
+
* </script>
|
|
476
|
+
*
|
|
477
|
+
* <template>
|
|
478
|
+
* <button @click="execute" :disabled="isLoading">
|
|
479
|
+
* {{ isLoading ? "Processing..." : "Pay Now" }}
|
|
480
|
+
* </button>
|
|
481
|
+
* </template>
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
declare function useAsyncPayment<T>(options: UseAsyncPaymentOptions<T>): UseAsyncPaymentReturn<T>;
|
|
485
|
+
|
|
486
|
+
/** EVM Chain IDs (CAIP-2 format: eip155:chainId) */
|
|
487
|
+
declare const EVM_CHAIN_IDS: {
|
|
488
|
+
readonly ETHEREUM_MAINNET: "1";
|
|
489
|
+
readonly BASE_MAINNET: "8453";
|
|
490
|
+
readonly BASE_SEPOLIA: "84532";
|
|
491
|
+
readonly ARBITRUM_MAINNET: "42161";
|
|
492
|
+
readonly ARBITRUM_SEPOLIA: "421614";
|
|
493
|
+
};
|
|
494
|
+
/** Solana Network References (CAIP-2 format: solana:genesisHash) */
|
|
495
|
+
declare const SOLANA_NETWORK_REFS: {
|
|
496
|
+
readonly MAINNET: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
497
|
+
readonly DEVNET: "EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
498
|
+
};
|
|
499
|
+
/** TON Network References (CAIP-2 format: ton:workchain) */
|
|
500
|
+
declare const TON_NETWORK_REFS: {
|
|
501
|
+
readonly MAINNET: "-239";
|
|
502
|
+
readonly TESTNET: "-3";
|
|
503
|
+
};
|
|
504
|
+
/** TRON Network References */
|
|
505
|
+
declare const TRON_NETWORK_REFS: {
|
|
506
|
+
readonly MAINNET: "mainnet";
|
|
507
|
+
readonly NILE: "nile";
|
|
508
|
+
readonly SHASTA: "shasta";
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Normalizes payment requirements into an array.
|
|
512
|
+
*
|
|
513
|
+
* @param paymentRequirements - A single requirement or array of requirements.
|
|
514
|
+
* @returns An array of payment requirements.
|
|
515
|
+
*/
|
|
516
|
+
declare function normalizePaymentRequirements(paymentRequirements: PaymentRequirements | PaymentRequirements[]): PaymentRequirements[];
|
|
517
|
+
/**
|
|
518
|
+
* Returns preferred networks for payment selection.
|
|
519
|
+
*
|
|
520
|
+
* @param testnet - Whether to prefer testnet networks.
|
|
521
|
+
* @returns Ordered list of preferred networks (CAIP-2 format).
|
|
522
|
+
*/
|
|
523
|
+
declare function getPreferredNetworks(testnet: boolean): string[];
|
|
524
|
+
/**
|
|
525
|
+
* Selects the most appropriate payment requirement.
|
|
526
|
+
*
|
|
527
|
+
* @param paymentRequirements - Available payment requirements.
|
|
528
|
+
* @param testnet - Whether to prefer testnet networks.
|
|
529
|
+
* @returns The selected payment requirement.
|
|
530
|
+
*/
|
|
531
|
+
declare function choosePaymentRequirement(paymentRequirements: PaymentRequirements | PaymentRequirements[], testnet: boolean): PaymentRequirements;
|
|
532
|
+
/**
|
|
533
|
+
* Determines if the network is EVM-based.
|
|
534
|
+
*
|
|
535
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
536
|
+
* @returns True if the network is EVM-based.
|
|
537
|
+
*/
|
|
538
|
+
declare function isEvmNetwork(network: string): boolean;
|
|
539
|
+
/**
|
|
540
|
+
* Determines if the network is Solana-based.
|
|
541
|
+
*
|
|
542
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
543
|
+
* @returns True if the network is Solana-based.
|
|
544
|
+
*/
|
|
545
|
+
declare function isSvmNetwork(network: string): boolean;
|
|
546
|
+
/**
|
|
547
|
+
* Determines if the network is TON-based.
|
|
548
|
+
*
|
|
549
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
550
|
+
* @returns True if the network is TON-based.
|
|
551
|
+
*/
|
|
552
|
+
declare function isTonNetwork(network: string): boolean;
|
|
553
|
+
/**
|
|
554
|
+
* Determines if the network is TRON-based.
|
|
555
|
+
*
|
|
556
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
557
|
+
* @returns True if the network is TRON-based.
|
|
558
|
+
*/
|
|
559
|
+
declare function isTronNetwork(network: string): boolean;
|
|
560
|
+
/**
|
|
561
|
+
* Gets a human-readable display name for a network.
|
|
562
|
+
*
|
|
563
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
564
|
+
* @returns A display name suitable for UI use.
|
|
565
|
+
*/
|
|
566
|
+
declare function getNetworkDisplayName(network: string): string;
|
|
567
|
+
/**
|
|
568
|
+
* Determines if the network is a testnet.
|
|
569
|
+
*
|
|
570
|
+
* @param network - The network identifier (CAIP-2 format).
|
|
571
|
+
* @returns True if the network is a testnet.
|
|
572
|
+
*/
|
|
573
|
+
declare function isTestnetNetwork(network: string): boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Truncates an address for display.
|
|
576
|
+
*
|
|
577
|
+
* @param address - The full address.
|
|
578
|
+
* @param startChars - Number of characters to show at start (default: 6).
|
|
579
|
+
* @param endChars - Number of characters to show at end (default: 4).
|
|
580
|
+
* @returns The truncated address.
|
|
581
|
+
*/
|
|
582
|
+
declare function truncateAddress(address: string, startChars?: number, endChars?: number): string;
|
|
583
|
+
/**
|
|
584
|
+
* Formats a token amount for display.
|
|
585
|
+
*
|
|
586
|
+
* @param amount - The amount as a string (in smallest unit).
|
|
587
|
+
* @param decimals - The token decimals (default: 6 for USDT).
|
|
588
|
+
* @param maxDecimals - Maximum decimal places to show (default: 2).
|
|
589
|
+
* @returns The formatted amount.
|
|
590
|
+
*/
|
|
591
|
+
declare function formatTokenAmount(amount: string, decimals?: number, maxDecimals?: number): string;
|
|
592
|
+
/**
|
|
593
|
+
* Gets the asset display name.
|
|
594
|
+
*
|
|
595
|
+
* @param asset - The asset identifier (e.g., "usdt", "usdt0").
|
|
596
|
+
* @returns A display name suitable for UI use.
|
|
597
|
+
*/
|
|
598
|
+
declare function getAssetDisplayName(asset: string): string;
|
|
599
|
+
|
|
600
|
+
export { AddressDisplay, type AddressDisplayProps, EVM_CHAIN_IDS, PaymentButton, type PaymentButtonProps, PaymentDetails, type PaymentDetailsProps, type PaymentState, type PaymentStatus, PaymentStatusDisplay, type PaymentStatusDisplayProps, SOLANA_NETWORK_REFS, Spinner, type SpinnerProps, TON_NETWORK_REFS, TRON_NETWORK_REFS, choosePaymentRequirement, formatTokenAmount, getAssetDisplayName, getNetworkDisplayName, getPreferredNetworks, isEvmNetwork, isSvmNetwork, isTestnetNetwork, isTonNetwork, isTronNetwork, normalizePaymentRequirements, spinnerStyles, truncateAddress, useAsyncPayment, usePaymentRequired, usePaymentStatus };
|