@unifold/ui-react 0.1.9 → 0.1.11

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,248 +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
- deposit_wallet_id: string;
119
- owner_type?: string;
120
- owner_id?: string;
121
- transaction_hash: string;
122
- recipient_address: string;
123
- provider: string;
124
- provider_id: string;
125
- source_chain_type: string;
126
- source_chain_id: string;
127
- source_token_address: string;
128
- destination_chain_type: string;
129
- destination_chain_id: string;
130
- destination_token_address: string;
131
- source_amount_base_unit: string;
132
- source_amount_usd?: string;
133
- destination_amount_base_unit: string;
134
- provider_metadata: unknown;
135
- created_at?: string;
136
- updated_at?: string;
137
- explorer_url: string;
138
- destination_explorer_url: string | null;
139
- destination_transaction_hashes: string[];
140
- status: ExecutionStatus;
141
- source_token_metadata?: {
142
- icon_url: string;
143
- icon_urls?: IconUrl[];
144
- };
145
- destination_token_metadata?: {
146
- icon_url: string;
147
- icon_urls?: IconUrl[];
148
- };
149
- deposit_wallet?: {
150
- id: string;
151
- chain_type: string;
152
- address_type: string | null;
153
- address: string;
154
- is_primary: boolean;
155
- created_at: string;
156
- updated_at: string;
157
- last_used_at: string | null;
158
- };
159
- }
160
- declare const SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
161
- interface QueryExecutionsRequest {
162
- external_user_id: string;
163
- }
164
- interface QueryExecutionsResponse {
165
- data: AutoSwapResponse[];
166
- }
167
- /**
168
- * Query all direct executions for a user
169
- * Returns ALL executions - filter client-side for new ones
170
- * @param externalUserId - External user ID
171
- * @param publishableKey - Optional publishable key, defaults to configured key
172
- */
173
- declare function queryExecutions(externalUserId: string, publishableKey?: string): Promise<QueryExecutionsResponse>;
174
- interface SupportedChain {
175
- chain_id: string;
176
- chain_name: string;
177
- chain_type: string;
178
- icon_url: string;
179
- token_address: string;
180
- estimated_price_impact_percent: number;
181
- max_slippage_percent: number;
182
- estimated_processing_time: number | null;
183
- minimum_deposit_amount_usd: number;
184
- }
185
- interface SupportedToken {
186
- symbol: string;
187
- name: string;
188
- icon_url: string;
189
- is_newly_added: boolean;
190
- chains: SupportedChain[];
191
- }
192
- interface SupportedDepositTokensResponse {
193
- data: SupportedToken[];
194
- }
195
- /**
196
- * Get supported deposit tokens
197
- * @param publishableKey - Optional publishable key, defaults to configured key
198
- */
199
- declare function getSupportedDepositTokens(publishableKey?: string): Promise<SupportedDepositTokensResponse>;
200
- interface MeldQuote {
201
- transaction_type: string;
202
- payment_method_type: string;
203
- source_amount: number;
204
- source_amount_without_fees: number;
205
- fiat_amount_without_fees: number;
206
- destination_amount_without_fees: number | null;
207
- source_currency_code: string;
208
- country_code: string;
209
- total_fee: number;
210
- network_fee: number;
211
- transaction_fee: number;
212
- destination_amount: number;
213
- destination_currency_code: string;
214
- exchange_rate: number;
215
- customer_score: number;
216
- service_provider: string;
217
- service_provider_display_name: string;
218
- institution_name: string | null;
219
- low_kyc: boolean | null;
220
- partner_fee: number | null;
221
- icon_url: string;
222
- }
223
- interface MeldQuotesRequest {
224
- country_code: string;
225
- destination_currency_code: string;
226
- source_amount: string;
227
- source_currency_code: string;
228
- }
229
- interface MeldQuotesResponse {
230
- data: MeldQuote[];
231
- }
232
- /**
233
- * Get Meld onramp quotes
234
- * @param request - Meld quotes request
235
- * @param publishableKey - Optional publishable key, defaults to configured key
236
- */
237
- declare function getMeldQuotes(request: MeldQuotesRequest, publishableKey?: string): Promise<MeldQuotesResponse>;
238
- interface MeldSessionRequest {
239
- service_provider: string;
240
- country_code: string;
241
- destination_currency_code: string;
242
- source_currency_code: string;
243
- wallet_address: string;
244
- source_amount: string;
245
- }
246
- interface MeldSessionResponse {
247
- id: string;
248
- external_session_id: string | null;
249
- external_customer_id: string | null;
250
- customer_id: string;
251
- widget_url: string;
252
- service_provider_widget_url: string;
253
- token: string;
254
- }
255
- /**
256
- * Create a Meld onramp session
257
- * @param request - Meld session request
258
- * @param publishableKey - Optional publishable key, defaults to configured key
259
- */
260
- declare function createMeldSession(request: MeldSessionRequest, publishableKey?: string): Promise<MeldSessionResponse>;
261
- interface IconUrl {
262
- url: string;
263
- format: "svg" | "png";
264
- }
265
- interface FiatCurrency {
266
- currency_code: string;
267
- name: string;
268
- icon_url: string;
269
- icon_urls?: IconUrl[];
270
- }
271
- interface FiatCurrenciesResponse {
272
- data: FiatCurrency[];
273
- preferred: string[];
274
- }
275
- /**
276
- * Get supported fiat currencies
277
- * @param publishableKey - Optional publishable key, defaults to configured key
278
- */
279
- declare function getFiatCurrencies(publishableKey?: string): Promise<FiatCurrenciesResponse>;
280
- interface FeaturedToken {
281
- name: string;
282
- position: number;
283
- icon_urls: IconUrl[];
284
- }
285
- interface PaymentNetwork {
286
- name: string;
287
- icon_urls: IconUrl[];
288
- }
289
-
290
50
  interface TransferCryptoProps {
291
51
  userId: string;
292
52
  publishableKey: string;
@@ -329,7 +89,6 @@ interface TransferCryptoBaseProps {
329
89
  destinationChainType?: "ethereum" | "solana" | "bitcoin";
330
90
  destinationChainId?: string;
331
91
  destinationTokenAddress?: string;
332
- copyButtonMode?: "compact" | "fullWidth";
333
92
  layoutVariant?: LayoutVariant;
334
93
  showDetailedDropdowns?: boolean;
335
94
  onExecutionsChange?: (executions: AutoSwapResponse[]) => void;
@@ -345,7 +104,7 @@ interface TransferCryptoBaseProps {
345
104
  }) => void;
346
105
  wallets?: Wallet[];
347
106
  }
348
- 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;
349
108
 
350
109
  interface BuyWithCardProps {
351
110
  userId: string;
@@ -397,18 +156,20 @@ interface DepositSuccessToastProps {
397
156
  tokenIconUrl?: string;
398
157
  sourceAmountBaseUnit?: string;
399
158
  onClose: () => void;
159
+ execution?: AutoSwapResponse;
400
160
  }
401
- 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;
402
162
 
403
163
  interface DepositsModalProps {
404
164
  open: boolean;
405
165
  onOpenChange: (open: boolean) => void;
166
+ onCloseAll?: () => void;
406
167
  executions: AutoSwapResponse[];
407
168
  userId: string;
408
169
  publishableKey: string;
409
170
  themeClass?: string;
410
171
  }
411
- 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;
412
173
 
413
174
  interface StyledQRCodeProps {
414
175
  value: string;
@@ -449,13 +210,10 @@ interface DepositExecutionItemProps {
449
210
  }
450
211
  declare function DepositExecutionItem({ execution, onClick, }: DepositExecutionItemProps): react_jsx_runtime.JSX.Element;
451
212
 
452
- interface DepositDetailModalProps {
453
- open: boolean;
454
- onOpenChange: (open: boolean) => void;
455
- execution: AutoSwapResponse | null;
456
- themeClass?: string;
213
+ interface DepositDetailContentProps {
214
+ execution: AutoSwapResponse;
457
215
  }
458
- 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;
459
217
 
460
218
  interface CurrencyListItemProps {
461
219
  currency: FiatCurrency;
@@ -514,31 +272,6 @@ declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
514
272
  declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
515
273
  declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
516
274
 
517
- /**
518
- * User IP information interface
519
- */
520
- interface UserIpInfo {
521
- alpha2: string;
522
- state?: string;
523
- }
524
- /**
525
- * Hook to fetch user's IP-based location information
526
- *
527
- * Uses ipapi.co to detect the user's country and state.
528
- *
529
- * The result is cached in-memory using React Query:
530
- * - Data persists for the entire browser session
531
- * - Shared across all components using this hook
532
- * - Reduces API calls and protects against rate limiting
533
- *
534
- * @returns User IP information including country code
535
- */
536
- declare function useUserIp(): {
537
- userIpInfo: UserIpInfo | undefined;
538
- isLoading: boolean;
539
- error: Error | null;
540
- };
541
-
542
275
  interface ThemeContextValue {
543
276
  themeClass: string;
544
277
  }
@@ -550,70 +283,4 @@ declare function useTheme(): ThemeContextValue;
550
283
 
551
284
  declare function cn(...inputs: ClassValue[]): string;
552
285
 
553
- declare const i18n: {
554
- transferCrypto: {
555
- priceImpact: {
556
- label: string;
557
- tooltip: string;
558
- finalCost: string;
559
- };
560
- slippage: {
561
- label: string;
562
- auto: string;
563
- tooltip: string;
564
- finalCost: string;
565
- };
566
- processingTime: {
567
- label: string;
568
- lessThanMinutes: string;
569
- lessThanHours: string;
570
- };
571
- minDeposit: {
572
- label: string;
573
- tooltip: string;
574
- };
575
- help: {
576
- needHelp: string;
577
- contactSupport: string;
578
- };
579
- terms: {
580
- termsApply: string;
581
- };
582
- supportedToken: string;
583
- supportedChain: string;
584
- depositAddress: {
585
- label: string;
586
- tooltip: string;
587
- };
588
- copyAddress: string;
589
- copied: string;
590
- loading: string;
591
- loadingQRCode: string;
592
- noAddressAvailable: string;
593
- noChainsAvailable: string;
594
- };
595
- depositModal: {
596
- transferCrypto: {
597
- title: string;
598
- subtitle: string;
599
- };
600
- depositWithCard: {
601
- title: string;
602
- subtitle: string;
603
- };
604
- quotes: string;
605
- };
606
- buyWithCard: {
607
- onramp: {
608
- completeTransaction: string;
609
- canCloseModal: string;
610
- youUse: string;
611
- youBuy: string;
612
- youReceive: string;
613
- intentAddressNote: string;
614
- };
615
- };
616
- };
617
- type I18nStrings = typeof i18n;
618
-
619
- 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 };