@unifold/connect-react 0.1.40 → 0.1.42

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
@@ -132,6 +132,10 @@ Launches the deposit modal with the specified configuration. **Returns a Promise
132
132
  | `destinationTokenAddress` | string | ✅ | Token contract address |
133
133
  | `destinationTokenSymbol` | string | ✅ | Token symbol (e.g., "USDC") |
134
134
  | `recipientAddress` | string | ✅ | Recipient wallet address |
135
+ | `defaultSourceChainType` | string | - | Pre-select source chain type in Transfer Crypto (e.g. `"solana"`, `"ethereum"`). Must be paired with `defaultSourceChainId` + symbol or token address. If omitted or no match, defaults to the first token from `/supported_deposit_tokens`. |
136
+ | `defaultSourceChainId` | string | - | Source chain ID (e.g. `"mainnet"`, `"137"`). Paired with `defaultSourceChainType`. |
137
+ | `defaultSourceTokenAddress` | string | - | Source token contract address. Paired with chain type + chain ID. |
138
+ | `defaultSourceSymbol` | string | - | Source token symbol (e.g. `"USDC"`). Paired with chain type + chain ID. |
135
139
  | `onSuccess` | function | - | Success callback (fired immediately) |
136
140
  | `onError` | function | - | Error callback (fired immediately) |
137
141
  | `initialScreen` | `'main' \| 'transfer' \| 'card' \| 'tracker'` | - | `main` (default) = deposit menu. `transfer` / `card` use the **same geo/validation gates** as the menu. `tracker` opens the list **without** those gates. If not `main`, the header **back** is hidden (standalone); from `main`, back returns to the menu. Card quotes/onramp and tracker detail still show back for inner steps. |
package/dist/index.d.mts CHANGED
@@ -1,13 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, AllowedCountryResult } from '@unifold/ui-react';
4
- export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode } from '@unifold/ui-react';
5
- export { AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionRequest, OnrampSessionResponse, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SupportedChain, SupportedDepositTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp } from '@unifold/core';
3
+ import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
4
+ export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, WithdrawTransactionInfo } from '@unifold/ui-react';
5
+ export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionRequest, OnrampSessionResponse, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
6
6
 
7
7
  interface UnifoldConnectProviderConfig {
8
8
  publishableKey: string;
9
9
  config?: {
10
10
  modalTitle?: string;
11
+ /** Custom title for the withdraw modal. @default `"Withdraw"` */
12
+ withdrawModalTitle?: string;
11
13
  hideDepositTracker?: boolean;
12
14
  /** Show balance in deposit modal header. Defaults to true */
13
15
  showBalanceHeader?: boolean;
@@ -66,6 +68,18 @@ interface DepositConfig {
66
68
  destinationTokenAddress: string;
67
69
  destinationTokenSymbol: string;
68
70
  recipientAddress: string;
71
+ /**
72
+ * Pre-select source token/chain in the Transfer Crypto view.
73
+ * All four props are optional. To match a specific token, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
74
+ * If omitted or no match is found in `/supported_deposit_tokens`, the first available token and chain are used.
75
+ */
76
+ defaultSourceChainType?: ChainType;
77
+ /** Source chain ID (e.g. `"mainnet"`, `"137"`). Must be paired with `defaultSourceChainType` and a symbol or token address. */
78
+ defaultSourceChainId?: string;
79
+ /** Source token contract address. Must be paired with `defaultSourceChainType` + `defaultSourceChainId` to match. */
80
+ defaultSourceTokenAddress?: string;
81
+ /** Source token symbol (e.g. `"USDC"`). Must be paired with `defaultSourceChainType` + `defaultSourceChainId` to match. */
82
+ defaultSourceSymbol?: string;
69
83
  /** How to confirm deposit: 'auto_ui' (default), 'auto_silent', or 'manual' */
70
84
  depositConfirmationMode?: DepositConfirmationMode;
71
85
  onSuccess?: (data: DepositResult) => void;
@@ -80,11 +94,56 @@ interface DepositConfig {
80
94
  */
81
95
  initialScreen?: DepositModalInitialScreen;
82
96
  }
97
+ interface WithdrawResult {
98
+ message: string;
99
+ transaction?: unknown;
100
+ }
101
+ interface WithdrawError {
102
+ message: string;
103
+ error?: unknown;
104
+ code?: string;
105
+ }
106
+ interface WithdrawConfig {
107
+ /** External user ID — required, same as deposit */
108
+ externalUserId: string;
109
+ /** Source token chain type (e.g. 'ethereum', 'solana'). Must be a supported stablecoin. */
110
+ sourceChainType: ChainType;
111
+ /** Source token chain ID (e.g. '8453', 'mainnet') */
112
+ sourceChainId: string;
113
+ /** Source token contract address */
114
+ sourceTokenAddress: string;
115
+ /** Source token symbol (e.g. 'USDC'). Optional but recommended for display. */
116
+ sourceTokenSymbol?: string;
117
+ /** Optional: pre-fill the recipient address the user is withdrawing to */
118
+ recipientAddress?: string;
119
+ /**
120
+ * The user's wallet address (the sender). Used to:
121
+ * 1. Fetch balance for quick-select chips (25%/50%/75%/MAX)
122
+ * 2. Detect if a matching browser wallet is connected
123
+ */
124
+ senderAddress: string;
125
+ /**
126
+ * Callback invoked with transaction details when user confirms withdrawal.
127
+ * The platform must implement the actual transaction signing/sending since
128
+ * we don't have the private key.
129
+ *
130
+ * Optional — if omitted, the user must have a matching connected browser wallet
131
+ * to execute the withdrawal. If neither `withdraw` nor a connected wallet is available,
132
+ * the modal will show an error.
133
+ */
134
+ withdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
135
+ onSuccess?: (data: WithdrawResult) => void;
136
+ onError?: (error: WithdrawError) => void;
137
+ onClose?: () => void;
138
+ }
139
+
83
140
  declare function UnifoldProvider({ children, publishableKey, config, }: React.PropsWithChildren<UnifoldConnectProviderConfig>): react_jsx_runtime.JSX.Element;
84
141
  declare function useUnifold(): {
85
142
  publishableKey: string;
86
143
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
87
144
  closeDeposit: () => void;
145
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
146
+ closeWithdraw: () => void;
88
147
  };
89
148
  /**
90
149
  * Convenience wrapper for useAllowedCountry that automatically passes publishableKey from context
@@ -110,4 +169,4 @@ declare function useUnifold(): {
110
169
  */
111
170
  declare function useAllowedCountry(): AllowedCountryResult;
112
171
 
113
- export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, useAllowedCountry, useUnifold };
172
+ export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, type WithdrawConfig, type WithdrawError, type WithdrawResult, useAllowedCountry, useUnifold };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
- import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, AllowedCountryResult } from '@unifold/ui-react';
4
- export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode } from '@unifold/ui-react';
5
- export { AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionRequest, OnrampSessionResponse, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SupportedChain, SupportedDepositTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp } from '@unifold/core';
3
+ import { ThemeMode, ThemeConfig, FontConfig, ComponentConfig, DepositModalInitialScreen, ChainType, DepositConfirmationMode, WithdrawTransactionInfo, AllowedCountryResult } from '@unifold/ui-react';
4
+ export { AllowedCountryResult, BrowserWalletAmountQuickSelect, Button, ButtonProps, ButtonTokens, CardTokens, ComponentConfig, ComponentTokens, ConfirmingView, ContainerTokens, CustomThemeColors, DepositConfirmationMode, DepositModalInitialScreen as DepositInitialScreen, FontConfig, HeaderTokens, InputTokens, ListTokens, SearchTokens, ThemeColors, ThemeConfig, ThemeMode, WithdrawTransactionInfo } from '@unifold/ui-react';
5
+ export { ActionType, AutoSwapRequest, AutoSwapResponse, ChainType, CreateDepositAddressRequest, DefaultTokenChain, DefaultTokenMetadata, DefaultTokenResponse, DepositAddressResponse, DestinationToken, DestinationTokenChain, ExecutionStatus, FeaturedToken, FiatCurrenciesResponse, FiatCurrency, I18nStrings, IconUrl, IpAddressResponse, OnrampQuote, OnrampQuotesRequest, OnrampQuotesResponse, OnrampSessionRequest, OnrampSessionResponse, PaymentNetwork, ProjectConfigResponse, QueryExecutionsRequest, QueryExecutionsResponse, SOLANA_USDC_ADDRESS, SendSolanaTransactionRequest, SendSolanaTransactionResponse, SupportedChain, SupportedDepositTokensResponse, SupportedDestinationTokensResponse, SupportedToken, TokenChain, TokenChainIconUrl, TokenChainsResponse, UserIpInfo, Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp } from '@unifold/core';
6
6
 
7
7
  interface UnifoldConnectProviderConfig {
8
8
  publishableKey: string;
9
9
  config?: {
10
10
  modalTitle?: string;
11
+ /** Custom title for the withdraw modal. @default `"Withdraw"` */
12
+ withdrawModalTitle?: string;
11
13
  hideDepositTracker?: boolean;
12
14
  /** Show balance in deposit modal header. Defaults to true */
13
15
  showBalanceHeader?: boolean;
@@ -66,6 +68,18 @@ interface DepositConfig {
66
68
  destinationTokenAddress: string;
67
69
  destinationTokenSymbol: string;
68
70
  recipientAddress: string;
71
+ /**
72
+ * Pre-select source token/chain in the Transfer Crypto view.
73
+ * All four props are optional. To match a specific token, provide `chainType` + `chainId` + (`symbol` OR `tokenAddress`).
74
+ * If omitted or no match is found in `/supported_deposit_tokens`, the first available token and chain are used.
75
+ */
76
+ defaultSourceChainType?: ChainType;
77
+ /** Source chain ID (e.g. `"mainnet"`, `"137"`). Must be paired with `defaultSourceChainType` and a symbol or token address. */
78
+ defaultSourceChainId?: string;
79
+ /** Source token contract address. Must be paired with `defaultSourceChainType` + `defaultSourceChainId` to match. */
80
+ defaultSourceTokenAddress?: string;
81
+ /** Source token symbol (e.g. `"USDC"`). Must be paired with `defaultSourceChainType` + `defaultSourceChainId` to match. */
82
+ defaultSourceSymbol?: string;
69
83
  /** How to confirm deposit: 'auto_ui' (default), 'auto_silent', or 'manual' */
70
84
  depositConfirmationMode?: DepositConfirmationMode;
71
85
  onSuccess?: (data: DepositResult) => void;
@@ -80,11 +94,56 @@ interface DepositConfig {
80
94
  */
81
95
  initialScreen?: DepositModalInitialScreen;
82
96
  }
97
+ interface WithdrawResult {
98
+ message: string;
99
+ transaction?: unknown;
100
+ }
101
+ interface WithdrawError {
102
+ message: string;
103
+ error?: unknown;
104
+ code?: string;
105
+ }
106
+ interface WithdrawConfig {
107
+ /** External user ID — required, same as deposit */
108
+ externalUserId: string;
109
+ /** Source token chain type (e.g. 'ethereum', 'solana'). Must be a supported stablecoin. */
110
+ sourceChainType: ChainType;
111
+ /** Source token chain ID (e.g. '8453', 'mainnet') */
112
+ sourceChainId: string;
113
+ /** Source token contract address */
114
+ sourceTokenAddress: string;
115
+ /** Source token symbol (e.g. 'USDC'). Optional but recommended for display. */
116
+ sourceTokenSymbol?: string;
117
+ /** Optional: pre-fill the recipient address the user is withdrawing to */
118
+ recipientAddress?: string;
119
+ /**
120
+ * The user's wallet address (the sender). Used to:
121
+ * 1. Fetch balance for quick-select chips (25%/50%/75%/MAX)
122
+ * 2. Detect if a matching browser wallet is connected
123
+ */
124
+ senderAddress: string;
125
+ /**
126
+ * Callback invoked with transaction details when user confirms withdrawal.
127
+ * The platform must implement the actual transaction signing/sending since
128
+ * we don't have the private key.
129
+ *
130
+ * Optional — if omitted, the user must have a matching connected browser wallet
131
+ * to execute the withdrawal. If neither `withdraw` nor a connected wallet is available,
132
+ * the modal will show an error.
133
+ */
134
+ withdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
135
+ onSuccess?: (data: WithdrawResult) => void;
136
+ onError?: (error: WithdrawError) => void;
137
+ onClose?: () => void;
138
+ }
139
+
83
140
  declare function UnifoldProvider({ children, publishableKey, config, }: React.PropsWithChildren<UnifoldConnectProviderConfig>): react_jsx_runtime.JSX.Element;
84
141
  declare function useUnifold(): {
85
142
  publishableKey: string;
86
143
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
87
144
  closeDeposit: () => void;
145
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
146
+ closeWithdraw: () => void;
88
147
  };
89
148
  /**
90
149
  * Convenience wrapper for useAllowedCountry that automatically passes publishableKey from context
@@ -110,4 +169,4 @@ declare function useUnifold(): {
110
169
  */
111
170
  declare function useAllowedCountry(): AllowedCountryResult;
112
171
 
113
- export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, useAllowedCountry, useUnifold };
172
+ export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, type WithdrawConfig, type WithdrawError, type WithdrawResult, useAllowedCountry, useUnifold };