@funkit/connect 3.3.0 → 3.4.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +0 -3
  3. package/dist/{chunk-YOJVBRUJ.js → chunk-77C753LI.js} +2 -2
  4. package/dist/{chunk-HFT6OV3T.js → chunk-BY224HGT.js} +1 -1
  5. package/dist/{chunk-ZGK66FYG.js → chunk-XWW5QOD4.js} +2 -2
  6. package/dist/components/Box/Box.d.ts +36 -36
  7. package/dist/components/Dialog/Dialog.css.d.ts +2 -5
  8. package/dist/components/Dropdown/BaseDropdown.d.ts +4 -2
  9. package/dist/components/Dropdown/ChainDropdown.d.ts +3 -1
  10. package/dist/components/Dropdown/TokenDropdown.d.ts +7 -1
  11. package/dist/components/FunCheckoutBlocked/FunCheckoutBlocked.d.ts +6 -1
  12. package/dist/components/FunCountdown/FunCountdown.d.ts +2 -1
  13. package/dist/components/FunOptionBox/FunOptionBox.css.d.ts +1 -1
  14. package/dist/components/FunPayments/FunPaymentMethods.d.ts +5 -13
  15. package/dist/components/Icons/BrokerageIcon.d.ts +4 -0
  16. package/dist/components/Icons/CreditCardIcon.d.ts +4 -0
  17. package/dist/components/Icons/EvmWallet.d.ts +3 -1
  18. package/dist/components/Icons/LightningBoltIcon.d.ts +3 -1
  19. package/dist/components/Icons/SocialMediaIcons.d.ts +12 -4
  20. package/dist/consts/assets.d.ts +1 -0
  21. package/dist/consts/funkit.d.ts +5 -1
  22. package/dist/css/sprinkles.css.d.ts +38 -38
  23. package/dist/domains/checkoutFees.d.ts +4 -2
  24. package/dist/domains/clientMetadata.d.ts +37 -0
  25. package/dist/domains/paymentMethods.d.ts +0 -5
  26. package/dist/domains/quote.d.ts +16 -0
  27. package/dist/hooks/useCheckoutAccountBalanceTransfer.d.ts +1 -1
  28. package/dist/hooks/useCheckoutQuoteNotification.d.ts +1 -1
  29. package/dist/hooks/useCheckoutTransferDepositAddress.d.ts +2 -1
  30. package/dist/hooks/useIsCheckoutRisky.d.ts +2 -0
  31. package/dist/hooks/usePaymentMethodIcon.d.ts +22 -0
  32. package/dist/hooks/useUsableWalletAssetsForCheckout.d.ts +3 -2
  33. package/dist/index.css +2143 -2124
  34. package/dist/index.js +10080 -9850
  35. package/dist/modals/CheckoutModal/CheckoutPrimaryInfo.d.ts +1 -2
  36. package/dist/modals/CheckoutModal/ConfirmationStep.d.ts +1 -1
  37. package/dist/modals/CheckoutModal/FunCheckoutModal.d.ts +1 -2
  38. package/dist/modals/CheckoutModal/InputAmount/InputAmountLayout.d.ts +11 -0
  39. package/dist/modals/CheckoutModal/InputAmount/InputAmountLoaded.d.ts +10 -0
  40. package/dist/modals/CheckoutModal/InputAmount/InputAmountLoading.d.ts +7 -0
  41. package/dist/modals/CheckoutModal/InputAmount/state.d.ts +73 -0
  42. package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +9 -0
  43. package/dist/modals/CheckoutModal/InputAmount/useCheckoutQuote.d.ts +17 -0
  44. package/dist/modals/CheckoutModal/InputAmount/utils.d.ts +23 -0
  45. package/dist/modals/CheckoutModal/InputAmount.d.ts +1 -1
  46. package/dist/modals/CheckoutModal/SelectBrokerage.d.ts +1 -1
  47. package/dist/modals/CheckoutModal/SelectPaymentMethod.d.ts +1 -1
  48. package/dist/modals/CheckoutModal/TransferToken.d.ts +4 -1
  49. package/dist/modals/CheckoutModal/useAccountBalancePostCheckout.d.ts +1 -1
  50. package/dist/modals/CheckoutModal/useAvailableBalanceForCheckout.d.ts +1 -1
  51. package/dist/modals/CheckoutModal/useSourceAssetConfirm.d.ts +2 -7
  52. package/dist/modals/CheckoutModal/useUpdateSourceAssetForCard.d.ts +1 -1
  53. package/dist/modals/FunCheckoutHistoryModal/FunCheckoutStatus.css.d.ts +2 -0
  54. package/dist/providers/FunkitCheckoutContext.d.ts +35 -60
  55. package/dist/providers/FunkitFlagsProvider.d.ts +2 -2
  56. package/dist/providers/FunkitMoonpayProvider.d.ts +1 -1
  57. package/dist/providers/FunkitThemeProvider.d.ts +4 -4
  58. package/dist/themes/baseTheme.js +1 -1
  59. package/dist/themes/darkTheme.d.ts +1 -1
  60. package/dist/themes/darkTheme.js +2 -2
  61. package/dist/themes/lightTheme.d.ts +1 -1
  62. package/dist/themes/lightTheme.js +2 -2
  63. package/dist/utils/checkout.d.ts +21 -2
  64. package/dist/utils/deposit.d.ts +10 -2
  65. package/dist/utils/flags/config.d.ts +11 -8
  66. package/dist/utils/formatNumber.d.ts +1 -1
  67. package/dist/utils/formatTimestamp.d.ts +8 -8
  68. package/dist/wallets/walletConnectors/index.js +40 -40
  69. package/package.json +4 -4
  70. package/dist/components/FunToast/FunShortToast.css.d.ts +0 -10
  71. package/dist/components/FunToast/FunShortToast.d.ts +0 -3
  72. package/dist/components/FunToast/FunToast.d.ts +0 -18
  73. package/dist/components/Icons/PaymentMethodIcons.d.ts +0 -27
  74. package/dist/providers/FunToastProvider.d.ts +0 -11
  75. package/dist/wallets/walletConnectors/chunk-25VW5TZP.js +0 -92
  76. package/dist/wallets/walletConnectors/chunk-2EMZOYQI.js +0 -101
  77. package/dist/wallets/walletConnectors/chunk-4HKPVECK.js +0 -95
  78. package/dist/wallets/walletConnectors/chunk-4K3EKHXR.js +0 -71
  79. package/dist/wallets/walletConnectors/chunk-57UUMOOZ.js +0 -95
  80. package/dist/wallets/walletConnectors/chunk-5K4DIMYR.js +0 -95
  81. package/dist/wallets/walletConnectors/chunk-5MVCKMZT.js +0 -94
  82. package/dist/wallets/walletConnectors/chunk-5NZLWT3Y.js +0 -73
  83. package/dist/wallets/walletConnectors/chunk-AUVBWDIK.js +0 -102
  84. package/dist/wallets/walletConnectors/chunk-AXPQHNUI.js +0 -71
  85. package/dist/wallets/walletConnectors/chunk-B5D7DYVV.js +0 -101
  86. package/dist/wallets/walletConnectors/chunk-B7FHT3CB.js +0 -94
  87. package/dist/wallets/walletConnectors/chunk-EFIENLEE.js +0 -98
  88. package/dist/wallets/walletConnectors/chunk-FLTQRYFS.js +0 -27
  89. package/dist/wallets/walletConnectors/chunk-HCKLWBE5.js +0 -98
  90. package/dist/wallets/walletConnectors/chunk-HLH777AC.js +0 -108
  91. package/dist/wallets/walletConnectors/chunk-HMDUVRZP.js +0 -98
  92. package/dist/wallets/walletConnectors/chunk-IR3YKU2N.js +0 -103
  93. package/dist/wallets/walletConnectors/chunk-J2BF4L2V.js +0 -87
  94. package/dist/wallets/walletConnectors/chunk-KDGMYRMC.js +0 -102
  95. package/dist/wallets/walletConnectors/chunk-L7QI6PBN.js +0 -108
  96. package/dist/wallets/walletConnectors/chunk-OKUX4BC4.js +0 -66
  97. package/dist/wallets/walletConnectors/chunk-QP2BIVXD.js +0 -73
  98. package/dist/wallets/walletConnectors/chunk-UWZQZY4S.js +0 -149
  99. package/dist/wallets/walletConnectors/chunk-UZEMNN3Q.js +0 -96
  100. package/dist/wallets/walletConnectors/chunk-VU6B3HMD.js +0 -96
  101. package/dist/wallets/walletConnectors/chunk-WAMHUVNP.js +0 -96
  102. package/dist/wallets/walletConnectors/chunk-YRK6XWL6.js +0 -149
  103. package/dist/wallets/walletConnectors/chunk-ZCKNEKQQ.js +0 -110
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- export declare function CheckoutPrimaryInfo({ checkoutId, showTokenAmount, }: {
3
- checkoutId: string;
2
+ export declare function CheckoutPrimaryInfo({ showTokenAmount, }: {
4
3
  showTokenAmount?: boolean;
5
4
  }): React.JSX.Element | null;
@@ -27,5 +27,5 @@ export type ConfirmationStepNext = {
27
27
  paymentMethodInfo: PaymentMethodInfo;
28
28
  };
29
29
  export declare function confirmationStepNext(state: ConfirmationStepState, payload: ConfirmationStepNext): StepTransition[FunCheckoutStep.CONFIRMATION];
30
- export declare function ConfirmationStep({ modalState, onNext, setModalState, }: StateTransitionProps<ConfirmationStepState, ConfirmationStepNext>): React.JSX.Element;
30
+ export declare function ConfirmationStep({ modalState, onNext, }: StateTransitionProps<ConfirmationStepState, ConfirmationStepNext>): React.JSX.Element;
31
31
  export {};
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  interface FunCheckoutModalProps {
3
3
  open: boolean;
4
4
  onClose: () => void;
5
- checkoutId: string | null;
6
5
  }
7
- export declare function FunCheckoutModal({ onClose, open, checkoutId, }: FunCheckoutModalProps): React.JSX.Element | null;
6
+ export declare function FunCheckoutModal({ onClose, open }: FunCheckoutModalProps): React.JSX.Element | null;
8
7
  export {};
@@ -0,0 +1,11 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { FunButtonProps } from '../../../components/FunButton/FunButton';
3
+ import { ErrorNotification } from './utils';
4
+ export declare function InputAmountLayout({ actionButtonProps, amountOptions, amountInput, amountInputSwitch, availableBalance, error, }: {
5
+ actionButtonProps: FunButtonProps;
6
+ availableBalance?: ReactNode;
7
+ amountOptions?: ReactNode;
8
+ amountInput: ReactNode;
9
+ amountInputSwitch: ReactNode;
10
+ error?: ErrorNotification;
11
+ }): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutContext';
3
+ import { AssetHoldingsItem } from '../../../utils/assets';
4
+ import { InputAmountNext, InputAmountState } from '../InputAmount';
5
+ import { StateTransitionProps } from '../stepTransition';
6
+ export declare function InputAmountLoaded({ checkoutItem, modalState, onNext, sourceHolding, unitPrice, }: StateTransitionProps<InputAmountState, InputAmountNext> & {
7
+ sourceHolding: AssetHoldingsItem | null;
8
+ checkoutItem: FunkitActiveCheckoutItem;
9
+ unitPrice: number;
10
+ }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { InputAmountNext, InputAmountState } from '../InputAmount';
3
+ import { StateTransitionProps } from '../stepTransition';
4
+ export declare function InputAmountLoading({ modalState, onBack, sourceHoldingError, unitPriceError, }: StateTransitionProps<InputAmountState, InputAmountNext> & {
5
+ sourceHoldingError: Error | null;
6
+ unitPriceError: Error | null;
7
+ }): React.JSX.Element;
@@ -0,0 +1,73 @@
1
+ import { PaymentMethod } from '~/domains/paymentMethods';
2
+ import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutContext';
3
+ import { AssetHoldingsItem } from '../../../utils/assets';
4
+ export interface AmountInputInitOptions {
5
+ apiKey: string;
6
+ checkoutItem: FunkitActiveCheckoutItem;
7
+ paymentMethod: PaymentMethod;
8
+ sourceHolding: AssetHoldingsItem | null;
9
+ /** Target asset unit price, in USD */
10
+ unitPrice: number;
11
+ }
12
+ export interface AmountInputState {
13
+ /** Current amount, in target asset */
14
+ assetAmount: number;
15
+ /** Current input value (with leading $ if in USD) */
16
+ inputValue: string;
17
+ /** Whether the input is currently in USD */
18
+ isInputInUsd: boolean;
19
+ /** Current amount, in USD */
20
+ usdAmount: number;
21
+ /** Estimated available amount, in USD (defaults to unlimited) */
22
+ usdAvailableAmount: number | null;
23
+ /** Maximum amount, in USD (defaults to unlimited) */
24
+ usdMaxAmount: number | null;
25
+ /** Minimum amount, in USD (defaults to 0) */
26
+ usdMinAmount: number | null;
27
+ }
28
+ /** Derived state includes additional fields that are pure functions of base state */
29
+ export interface AmountInputDerivedState extends AmountInputState {
30
+ inputError: AmountInputError | null;
31
+ isValid: boolean;
32
+ }
33
+ export type AmountInputAction = {
34
+ /** Switches between USD and absolute input mode */
35
+ type: 'setInputInUsd';
36
+ isInputInUsd: boolean;
37
+ } | {
38
+ /** Sets the input value as string */
39
+ type: 'setInputValue';
40
+ inputValue: string;
41
+ unitPrice: number;
42
+ } | {
43
+ /** Sets the input value as USD amount */
44
+ type: 'setUsdAmount';
45
+ unitPrice: number;
46
+ usdAmount: number;
47
+ } | {
48
+ /** Updates the available USD amount */
49
+ type: 'setUsdAvailableAmount';
50
+ usdAvailableAmount: number;
51
+ };
52
+ export type AmountInputError = {
53
+ /** Current amount is above available balance */
54
+ type: 'aboveAvailable';
55
+ usdAvailableAmount: number;
56
+ } | {
57
+ /** Current amount is above maximum */
58
+ type: 'aboveMax';
59
+ usdMaxAmount: number;
60
+ } | {
61
+ /** Current amount is below minimum */
62
+ type: 'belowMin';
63
+ usdMinAmount: number;
64
+ } | {
65
+ /** Available balance is 0 */
66
+ type: 'noAvailableBalance';
67
+ } | {
68
+ /** Input is empty */
69
+ type: 'noInput';
70
+ };
71
+ export declare function initializeState(init: AmountInputInitOptions): AmountInputState;
72
+ export declare function reduceState(state: AmountInputState, action: AmountInputAction): AmountInputState;
73
+ export declare function getDerivedState(state: AmountInputState): AmountInputDerivedState;
@@ -0,0 +1,9 @@
1
+ import { AmountInputDerivedState, AmountInputInitOptions } from './state';
2
+ interface UseAmountInputResult extends AmountInputDerivedState {
3
+ onChange(event: React.ChangeEvent<HTMLInputElement>): void;
4
+ setInputInUsd(isInputInUsd: boolean): void;
5
+ setUsdAmount(usdAmount: number): AmountInputDerivedState;
6
+ setUsdAvailableAmount(usdAvailableAmount: number): void;
7
+ }
8
+ export declare function useAmountInput(options: AmountInputInitOptions): UseAmountInputResult;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ interface TriggerNewQuoteOptions {
2
+ maxRetries: number;
3
+ targetAssetAmount: number;
4
+ }
5
+ interface UseCheckoutQuoteOptions {
6
+ checkoutId: string;
7
+ onFailure(maxTargetAssetAmount: number | undefined): void;
8
+ onSuccess(): void;
9
+ }
10
+ interface UseCheckoutQuoteResult {
11
+ error: string | null;
12
+ isQuoting: boolean;
13
+ step: string | null;
14
+ triggerNewQuote(options: TriggerNewQuoteOptions): void;
15
+ }
16
+ export declare function useCheckoutQuote({ onFailure, onSuccess, }: UseCheckoutQuoteOptions): UseCheckoutQuoteResult;
17
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { PaymentMethod } from '~/domains/paymentMethods';
3
+ import { FunkitActiveCheckoutItem } from '../../../providers/FunkitCheckoutContext';
4
+ import { AssetHoldingsItem } from '../../../utils/assets';
5
+ export declare const ASSET_DECIMALS = 5;
6
+ export declare const USD_DECIMALS = 2;
7
+ export declare const USD_INITIAL_AMOUNT = 100;
8
+ export declare const USD_PREFIX = "$";
9
+ export interface ErrorNotification {
10
+ message: ReactNode;
11
+ /** FunNotificationType */
12
+ type: 'error' | 'warning' | 'hint';
13
+ }
14
+ export declare function round(value: number, decimals: number,
15
+ /**
16
+ * Whether to round up ('ceil'), down ('floor'), or nearest ('round')
17
+ *
18
+ * Defauls to 'round'
19
+ **/
20
+ method?: 'ceil' | 'floor' | 'round'): number;
21
+ export declare function getUsdAvailableAmount(checkoutItem: FunkitActiveCheckoutItem, sourceBalance: AssetHoldingsItem | null): number | null;
22
+ export declare function getUsdMaxAmount(paymentMethod: PaymentMethod, apiKey: string): number | null;
23
+ export declare function getUsdMinAmount(paymentMethod: PaymentMethod): number;
@@ -9,4 +9,4 @@ export type InputAmountNext = {
9
9
  step: FunCheckoutStep.INPUT_AMOUNT;
10
10
  };
11
11
  export declare function inputAmountNext(state: InputAmountState, _payload: InputAmountNext): StepTransition[FunCheckoutStep.INPUT_AMOUNT];
12
- export declare function InputAmount({ modalState, onBack, onNext, }: StateTransitionProps<InputAmountState, InputAmountNext>): React.JSX.Element;
12
+ export declare function InputAmount(props: StateTransitionProps<InputAmountState, InputAmountNext>): React.JSX.Element;
@@ -16,5 +16,5 @@ export type SelectBrokerageNext = {
16
16
  };
17
17
  export declare function selectBrokerageNext(state: SelectBrokerageState, payload: SelectBrokerageNext): StepTransition[FunCheckoutStep.SELECT_BROKERAGE];
18
18
  type Props = StateTransitionProps<SelectBrokerageState, SelectBrokerageNext>;
19
- export declare function SelectBrokerage({ modalState, onNext }: Props): React.JSX.Element;
19
+ export declare function SelectBrokerage({ onNext }: Props): React.JSX.Element;
20
20
  export {};
@@ -23,5 +23,5 @@ export type SelectPaymentMethodNext = {
23
23
  export declare function selectPaymentMethodNext(state: SelectPaymentMethodState, payload: SelectPaymentMethodNext): StepTransition[FunCheckoutStep.SELECT_PAYMENT_METHOD];
24
24
  type Props = StateTransitionProps<SelectPaymentMethodState, SelectPaymentMethodNext>;
25
25
  export type SelectMethodPayloadData = UnionOmit<SelectPaymentMethodNext, 'step'>;
26
- export declare function SelectPaymentMethod({ modalState, onNext, onClose }: Props): React.JSX.Element;
26
+ export declare function SelectPaymentMethod({ onNext, onClose }: Props): React.JSX.Element;
27
27
  export {};
@@ -9,7 +9,10 @@ export type TransferTokenNext = {
9
9
  paymentMethodInfo: PaymentMethodAccountInfo;
10
10
  isLoggedIn: boolean;
11
11
  };
12
+ export interface TokenTransferSourceChainsAndAssets {
13
+ [chainId: number]: string[];
14
+ }
12
15
  export declare function transferTokenNext(state: TransferTokenState, payload: TransferTokenNext): StepTransition[FunCheckoutStep.TRANSFER_TOKEN];
13
16
  type Props = StateTransitionProps<TransferTokenState, TransferTokenNext>;
14
- export declare function TransferToken({ onBack, modalState }: Props): React.JSX.Element;
17
+ export declare function TransferToken({ onBack }: Props): React.JSX.Element;
15
18
  export {};
@@ -1,2 +1,2 @@
1
1
  import { Address } from 'viem';
2
- export declare function useAccountBalancePostCheckout(checkoutId: string, setPostCheckoutStepMessage: (s: string) => void, apiKey: string): (depositAddress: Address) => Promise<void>;
2
+ export declare function useAccountBalancePostCheckout(setPostCheckoutStepMessage: (s: string) => void, apiKey: string): (depositAddress: Address) => Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import { PaymentMethodInfo } from '../../domains/paymentMethods';
2
2
  import { QueryResult } from '../../types/utils';
3
3
  import { AssetHoldingsItem } from '../../utils/assets';
4
- export declare function useAvailableBalanceForCheckout(checkoutId: string, paymentMethodInfo: PaymentMethodInfo, targetChainId: string, assetChainId: string, assetSymbol: string | null): QueryResult<AssetHoldingsItem>;
4
+ export declare function useAvailableBalanceForCheckout(paymentMethodInfo: PaymentMethodInfo, targetChainId: string, assetChainId: string, assetSymbol: string | null): QueryResult<AssetHoldingsItem>;
@@ -1,13 +1,8 @@
1
- import { PaymentMethodInfo } from '../../domains/paymentMethods';
2
1
  import { FunkitActiveCheckoutItem } from '../../providers/FunkitCheckoutContext';
3
2
  export interface SourceAssetConfirmed {
4
3
  isQuoteSuccess: boolean;
5
- newPaymentMethodInfo: PaymentMethodInfo;
6
- quoteObject: FunkitActiveCheckoutItem | undefined;
7
- totalFeesUsd: number | undefined;
8
- estSubtotalUsd: number | undefined;
4
+ maxTargetAssetAmount: number | undefined;
9
5
  }
10
- export type OnSourceAssetConfirmed = (confirmed: SourceAssetConfirmed | undefined) => void;
11
6
  /**
12
7
  *
13
8
  * Note: this hook is EXTREMELY confusing in what is doing
@@ -20,7 +15,7 @@ export type OnSourceAssetConfirmed = (confirmed: SourceAssetConfirmed | undefine
20
15
  *
21
16
  * USE THIS WITH CAUTION
22
17
  **/
23
- export declare function useTriggerQuoteAndOtherStuffsWithExtremeCaution(checkoutId: string, onSuccess: (confirmed: SourceAssetConfirmed | undefined) => void, setPreloadedQuoteData?: (quoteData: FunkitActiveCheckoutItem) => void): {
18
+ export declare function useTriggerQuoteAndOtherStuffsWithExtremeCaution(onSuccess: (confirmed: SourceAssetConfirmed | undefined) => void, setPreloadedQuoteData?: (quoteData: FunkitActiveCheckoutItem) => void): {
24
19
  isSourceAssetConfirming: boolean;
25
20
  triggerAssetConfirm: () => void;
26
21
  onSourceAssetConfirmed: (preloadQuoteData?: boolean) => Promise<SourceAssetConfirmed | undefined>;
@@ -1,4 +1,4 @@
1
- export declare function useUpdateCardSourceAsset(checkoutId: string): {
1
+ export declare function useUpdateCardSourceAsset(): {
2
2
  onSelectCard: () => Promise<void>;
3
3
  isUpdating: boolean;
4
4
  };
@@ -0,0 +1,2 @@
1
+ export declare const GradientErrorBox: string;
2
+ export declare const GradientSuccessBox: string;
@@ -1,10 +1,13 @@
1
- import { CheckoutHistoryItem, CheckoutQuoteResponse } from '@funkit/api-base';
1
+ import { CheckoutHistoryItem } from '@funkit/api-base';
2
+ import { Operation } from '@funkit/core';
2
3
  import React, { ReactNode } from 'react';
3
4
  import { Abi, Address } from 'viem';
4
- import { CheckoutFees } from '../domains/checkoutFees';
5
5
  import { PaymentMethod, PaymentMethodInfo } from '../domains/paymentMethods';
6
- import { CheckoutHistoryStateMap } from '../utils/checkout';
6
+ import type { FunkitCheckoutQuoteResult } from '../domains/quote';
7
+ import { CheckoutHistoryDepositAddrMap, CheckoutHistoryStateMap } from '../utils/checkout';
7
8
  import { PurifiedCheckoutHistoryItem } from '../utils/purifyCheckoutHistoryItem';
9
+ export type { HistoricalCheckoutItem, ServerCheckoutConfig, } from '~/domains/clientMetadata';
10
+ export type { FunkitCheckoutQuoteResult } from '~/domains/quote';
8
11
  export interface FunkitCheckoutActionParams {
9
12
  contractAbi: Abi;
10
13
  contractAddress: Address;
@@ -52,13 +55,6 @@ export interface FunkitCheckoutConfig {
52
55
  /** User identification within customer's app for logging and customer dashboard purposes (future). **/
53
56
  externalCheckoutUserId?: string;
54
57
  }
55
- type FunkitCheckoutQuoteResult = {
56
- baseQuote: CheckoutQuoteResponse;
57
- finalTimeEstimationMs: number;
58
- finalPaymentTokenAmount: string;
59
- finalTotalUsd: string;
60
- finalFeesBreakdown: CheckoutFees;
61
- };
62
58
  interface FunkitCheckoutValidationResult {
63
59
  isValid: boolean;
64
60
  message: string;
@@ -125,51 +121,42 @@ export interface FunkitActiveCheckoutItem {
125
121
  symbol: string | null;
126
122
  chainId: string;
127
123
  };
124
+ /** Time of completion of the active checkout item. For frontend use only. **/
125
+ completedTimestampMs: number | null;
128
126
  }
129
- export type ServerPaymentMethodInfo = Omit<PaymentMethodInfo, 'titleIcon' | 'descriptionIcon'>;
130
- export type ServerCheckoutConfig = Omit<FunkitCheckoutConfig, 'generateActionsParams'> & {
131
- generateActionsParams?: string;
132
- };
133
- /** Serializable data from FE checkout item */
134
- export type HistoricalCheckoutItem = {
135
- id: FunkitActiveCheckoutItem['id'];
136
- startTimestampMs: FunkitActiveCheckoutItem['startTimestampMs'];
137
- draftDollarValue: FunkitActiveCheckoutItem['draftDollarValue'];
138
- finalDollarValue: FunkitActiveCheckoutItem['finalDollarValue'];
139
- latestQuote: FunkitActiveCheckoutItem['latestQuote'];
140
- depositAddress: FunkitActiveCheckoutItem['depositAddress'];
141
- initSettings: {
142
- config: ServerCheckoutConfig;
143
- };
144
- selectedSourceAssetInfo: FunkitActiveCheckoutItem['selectedSourceAssetInfo'];
145
- selectedPaymentMethodInfo: ServerPaymentMethodInfo | null;
146
- };
147
- export declare function FunkitCheckoutProvider({ children }: {
148
- children: ReactNode;
149
- }): React.JSX.Element;
150
- interface useFunkitPreCheckoutInternalReturn {
151
- checkoutItem: null | FunkitActiveCheckoutItem;
127
+ interface FunkitCheckoutContextInterface {
128
+ checkoutItem: FunkitActiveCheckoutItem | null;
129
+ checkoutHistoryList: CheckoutHistoryItem[];
130
+ checkoutHistoryStateMap: CheckoutHistoryStateMap;
131
+ checkoutHistoryDepositAddrMap: CheckoutHistoryDepositAddrMap;
132
+ checkoutHistoryCurrentDepositAddrMap: CheckoutHistoryDepositAddrMap;
133
+ isCheckoutHistoryInited: boolean;
134
+ isRefreshingCheckoutHistory: boolean;
152
135
  reDraftSymbol: symbol;
153
- updateSourceAsset: (newSourceAsset: Address, newSourceAssetSymbol: string, newSourceAssetChainId: string) => void;
154
- updateTargetAssetAmount: (newTargetAssetAmount: number) => void;
155
- updateSelectedPaymentMethodInfo: (newPaymentMethodInfo: PaymentMethodInfo) => void;
156
- confirmCheckout: (shouldBatchOpBypassInit: boolean, stepMessageSetter: (m: string) => void) => Promise<Address>;
157
- cancelCheckout: (depositAddress: Address) => Promise<boolean>;
158
- getCheckoutDraftDollarValue: () => Promise<number>;
159
- clearCheckoutQuoteMessages: () => void;
160
- getCheckoutQuote: (sponsorInitialTransferGasLimit: number, newPaymentMethodInfo: PaymentMethodInfo, disableInformationStreaming?: boolean) => Promise<{
136
+ startCheckoutHistoryListener(recipientAddr?: Address | undefined): NodeJS.Timeout;
137
+ stopCheckoutHistoryListener(cancelIntervalId?: NodeJS.Timeout): void;
138
+ initNewCheckout(initSettings: useFunkitCheckoutPropsFinal): string;
139
+ updateSourceAsset(selectedSourceAsset: Address, selectedSourceAssetSymbol: string, selectedSourceAssetChainId: string): void;
140
+ updateTargetAssetAmount(newTargetAssetAmount: number): void;
141
+ updateSelectedPaymentMethodInfo(newPaymentMethodInfo: PaymentMethodInfo): void;
142
+ confirmCheckout(shouldBatchOpBypassInit: boolean, stepMessageSetter: (m: string) => void): Promise<Address>;
143
+ cancelCheckout(depositAddress: Address): Promise<boolean>;
144
+ clearCheckoutQuoteMessages(): void;
145
+ getCheckoutQuote(sponsorInitialTransferGasLimit: number, newPaymentMethodInfo: PaymentMethodInfo, disableInformationStreaming?: boolean): Promise<{
161
146
  success: boolean;
162
147
  shellCheckoutItemWithNextQuote: FunkitActiveCheckoutItem | undefined;
163
- totalFeesUsd: number | undefined;
164
- estSubtotalUsd: number | undefined;
148
+ maxTargetAssetAmount: number | undefined;
165
149
  errorObject?: any;
166
150
  }>;
167
- setCheckoutQuote: (quote: FunkitActiveCheckoutItem) => void;
151
+ getCheckoutDraftDollarValue(): Promise<number>;
152
+ generateSignedBatchOperation(actionsParams: FunkitCheckoutActionParams[], assetChainId: string, bypassWalletInit: boolean, stepMessageSetter: (m: string) => void): Promise<null | Operation>;
153
+ setCheckoutQuote(quote: FunkitActiveCheckoutItem): void;
154
+ setCompletedTimestamp(timestampMs: number): void;
168
155
  }
169
- /**
170
- * Internal hook to handle frontend pre-checkout operations, PER-CHECKOUT ITEM.
171
- */
172
- export declare const useFunkitPreCheckoutInternal: (checkoutId: string) => useFunkitPreCheckoutInternalReturn;
156
+ export declare function FunkitCheckoutProvider({ children }: {
157
+ children: ReactNode;
158
+ }): React.JSX.Element;
159
+ export declare function useCheckoutContext(): FunkitCheckoutContextInterface;
173
160
  /**
174
161
  * Internal hook to handle post-checkout, PER-BACKEND-CHECKOUT ITEM.
175
162
  */
@@ -177,17 +164,6 @@ export declare const useFunkitPostCheckoutInternal: (depositAddress: Address) =>
177
164
  isLoading: boolean;
178
165
  checkoutHistoryInfo: CheckoutHistoryItem | undefined;
179
166
  };
180
- /**
181
- * Internal hook to get all post-checkout items
182
- */
183
- export declare const useFunkitAllPostCheckoutsInternal: () => {
184
- checkoutHistoryList: CheckoutHistoryItem[];
185
- checkoutHistoryStateMap: CheckoutHistoryStateMap;
186
- isCheckoutHistoryInited: boolean;
187
- isRefreshingCheckoutHistory: boolean;
188
- startCheckoutHistoryListener: (recipientAddr?: Address | undefined) => NodeJS.Timeout;
189
- stopCheckoutHistoryListener: (cancelIntervalId?: NodeJS.Timeout) => void;
190
- };
191
167
  /**
192
168
  * External hook for user to kickstart a checkout in their app
193
169
  */
@@ -208,4 +184,3 @@ export declare function useCheckoutsListenerByUserId(userId: string): PurifiedCh
208
184
  * @returns PurifiedCheckoutHistoryItem | undefined
209
185
  */
210
186
  export declare function useCheckoutListenerByCheckoutId(checkoutId: string): PurifiedCheckoutHistoryItem | undefined;
211
- export {};
@@ -6,7 +6,7 @@ export type FlagValue<K extends FlagKey> = InferFlagType<(typeof offlineConfig)[
6
6
  export type FlagValues = {
7
7
  [K in FlagKey]?: FlagValue<K>;
8
8
  };
9
- export type GetFlagFunction = <K extends FlagKey>(flagKey: K, fallback: FlagValue<K>) => FlagValue<K>;
9
+ export type GetFlagFunction = <K extends FlagKey>(flagKey: K, fallback?: FlagValue<K>) => FlagValue<K>;
10
10
  export interface FunkitFlagsContextValue {
11
11
  /** Error fetching flag config from server */
12
12
  error: Error | null;
@@ -22,4 +22,4 @@ export declare function FunkitFlagsProvider({ children }: {
22
22
  children: ReactNode;
23
23
  }): React.JSX.Element;
24
24
  export declare function useFlags(): FunkitFlagsContextValue;
25
- export declare function useFlag<K extends FlagKey>(flagKey: K, fallback: FlagValue<K>): FlagValue<K>;
25
+ export declare function useFlag<K extends FlagKey>(flagKey: K, fallback?: FlagValue<K>): FlagValue<K>;
@@ -20,6 +20,6 @@ export interface UserIpInfoFromMoonpay {
20
20
  export declare const geoCheckInProgressProps: FunButtonProps;
21
21
  export declare function useFunkitUserIp(): {
22
22
  isLoadingGeoCheck: boolean;
23
- isUserBlockedForCheckout: boolean;
23
+ isUserGeoblocked: boolean;
24
24
  userIpInfo: UserIpInfoFromMoonpay | undefined;
25
25
  };
@@ -31,6 +31,7 @@ export declare const defaultTheme: {
31
31
  hoverState: string;
32
32
  offBackgroundInverse: string;
33
33
  lightStroke: string;
34
+ mediumStroke: string;
34
35
  strokeColor: string;
35
36
  dydxSwitchActiveBackground: string;
36
37
  primaryText: string;
@@ -60,7 +61,6 @@ export declare const defaultTheme: {
60
61
  buttonBackground: string;
61
62
  buttonBackgroundHover: string;
62
63
  buttonBackgroundDisabled: string;
63
- buttonText: string;
64
64
  buttonStroke: string;
65
65
  buttonTextSecondaryDisabled: string;
66
66
  buttonTextSecondary: string;
@@ -187,6 +187,7 @@ export declare const useActiveTheme: () => {
187
187
  hoverState: string;
188
188
  offBackgroundInverse: string;
189
189
  lightStroke: string;
190
+ mediumStroke: string;
190
191
  strokeColor: string;
191
192
  dydxSwitchActiveBackground: string;
192
193
  primaryText: string;
@@ -216,7 +217,6 @@ export declare const useActiveTheme: () => {
216
217
  buttonBackground: string;
217
218
  buttonBackgroundHover: string;
218
219
  buttonBackgroundDisabled: string;
219
- buttonText: string;
220
220
  buttonStroke: string;
221
221
  buttonTextSecondaryDisabled: string;
222
222
  buttonTextSecondary: string;
@@ -331,6 +331,7 @@ export declare const useActiveTheme: () => {
331
331
  hoverState: string;
332
332
  offBackgroundInverse: string;
333
333
  lightStroke: string;
334
+ mediumStroke: string;
334
335
  strokeColor: string;
335
336
  dydxSwitchActiveBackground: string;
336
337
  primaryText: string;
@@ -360,7 +361,6 @@ export declare const useActiveTheme: () => {
360
361
  buttonBackground: string;
361
362
  buttonBackgroundHover: string;
362
363
  buttonBackgroundDisabled: string;
363
- buttonText: string;
364
364
  buttonStroke: string;
365
365
  buttonTextSecondaryDisabled: string;
366
366
  buttonTextSecondary: string;
@@ -474,6 +474,7 @@ export declare const useActiveTheme: () => {
474
474
  hoverState: string;
475
475
  offBackgroundInverse: string;
476
476
  lightStroke: string;
477
+ mediumStroke: string;
477
478
  strokeColor: string;
478
479
  dydxSwitchActiveBackground: string;
479
480
  primaryText: string;
@@ -503,7 +504,6 @@ export declare const useActiveTheme: () => {
503
504
  buttonBackground: string;
504
505
  buttonBackgroundHover: string;
505
506
  buttonBackgroundDisabled: string;
506
- buttonText: string;
507
507
  buttonStroke: string;
508
508
  buttonTextSecondaryDisabled: string;
509
509
  buttonTextSecondary: string;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  baseTheme
4
- } from "../chunk-HFT6OV3T.js";
4
+ } from "../chunk-BY224HGT.js";
5
5
  export {
6
6
  baseTheme
7
7
  };
@@ -31,6 +31,7 @@ export declare const darkTheme: {
31
31
  hoverState: string;
32
32
  offBackgroundInverse: string;
33
33
  lightStroke: string;
34
+ mediumStroke: string;
34
35
  strokeColor: string;
35
36
  dydxSwitchActiveBackground: string;
36
37
  primaryText: string;
@@ -60,7 +61,6 @@ export declare const darkTheme: {
60
61
  buttonBackground: string;
61
62
  buttonBackgroundHover: string;
62
63
  buttonBackgroundDisabled: string;
63
- buttonText: string;
64
64
  buttonStroke: string;
65
65
  buttonTextSecondaryDisabled: string;
66
66
  buttonTextSecondary: string;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  darkTheme
4
- } from "../chunk-ZGK66FYG.js";
5
- import "../chunk-HFT6OV3T.js";
4
+ } from "../chunk-XWW5QOD4.js";
5
+ import "../chunk-BY224HGT.js";
6
6
  export {
7
7
  darkTheme
8
8
  };
@@ -31,6 +31,7 @@ export declare const lightTheme: {
31
31
  hoverState: string;
32
32
  offBackgroundInverse: string;
33
33
  lightStroke: string;
34
+ mediumStroke: string;
34
35
  strokeColor: string;
35
36
  dydxSwitchActiveBackground: string;
36
37
  primaryText: string;
@@ -60,7 +61,6 @@ export declare const lightTheme: {
60
61
  buttonBackground: string;
61
62
  buttonBackgroundHover: string;
62
63
  buttonBackgroundDisabled: string;
63
- buttonText: string;
64
64
  buttonStroke: string;
65
65
  buttonTextSecondaryDisabled: string;
66
66
  buttonTextSecondary: string;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  lightTheme
4
- } from "../chunk-YOJVBRUJ.js";
5
- import "../chunk-HFT6OV3T.js";
4
+ } from "../chunk-77C753LI.js";
5
+ import "../chunk-BY224HGT.js";
6
6
  export {
7
7
  lightTheme
8
8
  };
@@ -2,7 +2,7 @@ import { CheckoutHistoryItem, CheckoutState } from '@funkit/api-base';
2
2
  import { Address, Hex } from 'viem';
3
3
  import { UseConfigReturnType } from 'wagmi';
4
4
  import { PaymentMethod } from '../domains/paymentMethods';
5
- import { FunkitActiveCheckoutItem, FunkitCheckoutConfig, HistoricalCheckoutItem, ServerCheckoutConfig } from '../providers/FunkitCheckoutContext';
5
+ import { FunkitActiveCheckoutItem, FunkitCheckoutConfig, FunkitCheckoutQuoteResult, HistoricalCheckoutItem, ServerCheckoutConfig } from '../providers/FunkitCheckoutContext';
6
6
  export declare const MOONPAY_TIME_ESTIMATE_MS = 120000;
7
7
  export declare const MESH_TIME_ESTIMATE_MS = 300000;
8
8
  export declare const DUMMY_TRANSFER_PARAMS: {
@@ -18,10 +18,12 @@ export declare function validateCheckoutConfig(config: Partial<FunkitCheckoutCon
18
18
  isValid: boolean;
19
19
  message: string;
20
20
  };
21
- export declare const hasSufficientBalance: (wagmiConfig: UseConfigReturnType, walletAddress: string, tokenAddress: string, tokenChainId: string, tokenAddressAmount: number) => Promise<{
21
+ export declare const hasSufficientBalance: (wagmiConfig: UseConfigReturnType, walletAddress: string, tokenAddress: string, tokenChainId: string, requiredAssetAmount: number) => Promise<{
22
+ balance: number;
22
23
  result: boolean;
23
24
  tokenTicker: string;
24
25
  } | {
26
+ balance: number;
25
27
  result: boolean;
26
28
  tokenTicker: null;
27
29
  }>;
@@ -29,8 +31,13 @@ export declare const hasSufficientBalance: (wagmiConfig: UseConfigReturnType, wa
29
31
  * Checks whether user has sufficient targetAsset + targetAssetAmount in their wallet
30
32
  */
31
33
  export declare const testAutoExecutionDuringCheckout: (config: FunkitCheckoutConfig, walletAddress: string, wagmiConfig: UseConfigReturnType) => Promise<{
34
+ balance: number;
32
35
  result: boolean;
33
36
  tokenTicker: string;
37
+ } | {
38
+ balance: number;
39
+ result: boolean;
40
+ tokenTicker: null;
34
41
  } | {
35
42
  result: boolean;
36
43
  tokenTicker: null;
@@ -122,3 +129,15 @@ export declare function getEstimateEndTimeInfo(createdTimeMs: number, checkoutIt
122
129
  * - e.g. "0.12345 ETH"
123
130
  */
124
131
  export declare function getCheckoutItemDisplay(checkoutConfig: FunkitCheckoutConfig | ServerCheckoutConfig, hideAmount?: boolean): string;
132
+ /**
133
+ * Given the result of a quote, estimate the maximum targetAssetAmount for which the checkout should succeed.
134
+ * The result is then reduced by 1% to further reduce the risk of insufficient funds.
135
+ *
136
+ * NOTE: This assumes fees are (roughly) constant, at least when the target amount does not change much.
137
+ * Only the API could give us a true number here.
138
+ *
139
+ * @param sourceAssetBalance - Total source asset balance
140
+ * @param config - Checkout config
141
+ * @param quoteResult - Failed quote results
142
+ */
143
+ export declare function getMaxTargetAssetAmountEstimate(sourceAssetBalance: number, config: FunkitCheckoutConfig, quoteResult: FunkitCheckoutQuoteResult): number;
@@ -1,4 +1,12 @@
1
1
  export declare const MINIMUM_MOONPAY_DEPOSIT_AMOUNT_USD = 35;
2
2
  export declare const MAXIMUM_MOONPAY_DEPOSIT_AMOUNT_USD = 10000;
3
- export declare function isAmountInvalidForMoonpay(amountUsd: number): boolean;
4
- export declare function generateInsufficientAmountForMoonpayError(isShortened: boolean): string;
3
+ export declare function checkAmountForMoonpay(amountUsd: number): {
4
+ readonly isInvalid: true;
5
+ readonly message: "$35 minimum required for the selected payment method.";
6
+ } | {
7
+ readonly isInvalid: true;
8
+ readonly message: "$10000 maximum exceeded for the selected payment method.";
9
+ } | {
10
+ readonly isInvalid: false;
11
+ readonly message?: undefined;
12
+ };