@funkit/connect 12.15.3 → 12.17.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 +80 -0
- package/dist/clients/axiom.d.ts +11 -3
- package/dist/clients/axiom.js +3 -1
- package/dist/clients/{chunk-7JYLS7IF.js → chunk-2L6IKKNH.js} +48 -32
- package/dist/clients/{chunk-6IH7AWFA.js → chunk-HANOVGPH.js} +1 -1
- package/dist/clients/{chunk-OB5GKTP2.js → chunk-LVR6RQMO.js} +1 -1
- package/dist/clients/chunk-R25GIAD5.js +59 -0
- package/dist/clients/{chunk-UZ3NA7HN.js → chunk-TWP5LFPX.js} +5 -5
- package/dist/clients/{chunk-BKK2BFIP.js → chunk-V4RIF2NR.js} +1 -1
- package/dist/clients/fanatics.js +2 -2
- package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
- package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +4 -4
- package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
- package/dist/clients/lighter.d.ts +29 -16
- package/dist/clients/lighter.js +149 -68
- package/dist/clients/mallard.js +2 -2
- package/dist/clients/nado.js +3 -3
- package/dist/consts/customers.d.ts +12 -1
- package/dist/domains/convert/assets.d.ts +22 -0
- package/dist/domains/convert/balances.d.ts +35 -0
- package/dist/domains/convert/errors.d.ts +38 -0
- package/dist/domains/convert/execution.d.ts +39 -0
- package/dist/domains/convert/inputAmount.d.ts +24 -0
- package/dist/domains/convert/quote.d.ts +24 -0
- package/dist/domains/convert/recipient.d.ts +21 -0
- package/dist/domains/convert/settlement.d.ts +47 -0
- package/dist/domains/convert/sourceWallet.d.ts +29 -0
- package/dist/domains/convert/submit.d.ts +46 -0
- package/dist/domains/convert/types.d.ts +165 -0
- package/dist/domains/nativeFeeReserve.d.ts +29 -0
- package/dist/domains/quote.d.ts +14 -1
- package/dist/hooks/queries/useWithdrawFops.d.ts +6 -0
- package/dist/hooks/queries/useWithdrawalQuote.d.ts +4 -1
- package/dist/hooks/statsig/index.d.ts +1 -1
- package/dist/hooks/track/WithdrawModalEvent.d.ts +1 -0
- package/dist/hooks/track/analytics/events.d.ts +59 -1
- package/dist/hooks/track/analytics/mappers.d.ts +5 -10
- package/dist/hooks/track/analytics/resolveIframeStepNavigation.d.ts +18 -0
- package/dist/hooks/track/analytics/useDepositAnalytics.d.ts +2 -2
- package/dist/hooks/track/analytics/useTrackSwappedIframeEvents.d.ts +5 -0
- package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +2 -2
- package/dist/hooks/track/useQuoteAttemptCounter.d.ts +2 -0
- package/dist/hooks/useConvertAssets.d.ts +9 -0
- package/dist/hooks/useConvertBalances.d.ts +44 -0
- package/dist/hooks/useConvertExecute.d.ts +77 -0
- package/dist/hooks/useConvertInputAmount.d.ts +26 -0
- package/dist/hooks/useConvertMaxAmount.d.ts +11 -0
- package/dist/hooks/useConvertQuote.d.ts +33 -0
- package/dist/hooks/useConvertTransactionStatus.d.ts +23 -0
- package/dist/hooks/useMaxSpendableAmount.d.ts +19 -0
- package/dist/hooks/usePrepareConvertSubmit.d.ts +22 -0
- package/dist/hooks/useStepQueryReadiness.d.ts +45 -15
- package/dist/hooks/useSwappedBuyingCrypto.d.ts +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2572 -1800
- package/dist/modals/CheckoutModal/SwappedIframe/swappedIframeReady.track.d.ts +8 -0
- package/dist/modals/CheckoutModal/stepTransition.d.ts +1 -2
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +48 -15
- package/dist/modals/WithdrawalModal/WithdrawAmountInput.d.ts +3 -1
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +4 -1
- package/dist/modals/WithdrawalModal/useMaxWithdrawableAmount.d.ts +10 -0
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +28 -8
- package/dist/providers/FunkitCheckoutContext/types.d.ts +7 -0
- package/dist/providers/FunkitQuoteContext.track.d.ts +23 -3
- package/dist/providers/FunkitStatsigWhnProvider.d.ts +0 -11
- package/dist/providers/SwappedProvider.d.ts +11 -2
- package/dist/utils/customer.d.ts +34 -4
- package/dist/wallets/walletConnectors/index.js +41 -41
- package/package.json +6 -6
- package/dist/clients/chunk-6EU6CXNH.js +0 -20
- package/dist/hooks/statsig/useExperimentV2.d.ts +0 -8
- package/dist/utils/statsig/client.d.ts +0 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ConvertAsset, ConvertResolvedAsset } from '../domains/convert/types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the host's Convert asset list. Waits for the supported-assets list
|
|
4
|
+
* (already loading for the checkout modal) so every token that it covers
|
|
5
|
+
* resolves without a network call. If that list fails to load, resolution
|
|
6
|
+
* still runs and every token takes the per-token fallback instead of the
|
|
7
|
+
* screen staying empty.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useConvertAssets(assets: ConvertAsset[] | undefined): import("@tanstack/react-query").UseQueryResult<ConvertResolvedAsset[], Error>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ConvertBalances } from '../domains/convert/balances';
|
|
2
|
+
import type { ConvertRecipientAddresses, ConvertResolvedAsset, GetConvertBalances } from '../domains/convert/types';
|
|
3
|
+
interface UseConvertBalancesParams {
|
|
4
|
+
/** Resolved assets; one read covers all of them. */
|
|
5
|
+
assets: ConvertResolvedAsset[] | undefined;
|
|
6
|
+
getBalances: GetConvertBalances | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The host's account per VM. Part of the cache key, so an account switch
|
|
9
|
+
* never shows the previous account's balances. These are the host's receive
|
|
10
|
+
* addresses: an identity for the account, not a claim about which wallet
|
|
11
|
+
* each balance was read from (Polygon pUSD is read from the proxy).
|
|
12
|
+
*/
|
|
13
|
+
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
14
|
+
/** Poll cadence; overridable so tests don't wait a minute. */
|
|
15
|
+
refetchIntervalMs?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface UseConvertBalancesResult {
|
|
18
|
+
/**
|
|
19
|
+
* One entry per listed asset, keyed by `convertBalanceKey`; `undefined`
|
|
20
|
+
* until the first read for the current asset list and account settles. A
|
|
21
|
+
* failed poll keeps the last good read.
|
|
22
|
+
*/
|
|
23
|
+
balances: ConvertBalances | undefined;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
/** The latest read threw. `balances` still holds the last good one, if any. */
|
|
26
|
+
isError: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Read again now, e.g. before signing or after a convert settles. Resolves
|
|
29
|
+
* with the fresh balances and rejects if the host's read failed, so a
|
|
30
|
+
* caller never mistakes the last good read for a fresh one.
|
|
31
|
+
* - With `assets`, reads only those and merges them into the cached
|
|
32
|
+
* balances; the rest keep their last read.
|
|
33
|
+
* - Without, reads every listed asset.
|
|
34
|
+
*/
|
|
35
|
+
refetch: (assets?: ConvertResolvedAsset[]) => Promise<ConvertBalances>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Owns Convert's balance state: one query for every listed asset, polled on
|
|
39
|
+
* a timer while mounted. Keyed by the asset list and the host's account, so a
|
|
40
|
+
* change to either is a cache miss; a late response for an old key can't
|
|
41
|
+
* replace a newer one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useConvertBalances({ assets, getBalances, recipientAddresses, refetchIntervalMs, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { DirectExecution } from '@funkit/api-base';
|
|
2
|
+
import { type ConvertExecutionContext } from '../domains/convert/settlement';
|
|
3
|
+
import type { ConvertSourceWalletSelection } from '../domains/convert/sourceWallet';
|
|
4
|
+
import type { ConvertSubmitPreparation } from '../domains/convert/submit';
|
|
5
|
+
import type { ConvertConfig, ConvertResolvedAsset } from '../domains/convert/types';
|
|
6
|
+
/** A conversion whose deposit was sent and recorded; what status tracks. */
|
|
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
|
+
};
|
|
48
|
+
interface UseConvertExecuteParams {
|
|
49
|
+
sourceAsset: ConvertResolvedAsset | undefined;
|
|
50
|
+
destinationAsset: ConvertResolvedAsset | undefined;
|
|
51
|
+
/** The resolver's wallet for the source chain, the same one that quoted. */
|
|
52
|
+
sourceWallet: ConvertSourceWalletSelection | undefined;
|
|
53
|
+
recipientAddress: string | undefined;
|
|
54
|
+
amountInBaseUnits: bigint | undefined;
|
|
55
|
+
/** `usePrepareConvertSubmit`'s check; only its `ready` quote is signed. */
|
|
56
|
+
prepareSubmit: () => Promise<ConvertSubmitPreparation>;
|
|
57
|
+
/**
|
|
58
|
+
* The host's callback: quote problems, failures before funds move, and an
|
|
59
|
+
* `unknown` outcome.
|
|
60
|
+
*/
|
|
61
|
+
onError?: ConvertConfig['onError'];
|
|
62
|
+
}
|
|
63
|
+
export interface UseConvertExecuteResult {
|
|
64
|
+
state: ConvertExecuteState;
|
|
65
|
+
/**
|
|
66
|
+
* Runs one conversion up to a recorded deposit. A call while one is
|
|
67
|
+
* running, or after its outcome turned unknown, does nothing.
|
|
68
|
+
*/
|
|
69
|
+
execute: () => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert's submit, like withdrawal's `useWithdrawal`: pre-sign check, source
|
|
73
|
+
* leg through the host's wallet, then a direct-execution record for
|
|
74
|
+
* `useConvertTransactionStatus` to follow. It never polls.
|
|
75
|
+
*/
|
|
76
|
+
export declare function useConvertExecute({ sourceAsset, destinationAsset, sourceWallet, recipientAddress, amountInBaseUnits, prepareSubmit, onError, }: UseConvertExecuteParams): UseConvertExecuteResult;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AmountUnit, type AmountUnitToggleState } from '../components/TokenSwapWidget/AmountUnitToggle/useAmountUnitToggle';
|
|
2
|
+
export interface ConvertInputAmountState extends AmountUnitToggleState {
|
|
3
|
+
/** What to quote: Max's exact amount, or the typed one. */
|
|
4
|
+
baseUnits: bigint | undefined;
|
|
5
|
+
/** The amount came from Max; typing clears it. */
|
|
6
|
+
isMax: boolean;
|
|
7
|
+
/** Above the source balance; `false` while the balance is unknown. */
|
|
8
|
+
exceedsBalance: boolean;
|
|
9
|
+
/** Sets an exact Max; the field shows it rounded down. */
|
|
10
|
+
setMax: (baseUnits: bigint) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convert's amount entry: the unit toggle plus an exact base-unit amount.
|
|
14
|
+
* - Max is held apart from the field text, which is capped at 5 decimals and
|
|
15
|
+
* can't carry an 18-decimal balance.
|
|
16
|
+
* - While Max is on, the field and its converted amounts are derived from it
|
|
17
|
+
* each render, so a price change or unit flip never leaves them stale.
|
|
18
|
+
* - Reset it (remount or key) when the source token changes, like the toggle.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useConvertInputAmount({ decimals, unitPriceUsd, balanceBaseUnits, initialUnit, }: {
|
|
21
|
+
decimals: number;
|
|
22
|
+
unitPriceUsd: number | undefined;
|
|
23
|
+
/** Source balance as a base-unit integer string, when known. */
|
|
24
|
+
balanceBaseUnits: string | undefined;
|
|
25
|
+
initialUnit?: AmountUnit;
|
|
26
|
+
}): ConvertInputAmountState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConvertBalanceState } from '../domains/convert/balances';
|
|
2
|
+
import type { ConvertResolvedAsset } from '../domains/convert/types';
|
|
3
|
+
/**
|
|
4
|
+
* What Max fills in for a Convert source, in its base units: the balance less
|
|
5
|
+
* its fee reserve. `null` disables Max: the balance is unavailable or not yet
|
|
6
|
+
* read, or a native EVM source's gas price is still loading.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useConvertMaxAmount({ asset, balance, }: {
|
|
9
|
+
asset: ConvertResolvedAsset;
|
|
10
|
+
balance: ConvertBalanceState | undefined;
|
|
11
|
+
}): bigint | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ConvertQuote } from '../domains/convert/quote';
|
|
2
|
+
import type { ConvertResolvedAsset } from '../domains/convert/types';
|
|
3
|
+
interface UseConvertQuoteParams {
|
|
4
|
+
sourceAsset: ConvertResolvedAsset | undefined;
|
|
5
|
+
destinationAsset: ConvertResolvedAsset | undefined;
|
|
6
|
+
/** Exact amount to spend; no quote for `undefined` or zero. */
|
|
7
|
+
amountInBaseUnits: bigint | undefined;
|
|
8
|
+
/** The source wallet that signs. */
|
|
9
|
+
userAddress: string | undefined;
|
|
10
|
+
recipientAddress: string | undefined;
|
|
11
|
+
/** Refresh cadence; overridable so tests don't wait 25s. */
|
|
12
|
+
refetchIntervalMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface UseConvertQuoteResult {
|
|
15
|
+
/** The current quote; `undefined` while loading or after a failed fetch. */
|
|
16
|
+
quote: ConvertQuote | undefined;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
isError: boolean;
|
|
19
|
+
/** As thrown; a Relay rejection stays a `RelayQuoteError`. */
|
|
20
|
+
error: Error | null;
|
|
21
|
+
/** When the shown quote is replaced; seeds the countdown. */
|
|
22
|
+
refreshesAtMs: number | undefined;
|
|
23
|
+
/** Quote again now, e.g. when the user retries a failed quote. Rejects if it fails. */
|
|
24
|
+
refetch: () => Promise<ConvertQuote>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert's exact-in quote. Keyed by everything the request carries, so an
|
|
28
|
+
* edit never shows a quote for the old inputs, and refreshed on a timer while
|
|
29
|
+
* a quote is shown. A failed fetch hides the quote and stops the timer until
|
|
30
|
+
* the inputs change or `refetch` is called.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useConvertQuote({ sourceAsset, destinationAsset, amountInBaseUnits, userAddress, recipientAddress, refetchIntervalMs, }: UseConvertQuoteParams): UseConvertQuoteResult;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
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
|
+
/**
|
|
13
|
+
* Follows a registered conversion to settlement, like withdrawal's
|
|
14
|
+
* `useNadoWithdrawalStatus`: polls its direct execution with the same hook
|
|
15
|
+
* checkout and withdrawal status screens use, and fires the host's callback
|
|
16
|
+
* once when Relay reports a terminal status. A refund reads as a failure.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useConvertTransactionStatus({ submittedTransaction, onSuccess, onError, }: {
|
|
19
|
+
/** `useConvertExecute`'s submitted transaction; nothing is polled without one. */
|
|
20
|
+
submittedTransaction: ConvertSubmittedTransaction | undefined;
|
|
21
|
+
onSuccess?: ConvertConfig['onSuccess'];
|
|
22
|
+
onError?: ConvertConfig['onError'];
|
|
23
|
+
}): ConvertTransactionTracking;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Dnum } from 'dnum';
|
|
2
|
+
export interface MaxSpendableAmount {
|
|
3
|
+
/** A native EVM source's gas price hasn't loaded, so Max is unknown. */
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
/** The balance less its fee reserve. Only meaningful when `!isLoading`. */
|
|
6
|
+
getMaxSpendable: (balance: Dnum) => Dnum;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* What Max may fill in for a source token: the balance less its fee reserve.
|
|
10
|
+
* A function of the balance so a caller can apply it to a balance read after
|
|
11
|
+
* render (the pre-sign check).
|
|
12
|
+
* - EVM gas is the live gas price × checkout's Statsig gas-unit buffer.
|
|
13
|
+
* - A chain missing from the wagmi config, or a failed gas request, falls back
|
|
14
|
+
* to the full balance with a warning rather than leaving Max disabled.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useMaxSpendableAmount({ chainId, tokenAddress, }: {
|
|
17
|
+
chainId: string;
|
|
18
|
+
tokenAddress: string;
|
|
19
|
+
}): MaxSpendableAmount;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ConvertBalances } from '../domains/convert/balances';
|
|
2
|
+
import type { ConvertQuote } from '../domains/convert/quote';
|
|
3
|
+
import { type ConvertSubmitPreparation } from '../domains/convert/submit';
|
|
4
|
+
import type { ConvertResolvedAsset } from '../domains/convert/types';
|
|
5
|
+
interface UsePrepareConvertSubmitParams {
|
|
6
|
+
sourceAsset: ConvertResolvedAsset;
|
|
7
|
+
/** The amount being quoted, from `useConvertInputAmount`. */
|
|
8
|
+
amountInBaseUnits: bigint | undefined;
|
|
9
|
+
/** The quote on screen, from `useConvertQuote`; it's the one signed. */
|
|
10
|
+
quote: ConvertQuote | undefined;
|
|
11
|
+
/** `useConvertBalances.refetch`; called with only the source asset. */
|
|
12
|
+
refetchBalances: (assets: ConvertResolvedAsset[]) => Promise<ConvertBalances>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The pre-sign check, run on every submit before the first source step: check
|
|
16
|
+
* the quote on screen, re-read the source balance and check the amount against
|
|
17
|
+
* the fresh Max. Returns `ready` with the quote to execute, or why not to sign
|
|
18
|
+
* yet. Like withdrawal, it doesn't requote. Never signs, sends, or edits the
|
|
19
|
+
* amount.
|
|
20
|
+
*/
|
|
21
|
+
export declare function usePrepareConvertSubmit({ sourceAsset, amountInBaseUnits, quote, refetchBalances, }: UsePrepareConvertSubmitParams): () => Promise<ConvertSubmitPreparation>;
|
|
22
|
+
export {};
|
|
@@ -1,32 +1,62 @@
|
|
|
1
|
+
import type { FormOfPaymentType } from '@funkit/api-base';
|
|
2
|
+
import type { PaymentMethod } from '../domains/paymentMethods';
|
|
1
3
|
import type { CheckoutModalEvent } from '../hooks/track/CheckoutModalEvent';
|
|
4
|
+
import type { WithdrawModalEvent } from '../hooks/track/WithdrawModalEvent';
|
|
2
5
|
import type { useTrack } from '../hooks/track/useTrack';
|
|
3
|
-
import
|
|
6
|
+
import { FunCheckoutStep } from '../modals/CheckoutModal/FunCheckoutStep';
|
|
7
|
+
import type { WithdrawalModalStep } from '../modals/WithdrawalModal/types';
|
|
8
|
+
import type { useTrackV2 } from './track/useTrackV2';
|
|
9
|
+
import { type AnalyticsFlow } from './track/analytics/events';
|
|
10
|
+
/** Shared by the checkout and withdrawal modals — each has its own step enum. */
|
|
11
|
+
export type StepReadinessStep = FunCheckoutStep | WithdrawalModalStep;
|
|
4
12
|
export interface StepQueryMeta extends Record<string, unknown> {
|
|
5
|
-
/**
|
|
6
|
-
dependentSteps:
|
|
13
|
+
/** Modal steps that depend on this query being loaded */
|
|
14
|
+
dependentSteps: StepReadinessStep[];
|
|
7
15
|
/** camelCase identifier for this query, used as key in timing metadata */
|
|
8
16
|
name: string;
|
|
9
17
|
/** Statsig event to emit with this query's individual timing */
|
|
10
|
-
timingEvent: CheckoutModalEvent;
|
|
18
|
+
timingEvent: CheckoutModalEvent | WithdrawModalEvent;
|
|
19
|
+
/** This query is currently disabled by a prerequisite expected to resolve. */
|
|
20
|
+
enablePending?: boolean;
|
|
11
21
|
}
|
|
12
22
|
export declare function stepQueryMeta(params: {
|
|
13
23
|
name: string;
|
|
14
|
-
timingEvent: CheckoutModalEvent;
|
|
15
|
-
dependentSteps:
|
|
24
|
+
timingEvent: CheckoutModalEvent | WithdrawModalEvent;
|
|
25
|
+
dependentSteps: StepReadinessStep[];
|
|
26
|
+
enablePending?: boolean;
|
|
16
27
|
}): StepQueryMeta;
|
|
17
28
|
/**
|
|
18
|
-
* Ensures all React Query dependencies for a
|
|
19
|
-
* marking the step as ready. Queries opt in via
|
|
20
|
-
* query options.
|
|
29
|
+
* Ensures all React Query dependencies for a modal step (checkout or
|
|
30
|
+
* withdrawal) are loaded before marking the step as ready. Queries opt in via
|
|
31
|
+
* `stepQueryMeta()` in their query options.
|
|
21
32
|
*
|
|
22
33
|
* Emits:
|
|
23
34
|
* - A per-query Statsig event (the query's `timingEvent`) with duration as value
|
|
24
|
-
* - A step-level measured event (`
|
|
35
|
+
* - A step-level measured event (from `readyEventMap`, if provided) with
|
|
36
|
+
* per-query timing metadata
|
|
37
|
+
* - {@link AnalyticsEvent.PERF_STEP_READY} with per-query timing metadata
|
|
25
38
|
*
|
|
26
|
-
* Steps without dependencies are skipped — no event is emitted
|
|
27
|
-
* `isStepReady` is set immediately.
|
|
39
|
+
* Steps without dependencies are skipped — no event is emitted.
|
|
28
40
|
*/
|
|
29
|
-
export declare function useStepQueryReadiness(
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
export declare function useStepQueryReadiness(params: {
|
|
42
|
+
checkoutId: string | null;
|
|
43
|
+
logEvent: ReturnType<typeof useTrack>['logEvent'];
|
|
44
|
+
logEventV2: ReturnType<typeof useTrackV2>;
|
|
45
|
+
logMeasuredEvent: ReturnType<typeof useTrack>['logMeasuredEvent'];
|
|
46
|
+
/** Flow of the visible step, which may differ from the checkout default. */
|
|
47
|
+
flow: AnalyticsFlow;
|
|
48
|
+
/** Selected payment method, if any, to attach to `fc_perf_step_ready`. */
|
|
49
|
+
paymentMethod: PaymentMethod | Lowercase<FormOfPaymentType> | null;
|
|
50
|
+
/** Legacy `fc::`/`fw::` step-level event to fire per step, if any. */
|
|
51
|
+
readyEventMap?: Partial<Record<StepReadinessStep, CheckoutModalEvent | WithdrawModalEvent>>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the owning modal is currently open. The modal component stays
|
|
54
|
+
* mounted across close (`Dialog` just hides it), so an in-flight
|
|
55
|
+
* `ensureStepQueries` call (e.g. waiting on a disabled query, or awaiting
|
|
56
|
+
* `ensureQueryData`) would otherwise keep running in the background and
|
|
57
|
+
* fire a step-ready event well after the user closed the modal.
|
|
58
|
+
*/
|
|
59
|
+
isModalOpen: boolean;
|
|
60
|
+
}): {
|
|
61
|
+
ensureStepQueries: (step: StepReadinessStep) => Promise<void>;
|
|
32
62
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SwappedBuyingCrypto } from '@funkit/connect-core';
|
|
2
|
+
import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext/types';
|
|
3
|
+
/**
|
|
4
|
+
* Destination token for the Swapped on-ramp's "of <token>" row, from the
|
|
5
|
+
* checkout config. The config's `targetAssetTicker` / `iconSrc` already hold
|
|
6
|
+
* the selected dynamic candidate, so no candidate lookup is needed here.
|
|
7
|
+
*
|
|
8
|
+
* Rollout is gated: `enable-swapped-destination-token` is off until Swapped's
|
|
9
|
+
* widget change is live, so the embed's own deploy can't flip the row on for
|
|
10
|
+
* every customer. Integrators opt out per checkout with
|
|
11
|
+
* `showFiatDestinationToken: false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSwappedBuyingCrypto(config: Pick<FunkitCheckoutConfig, 'targetAssetTicker' | 'iconSrc' | 'showFiatDestinationToken'>): SwappedBuyingCrypto | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,5 +49,6 @@ 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 type { ConvertAsset, ConvertConfig, ConvertErrorResult, ConvertErrorStage, ConvertRecipientAddresses, ConvertResolvedAsset, ConvertAssetBalance, ConvertSourceWallet, ConvertSuccessResult, ConvertTransaction, ConvertVm, GetConvertBalances, GetConvertSourceWallet, } from './domains/convert/types';
|
|
52
53
|
export { useFunkitAccount, useFunkitDisconnect, useFunkitReconnect, useFunkitSwitchChains, } from './providers/GeneralWalletProvider';
|
|
53
54
|
export { SelectedHomeTab } from './modals/ProfileDetails/FunProfileViews/Home';
|