@funkit/connect 12.17.0 → 12.18.1
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/CHANGELOG.md +38 -0
- package/dist/clients/axiom.d.ts +0 -4
- package/dist/clients/{chunk-V4RIF2NR.js → chunk-AELXD5XA.js} +1 -1
- package/dist/clients/{chunk-HANOVGPH.js → chunk-FOXMRDKD.js} +1 -1
- package/dist/clients/{chunk-TWP5LFPX.js → chunk-G6A62MZO.js} +5 -5
- package/dist/clients/{chunk-LVR6RQMO.js → chunk-L6JL2XJY.js} +1 -1
- package/dist/clients/{chunk-I5VRAFH6.js → chunk-LCYJLY4X.js} +1 -1
- package/dist/clients/{chunk-2L6IKKNH.js → chunk-YSAAJSWT.js} +224 -16
- package/dist/clients/fanatics.js +2 -2
- package/dist/clients/internal/nado/withdrawalCallback.js +4 -4
- package/dist/clients/internal/nado/withdrawalConfig.js +2 -2
- package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +5 -5
- package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
- package/dist/clients/lighter.css +8 -8
- package/dist/clients/lighter.js +3 -3
- package/dist/clients/mallard.js +2 -2
- package/dist/clients/nado.js +4 -4
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +3 -1
- package/dist/components/LargeAmountInput/LargeAmountInput.d.ts +3 -1
- package/dist/components/TokenSwapWidget/TokenSelectButton/TokenSelectButton.d.ts +5 -2
- package/dist/components/TokenSwapWidget/TokenSwapCard/TokenSwapCard.d.ts +7 -3
- package/dist/components/TokenSwapWidget/TokenSwapWidget.d.ts +7 -2
- package/dist/domains/convert/assets.d.ts +9 -1
- package/dist/domains/convert/balances.d.ts +31 -8
- package/dist/domains/convert/errors.d.ts +2 -2
- package/dist/domains/convert/hostTimeout.d.ts +8 -0
- package/dist/domains/convert/inputAmount.d.ts +30 -1
- package/dist/domains/convert/quote.d.ts +17 -8
- package/dist/domains/convert/recipient.d.ts +2 -1
- package/dist/domains/convert/reducer.d.ts +112 -0
- package/dist/domains/convert/screen.d.ts +169 -0
- package/dist/domains/convert/settlement.d.ts +6 -1
- package/dist/domains/convert/sourceWallet.d.ts +5 -4
- package/dist/domains/convert/submit.d.ts +25 -4
- package/dist/domains/convert/types.d.ts +15 -6
- package/dist/domains/convert/view.d.ts +111 -0
- package/dist/hooks/track/CheckoutModalEvent.d.ts +2 -0
- package/dist/hooks/useConvertAssetList.d.ts +23 -0
- package/dist/hooks/useConvertAssets.d.ts +3 -1
- package/dist/hooks/useConvertBalances.d.ts +9 -3
- package/dist/hooks/useConvertExecute.d.ts +17 -61
- package/dist/hooks/useConvertQuote.d.ts +22 -2
- package/dist/hooks/useConvertSelectionWallets.d.ts +34 -0
- package/dist/hooks/useConvertTransactionStatus.d.ts +11 -17
- package/dist/index.css +8 -8
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6471 -2584
- package/dist/modals/CheckoutModal/Convert/ConvertAssetList.d.ts +16 -0
- package/dist/modals/CheckoutModal/Convert/ConvertAssetRow.d.ts +21 -0
- package/dist/modals/CheckoutModal/Convert/ConvertChainPills.d.ts +14 -0
- package/dist/modals/CheckoutModal/Convert/ConvertSelectDestinationStep.d.ts +30 -0
- package/dist/modals/CheckoutModal/Convert/ConvertSelectSourceStep.d.ts +18 -0
- package/dist/modals/CheckoutModal/Convert/ConvertStep.d.ts +4 -2
- package/dist/modals/CheckoutModal/FunCheckoutStep.d.ts +2 -0
- package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +5 -3
- package/dist/modals/CheckoutModal/Withdrawal/WithdrawalComplete.d.ts +5 -2
- package/dist/modals/CheckoutModal/Withdrawal/WithdrawalEnterAmount.d.ts +4 -2
- package/dist/modals/CheckoutModal/stepTransition.d.ts +6 -0
- package/dist/modals/CheckoutModal/stepTransition.shared.d.ts +0 -1
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +15 -4
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +7 -7
- package/dist/modals/WithdrawalModal/useMultiSourceWithdrawal.d.ts +41 -0
- package/dist/providers/ConvertProvider.d.ts +40 -0
- package/dist/providers/FunkitCheckoutContext/index.d.ts +2 -2
- package/dist/providers/FunkitCheckoutContext/types.d.ts +36 -2
- package/dist/shadow-css.js +1 -1
- package/dist/utils/withdrawal.d.ts +28 -1
- package/dist/wallets/multiSourceWithdrawal.d.ts +36 -0
- package/dist/wallets/walletConnectors/index.js +45 -45
- package/package.json +5 -5
- package/dist/hooks/useConvertInputAmount.d.ts +0 -26
- package/dist/hooks/useConvertMaxAmount.d.ts +0 -11
- package/dist/hooks/usePrepareConvertSubmit.d.ts +0 -22
- /package/dist/clients/{chunk-4DBUYTEE.js → chunk-LICTGZXW.js} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ConvertAssetListStatus } from '../../../domains/convert/assets';
|
|
3
|
+
import { type ConvertAssetOption } from './ConvertAssetRow';
|
|
4
|
+
interface ConvertAssetListProps {
|
|
5
|
+
status: ConvertAssetListStatus;
|
|
6
|
+
options: ConvertAssetOption[];
|
|
7
|
+
selectedKey: string | undefined;
|
|
8
|
+
emptyText: string;
|
|
9
|
+
onSelect: (key: string) => void;
|
|
10
|
+
onRetry: () => void;
|
|
11
|
+
/** Heading above the rows; left off the loading, failed and empty states. */
|
|
12
|
+
label?: string;
|
|
13
|
+
}
|
|
14
|
+
/** A Convert token screen's list, with its loading, failed and empty states. */
|
|
15
|
+
export declare function ConvertAssetList({ status, options, selectedKey, emptyText, onSelect, onRetry, label, }: ConvertAssetListProps): React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ConvertBalanceState } from '../../../domains/convert/balances';
|
|
3
|
+
import type { ConvertResolvedAsset } from '../../../domains/convert/types';
|
|
4
|
+
/** One row on a Convert token screen. */
|
|
5
|
+
export interface ConvertAssetOption {
|
|
6
|
+
asset: ConvertResolvedAsset;
|
|
7
|
+
key: string;
|
|
8
|
+
/** `undefined` until the first balance read lands. */
|
|
9
|
+
balance: ConvertBalanceState | undefined;
|
|
10
|
+
/** The balance in USD; `undefined` when the balance is unknown. */
|
|
11
|
+
usdAmount: number | undefined;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
/** Worth less than the minimum Convert quotes, so it can't be a source. */
|
|
14
|
+
isBelowMinimum?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** A Convert asset, drawn as a row of the checkout's wallet asset list. */
|
|
17
|
+
export declare function ConvertAssetRow({ option, isSelected, onSelect, }: {
|
|
18
|
+
option: ConvertAssetOption;
|
|
19
|
+
isSelected: boolean;
|
|
20
|
+
onSelect: (key: string) => void;
|
|
21
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ConvertChainPillsProps {
|
|
3
|
+
chainIds: string[];
|
|
4
|
+
activeChainId: string | undefined;
|
|
5
|
+
onChange: (chainId: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The destination screen's chain picker: one pill per chain, icon only, with
|
|
9
|
+
* the active one widened to show its name. The highlight slides to the picked
|
|
10
|
+
* pill and the widths ease, like the modal's header tabs. Scrolls sideways
|
|
11
|
+
* when the chains don't fit, e.g. eight on a phone.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ConvertChainPills({ chainIds, activeChainId, onChange, }: ConvertChainPillsProps): React.JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ConvertBalances } from '../../../domains/convert/balances';
|
|
2
|
+
import type { ConvertRecipientAddresses, ConvertResolvedAsset } from '../../../domains/convert/types';
|
|
3
|
+
import { FunCheckoutStep } from '../FunCheckoutStep';
|
|
4
|
+
import type { ModalStepInfo } from '../stepTransition';
|
|
5
|
+
import { type CheckoutModalCommonState } from '../stepTransition.shared';
|
|
6
|
+
import type { ConvertAssetOption } from './ConvertAssetRow';
|
|
7
|
+
export type ConvertSelectDestinationState = CheckoutModalCommonState;
|
|
8
|
+
export type ConvertSelectDestinationNext = Record<never, never>;
|
|
9
|
+
/** Destination chains in the host's order, without a chain whose only token is the source. */
|
|
10
|
+
export declare function getConvertDestinationChainIds({ assets, sourceKey, }: {
|
|
11
|
+
assets: ConvertResolvedAsset[];
|
|
12
|
+
sourceKey: string | undefined;
|
|
13
|
+
}): string[];
|
|
14
|
+
/**
|
|
15
|
+
* The chain whose tokens the destination screen opens on: the picked
|
|
16
|
+
* destination's, otherwise the first one listed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getInitialDestinationChainId({ chainIds, destinationAsset, }: {
|
|
19
|
+
chainIds: string[];
|
|
20
|
+
destinationAsset: ConvertResolvedAsset | undefined;
|
|
21
|
+
}): string | undefined;
|
|
22
|
+
/** One chain's destination rows, in the host's order, without the source. */
|
|
23
|
+
export declare function getConvertDestinationOptions({ assets, balances, chainId, sourceKey, recipientAddresses, }: {
|
|
24
|
+
assets: ConvertResolvedAsset[];
|
|
25
|
+
balances: ConvertBalances | undefined;
|
|
26
|
+
chainId: string;
|
|
27
|
+
sourceKey: string | undefined;
|
|
28
|
+
recipientAddresses: ConvertRecipientAddresses;
|
|
29
|
+
}): ConvertAssetOption[];
|
|
30
|
+
export declare const ConvertSelectDestinationStepInfo: ModalStepInfo<FunCheckoutStep.CONVERT_SELECT_DESTINATION>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ConvertBalances } from '../../../domains/convert/balances';
|
|
2
|
+
import type { ConvertResolvedAsset } from '../../../domains/convert/types';
|
|
3
|
+
import { FunCheckoutStep } from '../FunCheckoutStep';
|
|
4
|
+
import type { ModalStepInfo } from '../stepTransition';
|
|
5
|
+
import { type CheckoutModalCommonState } from '../stepTransition.shared';
|
|
6
|
+
import type { ConvertAssetOption } from './ConvertAssetRow';
|
|
7
|
+
export type ConvertSelectSourceState = CheckoutModalCommonState;
|
|
8
|
+
export type ConvertSelectSourceNext = Record<never, never>;
|
|
9
|
+
/**
|
|
10
|
+
* The source screen's rows: held tokens by USD value, disabled ones last.
|
|
11
|
+
* - Under the $1 minimum is disabled ("Low Balance"): Relay won't quote it.
|
|
12
|
+
* - An unreadable balance stays listed but disabled, so funds never look gone.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getConvertSourceOptions({ assets, balances, }: {
|
|
15
|
+
assets: ConvertResolvedAsset[];
|
|
16
|
+
balances: ConvertBalances;
|
|
17
|
+
}): ConvertAssetOption[];
|
|
18
|
+
export declare const ConvertSelectSourceStepInfo: ModalStepInfo<FunCheckoutStep.CONVERT_SELECT_SOURCE>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FunCheckoutStep } from '../FunCheckoutStep';
|
|
2
2
|
import type { ModalStepInfo } from '../stepTransition';
|
|
3
|
-
import type
|
|
3
|
+
import { type CheckoutModalCommonState } from '../stepTransition.shared';
|
|
4
4
|
export type ConvertState = CheckoutModalCommonState;
|
|
5
|
-
export
|
|
5
|
+
export interface ConvertNext {
|
|
6
|
+
assetScreen: 'source' | 'destination';
|
|
7
|
+
}
|
|
6
8
|
export declare const ConvertStepInfo: ModalStepInfo<FunCheckoutStep.CONVERT>;
|
|
@@ -23,6 +23,8 @@ export declare enum FunCheckoutStep {
|
|
|
23
23
|
SWAPPED_IFRAME = "swapped_iframe",
|
|
24
24
|
PERPS_TRANSFER = "perps_transfer",
|
|
25
25
|
CONVERT = "convert",
|
|
26
|
+
CONVERT_SELECT_SOURCE = "convert_select_source",
|
|
27
|
+
CONVERT_SELECT_DESTINATION = "convert_select_destination",
|
|
26
28
|
WITHDRAWAL_ENTER_AMOUNT = "withdrawal_enter_amount",
|
|
27
29
|
WITHDRAWAL_COMPLETE = "withdrawal_complete"
|
|
28
30
|
}
|
|
@@ -4,7 +4,7 @@ import type { Hex } from 'viem';
|
|
|
4
4
|
import { type ConnectablePaymentMethodInfo, PaymentMethod, type PaymentMethodBitcoinLightningInfo, type PaymentMethodCardInfo, type PaymentMethodCashAppLightningInfo, type PaymentMethodVirtualBankIncompleteInfo } from '../../../domains/paymentMethods';
|
|
5
5
|
import type { FunkitCheckoutQuoteResult } from '../../../domains/quote';
|
|
6
6
|
import { type PaymentMethodType } from '../../../hooks/usePaymentSources';
|
|
7
|
-
import { type
|
|
7
|
+
import { type MultiSourceWithdrawalConfig, type SingleWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
8
8
|
import { type CheckoutModalCommonState, FunCheckoutStep } from '../stepTransition.shared';
|
|
9
9
|
import { type ModalStepComponentProps, type ModalStepInfo } from '../stepTransition';
|
|
10
10
|
import type { SwappedMode } from '../../../providers/SwappedProvider';
|
|
@@ -19,7 +19,7 @@ export type SourceChangeState = CheckoutModalCommonState & {
|
|
|
19
19
|
* UI while still on SourceChange. Cleared when leaving the tab so the effect
|
|
20
20
|
* reverts back to deposit mode. Read only by that effect.
|
|
21
21
|
*/
|
|
22
|
-
withdrawalConfig?:
|
|
22
|
+
withdrawalConfig?: SingleWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
23
23
|
};
|
|
24
24
|
export type SourceChangeNext = {
|
|
25
25
|
connectNew: false;
|
|
@@ -71,7 +71,7 @@ export type SourceChangeNext = {
|
|
|
71
71
|
} | {
|
|
72
72
|
/** Enter the cashier withdrawal flow with a resolved single-method config. */
|
|
73
73
|
withdraw: true;
|
|
74
|
-
withdrawalConfig:
|
|
74
|
+
withdrawalConfig: SingleWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
75
75
|
} | {
|
|
76
76
|
/**
|
|
77
77
|
* Inline withdrawal (swapped-withdrawal flag off): the amount form is
|
|
@@ -79,6 +79,8 @@ export type SourceChangeNext = {
|
|
|
79
79
|
* to the completion screen rather than through WITHDRAWAL_ENTER_AMOUNT.
|
|
80
80
|
*/
|
|
81
81
|
withdrawComplete: true;
|
|
82
|
+
/** The source that ran — the picked one on a multi-source config. */
|
|
83
|
+
executedConfig: SingleWithdrawalConfig;
|
|
82
84
|
hash: Hex;
|
|
83
85
|
withdrawnAmount: string;
|
|
84
86
|
tokenSymbol: string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
3
|
import type { FunkitCheckoutQuoteResult } from '../../../domains/quote';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MultiSourceWithdrawalConfig, SingleWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
5
5
|
import { type CheckoutModalCommonState, FunCheckoutStep } from '../stepTransition.shared';
|
|
6
6
|
import { type ModalStepComponentProps, type ModalStepInfo } from '../stepTransition';
|
|
7
7
|
export type WithdrawalCompleteState = CheckoutModalCommonState & {
|
|
8
|
-
|
|
8
|
+
/** The config to reopen on "New withdrawal". */
|
|
9
|
+
withdrawalConfig: SingleWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
10
|
+
/** The source that ran; what the success screen describes. */
|
|
11
|
+
executedConfig: SingleWithdrawalConfig;
|
|
9
12
|
hash: Hex;
|
|
10
13
|
withdrawnAmount: string;
|
|
11
14
|
tokenSymbol: string;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
3
|
import type { FunkitCheckoutQuoteResult } from '../../../domains/quote';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MultiSourceWithdrawalConfig, SingleWithdrawalConfig } from '../../../providers/FunkitCheckoutContext';
|
|
5
5
|
import { type CheckoutModalCommonState, FunCheckoutStep } from '../stepTransition.shared';
|
|
6
6
|
import { type ModalStepComponentProps, type ModalStepInfo } from '../stepTransition';
|
|
7
7
|
export type WithdrawalEnterAmountState = CheckoutModalCommonState & {
|
|
8
|
-
withdrawalConfig:
|
|
8
|
+
withdrawalConfig: SingleWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
9
9
|
};
|
|
10
10
|
export type WithdrawalEnterAmountNext = {
|
|
11
|
+
/** The source that ran — the picked one on a multi-source config. */
|
|
12
|
+
executedConfig: SingleWithdrawalConfig;
|
|
11
13
|
hash: Hex;
|
|
12
14
|
withdrawnAmount: string;
|
|
13
15
|
tokenSymbol: string;
|
|
@@ -6,6 +6,8 @@ import { type VirtualFiatAccountNext, type VirtualFiatAccountState } from '../..
|
|
|
6
6
|
import { type DynamicTargetAssetCandidate, FunCheckoutStartingStep, type FunkitActiveCheckoutItem } from '../../providers/FunkitCheckoutContext';
|
|
7
7
|
import { type FunkitTextCustomizationsConfig } from '../../providers/FunkitConfigContext';
|
|
8
8
|
import { type PerpsTransferNext, type PerpsTransferState } from '../PolymarketPerpsTransfer/PerpsTransferStep';
|
|
9
|
+
import { type ConvertSelectDestinationNext, type ConvertSelectDestinationState } from './Convert/ConvertSelectDestinationStep';
|
|
10
|
+
import { type ConvertSelectSourceNext, type ConvertSelectSourceState } from './Convert/ConvertSelectSourceStep';
|
|
9
11
|
import { type ConvertNext, type ConvertState } from './Convert/ConvertStep';
|
|
10
12
|
import { type BrokerageSuccessState } from './Brokerage/BrokerageSuccessModal';
|
|
11
13
|
import { type BrokerageTwoFANext, type BrokerageTwoFAState } from './Brokerage/BrokerageTwoFA';
|
|
@@ -113,6 +115,8 @@ export type CheckoutModalState<S extends FunCheckoutStep = FunCheckoutStep> = {
|
|
|
113
115
|
[FunCheckoutStep.SWAPPED_IFRAME]: SwappedIframeState;
|
|
114
116
|
[FunCheckoutStep.PERPS_TRANSFER]: PerpsTransferState;
|
|
115
117
|
[FunCheckoutStep.CONVERT]: ConvertState;
|
|
118
|
+
[FunCheckoutStep.CONVERT_SELECT_SOURCE]: ConvertSelectSourceState;
|
|
119
|
+
[FunCheckoutStep.CONVERT_SELECT_DESTINATION]: ConvertSelectDestinationState;
|
|
116
120
|
[FunCheckoutStep.WITHDRAWAL_ENTER_AMOUNT]: WithdrawalEnterAmountState;
|
|
117
121
|
[FunCheckoutStep.WITHDRAWAL_COMPLETE]: WithdrawalCompleteState;
|
|
118
122
|
}[T] & {
|
|
@@ -145,6 +149,8 @@ export type NextPayload<S extends FunCheckoutStep = FunCheckoutStep> = {
|
|
|
145
149
|
[FunCheckoutStep.SWAPPED_IFRAME]: SwappedIframeNext;
|
|
146
150
|
[FunCheckoutStep.PERPS_TRANSFER]: PerpsTransferNext;
|
|
147
151
|
[FunCheckoutStep.CONVERT]: ConvertNext;
|
|
152
|
+
[FunCheckoutStep.CONVERT_SELECT_SOURCE]: ConvertSelectSourceNext;
|
|
153
|
+
[FunCheckoutStep.CONVERT_SELECT_DESTINATION]: ConvertSelectDestinationNext;
|
|
148
154
|
[FunCheckoutStep.WITHDRAWAL_ENTER_AMOUNT]: WithdrawalEnterAmountNext;
|
|
149
155
|
[FunCheckoutStep.WITHDRAWAL_COMPLETE]: WithdrawalCompleteNext;
|
|
150
156
|
}[S] & {
|
|
@@ -9,7 +9,6 @@ export interface CheckoutModalCommonState {
|
|
|
9
9
|
/** Whether checkout should not be allowed to continue due to security reasons*/
|
|
10
10
|
isBlocked?: boolean;
|
|
11
11
|
startingStep: FunCheckoutStartingStep;
|
|
12
|
-
targetChainId: string;
|
|
13
12
|
showWalletOptions?: boolean;
|
|
14
13
|
hideBottomDivider: boolean;
|
|
15
14
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WithdrawalAmountSelectionType } from '../../hooks/track/analytics/events';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SingleWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
4
4
|
import type { SourceTokenOption } from '../../providers/FunkitCheckoutContext';
|
|
5
5
|
export type { SourceTokenOption };
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A dropdown row. `ticker` denominates the amount when the selection key
|
|
8
|
+
* isn't a token symbol (a multi-source id such as `ETH_BASE`).
|
|
9
|
+
*/
|
|
10
|
+
export type SourceDropdownOption = SourceTokenOption & {
|
|
11
|
+
ticker?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdrawalInputAmount, sourceTokenBalance, maxWithdrawableAmount, isWithdrawAmountTooLow, isWithdrawAmountTooHigh, isWithdrawAmountAboveBalance, isWithdrawAmountValid, minWithdrawalDisplayValue, config, sourceTokenOptions, onSourceTokenChange, selectedSourceToken, showChainBadges, isSourceTokenChangeDisabled, sourceTokenUsdPrice, onAmountSelectionChange, onAmountChanged, onMaxButtonClicked, }: {
|
|
14
|
+
config: SingleWithdrawalConfig;
|
|
8
15
|
sourceTokenBalance: string;
|
|
9
16
|
/** What Max fills in — the balance less any reserve for network fees. */
|
|
10
17
|
maxWithdrawableAmount?: string;
|
|
@@ -28,10 +35,14 @@ export declare function WithdrawAmountInput({ withdrawalInputAmount, setWithdraw
|
|
|
28
35
|
* the component re-derives which one it got (see `isMinInTokenUnits`).
|
|
29
36
|
*/
|
|
30
37
|
minWithdrawalDisplayValue: number;
|
|
31
|
-
sourceTokenOptions?:
|
|
38
|
+
sourceTokenOptions?: SourceDropdownOption[];
|
|
32
39
|
onSourceTokenChange?: (opt: SourceTokenOption) => void;
|
|
33
40
|
/** Currently selected source token symbol (drives chip label + icon). */
|
|
34
41
|
selectedSourceToken?: string;
|
|
42
|
+
/** Options sit on different chains (ETH on Base and on Ink); badge each icon. */
|
|
43
|
+
showChainBadges?: boolean;
|
|
44
|
+
/** Locks the dropdown, e.g. while a withdrawal is signing. */
|
|
45
|
+
isSourceTokenChangeDisabled?: boolean;
|
|
35
46
|
/**
|
|
36
47
|
* USD price per unit of the source token (e.g. ~1620 for ETH).
|
|
37
48
|
* When omitted, the USD equivalent is rendered as "-" rather than
|
|
@@ -2,18 +2,18 @@ import React from 'react';
|
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
3
|
import { type ModalBottomBarIdType } from '../../components/Dialog/Dialog';
|
|
4
4
|
import type { FunCheckoutStep } from '../../modals/CheckoutModal/FunCheckoutStep';
|
|
5
|
-
import type {
|
|
5
|
+
import type { FunkitActiveWithdrawalItem, MultiSourceWithdrawalConfig, SingleWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
6
6
|
import { type WithdrawalFormData } from './useWithdrawal';
|
|
7
7
|
import { WithdrawalModalStep } from './types';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Multi-method configs are resolved in WithdrawalModal before reaching here; a
|
|
10
|
+
* multi-source config is resolved by {@link MultiSourceWithdrawContent}.
|
|
11
11
|
*/
|
|
12
|
-
type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
|
|
13
12
|
interface WithdrawContentProps {
|
|
14
13
|
analyticsStep: FunCheckoutStep | WithdrawalModalStep;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/** `executedConfig` is the source that ran — the picked one on a multi-source config. */
|
|
15
|
+
onContinue: (withdrawal: WithdrawalFormData, txHash: Hex, executedConfig: SingleWithdrawalConfig) => void;
|
|
16
|
+
config: SingleWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
17
17
|
withdrawalItem: FunkitActiveWithdrawalItem | null;
|
|
18
18
|
/**
|
|
19
19
|
* Switch a Lighter Fast withdrawal to the Lighter Secure method. Wired by
|
|
@@ -34,5 +34,5 @@ interface WithdrawContentProps {
|
|
|
34
34
|
*/
|
|
35
35
|
disableSubmit?: boolean;
|
|
36
36
|
}
|
|
37
|
-
export declare
|
|
37
|
+
export declare const WithdrawContent: (props: WithdrawContentProps) => React.JSX.Element;
|
|
38
38
|
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import type { TransferTokenDefault } from '../../hooks/useTokenAndChainDropdown';
|
|
3
|
+
import type { FunkitActiveWithdrawalItem, MultiSourceWithdrawalConfig, SingleWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
|
|
4
|
+
import type { SourceDropdownOption } from './WithdrawAmountInput';
|
|
5
|
+
import type { WithdrawalFormData } from './useWithdrawal';
|
|
6
|
+
/** The multi-source dropdown, as seen by the single-source form. */
|
|
7
|
+
export interface SourceSwitcher {
|
|
8
|
+
options: SourceDropdownOption[];
|
|
9
|
+
selectedId: string;
|
|
10
|
+
/** `receiveSelection` is what the current form shows, carried to the next. */
|
|
11
|
+
onSelect: (id: string, receiveSelection: ReceiveSelection) => void;
|
|
12
|
+
}
|
|
13
|
+
/** What the user picked on the receive side: where funds go and as what. */
|
|
14
|
+
export interface ReceiveSelection {
|
|
15
|
+
recipientAddress: string;
|
|
16
|
+
destination?: TransferTokenDefault;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the picked source and everything the single-source form needs to
|
|
20
|
+
* run it. `null` only for an empty container.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useMultiSourceWithdrawal({ config, withdrawalItem, onContinue, }: {
|
|
23
|
+
config: MultiSourceWithdrawalConfig;
|
|
24
|
+
withdrawalItem: FunkitActiveWithdrawalItem | null;
|
|
25
|
+
onContinue: (withdrawal: WithdrawalFormData, txHash: Hex, executedConfig: SingleWithdrawalConfig) => void;
|
|
26
|
+
}): {
|
|
27
|
+
sourceId: string;
|
|
28
|
+
config: SingleWithdrawalConfig;
|
|
29
|
+
withdrawalItem: {
|
|
30
|
+
withdrawalSourceTokenBalance: ((params: import("../../providers/FunkitCheckoutContext").WithdrawalSourceTokenBalanceParams) => string | number) | undefined;
|
|
31
|
+
id: string;
|
|
32
|
+
initSettings: Partial<import("../../providers/FunkitCheckoutContext").UseFunkitCheckoutPropsWithFullConfig>;
|
|
33
|
+
} | null;
|
|
34
|
+
sourceSwitcher: {
|
|
35
|
+
options: SourceDropdownOption[];
|
|
36
|
+
selectedId: string;
|
|
37
|
+
onSelect: (id: string, receiveSelection: ReceiveSelection) => void;
|
|
38
|
+
};
|
|
39
|
+
initialReceiveSelection: ReceiveSelection | undefined;
|
|
40
|
+
onContinue: (withdrawal: WithdrawalFormData, txHash: Hex, executedConfig: SingleWithdrawalConfig) => void;
|
|
41
|
+
} | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type ConvertView } from '../domains/convert/view';
|
|
3
|
+
import { FunCheckoutStep } from '../modals/CheckoutModal/FunCheckoutStep';
|
|
4
|
+
import type { FunkitActiveCheckoutItem } from './FunkitCheckoutContext';
|
|
5
|
+
export declare const CONVERT_QUOTE_INPUT_DEBOUNCE_MS = 300;
|
|
6
|
+
/** How long the success label shows before the screen returns to Convert. */
|
|
7
|
+
export declare const CONVERT_SUCCESS_RESET_MS = 2000;
|
|
8
|
+
/** How long the success label shows before the modal closes, when the host asks for that. */
|
|
9
|
+
export declare const CONVERT_SUCCESS_CLOSE_MS = 3000;
|
|
10
|
+
export interface ConvertContextValue {
|
|
11
|
+
/** Everything the Convert screens render. */
|
|
12
|
+
view: ConvertView;
|
|
13
|
+
editAmount: (inputValue: string) => void;
|
|
14
|
+
/** Flips USD and token entry at the live price. */
|
|
15
|
+
toggleUnit: () => void;
|
|
16
|
+
setMax: (maxBaseUnits: bigint) => void;
|
|
17
|
+
/** Keys are `convertAssetKey`s. A different source drops the amount. */
|
|
18
|
+
pickSource: (sourceKey: string) => void;
|
|
19
|
+
pickDestination: (destinationKey: string) => void;
|
|
20
|
+
swapDirection: () => void;
|
|
21
|
+
/** Converts the quote on screen; the host's callbacks hear the outcome. */
|
|
22
|
+
convert: () => void;
|
|
23
|
+
/** Asks again for whatever failed: a host lookup, else the quote. */
|
|
24
|
+
retry: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function useConvert(): ConvertContextValue;
|
|
27
|
+
interface ConvertProviderProps {
|
|
28
|
+
checkoutItem: FunkitActiveCheckoutItem;
|
|
29
|
+
/** The modal's step: live reads run only on a Convert screen or mid-conversion. */
|
|
30
|
+
step: FunCheckoutStep;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert's draft, live reads and submission for the whole checkout modal, so
|
|
36
|
+
* they outlive the screens: the token screens and a tab switch unmount them.
|
|
37
|
+
* Without a Convert config it renders its children only.
|
|
38
|
+
*/
|
|
39
|
+
export declare function ConvertProvider({ checkoutItem, step, onClose, children, }: ConvertProviderProps): React.JSX.Element;
|
|
40
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import { type PaymentMethodInfo } from '../../domains/paymentMethods';
|
|
|
6
6
|
import type { AssetHoldingsItem } from '../../utils/assets';
|
|
7
7
|
import type { WithdrawalClient, WithdrawalTransaction } from '../../wallets/Wallet';
|
|
8
8
|
import { type FunkitCheckoutQuoteResult } from '../FunkitHistoryContext';
|
|
9
|
-
import type {
|
|
9
|
+
import type { DynamicTargetAssetCandidate, FunkitActiveCheckoutItem, FunkitActiveWithdrawalItem, FunkitCheckoutConfig, FunkitWithdrawalConfig, MultiSourceWithdrawalConfig, PolymarketPerpsTransferPending, SingleWithdrawalConfig, UseFunkitCheckoutProps, UseFunkitCheckoutPropsWithFullConfig } from './types';
|
|
10
10
|
export * from './types';
|
|
11
11
|
interface FunkitCheckoutContextInterface {
|
|
12
12
|
checkoutItem: FunkitActiveCheckoutItem | null;
|
|
@@ -56,7 +56,7 @@ interface FunkitCheckoutContextInterface {
|
|
|
56
56
|
* makes revert lossless. Used by the cashier withdraw tab; the standalone
|
|
57
57
|
* `WithdrawalModal` uses {@link initNewWithdrawal} instead.
|
|
58
58
|
*/
|
|
59
|
-
convertActiveCheckoutToWithdrawal(config:
|
|
59
|
+
convertActiveCheckoutToWithdrawal(config: SingleWithdrawalConfig | MultiSourceWithdrawalConfig): void;
|
|
60
60
|
/** Restore the deposit snapshot taken by {@link convertActiveCheckoutToWithdrawal} and clear `withdrawalItem`. */
|
|
61
61
|
revertActiveCheckoutFromWithdrawal(): void;
|
|
62
62
|
applyDynamicRouting(path: ApplyDynamicRoutingPath): void;
|
|
@@ -571,7 +571,7 @@ export interface WithdrawalMethodOption {
|
|
|
571
571
|
* The actual withdrawal config that drives the flow once the user selects
|
|
572
572
|
* this option. Must be a single concrete (non-multi) config.
|
|
573
573
|
*/
|
|
574
|
-
config:
|
|
574
|
+
config: SingleWithdrawalConfig;
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
577
|
* Withdrawal config that presents the user with a selection screen before
|
|
@@ -589,7 +589,41 @@ export interface MultiMethodWithdrawalConfig {
|
|
|
589
589
|
methods: WithdrawalMethodOption[];
|
|
590
590
|
disableConnectedWallet?: boolean;
|
|
591
591
|
}
|
|
592
|
-
|
|
592
|
+
/** A config that drives the flow directly: one chain, one token, one wallet. */
|
|
593
|
+
export type SingleWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
|
|
594
|
+
/** One entry in a {@link MultiSourceWithdrawalConfig} dropdown. */
|
|
595
|
+
export interface WithdrawalSourceOption {
|
|
596
|
+
/** Unique key (e.g. `ETH_BASE`); two sources may share a ticker. Used for selection and analytics. */
|
|
597
|
+
id: string;
|
|
598
|
+
/** Dropdown label. Defaults to the config's `sourceTokenSymbol`. */
|
|
599
|
+
label?: string;
|
|
600
|
+
iconSrc?: string;
|
|
601
|
+
/**
|
|
602
|
+
* Drives the whole flow while selected: chain, token, wallet, balance and
|
|
603
|
+
* limits (`getMinWithdrawalAmount`, `getMinWithdrawalUSD`, ...). Its own
|
|
604
|
+
* `sourceTokens` list is ignored.
|
|
605
|
+
*/
|
|
606
|
+
config: SingleWithdrawalConfig;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Withdrawal config whose source is picked from the amount screen's dropdown.
|
|
610
|
+
* Sources may sit on different chains and wallets; each is a complete config,
|
|
611
|
+
* so balances and limits are per source. See `createMultiSourceWithdrawalConfig`.
|
|
612
|
+
* Crypto only: cash (Swapped) withdrawal is picked before a source, so it is
|
|
613
|
+
* not offered for this config.
|
|
614
|
+
*/
|
|
615
|
+
export interface MultiSourceWithdrawalConfig {
|
|
616
|
+
/** Title shown in the modal header. */
|
|
617
|
+
modalTitle: string;
|
|
618
|
+
/** Optional meta under the title. */
|
|
619
|
+
modalTitleMeta?: string;
|
|
620
|
+
disableConnectedWallet?: boolean;
|
|
621
|
+
/** Dropdown order. Each entry is a whole config; not a config's `sourceTokens`. */
|
|
622
|
+
sources: WithdrawalSourceOption[];
|
|
623
|
+
/** Initially selected source. Defaults to the first. */
|
|
624
|
+
defaultSourceId?: string;
|
|
625
|
+
}
|
|
626
|
+
export type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig | MultiMethodWithdrawalConfig | MultiSourceWithdrawalConfig;
|
|
593
627
|
export interface FunkitCheckoutValidationResult {
|
|
594
628
|
isValid: boolean;
|
|
595
629
|
message: string;
|