@funkit/connect 12.17.0 → 12.18.0
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 +29 -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/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 +6460 -2580
- 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 +43 -43
- package/package.json +3 -3
- 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
|
@@ -16,8 +16,8 @@ export interface ConvertAsset {
|
|
|
16
16
|
address: string;
|
|
17
17
|
symbol: string;
|
|
18
18
|
/**
|
|
19
|
-
* Icon to show for this token. Optional:
|
|
20
|
-
*
|
|
19
|
+
* Icon to show for this token. Optional: the SDK falls back to its own
|
|
20
|
+
* logo. Must be an http(s) URL.
|
|
21
21
|
*/
|
|
22
22
|
iconSrc?: string;
|
|
23
23
|
}
|
|
@@ -54,13 +54,14 @@ export type ConvertSourceWallet = {
|
|
|
54
54
|
signer: HypercoreSigner;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
|
-
* Resolves the signing wallet for a source
|
|
58
|
-
* source or flips direction, never for
|
|
59
|
-
*
|
|
57
|
+
* Resolves the signing wallet for a source asset. Called when the user picks a
|
|
58
|
+
* source or flips direction, never for assets they haven't chosen. The asset
|
|
59
|
+
* lets one chain resolve to different wallets, e.g. Polygon pUSD to the
|
|
60
|
+
* Polymarket proxy client and other Polygon tokens to the EOA.
|
|
60
61
|
* @experimental
|
|
61
62
|
*/
|
|
62
63
|
export type GetConvertSourceWallet = (params: {
|
|
63
|
-
|
|
64
|
+
asset: ConvertResolvedAsset;
|
|
64
65
|
}) => Promise<ConvertSourceWallet>;
|
|
65
66
|
/**
|
|
66
67
|
* One listed asset's balance, as the host read it: a base-unit integer string
|
|
@@ -71,6 +72,8 @@ export interface ConvertAssetBalance {
|
|
|
71
72
|
chainId: string;
|
|
72
73
|
address: string;
|
|
73
74
|
balance: string;
|
|
75
|
+
/** USD per whole token. A missing or invalid price makes the asset unavailable. */
|
|
76
|
+
unitPriceUsd: number;
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
76
79
|
* Reads live balances for the assets it's given, in one call.
|
|
@@ -162,4 +165,10 @@ export interface ConvertConfig {
|
|
|
162
165
|
getBalances: GetConvertBalances;
|
|
163
166
|
onSuccess?: (result: ConvertSuccessResult) => void;
|
|
164
167
|
onError?: (error: ConvertErrorResult) => void;
|
|
168
|
+
/**
|
|
169
|
+
* Close the modal a few seconds after a conversion settles, once the host's
|
|
170
|
+
* own UI reflects the new balances. Off, or if the user has moved to another
|
|
171
|
+
* tab meanwhile, the screen returns to Convert for another conversion instead.
|
|
172
|
+
*/
|
|
173
|
+
closeOnSuccess?: boolean;
|
|
165
174
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import type { ErrorNotification } from '../../components/FunNotification/FunNotification';
|
|
3
|
+
import { type ConvertAssetListStatus } from './assets';
|
|
4
|
+
import { type ConvertBalanceState, type ConvertBalances } from './balances';
|
|
5
|
+
import { type ConvertAmount } from './inputAmount';
|
|
6
|
+
import type { ConvertQuote } from './quote';
|
|
7
|
+
import type { ConvertDraft, ConvertSnapshot, ConvertSubmission } from './reducer';
|
|
8
|
+
import type { ConvertRecipientSelection } from './recipient';
|
|
9
|
+
import { type ConvertActionButton, type ConvertPhase, type ConvertScreenIssue, getConvertReceiveAmounts } from './screen';
|
|
10
|
+
import type { ConvertSourceWalletSelection } from './sourceWallet';
|
|
11
|
+
import type { ConvertResolvedAsset } from './types';
|
|
12
|
+
/** The live reads the draft is checked against, before any quote. */
|
|
13
|
+
export interface ConvertLiveInputs {
|
|
14
|
+
status: ConvertAssetListStatus;
|
|
15
|
+
assets: ConvertResolvedAsset[];
|
|
16
|
+
balances: ConvertBalances | undefined;
|
|
17
|
+
isBalancesFetching: boolean;
|
|
18
|
+
sourceWallet: ConvertSourceWalletSelection | undefined;
|
|
19
|
+
isSourceWalletFetching: boolean;
|
|
20
|
+
recipient: ConvertRecipientSelection | undefined;
|
|
21
|
+
isRecipientFetching: boolean;
|
|
22
|
+
/** The source's Max; `null` while unknown. */
|
|
23
|
+
maxBaseUnits: bigint | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ConvertLiveQuote {
|
|
26
|
+
/** The amount last sent to the quote, after the typing pause. */
|
|
27
|
+
amountBaseUnits: bigint | undefined;
|
|
28
|
+
quote: ConvertQuote | undefined;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
isFetching: boolean;
|
|
31
|
+
isError: boolean;
|
|
32
|
+
error: Error | null;
|
|
33
|
+
refreshesAtMs: number | undefined;
|
|
34
|
+
}
|
|
35
|
+
export interface ConvertLive extends ConvertLiveInputs {
|
|
36
|
+
quote: ConvertLiveQuote;
|
|
37
|
+
}
|
|
38
|
+
/** The draft read against live data: what's picked, the amount, and what to quote. */
|
|
39
|
+
export interface ConvertDraftReading {
|
|
40
|
+
sourceAsset: ConvertResolvedAsset | undefined;
|
|
41
|
+
destinationAsset: ConvertResolvedAsset | undefined;
|
|
42
|
+
sourceBalance: ConvertBalanceState | undefined;
|
|
43
|
+
amount: ConvertAmount;
|
|
44
|
+
amountIssue: ConvertScreenIssue | undefined;
|
|
45
|
+
/** `undefined` while the amount has an issue, so nothing is quoted. */
|
|
46
|
+
quoteAmountBaseUnits: bigint | undefined;
|
|
47
|
+
userAddress: string | undefined;
|
|
48
|
+
recipientAddress: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** What Retry asks again for; `balances` reloads the asset list too, if that failed. */
|
|
51
|
+
export type ConvertRetryTarget = 'balances' | 'sourceWallet' | 'recipient' | 'quote';
|
|
52
|
+
/** Everything the Convert screens render. */
|
|
53
|
+
export interface ConvertView {
|
|
54
|
+
status: ConvertAssetListStatus;
|
|
55
|
+
assets: ConvertResolvedAsset[];
|
|
56
|
+
balances: ConvertBalances | undefined;
|
|
57
|
+
sourceAsset: ConvertResolvedAsset | undefined;
|
|
58
|
+
destinationAsset: ConvertResolvedAsset | undefined;
|
|
59
|
+
/** Token units; `undefined` while unknown, so it never reads as 0. */
|
|
60
|
+
sourceTokenBalance: number | undefined;
|
|
61
|
+
destinationTokenBalance: number | undefined;
|
|
62
|
+
amount: ConvertAmount;
|
|
63
|
+
/** The source's Max; `null` while unknown or locked. */
|
|
64
|
+
maxBaseUnits: bigint | null;
|
|
65
|
+
/** Shows the unit switch; off without a price to convert with. Locked, the widget disables it. */
|
|
66
|
+
canToggleUnit: boolean;
|
|
67
|
+
quote: ConvertQuote | undefined;
|
|
68
|
+
isQuoteLoading: boolean;
|
|
69
|
+
/** `undefined` hides the countdown: no quote, or one being converted. */
|
|
70
|
+
refreshesAtMs: number | undefined;
|
|
71
|
+
receiveAmounts: ReturnType<typeof getConvertReceiveAmounts>;
|
|
72
|
+
notification: ErrorNotification | undefined;
|
|
73
|
+
actionButton: ConvertActionButton;
|
|
74
|
+
phase: ConvertPhase | undefined;
|
|
75
|
+
/** Nothing on screen can change from the submission until it settles, and after `untrackable`. */
|
|
76
|
+
isLocked: boolean;
|
|
77
|
+
/** Nothing to convert from; the source card offers Deposit instead. */
|
|
78
|
+
isDepositRequired: boolean;
|
|
79
|
+
retryTargets: ConvertRetryTarget[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The draft against live data. The provider quotes `quoteAmountBaseUnits`
|
|
83
|
+
* with it, and {@link deriveConvertView} reads it again for the screen.
|
|
84
|
+
*/
|
|
85
|
+
export declare function readConvertDraft({ draft, live, }: {
|
|
86
|
+
draft: ConvertDraft;
|
|
87
|
+
live: ConvertLiveInputs;
|
|
88
|
+
}): ConvertDraftReading;
|
|
89
|
+
/**
|
|
90
|
+
* What a press converts, frozen for the locked view. `undefined` without
|
|
91
|
+
* everything signing needs; Convert is disabled then anyway.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getConvertSnapshot({ reading, sourceWallet, amountBaseUnits, quote, }: {
|
|
94
|
+
reading: ConvertDraftReading;
|
|
95
|
+
sourceWallet: ConvertSourceWalletSelection | undefined;
|
|
96
|
+
/** The amount the quote was requested for, after the typing pause. */
|
|
97
|
+
amountBaseUnits: bigint | undefined;
|
|
98
|
+
/** The quote on screen, unless it's already been signed. */
|
|
99
|
+
quote: ConvertQuote | undefined;
|
|
100
|
+
}): ConvertSnapshot | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Everything the Convert screens render. While a submission is locked it reads
|
|
103
|
+
* the snapshot; otherwise the draft against live data, with a failed
|
|
104
|
+
* submission's issue until the next edit ends it.
|
|
105
|
+
*/
|
|
106
|
+
export declare function deriveConvertView({ draft, live, submission, t, }: {
|
|
107
|
+
draft: ConvertDraft;
|
|
108
|
+
live: ConvertLive;
|
|
109
|
+
submission: ConvertSubmission | undefined;
|
|
110
|
+
t: TFunction;
|
|
111
|
+
}): ConvertView;
|
|
@@ -26,6 +26,8 @@ export declare enum CheckoutModalEvent {
|
|
|
26
26
|
NAVIGATE_SWAPPED_IFRAME = "fc::navigate::swapped_iframe",
|
|
27
27
|
NAVIGATE_PERPS_TRANSFER = "fc::navigate::perps_transfer",
|
|
28
28
|
NAVIGATE_CONVERT = "fc::navigate::convert",
|
|
29
|
+
NAVIGATE_CONVERT_SELECT_SOURCE = "fc::navigate::convert_select_source",
|
|
30
|
+
NAVIGATE_CONVERT_SELECT_DESTINATION = "fc::navigate::convert_select_destination",
|
|
29
31
|
READY_CONFIRMATION = "fc::ready::confirmation",
|
|
30
32
|
READY_INPUT_AMOUNT = "fc::ready::input_amount",
|
|
31
33
|
READY_SELECT_ASSET = "fc::ready::select_asset",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ConvertBalances } from '../domains/convert/balances';
|
|
2
|
+
import type { ConvertConfig, ConvertResolvedAsset } from '../domains/convert/types';
|
|
3
|
+
import type { ConvertAssetListStatus } from '../domains/convert/assets';
|
|
4
|
+
export interface ConvertAssetListResult {
|
|
5
|
+
status: ConvertAssetListStatus;
|
|
6
|
+
/** Resolved assets; empty until they resolve or when the host lists none. */
|
|
7
|
+
assets: ConvertResolvedAsset[];
|
|
8
|
+
balances: ConvertBalances | undefined;
|
|
9
|
+
/** Balances are being read, including a poll or retry. */
|
|
10
|
+
isBalancesFetching: boolean;
|
|
11
|
+
/** Loads again after a failure. */
|
|
12
|
+
retry: () => void;
|
|
13
|
+
/** Reads the given assets (all by default) again; rejects if the read fails. */
|
|
14
|
+
refetchBalances: (assets?: ConvertResolvedAsset[]) => Promise<ConvertBalances>;
|
|
15
|
+
}
|
|
16
|
+
/** The host's Convert assets and balances, read once for every Convert screen by `ConvertProvider`. */
|
|
17
|
+
export declare function useConvertAssetList({ checkoutId, config, enabled, }: {
|
|
18
|
+
/** The checkout session; Convert's host reads are cached per checkout. */
|
|
19
|
+
checkoutId: string | undefined;
|
|
20
|
+
config: ConvertConfig | undefined;
|
|
21
|
+
/** Off stops reads and polling; the last read stays readable. */
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
}): ConvertAssetListResult;
|
|
@@ -6,4 +6,6 @@ import type { ConvertAsset, ConvertResolvedAsset } from '../domains/convert/type
|
|
|
6
6
|
* still runs and every token takes the per-token fallback instead of the
|
|
7
7
|
* screen staying empty.
|
|
8
8
|
*/
|
|
9
|
-
export declare function useConvertAssets(assets: ConvertAsset[] | undefined
|
|
9
|
+
export declare function useConvertAssets(assets: ConvertAsset[] | undefined, { enabled }?: {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}): import("@tanstack/react-query").UseQueryResult<ConvertResolvedAsset[], Error>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type ConvertBalances } from '../domains/convert/balances';
|
|
2
2
|
import type { ConvertRecipientAddresses, ConvertResolvedAsset, GetConvertBalances } from '../domains/convert/types';
|
|
3
|
+
export declare const BALANCES_QUERY_KEY: readonly ["convert", "balances"];
|
|
3
4
|
interface UseConvertBalancesParams {
|
|
5
|
+
/** Scopes reads to one checkout, whose `getBalances` may differ from the last. */
|
|
6
|
+
checkoutId: string | undefined;
|
|
4
7
|
/** Resolved assets; one read covers all of them. */
|
|
5
8
|
assets: ConvertResolvedAsset[] | undefined;
|
|
6
9
|
getBalances: GetConvertBalances | undefined;
|
|
@@ -11,17 +14,20 @@ interface UseConvertBalancesParams {
|
|
|
11
14
|
* each balance was read from (Polygon pUSD is read from the proxy).
|
|
12
15
|
*/
|
|
13
16
|
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
14
|
-
/** Poll cadence; overridable so tests don't wait a minute. */
|
|
15
17
|
refetchIntervalMs?: number;
|
|
18
|
+
/** Off stops reads and polling; the last read stays readable. */
|
|
19
|
+
enabled?: boolean;
|
|
16
20
|
}
|
|
17
21
|
export interface UseConvertBalancesResult {
|
|
18
22
|
/**
|
|
19
|
-
* One entry per listed asset, keyed by `
|
|
23
|
+
* One entry per listed asset, keyed by `convertAssetKey`; `undefined`
|
|
20
24
|
* until the first read for the current asset list and account settles. A
|
|
21
25
|
* failed poll keeps the last good read.
|
|
22
26
|
*/
|
|
23
27
|
balances: ConvertBalances | undefined;
|
|
24
28
|
isLoading: boolean;
|
|
29
|
+
/** A read is running, including a poll or retry with balances shown. */
|
|
30
|
+
isFetching: boolean;
|
|
25
31
|
/** The latest read threw. `balances` still holds the last good one, if any. */
|
|
26
32
|
isError: boolean;
|
|
27
33
|
/**
|
|
@@ -40,5 +46,5 @@ export interface UseConvertBalancesResult {
|
|
|
40
46
|
* change to either is a cache miss; a late response for an old key can't
|
|
41
47
|
* replace a newer one.
|
|
42
48
|
*/
|
|
43
|
-
export declare function useConvertBalances({ assets, getBalances, recipientAddresses, refetchIntervalMs, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
49
|
+
export declare function useConvertBalances({ checkoutId, assets, getBalances, recipientAddresses, refetchIntervalMs, enabled, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
44
50
|
export {};
|
|
@@ -1,77 +1,33 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import type { ConvertSubmitPreparation } from '../domains/convert/submit';
|
|
1
|
+
import { type Dispatch } from 'react';
|
|
2
|
+
import type { ConvertBalances } from '../domains/convert/balances';
|
|
3
|
+
import type { ConvertEvent, ConvertSnapshot } from '../domains/convert/reducer';
|
|
5
4
|
import type { ConvertConfig, ConvertResolvedAsset } from '../domains/convert/types';
|
|
6
|
-
|
|
7
|
-
export interface ConvertSubmittedTransaction {
|
|
8
|
-
context: ConvertExecutionContext;
|
|
9
|
-
directExecution: DirectExecution;
|
|
10
|
-
}
|
|
11
|
-
export type ConvertExecuteState = {
|
|
12
|
-
status: 'idle';
|
|
13
|
-
} | {
|
|
14
|
-
status: 'executing';
|
|
15
|
-
}
|
|
16
|
-
/** The pre-sign check stopped it; nothing was sent. Execute again once fixed. */
|
|
17
|
-
| {
|
|
18
|
-
status: 'blocked';
|
|
19
|
-
preparation: Extract<ConvertSubmitPreparation, {
|
|
20
|
-
status: 'blocked';
|
|
21
|
-
}>;
|
|
22
|
-
}
|
|
23
|
-
/** The source leg failed before any funds moved; execute again to retry. */
|
|
24
|
-
| {
|
|
25
|
-
status: 'failed';
|
|
26
|
-
error: unknown;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sent and recorded; `useConvertTransactionStatus` follows it from here.
|
|
30
|
-
* Execute is open again, so the screen keeps Convert disabled while the
|
|
31
|
-
* status is pending.
|
|
32
|
-
*/
|
|
33
|
-
| {
|
|
34
|
-
status: 'submitted';
|
|
35
|
-
transaction: ConvertSubmittedTransaction;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Funds may have moved but there's nothing to track: recording the direct
|
|
39
|
-
* execution failed, or the wallet failed after sending with no deposit id.
|
|
40
|
-
* Final; the host's `onError` hears about it, and execute stays locked so
|
|
41
|
-
* the funds can't be sent twice.
|
|
42
|
-
*/
|
|
43
|
-
| {
|
|
44
|
-
status: 'unknown';
|
|
45
|
-
sourceTxId: string | undefined;
|
|
46
|
-
error: unknown;
|
|
47
|
-
};
|
|
5
|
+
import type { MaxSpendableAmount } from '../hooks/useMaxSpendableAmount';
|
|
48
6
|
interface UseConvertExecuteParams {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
amountInBaseUnits: bigint | undefined;
|
|
55
|
-
/** `usePrepareConvertSubmit`'s check; only its `ready` quote is signed. */
|
|
56
|
-
prepareSubmit: () => Promise<ConvertSubmitPreparation>;
|
|
7
|
+
dispatch: Dispatch<ConvertEvent>;
|
|
8
|
+
/** The source's fee reserve, for the pre-sign check's fresh Max. */
|
|
9
|
+
feeReserve: MaxSpendableAmount;
|
|
10
|
+
/** Called with only the source asset. */
|
|
11
|
+
refetchBalances: (assets: ConvertResolvedAsset[]) => Promise<ConvertBalances>;
|
|
57
12
|
/**
|
|
58
13
|
* The host's callback: quote problems, failures before funds move, and an
|
|
59
|
-
*
|
|
14
|
+
* untrackable outcome.
|
|
60
15
|
*/
|
|
61
16
|
onError?: ConvertConfig['onError'];
|
|
62
17
|
}
|
|
63
18
|
export interface UseConvertExecuteResult {
|
|
64
|
-
state: ConvertExecuteState;
|
|
65
19
|
/**
|
|
66
|
-
* Runs one conversion up to a recorded deposit
|
|
67
|
-
*
|
|
20
|
+
* Runs one conversion of `snapshot` up to a recorded deposit, signing only
|
|
21
|
+
* what the pre-sign check passes. A call while one is running, or after its
|
|
22
|
+
* outcome turned untrackable, does nothing.
|
|
68
23
|
*/
|
|
69
|
-
execute: () => Promise<void>;
|
|
24
|
+
execute: (snapshot: ConvertSnapshot) => Promise<void>;
|
|
70
25
|
}
|
|
71
26
|
/**
|
|
72
27
|
* Convert's submit, like withdrawal's `useWithdrawal`: pre-sign check, source
|
|
73
28
|
* leg through the host's wallet, then a direct-execution record for
|
|
74
|
-
* `useConvertTransactionStatus` to follow.
|
|
29
|
+
* `useConvertTransactionStatus` to follow. Holds no state: it reports each
|
|
30
|
+
* step to the reducer, and never polls.
|
|
75
31
|
*/
|
|
76
|
-
export declare function useConvertExecute({
|
|
32
|
+
export declare function useConvertExecute({ dispatch, feeReserve, refetchBalances, onError, }: UseConvertExecuteParams): UseConvertExecuteResult;
|
|
77
33
|
export {};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type ConvertQuote } from '../domains/convert/quote';
|
|
2
2
|
import type { ConvertResolvedAsset } from '../domains/convert/types';
|
|
3
|
+
export declare const CONVERT_QUOTE_REFRESH_MS = 30000;
|
|
4
|
+
export declare const CONVERT_QUOTE_QUERY_KEY: readonly ["convert", "quote"];
|
|
3
5
|
interface UseConvertQuoteParams {
|
|
6
|
+
/**
|
|
7
|
+
* Scopes quotes to one checkout, like withdrawal's, so a reopened checkout
|
|
8
|
+
* never reuses one from before.
|
|
9
|
+
*/
|
|
10
|
+
checkoutId: string;
|
|
4
11
|
sourceAsset: ConvertResolvedAsset | undefined;
|
|
5
12
|
destinationAsset: ConvertResolvedAsset | undefined;
|
|
6
13
|
/** Exact amount to spend; no quote for `undefined` or zero. */
|
|
@@ -8,13 +15,26 @@ interface UseConvertQuoteParams {
|
|
|
8
15
|
/** The source wallet that signs. */
|
|
9
16
|
userAddress: string | undefined;
|
|
10
17
|
recipientAddress: string | undefined;
|
|
11
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Off stops all fetching and keeps the shown quote. On re-enable TanStack
|
|
20
|
+
* refetches a quote past its refresh time at once, reporting `isFetching`
|
|
21
|
+
* from that render, so it's never signed stale.
|
|
22
|
+
*/
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Bumped per sent deposit, so the next attempt never reuses a quote whose
|
|
26
|
+
* Relay request was already sent.
|
|
27
|
+
*/
|
|
28
|
+
sentCount?: number;
|
|
29
|
+
/** Refresh cadence; overridable so tests don't wait 30s. */
|
|
12
30
|
refetchIntervalMs?: number;
|
|
13
31
|
}
|
|
14
32
|
export interface UseConvertQuoteResult {
|
|
15
33
|
/** The current quote; `undefined` while loading or after a failed fetch. */
|
|
16
34
|
quote: ConvertQuote | undefined;
|
|
17
35
|
isLoading: boolean;
|
|
36
|
+
/** A fetch is running, including a timed refresh while a quote is shown. */
|
|
37
|
+
isFetching: boolean;
|
|
18
38
|
isError: boolean;
|
|
19
39
|
/** As thrown; a Relay rejection stays a `RelayQuoteError`. */
|
|
20
40
|
error: Error | null;
|
|
@@ -29,5 +49,5 @@ export interface UseConvertQuoteResult {
|
|
|
29
49
|
* a quote is shown. A failed fetch hides the quote and stops the timer until
|
|
30
50
|
* the inputs change or `refetch` is called.
|
|
31
51
|
*/
|
|
32
|
-
export declare function useConvertQuote({ sourceAsset, destinationAsset, amountInBaseUnits, userAddress, recipientAddress, refetchIntervalMs, }: UseConvertQuoteParams): UseConvertQuoteResult;
|
|
52
|
+
export declare function useConvertQuote({ checkoutId, sourceAsset, destinationAsset, amountInBaseUnits, userAddress, recipientAddress, enabled: isEnabled, sentCount, refetchIntervalMs, }: UseConvertQuoteParams): UseConvertQuoteResult;
|
|
33
53
|
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ConvertRecipientSelection } from '../domains/convert/recipient';
|
|
2
|
+
import { type ConvertSourceWalletSelection } from '../domains/convert/sourceWallet';
|
|
3
|
+
import type { ConvertRecipientAddresses, ConvertResolvedAsset, GetConvertSourceWallet } from '../domains/convert/types';
|
|
4
|
+
export interface ConvertSelectionLookup<Selection> {
|
|
5
|
+
/** `undefined` while it resolves, or with nothing picked. */
|
|
6
|
+
selection: Selection | undefined;
|
|
7
|
+
/** The lookup is running, including a retry. */
|
|
8
|
+
isFetching: boolean;
|
|
9
|
+
/** Looks up again, e.g. after the host's resolver failed or timed out. */
|
|
10
|
+
retry: () => void;
|
|
11
|
+
}
|
|
12
|
+
/** Where the chosen destination's funds land. */
|
|
13
|
+
export declare function useConvertRecipient({ checkoutId, asset, recipientAddresses, enabled, }: {
|
|
14
|
+
/** Scopes the answer to one checkout, whose host callbacks may differ from the last. */
|
|
15
|
+
checkoutId: string | undefined;
|
|
16
|
+
asset: ConvertResolvedAsset | undefined;
|
|
17
|
+
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
18
|
+
/** Off keeps the last answer without asking the host. */
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
}): ConvertSelectionLookup<ConvertRecipientSelection>;
|
|
21
|
+
/**
|
|
22
|
+
* The signing wallet for the chosen source. Keyed on the asset, since the host
|
|
23
|
+
* may resolve different wallets for tokens on one chain.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useConvertSourceWallet({ checkoutId, asset, getSourceWallet, recipientAddresses, enabled, }: {
|
|
26
|
+
/** Scopes the wallet to one checkout, so a replaced host wallet is never reused. */
|
|
27
|
+
checkoutId: string | undefined;
|
|
28
|
+
asset: ConvertResolvedAsset | undefined;
|
|
29
|
+
getSourceWallet: GetConvertSourceWallet | undefined;
|
|
30
|
+
/** Only keys the cache to the host's account. */
|
|
31
|
+
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
32
|
+
/** Off keeps the last answer without asking the host. */
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
}): ConvertSelectionLookup<ConvertSourceWalletSelection>;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
+
import { type Dispatch } from 'react';
|
|
2
|
+
import type { ConvertEvent, ConvertSubmission } from '../domains/convert/reducer';
|
|
1
3
|
import type { ConvertConfig } from '../domains/convert/types';
|
|
2
|
-
import type { ConvertSubmittedTransaction } from './useConvertExecute';
|
|
3
|
-
/** Like Nado's withdrawal status; pending until a conversion is submitted and settles. */
|
|
4
|
-
export type ConvertTransactionStatus = 'pending' | 'completed' | 'failed';
|
|
5
|
-
export interface ConvertTransactionTracking {
|
|
6
|
-
status: ConvertTransactionStatus;
|
|
7
|
-
/** Relay's fill transaction, once completed. */
|
|
8
|
-
destinationTxIds: string[];
|
|
9
|
-
/** Only when Relay reports a measured amount; never the quote. */
|
|
10
|
-
settledAmountOutBaseUnits: string | undefined;
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
|
-
* Follows a
|
|
5
|
+
* Follows a recorded conversion to settlement, like withdrawal's
|
|
14
6
|
* `useNadoWithdrawalStatus`: polls its direct execution with the same hook
|
|
15
|
-
* checkout and withdrawal status screens use
|
|
16
|
-
*
|
|
7
|
+
* checkout and withdrawal status screens use. Once per conversion, when Relay
|
|
8
|
+
* reports a terminal status, it fires the host's callback and reports
|
|
9
|
+
* `COMPLETED` or `FILL_FAILED`. A refund reads as a failure.
|
|
17
10
|
*/
|
|
18
|
-
export declare function useConvertTransactionStatus({
|
|
19
|
-
/** `
|
|
20
|
-
|
|
11
|
+
export declare function useConvertTransactionStatus({ submission, dispatch, onSuccess, onError, }: {
|
|
12
|
+
/** Only a `pending` submission is polled. */
|
|
13
|
+
submission: ConvertSubmission | undefined;
|
|
14
|
+
dispatch: Dispatch<ConvertEvent>;
|
|
21
15
|
onSuccess?: ConvertConfig['onSuccess'];
|
|
22
16
|
onError?: ConvertConfig['onError'];
|
|
23
|
-
}):
|
|
17
|
+
}): void;
|
package/dist/index.css
CHANGED
|
@@ -17345,14 +17345,6 @@
|
|
|
17345
17345
|
background: var(--rk-colors-modalBackground);
|
|
17346
17346
|
}
|
|
17347
17347
|
|
|
17348
|
-
/* vanilla-extract-css-ns:src/components/FunSelectBrokerage/FunBrokerageItem.css.ts.vanilla.css?source=LmFuMzR5OTAgewogIGRpc3BsYXk6IGZsZXg7CiAganVzdGlmeS1jb250ZW50OiBzcGFjZS1iZXR3ZWVuOwogIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgZmxleDogMTsKfQ */
|
|
17349
|
-
[data-rk] .an34y90 {
|
|
17350
|
-
display: flex;
|
|
17351
|
-
justify-content: space-between;
|
|
17352
|
-
align-items: center;
|
|
17353
|
-
flex: 1;
|
|
17354
|
-
}
|
|
17355
|
-
|
|
17356
17348
|
/* vanilla-extract-css-ns:src/components/FunCountdown/FunCountdown.css.ts.vanilla.css?source=Ll8xdDBiYzExMSB7CiAgcG9zaXRpb246IGFic29sdXRlOwogIGxlZnQ6IDA7CiAgdG9wOiAwOwogIGJvdHRvbTogMDsKICB0cmFuc2Zvcm06IHJvdGF0ZSgtOTBkZWcpOwp9Ci5fMXQwYmMxMTMgewogIHBvc2l0aW9uOiBhYnNvbHV0ZTsKICBsZWZ0OiAwOwogIHRvcDogMDsKICBib3R0b206IDA7CiAgdHJhbnNmb3JtOiByb3RhdGUoLTkwZGVnKTsKfQ */
|
|
17357
17349
|
[data-rk] ._1t0bc111 {
|
|
17358
17350
|
position: absolute;
|
|
@@ -17369,6 +17361,14 @@
|
|
|
17369
17361
|
transform: rotate(-90deg);
|
|
17370
17362
|
}
|
|
17371
17363
|
|
|
17364
|
+
/* vanilla-extract-css-ns:src/components/FunSelectBrokerage/FunBrokerageItem.css.ts.vanilla.css?source=LmFuMzR5OTAgewogIGRpc3BsYXk6IGZsZXg7CiAganVzdGlmeS1jb250ZW50OiBzcGFjZS1iZXR3ZWVuOwogIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgZmxleDogMTsKfQ */
|
|
17365
|
+
[data-rk] .an34y90 {
|
|
17366
|
+
display: flex;
|
|
17367
|
+
justify-content: space-between;
|
|
17368
|
+
align-items: center;
|
|
17369
|
+
flex: 1;
|
|
17370
|
+
}
|
|
17371
|
+
|
|
17372
17372
|
/* vanilla-extract-css-ns:src/components/SourcePaymentMethodItem/SourcePaymentMethodItem.css.ts.vanilla.css?source=Ll8xeW9mZWZsMCB7CiAgZGlzcGxheTogaW5saW5lLWZsZXg7CiAgYWxpZ24taXRlbXM6IGNlbnRlcjsKICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjsKICBtaW4td2lkdGg6IDdweDsKfQouXzF5b2ZlZmwxIHsKICBwb3NpdGlvbjogcmVsYXRpdmU7Cn0KLl8xeW9mZWZsMSAuXzF5b2ZlZmwyIHsKICBiYWNrZ3JvdW5kOiBsaW5lYXItZ3JhZGllbnQoOTBkZWcsIHRyYW5zcGFyZW50IDYzLjE2JSwgdmFyKC0tcmstY29sb3JzLW9wdGlvbkJveEJhY2tncm91bmQpIDkxLjQ1JSk7Cn0KLl8xeW9mZWZsMTpob3ZlciAuXzF5b2ZlZmwyIHsKICBiYWNrZ3JvdW5kOiBsaW5lYXItZ3JhZGllbnQoOTBkZWcsIHRyYW5zcGFyZW50IDYzLjE2JSwgdmFyKC0tcmstY29sb3JzLW9mZkJhY2tncm91bmQpIDkxLjQ1JSk7Cn0 */
|
|
17373
17373
|
[data-rk] ._1yofefl0 {
|
|
17374
17374
|
display: inline-flex;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export { createAuthenticationAdapter, FunkitConnectAuthenticationProvider, } fro
|
|
|
20
20
|
export type { AuthenticationAdapter, FunkitConnectAuthenticationProviderProps, } from './providers/AuthenticationContext';
|
|
21
21
|
export type { AvatarComponent } from './providers/AvatarContext';
|
|
22
22
|
export type { CheckoutBlockedReason } from './modals/CheckoutModal/CheckoutBlockedReason';
|
|
23
|
-
export type { FunkitCheckoutActionParams, FunkitCheckoutConfig, FunkitCheckoutOnCloseResult, FunkitWithdrawalConfig, WalletWithdrawalConfig, CustomWithdrawalConfig, MultiMethodWithdrawalConfig, WithdrawalMethodOption, WithdrawalParam, WithdrawalFormData, WithdrawalSourceTokenBalanceParams, WithdrawalSourceCustomData, SourceTokenOption, WithdrawalCustomerData, LighterWithdrawalCustomerData, LighterRouteType, WithdrawalCustomerConfig, UseFunkitCheckoutPropsWithFullConfig, UseFunkitCheckoutProps, FunkitCheckoutValidationResult, FunkitCheckoutResult, DynamicTargetAssetCandidate, AddToWalletToken, TokenInfo, ModalTitleContext, DestinationLineItem, DestinationLineItemContext, LineItemSlot, LineItemValue, LineItemValueColor, WithdrawalFeeItem, WithdrawalFeeItemContext, } from './providers/FunkitCheckoutContext';
|
|
23
|
+
export type { FunkitCheckoutActionParams, FunkitCheckoutConfig, FunkitCheckoutOnCloseResult, FunkitWithdrawalConfig, WalletWithdrawalConfig, CustomWithdrawalConfig, MultiMethodWithdrawalConfig, WithdrawalMethodOption, MultiSourceWithdrawalConfig, WithdrawalSourceOption, SingleWithdrawalConfig, WithdrawalParam, WithdrawalFormData, WithdrawalSourceTokenBalanceParams, WithdrawalSourceCustomData, SourceTokenOption, WithdrawalCustomerData, LighterWithdrawalCustomerData, LighterRouteType, WithdrawalCustomerConfig, UseFunkitCheckoutPropsWithFullConfig, UseFunkitCheckoutProps, FunkitCheckoutValidationResult, FunkitCheckoutResult, DynamicTargetAssetCandidate, AddToWalletToken, TokenInfo, ModalTitleContext, DestinationLineItem, DestinationLineItemContext, LineItemSlot, LineItemValue, LineItemValueColor, WithdrawalFeeItem, WithdrawalFeeItemContext, } from './providers/FunkitCheckoutContext';
|
|
24
24
|
export { useFunkitCheckout, FunCheckoutStartingStep, } from './providers/FunkitCheckoutContext';
|
|
25
25
|
export type { FunkitCheckoutQuoteResult } from './domains/quote';
|
|
26
26
|
export type { FunkitConfig, FunkitUiCustomizationsConfig, FunkitTextCustomizationsConfig, } from './providers/FunkitConfigContext';
|
|
@@ -49,6 +49,7 @@ export type { FunkitConnectWalletConnectParameters, Wallet, WalletDetailsParams,
|
|
|
49
49
|
export { createConnectedWithdrawalClient } from './wallets/createConnectedWithdrawalClient';
|
|
50
50
|
export { useSolanaWithdrawalConfig, type SolanaWithdrawalConfig, } from './wallets/solanaWithdrawal';
|
|
51
51
|
export { useHypercoreWithdrawalConfig, type HypercoreSigner, type HypercoreWithdrawalOptions, } from './wallets/hypercoreWithdrawal';
|
|
52
|
+
export { createMultiSourceWithdrawalConfig, type MultiSourceWithdrawalOptions, } from './wallets/multiSourceWithdrawal';
|
|
52
53
|
export type { ConvertAsset, ConvertConfig, ConvertErrorResult, ConvertErrorStage, ConvertRecipientAddresses, ConvertResolvedAsset, ConvertAssetBalance, ConvertSourceWallet, ConvertSuccessResult, ConvertTransaction, ConvertVm, GetConvertBalances, GetConvertSourceWallet, } from './domains/convert/types';
|
|
53
54
|
export { useFunkitAccount, useFunkitDisconnect, useFunkitReconnect, useFunkitSwitchChains, } from './providers/GeneralWalletProvider';
|
|
54
55
|
export { SelectedHomeTab } from './modals/ProfileDetails/FunProfileViews/Home';
|