@funkit/connect 3.4.3 → 3.4.5
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 +31 -0
- package/dist/components/FunAssetAvatar/FunAssetAvatar.css.d.ts +0 -1
- package/dist/components/FunCountdown/FunCountdown.d.ts +2 -1
- package/dist/components/FunDivider/FunDivider.d.ts +1 -2
- package/dist/components/FunInput/FunInput.d.ts +1 -2
- package/dist/components/FunInput/FunTextAreaInput.d.ts +1 -5
- package/dist/components/FunNotification/FunNotification.d.ts +4 -0
- package/dist/components/FunPayments/FunPaymentMethods.d.ts +7 -15
- package/dist/components/FunSelect/FunSelect.d.ts +3 -4
- package/dist/components/FunSelectBrokerage/FunSelectBrokerage.d.ts +4 -3
- package/dist/components/FunSkeletonLoader/FunSkeletonBlock.d.ts +7 -2
- package/dist/components/FunTransactionSummary/FunTxSummaryComponents.d.ts +2 -2
- package/dist/consts/funkit.d.ts +1 -0
- package/dist/domains/asset.d.ts +2 -0
- package/dist/domains/checkoutFees.d.ts +2 -1
- package/dist/{hooks/useCheckoutStateBooleans.d.ts → domains/checkoutState.d.ts} +1 -1
- package/dist/domains/quote.d.ts +6 -4
- package/dist/hooks/useAutoClearState.d.ts +4 -0
- package/dist/hooks/useCountdown.d.ts +8 -0
- package/dist/hooks/useMesh.d.ts +1 -1
- package/dist/hooks/useWalletAssets.d.ts +3 -0
- package/dist/index.css +66 -52
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3480 -3653
- package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutConfirmation.d.ts +17 -0
- package/dist/modals/CheckoutModal/ConfirmationStep/usePostCheckout.d.ts +28 -0
- package/dist/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.d.ts +22 -0
- package/dist/modals/CheckoutModal/InputAmount/AvailableBalance.d.ts +8 -0
- package/dist/modals/CheckoutModal/InputAmount/InputAmountLayout.d.ts +5 -3
- package/dist/modals/CheckoutModal/InputAmount/InputAmountLoaded.d.ts +5 -2
- package/dist/modals/CheckoutModal/InputAmount/InputAmountLoading.d.ts +5 -2
- package/dist/modals/CheckoutModal/InputAmount/QuickOptions.d.ts +7 -0
- package/dist/modals/CheckoutModal/InputAmount/state.d.ts +2 -1
- package/dist/modals/CheckoutModal/InputAmount/useCheckoutQuote.d.ts +0 -1
- package/dist/modals/CheckoutModal/InputAmount/utils.d.ts +1 -7
- package/dist/modals/CheckoutModal/SourceChange.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken.d.ts +2 -4
- package/dist/modals/CheckoutModal/stepTransition.d.ts +4 -7
- package/dist/modals/CheckoutModal/useCheckoutQuote.d.ts +7 -0
- package/dist/modals/CheckoutModal/useSourceAssetConfirm.d.ts +9 -0
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutHistoryDetail.d.ts +1 -1
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutHistoryHelp.d.ts +1 -1
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutHistoryTransaction.css.d.ts +0 -2
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutHistoryTransaction.d.ts +7 -2
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutStatus.css.d.ts +1 -0
- package/dist/modals/FunCheckoutHistoryModal/FunCheckoutStatus.d.ts +1 -1
- package/dist/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.d.ts +5 -2
- package/dist/providers/FunkitCheckoutContext.d.ts +1 -1
- package/dist/providers/GeneralWalletProvider.d.ts +11 -10
- package/dist/utils/aborts.d.ts +1 -0
- package/dist/utils/assets.d.ts +10 -9
- package/dist/utils/combineChainSymbolOrAddress.d.ts +1 -1
- package/dist/utils/deepMerge.d.ts +5 -0
- package/dist/utils/flags/config.d.ts +4 -1
- package/dist/utils/payment.d.ts +3 -3
- package/dist/wallets/walletConnectors/index.js +51 -51
- package/package.json +1 -1
- package/dist/components/FunPayments/FunPaymentMeshType.d.ts +0 -10
- package/dist/modals/CheckoutModal/SelectPaymentMethod.d.ts +0 -24
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { ErrorNotification } from '~/components/FunNotification/FunNotification';
|
|
3
|
+
export interface CheckoutConfirmationError extends ErrorNotification {
|
|
4
|
+
durationMs?: number;
|
|
5
|
+
}
|
|
6
|
+
interface UseCheckoutConfirmationOptions {
|
|
7
|
+
onError(error: CheckoutConfirmationError): void;
|
|
8
|
+
onSuccess(depositAddress: Address): void;
|
|
9
|
+
}
|
|
10
|
+
interface UseCheckoutConfirmationResult {
|
|
11
|
+
confirmationError: CheckoutConfirmationError | null;
|
|
12
|
+
confirmationStepMessage: string | null;
|
|
13
|
+
handleCheckoutConfirmation(): Promise<void>;
|
|
14
|
+
isConfirming: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function useCheckoutConfirmation({ onError, onSuccess, }: UseCheckoutConfirmationOptions): UseCheckoutConfirmationResult;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { ErrorNotification } from '~/components/FunNotification/FunNotification';
|
|
3
|
+
import { PaymentMethodInfo } from '~/domains/paymentMethods';
|
|
4
|
+
export interface MoonpayDepositData {
|
|
5
|
+
depositToken: string;
|
|
6
|
+
depositTokenAmount: number;
|
|
7
|
+
depositTokenChainId: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PostCheckoutError extends ErrorNotification {
|
|
10
|
+
disableContinue: boolean;
|
|
11
|
+
durationMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PostCheckoutSuccessData {
|
|
14
|
+
depositAddress: Address;
|
|
15
|
+
moonpayData: MoonpayDepositData;
|
|
16
|
+
paymentMethodInfo: PaymentMethodInfo;
|
|
17
|
+
}
|
|
18
|
+
interface UsePostCheckoutOptions {
|
|
19
|
+
onSuccess(data: PostCheckoutSuccessData): void;
|
|
20
|
+
}
|
|
21
|
+
interface UsePostCheckoutResult {
|
|
22
|
+
handlePostCheckout(depositAddress: Address): Promise<void>;
|
|
23
|
+
isPostCheckoutLoading: boolean;
|
|
24
|
+
postCheckoutError: PostCheckoutError | null;
|
|
25
|
+
postCheckoutStepMessage: string | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function usePostCheckout({ onSuccess, }: UsePostCheckoutOptions): UsePostCheckoutResult;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ErrorNotification } from '~/components/FunNotification/FunNotification';
|
|
2
|
+
interface UseQuoteRefreshOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Freeze the latest quote state, e.g. so we do not change the quote mid-confirmation
|
|
5
|
+
*/
|
|
6
|
+
disableStateUpdates: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Called when the quote is refreshed
|
|
9
|
+
*/
|
|
10
|
+
onRefreshed(): void;
|
|
11
|
+
}
|
|
12
|
+
interface UseQuoteRefreshResult {
|
|
13
|
+
isQuoting: boolean;
|
|
14
|
+
/** This uses onSourceAssetConfirmed - do not call asynchronously! */
|
|
15
|
+
preloadQuote(): void;
|
|
16
|
+
quoteError: ErrorNotification | null;
|
|
17
|
+
quoteStepMessage: string | null;
|
|
18
|
+
/** Safe to call asynchronously */
|
|
19
|
+
refreshQuote(ignorePreloaded?: boolean): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function useQuoteRefresh({ disableStateUpdates, onRefreshed, }: UseQuoteRefreshOptions): UseQuoteRefreshResult;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AssetHoldingsItem } from '~/utils/assets';
|
|
3
|
+
interface AvailableBalanceProps {
|
|
4
|
+
sourceHolding?: AssetHoldingsItem;
|
|
5
|
+
usdAvailableAmount?: number | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const AvailableBalance: (props: AvailableBalanceProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { FunButtonProps } from '../../../components/FunButton/FunButton';
|
|
3
|
-
import { ErrorNotification } from '
|
|
4
|
-
|
|
3
|
+
import { ErrorNotification } from '../../../components/FunNotification/FunNotification';
|
|
4
|
+
interface InputAmountLayoutProps {
|
|
5
5
|
actionButtonProps: FunButtonProps;
|
|
6
6
|
availableBalance?: ReactNode;
|
|
7
7
|
amountOptions?: ReactNode;
|
|
8
8
|
amountInput: ReactNode;
|
|
9
9
|
amountInputSwitch: ReactNode;
|
|
10
10
|
error?: ErrorNotification;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
|
+
export declare function InputAmountLayout({ actionButtonProps, amountOptions, amountInput, amountInputSwitch, availableBalance, error, }: InputAmountLayoutProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -3,8 +3,11 @@ import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutConte
|
|
|
3
3
|
import { AssetHoldingsItem } from '../../../utils/assets';
|
|
4
4
|
import { InputAmountNext, InputAmountState } from '../InputAmount';
|
|
5
5
|
import { StateTransitionProps } from '../stepTransition';
|
|
6
|
-
|
|
6
|
+
interface InputAmountLoadedProps {
|
|
7
7
|
sourceHolding: AssetHoldingsItem | null;
|
|
8
8
|
checkoutItem: FunkitActiveCheckoutItem;
|
|
9
9
|
unitPrice: number;
|
|
10
|
-
|
|
10
|
+
isCardCheckout: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function InputAmountLoaded({ checkoutItem, modalState, onNext, sourceHolding, unitPrice, isCardCheckout, }: StateTransitionProps<InputAmountState, InputAmountNext> & InputAmountLoadedProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { InputAmountNext, InputAmountState } from '../InputAmount';
|
|
3
3
|
import { StateTransitionProps } from '../stepTransition';
|
|
4
|
-
|
|
4
|
+
interface InputAmountLoadingProps {
|
|
5
5
|
sourceHoldingError: Error | null;
|
|
6
6
|
unitPriceError: Error | null;
|
|
7
|
-
|
|
7
|
+
isCardCheckout: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function InputAmountLoading({ modalState, onBack, sourceHoldingError, unitPriceError, isCardCheckout, }: StateTransitionProps<InputAmountState, InputAmountNext> & InputAmountLoadingProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -2,12 +2,13 @@ import { PaymentMethod } from '~/domains/paymentMethods';
|
|
|
2
2
|
import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutContext';
|
|
3
3
|
import { AssetHoldingsItem } from '../../../utils/assets';
|
|
4
4
|
export interface AmountInputInitOptions {
|
|
5
|
-
apiKey: string;
|
|
6
5
|
checkoutItem: FunkitActiveCheckoutItem;
|
|
7
6
|
paymentMethod: PaymentMethod;
|
|
8
7
|
sourceHolding: AssetHoldingsItem | null;
|
|
9
8
|
/** Target asset unit price, in USD */
|
|
10
9
|
unitPrice: number;
|
|
10
|
+
/** Maximum checkout amount, in USD */
|
|
11
|
+
maxUsd: number;
|
|
11
12
|
}
|
|
12
13
|
export interface AmountInputState {
|
|
13
14
|
/** Current amount, in target asset */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
1
|
import { PaymentMethod } from '~/domains/paymentMethods';
|
|
3
2
|
import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutContext';
|
|
4
3
|
import { AssetHoldingsItem } from '../../../utils/assets';
|
|
@@ -6,11 +5,6 @@ export declare const ASSET_DECIMALS = 5;
|
|
|
6
5
|
export declare const USD_DECIMALS = 2;
|
|
7
6
|
export declare const USD_INITIAL_AMOUNT = 100;
|
|
8
7
|
export declare const USD_PREFIX = "$";
|
|
9
|
-
export interface ErrorNotification {
|
|
10
|
-
message: ReactNode;
|
|
11
|
-
/** FunNotificationType */
|
|
12
|
-
type: 'error' | 'warning' | 'hint';
|
|
13
|
-
}
|
|
14
8
|
export declare function round(value: number, decimals: number,
|
|
15
9
|
/**
|
|
16
10
|
* Whether to round up ('ceil'), down ('floor'), or nearest ('round')
|
|
@@ -19,5 +13,5 @@ export declare function round(value: number, decimals: number,
|
|
|
19
13
|
**/
|
|
20
14
|
method?: 'ceil' | 'floor' | 'round'): number;
|
|
21
15
|
export declare function getUsdAvailableAmount(checkoutItem: FunkitActiveCheckoutItem, sourceBalance: AssetHoldingsItem | null): number | null;
|
|
22
|
-
export declare function getUsdMaxAmount(paymentMethod: PaymentMethod,
|
|
16
|
+
export declare function getUsdMaxAmount(paymentMethod: PaymentMethod, maxUsd: number): number | null;
|
|
23
17
|
export declare function getUsdMinAmount(paymentMethod: PaymentMethod): number;
|
|
@@ -4,7 +4,7 @@ import { CheckoutModalCommonState, FunCheckoutStep, StateTransitionProps, StepTr
|
|
|
4
4
|
type ConnectablePaymentMethodInfo = PaymentMethodAccountInfo | PaymentMethodBrokerageInfo;
|
|
5
5
|
export interface SourceChangeState extends CheckoutModalCommonState {
|
|
6
6
|
step: FunCheckoutStep.SOURCE_CHANGE;
|
|
7
|
-
paymentMethodInfo: ConnectablePaymentMethodInfo;
|
|
7
|
+
paymentMethodInfo: ConnectablePaymentMethodInfo | null;
|
|
8
8
|
}
|
|
9
9
|
export type SourceChangeNext = {
|
|
10
10
|
step: FunCheckoutStep.SOURCE_CHANGE;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PaymentMethodAccountInfo, PaymentMethodBrokerageInfo } from '../../domains/paymentMethods';
|
|
3
2
|
import { CheckoutModalCommonState, FunCheckoutStep, StateTransitionProps, StepTransition } from './stepTransition';
|
|
4
3
|
export interface TransferTokenState extends CheckoutModalCommonState {
|
|
5
4
|
step: FunCheckoutStep.TRANSFER_TOKEN;
|
|
6
|
-
prevPaymentMethodInfo?: PaymentMethodAccountInfo | PaymentMethodBrokerageInfo;
|
|
7
5
|
}
|
|
8
6
|
export type TransferTokenNext = {
|
|
9
7
|
step: FunCheckoutStep.TRANSFER_TOKEN;
|
|
@@ -11,7 +9,7 @@ export type TransferTokenNext = {
|
|
|
11
9
|
export interface TokenTransferSourceChainsAndAssets {
|
|
12
10
|
[chainId: number]: string[];
|
|
13
11
|
}
|
|
14
|
-
export declare function transferTokenNext(state: TransferTokenState,
|
|
12
|
+
export declare function transferTokenNext(state: TransferTokenState, _payload: TransferTokenNext): StepTransition[FunCheckoutStep.TRANSFER_TOKEN];
|
|
15
13
|
type Props = StateTransitionProps<TransferTokenState, TransferTokenNext>;
|
|
16
|
-
export declare function TransferToken({
|
|
14
|
+
export declare function TransferToken({ onNext }: Props): React.JSX.Element;
|
|
17
15
|
export {};
|
|
@@ -9,7 +9,6 @@ import { MeshVerificationNext, MeshVerificationState } from './MeshVerification'
|
|
|
9
9
|
import { MoonpaySetupNext, MoonpaySetupState } from './MoonpaySetup';
|
|
10
10
|
import { SelectAssetNext, SelectAssetState } from './SelectAsset';
|
|
11
11
|
import { SelectBrokerageNext, SelectBrokerageState } from './SelectBrokerage';
|
|
12
|
-
import { SelectPaymentMethodNext, SelectPaymentMethodState } from './SelectPaymentMethod';
|
|
13
12
|
import { SourceChangeNext, SourceChangeState } from './SourceChange';
|
|
14
13
|
import { TransferTokenNext, TransferTokenState } from './TransferToken';
|
|
15
14
|
export interface CheckoutModalCommonState {
|
|
@@ -26,11 +25,10 @@ export interface StateTransitionProps<T, N> {
|
|
|
26
25
|
onClose: () => void;
|
|
27
26
|
}
|
|
28
27
|
export declare function extractCommonState(state: CheckoutModalState): CheckoutModalCommonState;
|
|
29
|
-
type CheckoutModalState = LoadingAccountState | ConfirmationStepState | ConnectExchangeState | InputAmountState | SelectAssetState |
|
|
28
|
+
type CheckoutModalState = LoadingAccountState | ConfirmationStepState | ConnectExchangeState | InputAmountState | SelectAssetState | SelectBrokerageState | SourceChangeState | MoonpaySetupState | MeshVerificationState | CheckoutCompleteState | TransferTokenState;
|
|
30
29
|
export declare enum FunCheckoutStep {
|
|
31
30
|
LOADING_ACCOUNT = "loading_account",
|
|
32
31
|
INPUT_AMOUNT = "input_amount",
|
|
33
|
-
SELECT_PAYMENT_METHOD = "select_payment",
|
|
34
32
|
SOURCE_CHANGE = "source_change",
|
|
35
33
|
CONFIRMATION = "confirmation",
|
|
36
34
|
MOONPAY_SETUP = "payment_setup",
|
|
@@ -42,9 +40,8 @@ export declare enum FunCheckoutStep {
|
|
|
42
40
|
TRANSFER_TOKEN = "transfer_token"
|
|
43
41
|
}
|
|
44
42
|
export interface StepTransition {
|
|
45
|
-
[FunCheckoutStep.LOADING_ACCOUNT]:
|
|
43
|
+
[FunCheckoutStep.LOADING_ACCOUNT]: SelectAssetState | TransferTokenState | SourceChangeState;
|
|
46
44
|
[FunCheckoutStep.INPUT_AMOUNT]: ConfirmationStepState;
|
|
47
|
-
[FunCheckoutStep.SELECT_PAYMENT_METHOD]: SelectBrokerageState | InputAmountState | SelectAssetState | TransferTokenState;
|
|
48
45
|
[FunCheckoutStep.CONFIRMATION]: MeshVerificationState | MoonpaySetupState | CheckoutCompleteState;
|
|
49
46
|
[FunCheckoutStep.MOONPAY_SETUP]: CheckoutCompleteState;
|
|
50
47
|
[FunCheckoutStep.SELECT_BROKERAGE]: ConnectExchangeState | SelectAssetState;
|
|
@@ -52,9 +49,9 @@ export interface StepTransition {
|
|
|
52
49
|
[FunCheckoutStep.SELECT_ASSET]: InputAmountState | SourceChangeState | LoadingAccountState;
|
|
53
50
|
[FunCheckoutStep.MESH_VERIFICATION]: CheckoutCompleteState;
|
|
54
51
|
[FunCheckoutStep.SOURCE_CHANGE]: SelectAssetState | SelectBrokerageState | InputAmountState | TransferTokenState;
|
|
55
|
-
[FunCheckoutStep.TRANSFER_TOKEN]:
|
|
52
|
+
[FunCheckoutStep.TRANSFER_TOKEN]: SourceChangeState;
|
|
56
53
|
}
|
|
57
|
-
type NextPayload = LoadingAccountNext | ConfirmationStepNext | ConnectExchangeNext | InputAmountNext | MeshVerificationNext | MoonpaySetupNext | SelectAssetNext |
|
|
54
|
+
type NextPayload = LoadingAccountNext | ConfirmationStepNext | ConnectExchangeNext | InputAmountNext | MeshVerificationNext | MoonpaySetupNext | SelectAssetNext | SelectBrokerageNext | SourceChangeNext | TransferTokenNext | {
|
|
58
55
|
step: FunCheckoutStep.CHECKOUT_COMPLETE;
|
|
59
56
|
};
|
|
60
57
|
export declare function useCheckoutModalTransition(checkoutItem: FunkitActiveCheckoutItem, onClose: () => void): {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FunkitActiveCheckoutItem } from '~/providers/FunkitCheckoutContext';
|
|
2
|
+
import { DeepPartial } from '~/utils/deepMerge';
|
|
3
|
+
export declare function useCheckoutQuote(): (overridingCheckoutItem?: DeepPartial<FunkitActiveCheckoutItem>) => Promise<{
|
|
4
|
+
baseQuote: import("@funkit/api-base").CheckoutQuoteResponse;
|
|
5
|
+
finalEstimation: import("~/domains/quote").FunkitCheckoutQuoteResult;
|
|
6
|
+
availableAssetAmount: number | undefined;
|
|
7
|
+
}>;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { Operation } from '@funkit/core';
|
|
2
|
+
import { PaymentMethodInfo } from '../../domains/paymentMethods';
|
|
1
3
|
import { FunkitActiveCheckoutItem } from '../../providers/FunkitCheckoutContext';
|
|
4
|
+
import { LoginType } from '../../providers/GeneralWalletProvider';
|
|
2
5
|
export interface SourceAssetConfirmed {
|
|
3
6
|
isQuoteSuccess: boolean;
|
|
4
7
|
maxTargetAssetAmount: number | undefined;
|
|
5
8
|
}
|
|
9
|
+
export declare function preparePaymentMethodInfo(selectedPaymentMethodInfo: PaymentMethodInfo | null, meshNetworkInfo: {
|
|
10
|
+
meshNetworkId: string | undefined;
|
|
11
|
+
} | null): Promise<import("../../domains/paymentMethods").PaymentMethodCardInfo | import("../../domains/paymentMethods").PaymentMethodBrokerageInfo | import("../../domains/paymentMethods").PaymentMethodAccountInfo>;
|
|
12
|
+
export declare function fetchSponsorInitialTransferGasLimit(checkoutItem: FunkitActiveCheckoutItem, loginType: LoginType, generateCheckoutTransferOpItems: (toAddress: string, tokenAmount: number | string) => Promise<{
|
|
13
|
+
transferOp: Operation | null;
|
|
14
|
+
}>): Promise<number>;
|
|
6
15
|
/**
|
|
7
16
|
*
|
|
8
17
|
* Note: this hook is EXTREMELY confusing in what is doing
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckoutHistoryItem } from '@funkit/api-base';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface FunCheckoutHistoryDetailProps {
|
|
4
|
-
checkoutHistoryInfo: CheckoutHistoryItem;
|
|
4
|
+
checkoutHistoryInfo: CheckoutHistoryItem | undefined;
|
|
5
5
|
onHelp: () => void;
|
|
6
6
|
onClose: () => void;
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CheckoutHistoryItem } from '@funkit/api-base';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare function FunCheckoutHistoryHelp({ checkoutHistoryInfo, onBackFromHelpPage, }: {
|
|
4
|
-
checkoutHistoryInfo: CheckoutHistoryItem;
|
|
4
|
+
checkoutHistoryInfo: CheckoutHistoryItem | undefined;
|
|
5
5
|
onBackFromHelpPage: () => void;
|
|
6
6
|
}): React.JSX.Element;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { CheckoutHistoryItem } from '@funkit/api-base';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { HistoricalCheckoutItem } from '../../providers/FunkitCheckoutContext';
|
|
3
4
|
interface FunTxSummaryHistoryProps {
|
|
4
|
-
checkoutHistoryItem: CheckoutHistoryItem;
|
|
5
|
+
checkoutHistoryItem: CheckoutHistoryItem | undefined;
|
|
5
6
|
isDelayed?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare function FunTxSummaryHistory({ checkoutHistoryItem, isDelayed, }: FunTxSummaryHistoryProps): React.JSX.Element;
|
|
9
|
+
type FunTxSummaryAdditionalInfoProps = {
|
|
10
|
+
checkoutItem: HistoricalCheckoutItem;
|
|
11
|
+
};
|
|
12
|
+
export declare const SourceDestinationSummary: ({ checkoutItem, }: FunTxSummaryAdditionalInfoProps) => React.JSX.Element;
|
|
8
13
|
export declare function OrderDetail({ checkoutHistoryItem, }: {
|
|
9
|
-
checkoutHistoryItem: CheckoutHistoryItem;
|
|
14
|
+
checkoutHistoryItem: CheckoutHistoryItem | undefined;
|
|
10
15
|
}): React.JSX.Element;
|
|
11
16
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CheckoutHistoryItem } from '@funkit/api-base';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface FunCheckoutStatusProps {
|
|
4
|
-
checkoutHistoryItem: CheckoutHistoryItem;
|
|
4
|
+
checkoutHistoryItem: CheckoutHistoryItem | undefined;
|
|
5
5
|
onOrderDelayed?: () => void;
|
|
6
6
|
}
|
|
7
7
|
export declare function FunCheckoutStatus({ checkoutHistoryItem, onOrderDelayed, }: FunCheckoutStatusProps): React.JSX.Element | null;
|
|
@@ -2,8 +2,11 @@ import { CheckoutHistoryItem } from '@funkit/api-base';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { HistoryContentPages } from '../../../../utils/checkoutHistory';
|
|
4
4
|
export declare const HOME_CHECKOUT_DISPLAY_ROW_HEIGHT = 52;
|
|
5
|
-
export declare const HomeCheckoutDisplayRow: ({ checkoutHistoryItem, onSelect, }: {
|
|
5
|
+
export declare const HomeCheckoutDisplayRow: ({ checkoutHistoryItem, disableSidePadding, onSelect, }: {
|
|
6
6
|
checkoutHistoryItem: CheckoutHistoryItem;
|
|
7
|
+
disableSidePadding?: boolean;
|
|
7
8
|
onSelect: (depositAddress: `0x${string}`, initialPage: HistoryContentPages) => void;
|
|
8
9
|
}) => React.JSX.Element;
|
|
9
|
-
export declare const HomeCheckoutDisplayRowSkeleton: (
|
|
10
|
+
export declare const HomeCheckoutDisplayRowSkeleton: ({ disableSidePadding, }: {
|
|
11
|
+
disableSidePadding?: boolean;
|
|
12
|
+
}) => React.JSX.Element;
|
|
@@ -138,7 +138,7 @@ interface FunkitCheckoutContextInterface {
|
|
|
138
138
|
startCheckoutHistoryListener(recipientAddr?: Address | undefined): NodeJS.Timeout;
|
|
139
139
|
stopCheckoutHistoryListener(cancelIntervalId?: NodeJS.Timeout): void;
|
|
140
140
|
initNewCheckout(initSettings: useFunkitCheckoutPropsFinal): string;
|
|
141
|
-
updateSourceAsset(selectedSource: Omit<AssetHoldingsItem, 'amount' | 'usdAmount'>): void;
|
|
141
|
+
updateSourceAsset(selectedSource: Omit<AssetHoldingsItem, 'amount' | 'usdAmount' | 'chainSymbolKey'>): void;
|
|
142
142
|
updateTargetAssetAmount(newTargetAssetAmount: number): void;
|
|
143
143
|
updateSelectedPaymentMethodInfo(newPaymentMethodInfo: PaymentMethodInfo): void;
|
|
144
144
|
confirmCheckout(shouldBatchOpBypassInit: boolean, stepMessageSetter: (m: string) => void): Promise<Address>;
|
|
@@ -7,11 +7,15 @@ export interface KnownAssetBalanceInfo extends AssetBalanceInfo {
|
|
|
7
7
|
price: number;
|
|
8
8
|
totalUsdValue: number;
|
|
9
9
|
}
|
|
10
|
+
export declare enum LoginType {
|
|
11
|
+
Web2 = "web2",
|
|
12
|
+
Web3 = "web3",
|
|
13
|
+
Guest = "guest"
|
|
14
|
+
}
|
|
10
15
|
interface GeneralWalletContextProps {
|
|
11
16
|
walletAddress: Address | '';
|
|
12
17
|
isUserLoggedIn: boolean;
|
|
13
|
-
|
|
14
|
-
isWeb3Login: boolean;
|
|
18
|
+
loginType: LoginType;
|
|
15
19
|
userInfo: FunkitUserInfo;
|
|
16
20
|
funWallet: FunWallet | null;
|
|
17
21
|
funWalletAuth: Auth | null;
|
|
@@ -26,8 +30,7 @@ export declare const useGeneralWallet: () => GeneralWalletContextProps;
|
|
|
26
30
|
export declare const useFunkitAccount: () => {
|
|
27
31
|
account: "" | `0x${string}`;
|
|
28
32
|
isConnected: boolean;
|
|
29
|
-
|
|
30
|
-
isWeb3Login: boolean;
|
|
33
|
+
loginType: LoginType;
|
|
31
34
|
address: undefined;
|
|
32
35
|
addresses: undefined;
|
|
33
36
|
chain: undefined;
|
|
@@ -40,8 +43,7 @@ export declare const useFunkitAccount: () => {
|
|
|
40
43
|
} | {
|
|
41
44
|
account: "" | `0x${string}`;
|
|
42
45
|
isConnected: boolean;
|
|
43
|
-
|
|
44
|
-
isWeb3Login: boolean;
|
|
46
|
+
loginType: LoginType;
|
|
45
47
|
address: Address;
|
|
46
48
|
addresses: readonly [Address, ...Address[]];
|
|
47
49
|
chain: import("viem").Chain | undefined;
|
|
@@ -54,8 +56,7 @@ export declare const useFunkitAccount: () => {
|
|
|
54
56
|
} | {
|
|
55
57
|
account: "" | `0x${string}`;
|
|
56
58
|
isConnected: boolean;
|
|
57
|
-
|
|
58
|
-
isWeb3Login: boolean;
|
|
59
|
+
loginType: LoginType;
|
|
59
60
|
address: Address | undefined;
|
|
60
61
|
addresses: readonly Address[] | undefined;
|
|
61
62
|
chain: import("viem").Chain | undefined;
|
|
@@ -68,8 +69,7 @@ export declare const useFunkitAccount: () => {
|
|
|
68
69
|
} | {
|
|
69
70
|
account: "" | `0x${string}`;
|
|
70
71
|
isConnected: boolean;
|
|
71
|
-
|
|
72
|
-
isWeb3Login: boolean;
|
|
72
|
+
loginType: LoginType;
|
|
73
73
|
address: Address | undefined;
|
|
74
74
|
addresses: readonly Address[] | undefined;
|
|
75
75
|
chain: import("viem").Chain | undefined;
|
|
@@ -80,6 +80,7 @@ export declare const useFunkitAccount: () => {
|
|
|
80
80
|
isDisconnected: false;
|
|
81
81
|
status: "connecting";
|
|
82
82
|
};
|
|
83
|
+
export declare const useFunkitUserInfo: () => FunkitUserInfo;
|
|
83
84
|
/**
|
|
84
85
|
* Replacement for wagmi's `disconnect` from `useDisconnect`
|
|
85
86
|
*/
|
package/dist/utils/aborts.d.ts
CHANGED
package/dist/utils/assets.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
+
import { LoginType } from '~/providers/GeneralWalletProvider';
|
|
1
2
|
import { PaymentMethod } from '../domains/paymentMethods';
|
|
2
3
|
import { FunkitActiveCheckoutItem, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
|
|
3
4
|
import { FlagValues } from '../providers/FunkitFlagsProvider';
|
|
5
|
+
export declare const ASSETS_LOW_VALUE_THRESHOLD = 0.1;
|
|
4
6
|
export declare const getNormalizedTokenBalance: (tokenBalance: bigint | number, decimals: number) => number;
|
|
5
|
-
export declare const isAssetUsableToPayForCheckout: (flags: FlagValues, checkoutItem: FunkitActiveCheckoutItem, paymentMethod: PaymentMethod, assetChainId: string, assetTokenAddress: string,
|
|
7
|
+
export declare const isAssetUsableToPayForCheckout: (flags: FlagValues, checkoutItem: FunkitActiveCheckoutItem, paymentMethod: PaymentMethod, assetChainId: string, assetTokenAddress: string, loginType: LoginType) => {
|
|
6
8
|
isUsable: boolean;
|
|
7
9
|
reason: string;
|
|
8
10
|
};
|
|
9
|
-
export declare const getAssetSymbolWithMaxUsdValue: ({ accountHoldingsMap, filterSymbols, }: {
|
|
10
|
-
accountHoldingsMap: AssetHoldingsMap;
|
|
11
|
-
filterSymbols?: Array<string>;
|
|
12
|
-
}) => string | null;
|
|
13
11
|
export declare const L1_FEES_ESTIMATE = 20;
|
|
14
12
|
export declare const L2_FEES_ESTIMATE = 1;
|
|
15
13
|
export declare const L2_COST_MARGIN_MULTIPLIER = 1.2;
|
|
@@ -23,6 +21,10 @@ export interface AssetHoldingsItem {
|
|
|
23
21
|
tokenAddress: `0x${string}`;
|
|
24
22
|
usdAmount: null | number;
|
|
25
23
|
pickedChainId: string;
|
|
24
|
+
chainSymbolKey: string;
|
|
25
|
+
}
|
|
26
|
+
export interface KnownAssetHoldingsItem extends AssetHoldingsItem {
|
|
27
|
+
usdAmount: number;
|
|
26
28
|
}
|
|
27
29
|
export interface AssetHoldingsMap {
|
|
28
30
|
[symbol: string]: AssetHoldingsItem;
|
|
@@ -39,12 +41,11 @@ export declare const getBaseFeeUsdEstimate: (checkoutItem: FunkitActiveCheckoutI
|
|
|
39
41
|
* Estimating overall fees
|
|
40
42
|
*/
|
|
41
43
|
export declare const getFeesUsdEstimate: (checkoutItem: FunkitActiveCheckoutItem, asset: AssetHoldingsItem) => number;
|
|
42
|
-
export declare const isAssetUsdAmountSufficient: (checkoutItem: FunkitActiveCheckoutItem, asset: AssetHoldingsItem | null) => boolean;
|
|
43
44
|
type RecommendedAsset = {
|
|
44
|
-
|
|
45
|
+
chainSymbolKey: string;
|
|
45
46
|
label: string | null;
|
|
46
|
-
}
|
|
47
|
-
export declare const getRecommendedAsset: (
|
|
47
|
+
};
|
|
48
|
+
export declare const getRecommendedAsset: (checkoutItem: FunkitActiveCheckoutItem, accountHoldings: KnownAssetHoldingsItem[]) => RecommendedAsset | null;
|
|
48
49
|
/**
|
|
49
50
|
* @returns formatted max usable USD balance from a given assets map */
|
|
50
51
|
export declare const getTotalAssetBalance: (assets: AssetHoldingsMap) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type DeepPartial<T> = T extends number | string | boolean | null | undefined ? T : {
|
|
2
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
3
|
+
};
|
|
4
|
+
/** NOTE: merging arrays is undefined behavior */
|
|
5
|
+
export declare function deepMerge<T extends object>(origin: T, ...objects: DeepPartial<T>[]): T;
|
|
@@ -18,7 +18,9 @@ export declare enum FlagKey {
|
|
|
18
18
|
/** Whether to enable Token Transfer as a payment method. */
|
|
19
19
|
EnableTokenTransfer = "enable_token_transfer",
|
|
20
20
|
/** Token Transfer payment method accepted source chain and assets */
|
|
21
|
-
TokenTransferSourceChainsAndAssets = "token_transfer_source_chains_and_assets"
|
|
21
|
+
TokenTransferSourceChainsAndAssets = "token_transfer_source_chains_and_assets",
|
|
22
|
+
/** Maximum usd amount that can be checked out. */
|
|
23
|
+
MaxCheckoutUsd = "max_checkout_usd"
|
|
22
24
|
}
|
|
23
25
|
export declare const flagConfig: {
|
|
24
26
|
[FlagKey.DisableMantleSourceAssets]: BooleanFlagConfig;
|
|
@@ -28,4 +30,5 @@ export declare const flagConfig: {
|
|
|
28
30
|
[FlagKey.ShowPoweredTagline]: BooleanFlagConfig;
|
|
29
31
|
[FlagKey.EnableTokenTransfer]: BooleanFlagConfig;
|
|
30
32
|
[FlagKey.TokenTransferSourceChainsAndAssets]: StringFlagConfig;
|
|
33
|
+
[FlagKey.MaxCheckoutUsd]: StringFlagConfig;
|
|
31
34
|
};
|
package/dist/utils/payment.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { LoginType } from '~/providers/GeneralWalletProvider';
|
|
1
2
|
import { PaymentMethodInfo } from '../domains/paymentMethods';
|
|
2
3
|
/**
|
|
3
4
|
* Generate a string for backend to indicate the source of a checkout funds
|
|
4
5
|
*/
|
|
5
|
-
export declare function generateSourceOfFundString({ paymentMethodInfo,
|
|
6
|
+
export declare function generateSourceOfFundString({ paymentMethodInfo, loginType, walletAddress, }: {
|
|
6
7
|
paymentMethodInfo: PaymentMethodInfo;
|
|
7
|
-
|
|
8
|
-
isWeb3Login: boolean;
|
|
8
|
+
loginType: LoginType;
|
|
9
9
|
walletAddress: string | undefined;
|
|
10
10
|
}): string;
|