@unifold/connect-react-native 0.1.30 → 0.1.32

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/index.d.mts CHANGED
@@ -190,6 +190,40 @@ interface ListTokens {
190
190
  /** List row border radius (default 12) */
191
191
  rowBorderRadius: number;
192
192
  }
193
+ /** All resolved component tokens */
194
+ interface ComponentTokens {
195
+ header: HeaderTokens;
196
+ card: CardTokens;
197
+ input: InputTokens;
198
+ button: ButtonTokens;
199
+ container: ContainerTokens;
200
+ search: SearchTokens;
201
+ list: ListTokens;
202
+ badge: BadgeTokens;
203
+ sheet: SheetTokens;
204
+ /** Card tokens for Add Funds menu options (Transfer Crypto, Deposit with Card, Deposit Tracker) */
205
+ depositMenu: {
206
+ card: CardTokens;
207
+ };
208
+ /** Card tokens for Transfer Crypto deposit address box */
209
+ transferCrypto: {
210
+ depositAddress: {
211
+ card: CardTokens;
212
+ };
213
+ };
214
+ /** Card tokens for Deposit with Card provider card and quote list rows */
215
+ depositCard: {
216
+ quoteProvider: {
217
+ card: CardTokens;
218
+ };
219
+ };
220
+ /** Card tokens for Deposit Tracker execution rows */
221
+ depositTracker: {
222
+ executionRow: {
223
+ card: CardTokens;
224
+ };
225
+ };
226
+ }
193
227
  /** Per-surface card overrides (config input) */
194
228
  interface DepositMenuOverrides {
195
229
  card?: Partial<CardTokens>;
@@ -258,13 +292,47 @@ interface ThemeProviderProps {
258
292
  /** Same props as ThemeProvider without children — for re-wrapping subtrees (e.g. nested modals). */
259
293
  type ThemeProviderConfig = Omit<ThemeProviderProps, "children">;
260
294
 
295
+ /** Resolved font families for use in styles */
296
+ interface ResolvedFonts {
297
+ regular: string | undefined;
298
+ medium: string | undefined;
299
+ semibold: string | undefined;
300
+ bold: string | undefined;
301
+ }
302
+ interface ThemeContextValue {
303
+ mode: ThemeMode;
304
+ colors: ThemeColors;
305
+ fonts: ResolvedFonts;
306
+ components: ComponentTokens;
307
+ isDark: boolean;
308
+ }
309
+ declare function useTheme(): ThemeContextValue;
310
+
261
311
  interface BorderRadiusConfig {
262
312
  borderTopLeftRadius?: number;
263
313
  borderTopRightRadius?: number;
264
314
  }
315
+ interface BottomSheetProps {
316
+ visible: boolean;
317
+ onClose: () => void;
318
+ children: React$1.ReactNode;
319
+ closeOnBackdropPress?: boolean;
320
+ showHandle?: boolean;
321
+ /** Height as percentage of screen (0-1), e.g. 0.9 for 90% */
322
+ heightPercent?: number;
323
+ /** Remove bottom safe area padding */
324
+ noPadding?: boolean;
325
+ /** Top-left corner radius (default: 24) */
326
+ borderTopLeftRadius?: number;
327
+ /** Top-right corner radius (default: 24) */
328
+ borderTopRightRadius?: number;
329
+ }
330
+ declare function BottomSheet({ visible, onClose, children, closeOnBackdropPress, showHandle, heightPercent, noPadding, borderTopLeftRadius, borderTopRightRadius, }: BottomSheetProps): react_jsx_runtime.JSX.Element;
265
331
 
266
332
  /** Controls which transfer crypto input variant is rendered */
267
333
  type TransferInputVariant = "single_input" | "double_input";
334
+ /** Controls which screen opens first when the deposit modal is shown */
335
+ type DepositInitialScreen = "main" | "transfer" | "card" | "tracker";
268
336
  interface DepositModalProps {
269
337
  /** Whether the modal is visible */
270
338
  visible: boolean;
@@ -323,6 +391,14 @@ interface DepositModalProps {
323
391
  depositConfirmationMode?: "auto_ui" | "auto_silent" | "manual";
324
392
  /** Transfer input variant: 'single_input' (unified selector) or 'double_input' (separate token/chain). Defaults to 'double_input' */
325
393
  transferInputVariant?: TransferInputVariant;
394
+ /**
395
+ * Which screen to open first. Defaults to 'main' (the option menu).
396
+ * - 'main': show the menu (default)
397
+ * - 'transfer': open Transfer Crypto immediately
398
+ * - 'card': open Buy with Card immediately
399
+ * - 'tracker': open Deposit Tracker immediately (ignored if hideDepositTracker is true)
400
+ */
401
+ initialScreen?: DepositInitialScreen;
326
402
  /** Callback when deposit succeeds */
327
403
  onDepositSuccess?: (data: {
328
404
  message: string;
@@ -373,6 +449,71 @@ interface DepositModalProps {
373
449
  * No-op when not `__DEV__`; empty / whitespace clears the override.
374
450
  */
375
451
  declare function setDevApiUrl(url: string): void;
452
+ /**
453
+ * Normalize an icon URL from API response
454
+ * If the URL is relative (starts with /), prepend the API base URL
455
+ * If the URL contains localhost, replace with the configured API base URL
456
+ * If the URL is already absolute (starts with http), return as-is
457
+ */
458
+ declare function normalizeIconUrl(iconUrl: string | undefined | null): string;
459
+ interface IconUrl {
460
+ url: string;
461
+ format: "svg" | "png";
462
+ }
463
+ /**
464
+ * Get the preferred icon URL from an object with icon_url and icon_urls
465
+ * @param item - Object with icon_url and optional icon_urls array
466
+ * @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
467
+ * @returns The URL string for the preferred format, or icon_url as fallback
468
+ */
469
+ declare function getPreferredIcon(item: {
470
+ icon_url: string;
471
+ icon_urls?: IconUrl[];
472
+ } | undefined | null, preferredFormat?: "svg" | "png"): string;
473
+ interface DestinationTokenChain {
474
+ chain_id: string;
475
+ chain_type: string;
476
+ chain_name: string;
477
+ icon_url: string;
478
+ icon_urls?: IconUrl[];
479
+ token_address: string;
480
+ }
481
+ interface DestinationToken {
482
+ symbol: string;
483
+ name: string;
484
+ icon_url: string;
485
+ icon_urls?: IconUrl[];
486
+ chains: DestinationTokenChain[];
487
+ }
488
+ interface SupportedDestinationTokensResponse {
489
+ data: DestinationToken[];
490
+ }
491
+ /**
492
+ * Get supported destination tokens for withdrawals
493
+ * @param publishableKey - Optional publishable key, defaults to configured key
494
+ */
495
+ declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
496
+
497
+ interface WithdrawTransactionInfo {
498
+ sourceChainType: string;
499
+ sourceChainId: string;
500
+ sourceTokenAddress: string;
501
+ sourceTokenSymbol: string;
502
+ sourceTokenIconUrl?: string;
503
+ destinationChainType: string;
504
+ destinationChainId: string;
505
+ destinationTokenAddress: string;
506
+ destinationTokenSymbol: string;
507
+ destinationChainName?: string;
508
+ destinationTokenIconUrl?: string;
509
+ amount: string;
510
+ amountBaseUnit: string;
511
+ submittedAt?: Date;
512
+ /** The Unifold deposit wallet address to send funds to */
513
+ withdrawIntentAddress: string;
514
+ /** The user-provided final destination address */
515
+ recipientAddress: string;
516
+ }
376
517
 
377
518
  /**
378
519
  * Result of the useAllowedCountry hook
@@ -490,13 +631,68 @@ interface DepositConfig {
490
631
  * - manual: Show "I've deposited" button. Clicking enters waiting UI and starts polling. No automatic polling.
491
632
  */
492
633
  depositConfirmationMode?: "auto_ui" | "auto_silent" | "manual";
634
+ /**
635
+ * Which screen to open first when the deposit modal appears.
636
+ * - 'main' (default): show the option menu
637
+ * - 'transfer': open Transfer Crypto immediately
638
+ * - 'card': open Buy with Card immediately
639
+ * - 'tracker': open Deposit Tracker immediately
640
+ */
641
+ initialScreen?: DepositInitialScreen;
493
642
  onSuccess?: (data: DepositResult) => void;
494
643
  onError?: (error: DepositError) => void;
495
644
  }
645
+ interface WithdrawResult {
646
+ message: string;
647
+ transaction?: unknown;
648
+ }
649
+ interface WithdrawError {
650
+ message: string;
651
+ error?: unknown;
652
+ code?: string;
653
+ }
654
+ /**
655
+ * Configuration for beginWithdraw().
656
+ *
657
+ * The consumer must provide `withdraw` to handle the actual transaction
658
+ * signing and broadcasting. The SDK creates the intermediary deposit wallet
659
+ * and polls for execution completion.
660
+ *
661
+ * Source token/chain must be passed directly.
662
+ */
663
+ interface WithdrawConfig {
664
+ externalUserId: string;
665
+ /** The user's wallet address — used to fetch balance. Wallet-agnostic: pass any address string. */
666
+ senderAddress: string;
667
+ /** Source token chain type (e.g. "ethereum") */
668
+ sourceChainType: "ethereum" | "solana" | "bitcoin";
669
+ /** Source token chain ID (e.g. "8453" for Base) */
670
+ sourceChainId: string;
671
+ /** Source token contract address */
672
+ sourceTokenAddress: string;
673
+ /** Source token symbol for display (e.g. "USDC") */
674
+ sourceTokenSymbol?: string;
675
+ /** Optional pre-fill for the recipient address field */
676
+ recipientAddress?: string;
677
+ /**
678
+ * Called when the user confirms withdrawal. The consumer is responsible for
679
+ * signing and broadcasting the transaction — matches the web SDK interface.
680
+ * @param txInfo - All information needed to construct the EVM/Solana transaction
681
+ */
682
+ withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
683
+ /** Called when the withdrawal execution reaches SUCCEEDED status */
684
+ onSuccess?: (data: WithdrawResult) => void;
685
+ /** Called on withdrawal errors */
686
+ onError?: (error: WithdrawError) => void;
687
+ /** Called when the user dismisses the withdraw modal */
688
+ onClose?: () => void;
689
+ }
496
690
  interface ConnectContextValue {
497
691
  publishableKey: string;
498
692
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
499
693
  closeDeposit: () => void;
694
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
695
+ closeWithdraw: () => void;
500
696
  }
501
697
  interface UnifoldProviderProps {
502
698
  children: ReactNode;
@@ -506,4 +702,4 @@ interface UnifoldProviderProps {
506
702
  declare function UnifoldProvider({ children, publishableKey, config, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
507
703
  declare function useUnifold(): ConnectContextValue;
508
704
 
509
- export { type AllowedCountryResult, type BorderRadiusConfig, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, type DepositResult, type FontConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeProviderConfig, type TransferInputVariant, type UnifoldConnectProviderConfig, UnifoldProvider, type UnifoldProviderProps, registerStripeOnramp, setDevApiUrl, useAllowedCountry, useUnifold };
705
+ export { type AllowedCountryResult, type BorderRadiusConfig, BottomSheet, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, type DepositInitialScreen, type DepositResult, type DestinationToken, type DestinationTokenChain, type FontConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeProviderConfig, type TransferInputVariant, type UnifoldConnectProviderConfig, UnifoldProvider, type UnifoldProviderProps, type WithdrawConfig, type WithdrawError, type WithdrawResult, type WithdrawTransactionInfo, getPreferredIcon, getSupportedDestinationTokens, normalizeIconUrl, registerStripeOnramp, setDevApiUrl, useAllowedCountry, useTheme, useUnifold };
package/dist/index.d.ts CHANGED
@@ -190,6 +190,40 @@ interface ListTokens {
190
190
  /** List row border radius (default 12) */
191
191
  rowBorderRadius: number;
192
192
  }
193
+ /** All resolved component tokens */
194
+ interface ComponentTokens {
195
+ header: HeaderTokens;
196
+ card: CardTokens;
197
+ input: InputTokens;
198
+ button: ButtonTokens;
199
+ container: ContainerTokens;
200
+ search: SearchTokens;
201
+ list: ListTokens;
202
+ badge: BadgeTokens;
203
+ sheet: SheetTokens;
204
+ /** Card tokens for Add Funds menu options (Transfer Crypto, Deposit with Card, Deposit Tracker) */
205
+ depositMenu: {
206
+ card: CardTokens;
207
+ };
208
+ /** Card tokens for Transfer Crypto deposit address box */
209
+ transferCrypto: {
210
+ depositAddress: {
211
+ card: CardTokens;
212
+ };
213
+ };
214
+ /** Card tokens for Deposit with Card provider card and quote list rows */
215
+ depositCard: {
216
+ quoteProvider: {
217
+ card: CardTokens;
218
+ };
219
+ };
220
+ /** Card tokens for Deposit Tracker execution rows */
221
+ depositTracker: {
222
+ executionRow: {
223
+ card: CardTokens;
224
+ };
225
+ };
226
+ }
193
227
  /** Per-surface card overrides (config input) */
194
228
  interface DepositMenuOverrides {
195
229
  card?: Partial<CardTokens>;
@@ -258,13 +292,47 @@ interface ThemeProviderProps {
258
292
  /** Same props as ThemeProvider without children — for re-wrapping subtrees (e.g. nested modals). */
259
293
  type ThemeProviderConfig = Omit<ThemeProviderProps, "children">;
260
294
 
295
+ /** Resolved font families for use in styles */
296
+ interface ResolvedFonts {
297
+ regular: string | undefined;
298
+ medium: string | undefined;
299
+ semibold: string | undefined;
300
+ bold: string | undefined;
301
+ }
302
+ interface ThemeContextValue {
303
+ mode: ThemeMode;
304
+ colors: ThemeColors;
305
+ fonts: ResolvedFonts;
306
+ components: ComponentTokens;
307
+ isDark: boolean;
308
+ }
309
+ declare function useTheme(): ThemeContextValue;
310
+
261
311
  interface BorderRadiusConfig {
262
312
  borderTopLeftRadius?: number;
263
313
  borderTopRightRadius?: number;
264
314
  }
315
+ interface BottomSheetProps {
316
+ visible: boolean;
317
+ onClose: () => void;
318
+ children: React$1.ReactNode;
319
+ closeOnBackdropPress?: boolean;
320
+ showHandle?: boolean;
321
+ /** Height as percentage of screen (0-1), e.g. 0.9 for 90% */
322
+ heightPercent?: number;
323
+ /** Remove bottom safe area padding */
324
+ noPadding?: boolean;
325
+ /** Top-left corner radius (default: 24) */
326
+ borderTopLeftRadius?: number;
327
+ /** Top-right corner radius (default: 24) */
328
+ borderTopRightRadius?: number;
329
+ }
330
+ declare function BottomSheet({ visible, onClose, children, closeOnBackdropPress, showHandle, heightPercent, noPadding, borderTopLeftRadius, borderTopRightRadius, }: BottomSheetProps): react_jsx_runtime.JSX.Element;
265
331
 
266
332
  /** Controls which transfer crypto input variant is rendered */
267
333
  type TransferInputVariant = "single_input" | "double_input";
334
+ /** Controls which screen opens first when the deposit modal is shown */
335
+ type DepositInitialScreen = "main" | "transfer" | "card" | "tracker";
268
336
  interface DepositModalProps {
269
337
  /** Whether the modal is visible */
270
338
  visible: boolean;
@@ -323,6 +391,14 @@ interface DepositModalProps {
323
391
  depositConfirmationMode?: "auto_ui" | "auto_silent" | "manual";
324
392
  /** Transfer input variant: 'single_input' (unified selector) or 'double_input' (separate token/chain). Defaults to 'double_input' */
325
393
  transferInputVariant?: TransferInputVariant;
394
+ /**
395
+ * Which screen to open first. Defaults to 'main' (the option menu).
396
+ * - 'main': show the menu (default)
397
+ * - 'transfer': open Transfer Crypto immediately
398
+ * - 'card': open Buy with Card immediately
399
+ * - 'tracker': open Deposit Tracker immediately (ignored if hideDepositTracker is true)
400
+ */
401
+ initialScreen?: DepositInitialScreen;
326
402
  /** Callback when deposit succeeds */
327
403
  onDepositSuccess?: (data: {
328
404
  message: string;
@@ -373,6 +449,71 @@ interface DepositModalProps {
373
449
  * No-op when not `__DEV__`; empty / whitespace clears the override.
374
450
  */
375
451
  declare function setDevApiUrl(url: string): void;
452
+ /**
453
+ * Normalize an icon URL from API response
454
+ * If the URL is relative (starts with /), prepend the API base URL
455
+ * If the URL contains localhost, replace with the configured API base URL
456
+ * If the URL is already absolute (starts with http), return as-is
457
+ */
458
+ declare function normalizeIconUrl(iconUrl: string | undefined | null): string;
459
+ interface IconUrl {
460
+ url: string;
461
+ format: "svg" | "png";
462
+ }
463
+ /**
464
+ * Get the preferred icon URL from an object with icon_url and icon_urls
465
+ * @param item - Object with icon_url and optional icon_urls array
466
+ * @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
467
+ * @returns The URL string for the preferred format, or icon_url as fallback
468
+ */
469
+ declare function getPreferredIcon(item: {
470
+ icon_url: string;
471
+ icon_urls?: IconUrl[];
472
+ } | undefined | null, preferredFormat?: "svg" | "png"): string;
473
+ interface DestinationTokenChain {
474
+ chain_id: string;
475
+ chain_type: string;
476
+ chain_name: string;
477
+ icon_url: string;
478
+ icon_urls?: IconUrl[];
479
+ token_address: string;
480
+ }
481
+ interface DestinationToken {
482
+ symbol: string;
483
+ name: string;
484
+ icon_url: string;
485
+ icon_urls?: IconUrl[];
486
+ chains: DestinationTokenChain[];
487
+ }
488
+ interface SupportedDestinationTokensResponse {
489
+ data: DestinationToken[];
490
+ }
491
+ /**
492
+ * Get supported destination tokens for withdrawals
493
+ * @param publishableKey - Optional publishable key, defaults to configured key
494
+ */
495
+ declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
496
+
497
+ interface WithdrawTransactionInfo {
498
+ sourceChainType: string;
499
+ sourceChainId: string;
500
+ sourceTokenAddress: string;
501
+ sourceTokenSymbol: string;
502
+ sourceTokenIconUrl?: string;
503
+ destinationChainType: string;
504
+ destinationChainId: string;
505
+ destinationTokenAddress: string;
506
+ destinationTokenSymbol: string;
507
+ destinationChainName?: string;
508
+ destinationTokenIconUrl?: string;
509
+ amount: string;
510
+ amountBaseUnit: string;
511
+ submittedAt?: Date;
512
+ /** The Unifold deposit wallet address to send funds to */
513
+ withdrawIntentAddress: string;
514
+ /** The user-provided final destination address */
515
+ recipientAddress: string;
516
+ }
376
517
 
377
518
  /**
378
519
  * Result of the useAllowedCountry hook
@@ -490,13 +631,68 @@ interface DepositConfig {
490
631
  * - manual: Show "I've deposited" button. Clicking enters waiting UI and starts polling. No automatic polling.
491
632
  */
492
633
  depositConfirmationMode?: "auto_ui" | "auto_silent" | "manual";
634
+ /**
635
+ * Which screen to open first when the deposit modal appears.
636
+ * - 'main' (default): show the option menu
637
+ * - 'transfer': open Transfer Crypto immediately
638
+ * - 'card': open Buy with Card immediately
639
+ * - 'tracker': open Deposit Tracker immediately
640
+ */
641
+ initialScreen?: DepositInitialScreen;
493
642
  onSuccess?: (data: DepositResult) => void;
494
643
  onError?: (error: DepositError) => void;
495
644
  }
645
+ interface WithdrawResult {
646
+ message: string;
647
+ transaction?: unknown;
648
+ }
649
+ interface WithdrawError {
650
+ message: string;
651
+ error?: unknown;
652
+ code?: string;
653
+ }
654
+ /**
655
+ * Configuration for beginWithdraw().
656
+ *
657
+ * The consumer must provide `withdraw` to handle the actual transaction
658
+ * signing and broadcasting. The SDK creates the intermediary deposit wallet
659
+ * and polls for execution completion.
660
+ *
661
+ * Source token/chain must be passed directly.
662
+ */
663
+ interface WithdrawConfig {
664
+ externalUserId: string;
665
+ /** The user's wallet address — used to fetch balance. Wallet-agnostic: pass any address string. */
666
+ senderAddress: string;
667
+ /** Source token chain type (e.g. "ethereum") */
668
+ sourceChainType: "ethereum" | "solana" | "bitcoin";
669
+ /** Source token chain ID (e.g. "8453" for Base) */
670
+ sourceChainId: string;
671
+ /** Source token contract address */
672
+ sourceTokenAddress: string;
673
+ /** Source token symbol for display (e.g. "USDC") */
674
+ sourceTokenSymbol?: string;
675
+ /** Optional pre-fill for the recipient address field */
676
+ recipientAddress?: string;
677
+ /**
678
+ * Called when the user confirms withdrawal. The consumer is responsible for
679
+ * signing and broadcasting the transaction — matches the web SDK interface.
680
+ * @param txInfo - All information needed to construct the EVM/Solana transaction
681
+ */
682
+ withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
683
+ /** Called when the withdrawal execution reaches SUCCEEDED status */
684
+ onSuccess?: (data: WithdrawResult) => void;
685
+ /** Called on withdrawal errors */
686
+ onError?: (error: WithdrawError) => void;
687
+ /** Called when the user dismisses the withdraw modal */
688
+ onClose?: () => void;
689
+ }
496
690
  interface ConnectContextValue {
497
691
  publishableKey: string;
498
692
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
499
693
  closeDeposit: () => void;
694
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
695
+ closeWithdraw: () => void;
500
696
  }
501
697
  interface UnifoldProviderProps {
502
698
  children: ReactNode;
@@ -506,4 +702,4 @@ interface UnifoldProviderProps {
506
702
  declare function UnifoldProvider({ children, publishableKey, config, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
507
703
  declare function useUnifold(): ConnectContextValue;
508
704
 
509
- export { type AllowedCountryResult, type BorderRadiusConfig, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, type DepositResult, type FontConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeProviderConfig, type TransferInputVariant, type UnifoldConnectProviderConfig, UnifoldProvider, type UnifoldProviderProps, registerStripeOnramp, setDevApiUrl, useAllowedCountry, useUnifold };
705
+ export { type AllowedCountryResult, type BorderRadiusConfig, BottomSheet, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, type DepositInitialScreen, type DepositResult, type DestinationToken, type DestinationTokenChain, type FontConfig, type ThemeColors, type ThemeConfig, type ThemeMode, type ThemeProviderConfig, type TransferInputVariant, type UnifoldConnectProviderConfig, UnifoldProvider, type UnifoldProviderProps, type WithdrawConfig, type WithdrawError, type WithdrawResult, type WithdrawTransactionInfo, getPreferredIcon, getSupportedDestinationTokens, normalizeIconUrl, registerStripeOnramp, setDevApiUrl, useAllowedCountry, useTheme, useUnifold };