@unifold/ui-react 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,7 +79,7 @@ The SDK exports all API functions for direct use:
79
79
 
80
80
  ```tsx
81
81
  import {
82
- createEOA,
82
+ createDepositAddress,
83
83
  queryExecutions,
84
84
  getSupportedDepositTokens,
85
85
  getMeldQuotes,
package/dist/index.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Wallet, AutoSwapResponse, FiatCurrency, ExecutionStatus, FeaturedToken, PaymentNetwork } from '@unifold/core';
3
+ export { AutoSwapRequest, AutoSwapResponse, CreateDepositAddressRequest, DepositAddressResponse, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, MeldQuote, MeldQuotesRequest, MeldQuotesResponse, MeldSessionRequest, MeldSessionResponse, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SupportedChain, SupportedDepositTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createMeldSession, getApiBaseUrl, getChainName, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getMeldQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp } from '@unifold/core';
2
4
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
5
  import * as React from 'react';
4
6
  import { VariantProps } from 'class-variance-authority';
@@ -45,234 +47,6 @@ interface DepositHeaderProps {
45
47
  }
46
48
  declare function DepositHeader({ title, showBack, showClose, onBack, onClose, badge, }: DepositHeaderProps): react_jsx_runtime.JSX.Element;
47
49
 
48
- declare function setApiConfig(config: {
49
- baseUrl?: string;
50
- publishableKey?: string;
51
- defaultConfig?: {
52
- destinationChainId?: string;
53
- destinationTokenAddress?: string;
54
- recipientAddress?: string;
55
- };
56
- }): void;
57
- declare function getApiBaseUrl(): string;
58
- /**
59
- * Build an icon URL using the API base URL
60
- * Converts relative paths like "/icons/networks/ethereum.svg" to full URLs
61
- * like "http://localhost:3002/api/public/icons/networks/ethereum.svg"
62
- */
63
- declare function getIconUrl(iconPath: string): string;
64
- /**
65
- * Build an icon URL using a custom CDN base URL
66
- * Converts relative paths like "/icons/networks/ethereum.svg" to full CDN URLs
67
- * Falls back to getIconUrl if no CDN URL is provided
68
- */
69
- declare function getIconUrlWithCdn(iconPath: string, assetCdnUrl?: string): string;
70
- interface Wallet {
71
- id: string;
72
- chain_type: "ethereum" | "solana" | "bitcoin";
73
- address_type: string | null;
74
- address: string;
75
- destination_chain_type: string;
76
- destination_chain_id: string;
77
- destination_token_address: string;
78
- recipient_address: string;
79
- is_primary: boolean;
80
- }
81
- interface EOAResponse {
82
- data: Wallet[];
83
- }
84
- interface CreateEOARequest {
85
- user_id: string;
86
- destination_chain_type: string;
87
- destination_chain_id: string;
88
- destination_token_address: string;
89
- recipient_address: string;
90
- client_metadata?: Record<string, unknown>;
91
- }
92
- /**
93
- * Create EOA wallets for a user
94
- * @param overrides - Override default configuration (user_id, recipient_address, etc.)
95
- * @param publishableKey - Optional publishable key, defaults to configured key
96
- */
97
- declare function createEOA(overrides?: Partial<CreateEOARequest>, publishableKey?: string): Promise<EOAResponse>;
98
- /**
99
- * Get wallet address for a specific chain type
100
- */
101
- declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin"): Wallet | undefined;
102
- interface AutoSwapRequest {
103
- wallet_id: string;
104
- origin_currency: string;
105
- }
106
- declare enum ExecutionStatus {
107
- DELAYED = "delayed",
108
- FAILED = "failed",
109
- PENDING = "pending",
110
- REFUNDED = "refunded",
111
- SUCCEEDED = "succeeded",
112
- WAITING = "waiting"
113
- }
114
- interface AutoSwapResponse {
115
- id: string;
116
- project_id: string;
117
- user_id: string;
118
- wallet_id: string;
119
- transaction_hash: string;
120
- recipient_address: string;
121
- provider: string;
122
- provider_id: string;
123
- source_chain_type: string;
124
- source_chain_id: string;
125
- source_token_address: string;
126
- destination_chain_type: string;
127
- destination_chain_id: string;
128
- destination_token_address: string;
129
- source_amount_base_unit: string;
130
- source_amount_usd?: string;
131
- destination_amount_base_unit: string;
132
- provider_metadata: unknown;
133
- created_at?: string;
134
- updated_at?: string;
135
- explorer_url: string;
136
- destination_explorer_url: string | null;
137
- destination_transaction_hashes: string[];
138
- status: ExecutionStatus;
139
- source_token_metadata?: {
140
- icon_url: string;
141
- };
142
- destination_token_metadata?: {
143
- icon_url: string;
144
- };
145
- }
146
- declare const SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
147
- interface QueryExecutionsRequest {
148
- external_user_id: string;
149
- }
150
- interface QueryExecutionsResponse {
151
- data: AutoSwapResponse[];
152
- }
153
- /**
154
- * Query all direct executions for a user
155
- * Returns ALL executions - filter client-side for new ones
156
- * @param externalUserId - External user ID
157
- * @param publishableKey - Optional publishable key, defaults to configured key
158
- */
159
- declare function queryExecutions(externalUserId: string, publishableKey?: string): Promise<QueryExecutionsResponse>;
160
- interface SupportedChain {
161
- chain_id: string;
162
- chain_name: string;
163
- chain_type: string;
164
- icon_url: string;
165
- token_address: string;
166
- estimated_price_impact_percent: number;
167
- max_slippage_percent: number;
168
- estimated_processing_time: number | null;
169
- minimum_deposit_amount_usd: number;
170
- }
171
- interface SupportedToken {
172
- symbol: string;
173
- name: string;
174
- icon_url: string;
175
- is_newly_added: boolean;
176
- chains: SupportedChain[];
177
- }
178
- interface SupportedDepositTokensResponse {
179
- data: SupportedToken[];
180
- }
181
- /**
182
- * Get supported deposit tokens
183
- * @param publishableKey - Optional publishable key, defaults to configured key
184
- */
185
- declare function getSupportedDepositTokens(publishableKey?: string): Promise<SupportedDepositTokensResponse>;
186
- interface MeldQuote {
187
- transaction_type: string;
188
- payment_method_type: string;
189
- source_amount: number;
190
- source_amount_without_fees: number;
191
- fiat_amount_without_fees: number;
192
- destination_amount_without_fees: number | null;
193
- source_currency_code: string;
194
- country_code: string;
195
- total_fee: number;
196
- network_fee: number;
197
- transaction_fee: number;
198
- destination_amount: number;
199
- destination_currency_code: string;
200
- exchange_rate: number;
201
- customer_score: number;
202
- service_provider: string;
203
- service_provider_display_name: string;
204
- institution_name: string | null;
205
- low_kyc: boolean | null;
206
- partner_fee: number | null;
207
- icon_url: string;
208
- }
209
- interface MeldQuotesRequest {
210
- country_code: string;
211
- destination_currency_code: string;
212
- source_amount: string;
213
- source_currency_code: string;
214
- }
215
- interface MeldQuotesResponse {
216
- data: MeldQuote[];
217
- }
218
- /**
219
- * Get Meld onramp quotes
220
- * @param request - Meld quotes request
221
- * @param publishableKey - Optional publishable key, defaults to configured key
222
- */
223
- declare function getMeldQuotes(request: MeldQuotesRequest, publishableKey?: string): Promise<MeldQuotesResponse>;
224
- interface MeldSessionRequest {
225
- service_provider: string;
226
- country_code: string;
227
- destination_currency_code: string;
228
- source_currency_code: string;
229
- wallet_address: string;
230
- source_amount: string;
231
- }
232
- interface MeldSessionResponse {
233
- id: string;
234
- external_session_id: string | null;
235
- external_customer_id: string | null;
236
- customer_id: string;
237
- widget_url: string;
238
- service_provider_widget_url: string;
239
- token: string;
240
- }
241
- /**
242
- * Create a Meld onramp session
243
- * @param request - Meld session request
244
- * @param publishableKey - Optional publishable key, defaults to configured key
245
- */
246
- declare function createMeldSession(request: MeldSessionRequest, publishableKey?: string): Promise<MeldSessionResponse>;
247
- interface IconUrl {
248
- url: string;
249
- format: "svg" | "png";
250
- }
251
- interface FiatCurrency {
252
- currency_code: string;
253
- name: string;
254
- icon_url: string;
255
- icon_urls?: IconUrl[];
256
- }
257
- interface FiatCurrenciesResponse {
258
- data: FiatCurrency[];
259
- preferred: string[];
260
- }
261
- /**
262
- * Get supported fiat currencies
263
- * @param publishableKey - Optional publishable key, defaults to configured key
264
- */
265
- declare function getFiatCurrencies(publishableKey?: string): Promise<FiatCurrenciesResponse>;
266
- interface FeaturedToken {
267
- name: string;
268
- position: number;
269
- icon_urls: IconUrl[];
270
- }
271
- interface PaymentNetwork {
272
- name: string;
273
- icon_urls: IconUrl[];
274
- }
275
-
276
50
  interface TransferCryptoProps {
277
51
  userId: string;
278
52
  publishableKey: string;
@@ -315,7 +89,6 @@ interface TransferCryptoBaseProps {
315
89
  destinationChainType?: "ethereum" | "solana" | "bitcoin";
316
90
  destinationChainId?: string;
317
91
  destinationTokenAddress?: string;
318
- copyButtonMode?: "compact" | "fullWidth";
319
92
  layoutVariant?: LayoutVariant;
320
93
  showDetailedDropdowns?: boolean;
321
94
  onExecutionsChange?: (executions: AutoSwapResponse[]) => void;
@@ -331,7 +104,7 @@ interface TransferCryptoBaseProps {
331
104
  }) => void;
332
105
  wallets?: Wallet[];
333
106
  }
334
- declare function TransferCryptoBase({ userId, publishableKey, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, copyButtonMode, layoutVariant, showDetailedDropdowns, onExecutionsChange, onDepositSuccess, onDepositError, wallets: externalWallets, }: TransferCryptoBaseProps): react_jsx_runtime.JSX.Element;
107
+ declare function TransferCryptoBase({ userId, publishableKey, recipientAddress, destinationChainType, destinationChainId, destinationTokenAddress, layoutVariant, showDetailedDropdowns, onExecutionsChange, onDepositSuccess, onDepositError, wallets: externalWallets, }: TransferCryptoBaseProps): react_jsx_runtime.JSX.Element;
335
108
 
336
109
  interface BuyWithCardProps {
337
110
  userId: string;
@@ -383,18 +156,20 @@ interface DepositSuccessToastProps {
383
156
  tokenIconUrl?: string;
384
157
  sourceAmountBaseUnit?: string;
385
158
  onClose: () => void;
159
+ execution?: AutoSwapResponse;
386
160
  }
387
- declare function DepositSuccessToast({ depositTx, orderSubmittedAt, status, tokenIconUrl, sourceAmountBaseUnit, onClose, }: DepositSuccessToastProps): react_jsx_runtime.JSX.Element;
161
+ declare function DepositSuccessToast({ depositTx, orderSubmittedAt, status, tokenIconUrl, sourceAmountBaseUnit, onClose, execution, }: DepositSuccessToastProps): react_jsx_runtime.JSX.Element;
388
162
 
389
163
  interface DepositsModalProps {
390
164
  open: boolean;
391
165
  onOpenChange: (open: boolean) => void;
166
+ onCloseAll?: () => void;
392
167
  executions: AutoSwapResponse[];
393
168
  userId: string;
394
169
  publishableKey: string;
395
170
  themeClass?: string;
396
171
  }
397
- declare function DepositsModal({ open, onOpenChange, executions: sessionExecutions, userId, publishableKey, themeClass, }: DepositsModalProps): react_jsx_runtime.JSX.Element;
172
+ declare function DepositsModal({ open, onOpenChange, onCloseAll, executions: sessionExecutions, userId, publishableKey, themeClass, }: DepositsModalProps): react_jsx_runtime.JSX.Element;
398
173
 
399
174
  interface StyledQRCodeProps {
400
175
  value: string;
@@ -435,13 +210,10 @@ interface DepositExecutionItemProps {
435
210
  }
436
211
  declare function DepositExecutionItem({ execution, onClick, }: DepositExecutionItemProps): react_jsx_runtime.JSX.Element;
437
212
 
438
- interface DepositDetailModalProps {
439
- open: boolean;
440
- onOpenChange: (open: boolean) => void;
441
- execution: AutoSwapResponse | null;
442
- themeClass?: string;
213
+ interface DepositDetailContentProps {
214
+ execution: AutoSwapResponse;
443
215
  }
444
- declare function DepositDetailModal({ open, onOpenChange, execution, themeClass, }: DepositDetailModalProps): react_jsx_runtime.JSX.Element | null;
216
+ declare function DepositDetailContent({ execution }: DepositDetailContentProps): react_jsx_runtime.JSX.Element;
445
217
 
446
218
  interface CurrencyListItemProps {
447
219
  currency: FiatCurrency;
@@ -500,31 +272,6 @@ declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
500
272
  declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
501
273
  declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
502
274
 
503
- /**
504
- * User IP information interface
505
- */
506
- interface UserIpInfo {
507
- alpha2: string;
508
- state?: string;
509
- }
510
- /**
511
- * Hook to fetch user's IP-based location information
512
- *
513
- * Uses ipapi.co to detect the user's country and state.
514
- *
515
- * The result is cached in-memory using React Query:
516
- * - Data persists for the entire browser session
517
- * - Shared across all components using this hook
518
- * - Reduces API calls and protects against rate limiting
519
- *
520
- * @returns User IP information including country code
521
- */
522
- declare function useUserIp(): {
523
- userIpInfo: UserIpInfo | undefined;
524
- isLoading: boolean;
525
- error: Error | null;
526
- };
527
-
528
275
  interface ThemeContextValue {
529
276
  themeClass: string;
530
277
  }
@@ -536,70 +283,4 @@ declare function useTheme(): ThemeContextValue;
536
283
 
537
284
  declare function cn(...inputs: ClassValue[]): string;
538
285
 
539
- declare const i18n: {
540
- transferCrypto: {
541
- priceImpact: {
542
- label: string;
543
- tooltip: string;
544
- finalCost: string;
545
- };
546
- slippage: {
547
- label: string;
548
- auto: string;
549
- tooltip: string;
550
- finalCost: string;
551
- };
552
- processingTime: {
553
- label: string;
554
- lessThanMinutes: string;
555
- lessThanHours: string;
556
- };
557
- minDeposit: {
558
- label: string;
559
- tooltip: string;
560
- };
561
- help: {
562
- needHelp: string;
563
- contactSupport: string;
564
- };
565
- terms: {
566
- termsApply: string;
567
- };
568
- supportedToken: string;
569
- supportedChain: string;
570
- depositAddress: {
571
- label: string;
572
- tooltip: string;
573
- };
574
- copyAddress: string;
575
- copied: string;
576
- loading: string;
577
- loadingQRCode: string;
578
- noAddressAvailable: string;
579
- noChainsAvailable: string;
580
- };
581
- depositModal: {
582
- transferCrypto: {
583
- title: string;
584
- subtitle: string;
585
- };
586
- depositWithCard: {
587
- title: string;
588
- subtitle: string;
589
- };
590
- quotes: string;
591
- };
592
- buyWithCard: {
593
- onramp: {
594
- completeTransaction: string;
595
- canCloseModal: string;
596
- youUse: string;
597
- youBuy: string;
598
- youReceive: string;
599
- intentAddressNote: string;
600
- };
601
- };
602
- };
603
- type I18nStrings = typeof i18n;
604
-
605
- export { type AutoSwapRequest, type AutoSwapResponse, Button, type ButtonProps, BuyWithCard, type CreateEOARequest, CurrencyListItem, CurrencyListSection, CurrencyModal, DepositDetailModal, DepositExecutionItem, DepositHeader, DepositModal, DepositSuccessToast, DepositTrackerButton, DepositWithCardButton, DepositsModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, type EOAResponse, ExecutionStatus, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type MeldQuote, type MeldQuotesRequest, type MeldQuotesResponse, type MeldSessionRequest, type MeldSessionResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, StyledQRCode, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, ThemeProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TransferCrypto, TransferCrypto2, TransferCryptoBase, TransferCryptoButton, type UserIpInfo, type Wallet, buttonVariants, cn, createEOA, createMeldSession, getApiBaseUrl, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getMeldQuotes, getSupportedDepositTokens, getWalletByChainType, i18n, queryExecutions, setApiConfig, useTheme, useUserIp };
286
+ export { Button, type ButtonProps, BuyWithCard, CurrencyListItem, CurrencyListSection, CurrencyModal, DepositDetailContent, DepositExecutionItem, DepositHeader, DepositModal, DepositSuccessToast, DepositTrackerButton, DepositWithCardButton, DepositsModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, StyledQRCode, ThemeProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TransferCrypto, TransferCrypto2, TransferCryptoBase, TransferCryptoButton, buttonVariants, cn, useTheme };