@unifold/connect-react-native 0.1.29 → 0.1.31

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
@@ -36,7 +36,7 @@ Link Pay uses `@stripe/stripe-react-native`, which includes **native** code (App
36
36
 
37
37
  Importing `@unifold/connect-react-native` loads the Stripe UI registration in the same JS bundle as the provider. Ensure the peer dependencies in **Installation** above are installed so Metro does not duplicate native modules.
38
38
 
39
- **`expo-constants`** is a **dependency** of `@unifold/connect-react-native`, and the SDK **entry** includes a static `import "expo-constants"` so Metro always links the module. (A `require("expo-constants")` only inside the prebuilt UI was not always enough for Metro’s graph.) You can still set **`config.stripeMerchantIdentifier`** on `UnifoldProvider` to override or skip reading the plugin from constants.
39
+ **`expo-constants`** is a **dependency** of `@unifold/connect-react-native`. The prebuilt bundle uses a **static** `import` from `expo-constants` (in the Stripe helper that reads the Expo plugin) so Metro always links the module. (A runtime `require("expo-constants")` in that path was still emitted inside the bundle and could trigger “unknown module” in Metro.) You can still set **`config.stripeMerchantIdentifier`** on `UnifoldProvider` to override or skip reading the plugin from constants.
40
40
 
41
41
  #### Expo Go vs development build vs prebuild
42
42
 
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,10 +292,42 @@ 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";
@@ -373,6 +439,71 @@ interface DepositModalProps {
373
439
  * No-op when not `__DEV__`; empty / whitespace clears the override.
374
440
  */
375
441
  declare function setDevApiUrl(url: string): void;
442
+ /**
443
+ * Normalize an icon URL from API response
444
+ * If the URL is relative (starts with /), prepend the API base URL
445
+ * If the URL contains localhost, replace with the configured API base URL
446
+ * If the URL is already absolute (starts with http), return as-is
447
+ */
448
+ declare function normalizeIconUrl(iconUrl: string | undefined | null): string;
449
+ interface IconUrl {
450
+ url: string;
451
+ format: "svg" | "png";
452
+ }
453
+ /**
454
+ * Get the preferred icon URL from an object with icon_url and icon_urls
455
+ * @param item - Object with icon_url and optional icon_urls array
456
+ * @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
457
+ * @returns The URL string for the preferred format, or icon_url as fallback
458
+ */
459
+ declare function getPreferredIcon(item: {
460
+ icon_url: string;
461
+ icon_urls?: IconUrl[];
462
+ } | undefined | null, preferredFormat?: "svg" | "png"): string;
463
+ interface DestinationTokenChain {
464
+ chain_id: string;
465
+ chain_type: string;
466
+ chain_name: string;
467
+ icon_url: string;
468
+ icon_urls?: IconUrl[];
469
+ token_address: string;
470
+ }
471
+ interface DestinationToken {
472
+ symbol: string;
473
+ name: string;
474
+ icon_url: string;
475
+ icon_urls?: IconUrl[];
476
+ chains: DestinationTokenChain[];
477
+ }
478
+ interface SupportedDestinationTokensResponse {
479
+ data: DestinationToken[];
480
+ }
481
+ /**
482
+ * Get supported destination tokens for withdrawals
483
+ * @param publishableKey - Optional publishable key, defaults to configured key
484
+ */
485
+ declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
486
+
487
+ interface WithdrawTransactionInfo {
488
+ sourceChainType: string;
489
+ sourceChainId: string;
490
+ sourceTokenAddress: string;
491
+ sourceTokenSymbol: string;
492
+ sourceTokenIconUrl?: string;
493
+ destinationChainType: string;
494
+ destinationChainId: string;
495
+ destinationTokenAddress: string;
496
+ destinationTokenSymbol: string;
497
+ destinationChainName?: string;
498
+ destinationTokenIconUrl?: string;
499
+ amount: string;
500
+ amountBaseUnit: string;
501
+ submittedAt?: Date;
502
+ /** The Unifold deposit wallet address to send funds to */
503
+ withdrawIntentAddress: string;
504
+ /** The user-provided final destination address */
505
+ recipientAddress: string;
506
+ }
376
507
 
377
508
  /**
378
509
  * Result of the useAllowedCountry hook
@@ -493,10 +624,57 @@ interface DepositConfig {
493
624
  onSuccess?: (data: DepositResult) => void;
494
625
  onError?: (error: DepositError) => void;
495
626
  }
627
+ interface WithdrawResult {
628
+ message: string;
629
+ transaction?: unknown;
630
+ }
631
+ interface WithdrawError {
632
+ message: string;
633
+ error?: unknown;
634
+ code?: string;
635
+ }
636
+ /**
637
+ * Configuration for beginWithdraw().
638
+ *
639
+ * The consumer must provide `withdraw` to handle the actual transaction
640
+ * signing and broadcasting. The SDK creates the intermediary deposit wallet
641
+ * and polls for execution completion.
642
+ *
643
+ * Source token/chain must be passed directly.
644
+ */
645
+ interface WithdrawConfig {
646
+ externalUserId: string;
647
+ /** The user's wallet address — used to fetch balance. Wallet-agnostic: pass any address string. */
648
+ senderAddress: string;
649
+ /** Source token chain type (e.g. "ethereum") */
650
+ sourceChainType: "ethereum" | "solana" | "bitcoin";
651
+ /** Source token chain ID (e.g. "8453" for Base) */
652
+ sourceChainId: string;
653
+ /** Source token contract address */
654
+ sourceTokenAddress: string;
655
+ /** Source token symbol for display (e.g. "USDC") */
656
+ sourceTokenSymbol?: string;
657
+ /** Optional pre-fill for the recipient address field */
658
+ recipientAddress?: string;
659
+ /**
660
+ * Called when the user confirms withdrawal. The consumer is responsible for
661
+ * signing and broadcasting the transaction — matches the web SDK interface.
662
+ * @param txInfo - All information needed to construct the EVM/Solana transaction
663
+ */
664
+ withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
665
+ /** Called when the withdrawal execution reaches SUCCEEDED status */
666
+ onSuccess?: (data: WithdrawResult) => void;
667
+ /** Called on withdrawal errors */
668
+ onError?: (error: WithdrawError) => void;
669
+ /** Called when the user dismisses the withdraw modal */
670
+ onClose?: () => void;
671
+ }
496
672
  interface ConnectContextValue {
497
673
  publishableKey: string;
498
674
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
499
675
  closeDeposit: () => void;
676
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
677
+ closeWithdraw: () => void;
500
678
  }
501
679
  interface UnifoldProviderProps {
502
680
  children: ReactNode;
@@ -506,4 +684,4 @@ interface UnifoldProviderProps {
506
684
  declare function UnifoldProvider({ children, publishableKey, config, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
507
685
  declare function useUnifold(): ConnectContextValue;
508
686
 
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 };
687
+ export { type AllowedCountryResult, type BorderRadiusConfig, BottomSheet, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, 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,10 +292,42 @@ 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";
@@ -373,6 +439,71 @@ interface DepositModalProps {
373
439
  * No-op when not `__DEV__`; empty / whitespace clears the override.
374
440
  */
375
441
  declare function setDevApiUrl(url: string): void;
442
+ /**
443
+ * Normalize an icon URL from API response
444
+ * If the URL is relative (starts with /), prepend the API base URL
445
+ * If the URL contains localhost, replace with the configured API base URL
446
+ * If the URL is already absolute (starts with http), return as-is
447
+ */
448
+ declare function normalizeIconUrl(iconUrl: string | undefined | null): string;
449
+ interface IconUrl {
450
+ url: string;
451
+ format: "svg" | "png";
452
+ }
453
+ /**
454
+ * Get the preferred icon URL from an object with icon_url and icon_urls
455
+ * @param item - Object with icon_url and optional icon_urls array
456
+ * @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
457
+ * @returns The URL string for the preferred format, or icon_url as fallback
458
+ */
459
+ declare function getPreferredIcon(item: {
460
+ icon_url: string;
461
+ icon_urls?: IconUrl[];
462
+ } | undefined | null, preferredFormat?: "svg" | "png"): string;
463
+ interface DestinationTokenChain {
464
+ chain_id: string;
465
+ chain_type: string;
466
+ chain_name: string;
467
+ icon_url: string;
468
+ icon_urls?: IconUrl[];
469
+ token_address: string;
470
+ }
471
+ interface DestinationToken {
472
+ symbol: string;
473
+ name: string;
474
+ icon_url: string;
475
+ icon_urls?: IconUrl[];
476
+ chains: DestinationTokenChain[];
477
+ }
478
+ interface SupportedDestinationTokensResponse {
479
+ data: DestinationToken[];
480
+ }
481
+ /**
482
+ * Get supported destination tokens for withdrawals
483
+ * @param publishableKey - Optional publishable key, defaults to configured key
484
+ */
485
+ declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
486
+
487
+ interface WithdrawTransactionInfo {
488
+ sourceChainType: string;
489
+ sourceChainId: string;
490
+ sourceTokenAddress: string;
491
+ sourceTokenSymbol: string;
492
+ sourceTokenIconUrl?: string;
493
+ destinationChainType: string;
494
+ destinationChainId: string;
495
+ destinationTokenAddress: string;
496
+ destinationTokenSymbol: string;
497
+ destinationChainName?: string;
498
+ destinationTokenIconUrl?: string;
499
+ amount: string;
500
+ amountBaseUnit: string;
501
+ submittedAt?: Date;
502
+ /** The Unifold deposit wallet address to send funds to */
503
+ withdrawIntentAddress: string;
504
+ /** The user-provided final destination address */
505
+ recipientAddress: string;
506
+ }
376
507
 
377
508
  /**
378
509
  * Result of the useAllowedCountry hook
@@ -493,10 +624,57 @@ interface DepositConfig {
493
624
  onSuccess?: (data: DepositResult) => void;
494
625
  onError?: (error: DepositError) => void;
495
626
  }
627
+ interface WithdrawResult {
628
+ message: string;
629
+ transaction?: unknown;
630
+ }
631
+ interface WithdrawError {
632
+ message: string;
633
+ error?: unknown;
634
+ code?: string;
635
+ }
636
+ /**
637
+ * Configuration for beginWithdraw().
638
+ *
639
+ * The consumer must provide `withdraw` to handle the actual transaction
640
+ * signing and broadcasting. The SDK creates the intermediary deposit wallet
641
+ * and polls for execution completion.
642
+ *
643
+ * Source token/chain must be passed directly.
644
+ */
645
+ interface WithdrawConfig {
646
+ externalUserId: string;
647
+ /** The user's wallet address — used to fetch balance. Wallet-agnostic: pass any address string. */
648
+ senderAddress: string;
649
+ /** Source token chain type (e.g. "ethereum") */
650
+ sourceChainType: "ethereum" | "solana" | "bitcoin";
651
+ /** Source token chain ID (e.g. "8453" for Base) */
652
+ sourceChainId: string;
653
+ /** Source token contract address */
654
+ sourceTokenAddress: string;
655
+ /** Source token symbol for display (e.g. "USDC") */
656
+ sourceTokenSymbol?: string;
657
+ /** Optional pre-fill for the recipient address field */
658
+ recipientAddress?: string;
659
+ /**
660
+ * Called when the user confirms withdrawal. The consumer is responsible for
661
+ * signing and broadcasting the transaction — matches the web SDK interface.
662
+ * @param txInfo - All information needed to construct the EVM/Solana transaction
663
+ */
664
+ withdraw: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
665
+ /** Called when the withdrawal execution reaches SUCCEEDED status */
666
+ onSuccess?: (data: WithdrawResult) => void;
667
+ /** Called on withdrawal errors */
668
+ onError?: (error: WithdrawError) => void;
669
+ /** Called when the user dismisses the withdraw modal */
670
+ onClose?: () => void;
671
+ }
496
672
  interface ConnectContextValue {
497
673
  publishableKey: string;
498
674
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
499
675
  closeDeposit: () => void;
676
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
677
+ closeWithdraw: () => void;
500
678
  }
501
679
  interface UnifoldProviderProps {
502
680
  children: ReactNode;
@@ -506,4 +684,4 @@ interface UnifoldProviderProps {
506
684
  declare function UnifoldProvider({ children, publishableKey, config, }: UnifoldProviderProps): react_jsx_runtime.JSX.Element;
507
685
  declare function useUnifold(): ConnectContextValue;
508
686
 
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 };
687
+ export { type AllowedCountryResult, type BorderRadiusConfig, BottomSheet, type ComponentConfig, type CustomThemeColors, type DepositConfig, type DepositError, 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 };