@unifold/connect-react 0.1.41 → 0.1.43

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
@@ -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, PaymentIntent, PaymentIntentDepositAddress, 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;
@@ -92,11 +94,76 @@ interface DepositConfig {
92
94
  */
93
95
  initialScreen?: DepositModalInitialScreen;
94
96
  }
97
+ interface CheckoutResult {
98
+ paymentIntentId: string;
99
+ status: string;
100
+ }
101
+ interface CheckoutError {
102
+ message: string;
103
+ error?: unknown;
104
+ code?: string;
105
+ }
106
+ interface WithdrawResult {
107
+ message: string;
108
+ transaction?: unknown;
109
+ }
110
+ interface WithdrawError {
111
+ message: string;
112
+ error?: unknown;
113
+ code?: string;
114
+ }
115
+ interface CheckoutConfig {
116
+ /** The client_secret from a PaymentIntent created on your server */
117
+ clientSecret: string;
118
+ /** Optional callbacks (fired immediately when events occur) */
119
+ onSuccess?: (data: CheckoutResult) => void;
120
+ onError?: (error: CheckoutError) => void;
121
+ /** Called when the user dismisses the checkout dialog */
122
+ onClose?: () => void;
123
+ }
124
+ interface WithdrawConfig {
125
+ /** External user ID — required, same as deposit */
126
+ externalUserId: string;
127
+ /** Source token chain type (e.g. 'ethereum', 'solana'). Must be a supported stablecoin. */
128
+ sourceChainType: ChainType;
129
+ /** Source token chain ID (e.g. '8453', 'mainnet') */
130
+ sourceChainId: string;
131
+ /** Source token contract address */
132
+ sourceTokenAddress: string;
133
+ /** Source token symbol (e.g. 'USDC'). Optional but recommended for display. */
134
+ sourceTokenSymbol?: string;
135
+ /** Optional: pre-fill the recipient address the user is withdrawing to */
136
+ recipientAddress?: string;
137
+ /**
138
+ * The user's wallet address (the sender). Used to:
139
+ * 1. Fetch balance for quick-select chips (25%/50%/75%/MAX)
140
+ * 2. Detect if a matching browser wallet is connected
141
+ */
142
+ senderAddress: string;
143
+ /**
144
+ * Callback invoked with transaction details when user confirms withdrawal.
145
+ * The platform must implement the actual transaction signing/sending since
146
+ * we don't have the private key.
147
+ *
148
+ * Optional — if omitted, the user must have a matching connected browser wallet
149
+ * to execute the withdrawal. If neither `withdraw` nor a connected wallet is available,
150
+ * the modal will show an error.
151
+ */
152
+ withdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
153
+ onSuccess?: (data: WithdrawResult) => void;
154
+ onError?: (error: WithdrawError) => void;
155
+ onClose?: () => void;
156
+ }
157
+
95
158
  declare function UnifoldProvider({ children, publishableKey, config, }: React.PropsWithChildren<UnifoldConnectProviderConfig>): react_jsx_runtime.JSX.Element;
96
159
  declare function useUnifold(): {
97
160
  publishableKey: string;
98
161
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
99
162
  closeDeposit: () => void;
163
+ beginCheckout: (config: CheckoutConfig) => Promise<CheckoutResult>;
164
+ closeCheckout: () => void;
165
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
166
+ closeWithdraw: () => void;
100
167
  };
101
168
  /**
102
169
  * Convenience wrapper for useAllowedCountry that automatically passes publishableKey from context
@@ -122,4 +189,4 @@ declare function useUnifold(): {
122
189
  */
123
190
  declare function useAllowedCountry(): AllowedCountryResult;
124
191
 
125
- export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, useAllowedCountry, useUnifold };
192
+ export { type CheckoutConfig, type CheckoutError, type CheckoutResult, 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, PaymentIntent, PaymentIntentDepositAddress, 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;
@@ -92,11 +94,76 @@ interface DepositConfig {
92
94
  */
93
95
  initialScreen?: DepositModalInitialScreen;
94
96
  }
97
+ interface CheckoutResult {
98
+ paymentIntentId: string;
99
+ status: string;
100
+ }
101
+ interface CheckoutError {
102
+ message: string;
103
+ error?: unknown;
104
+ code?: string;
105
+ }
106
+ interface WithdrawResult {
107
+ message: string;
108
+ transaction?: unknown;
109
+ }
110
+ interface WithdrawError {
111
+ message: string;
112
+ error?: unknown;
113
+ code?: string;
114
+ }
115
+ interface CheckoutConfig {
116
+ /** The client_secret from a PaymentIntent created on your server */
117
+ clientSecret: string;
118
+ /** Optional callbacks (fired immediately when events occur) */
119
+ onSuccess?: (data: CheckoutResult) => void;
120
+ onError?: (error: CheckoutError) => void;
121
+ /** Called when the user dismisses the checkout dialog */
122
+ onClose?: () => void;
123
+ }
124
+ interface WithdrawConfig {
125
+ /** External user ID — required, same as deposit */
126
+ externalUserId: string;
127
+ /** Source token chain type (e.g. 'ethereum', 'solana'). Must be a supported stablecoin. */
128
+ sourceChainType: ChainType;
129
+ /** Source token chain ID (e.g. '8453', 'mainnet') */
130
+ sourceChainId: string;
131
+ /** Source token contract address */
132
+ sourceTokenAddress: string;
133
+ /** Source token symbol (e.g. 'USDC'). Optional but recommended for display. */
134
+ sourceTokenSymbol?: string;
135
+ /** Optional: pre-fill the recipient address the user is withdrawing to */
136
+ recipientAddress?: string;
137
+ /**
138
+ * The user's wallet address (the sender). Used to:
139
+ * 1. Fetch balance for quick-select chips (25%/50%/75%/MAX)
140
+ * 2. Detect if a matching browser wallet is connected
141
+ */
142
+ senderAddress: string;
143
+ /**
144
+ * Callback invoked with transaction details when user confirms withdrawal.
145
+ * The platform must implement the actual transaction signing/sending since
146
+ * we don't have the private key.
147
+ *
148
+ * Optional — if omitted, the user must have a matching connected browser wallet
149
+ * to execute the withdrawal. If neither `withdraw` nor a connected wallet is available,
150
+ * the modal will show an error.
151
+ */
152
+ withdraw?: (txInfo: WithdrawTransactionInfo) => void | Promise<void>;
153
+ onSuccess?: (data: WithdrawResult) => void;
154
+ onError?: (error: WithdrawError) => void;
155
+ onClose?: () => void;
156
+ }
157
+
95
158
  declare function UnifoldProvider({ children, publishableKey, config, }: React.PropsWithChildren<UnifoldConnectProviderConfig>): react_jsx_runtime.JSX.Element;
96
159
  declare function useUnifold(): {
97
160
  publishableKey: string;
98
161
  beginDeposit: (config: DepositConfig) => Promise<DepositResult>;
99
162
  closeDeposit: () => void;
163
+ beginCheckout: (config: CheckoutConfig) => Promise<CheckoutResult>;
164
+ closeCheckout: () => void;
165
+ beginWithdraw: (config: WithdrawConfig) => Promise<WithdrawResult>;
166
+ closeWithdraw: () => void;
100
167
  };
101
168
  /**
102
169
  * Convenience wrapper for useAllowedCountry that automatically passes publishableKey from context
@@ -122,4 +189,4 @@ declare function useUnifold(): {
122
189
  */
123
190
  declare function useAllowedCountry(): AllowedCountryResult;
124
191
 
125
- export { type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, useAllowedCountry, useUnifold };
192
+ export { type CheckoutConfig, type CheckoutError, type CheckoutResult, type DepositConfig, type DepositError, type DepositResult, type UnifoldConnectProviderConfig, UnifoldProvider, type WithdrawConfig, type WithdrawError, type WithdrawResult, useAllowedCountry, useUnifold };