@funkit/connect 3.3.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +70 -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/FunAssetAvatar/FunAssetAvatar.d.ts +1 -1
  12. package/dist/components/FunBottomBar/FunBottomBar.css.d.ts +1 -1
  13. package/dist/components/FunButton/FunIconButton.d.ts +1 -0
  14. package/dist/components/FunCheckoutBlocked/FunCheckoutBlocked.d.ts +6 -1
  15. package/dist/components/FunCountdown/FunCountdown.d.ts +2 -1
  16. package/dist/components/FunOptionBox/FunOptionBox.css.d.ts +1 -1
  17. package/dist/components/FunPayments/FunPaymentMethods.d.ts +5 -13
  18. package/dist/components/FunPayments/FunPaymentMoonpayType.d.ts +4 -2
  19. package/dist/components/Icons/BrokerageIcon.d.ts +4 -0
  20. package/dist/components/Icons/CreditCardIcon.d.ts +4 -0
  21. package/dist/components/Icons/EvmWallet.d.ts +3 -1
  22. package/dist/components/Icons/LightningBoltIcon.d.ts +3 -1
  23. package/dist/components/Icons/SocialMediaIcons.d.ts +12 -4
  24. package/dist/config/getDefaultConfig.d.ts +33 -33
  25. package/dist/consts/assets.d.ts +2 -3
  26. package/dist/consts/funkit.d.ts +5 -1
  27. package/dist/consts/mesh.d.ts +36 -0
  28. package/dist/css/sprinkles.css.d.ts +38 -38
  29. package/dist/domains/checkoutFees.d.ts +4 -2
  30. package/dist/domains/clientMetadata.d.ts +37 -0
  31. package/dist/domains/paymentMethods.d.ts +28 -17
  32. package/dist/domains/quote.d.ts +31 -0
  33. package/dist/hooks/useCheckoutAccountBalanceTransfer.d.ts +1 -1
  34. package/dist/hooks/useCheckoutQuoteNotification.d.ts +1 -1
  35. package/dist/hooks/useCheckoutTransferDepositAddress.d.ts +2 -1
  36. package/dist/hooks/useEnabledTokenTransferChainTokens.d.ts +2 -0
  37. package/dist/hooks/useIsCheckoutRisky.d.ts +2 -0
  38. package/dist/hooks/useMesh.d.ts +5 -22
  39. package/dist/hooks/usePaymentMethodIcon.d.ts +22 -0
  40. package/dist/hooks/useUsableWalletAssetsForCheckout.d.ts +3 -2
  41. package/dist/index.css +2156 -2135
  42. package/dist/index.js +13723 -13433
  43. package/dist/modals/CheckoutModal/CheckoutPrimaryInfo.d.ts +1 -2
  44. package/dist/modals/CheckoutModal/ConfirmationStep.d.ts +1 -1
  45. package/dist/modals/CheckoutModal/FunCheckoutModal.d.ts +1 -2
  46. package/dist/modals/CheckoutModal/InputAmount/InputAmountLayout.d.ts +11 -0
  47. package/dist/modals/CheckoutModal/InputAmount/InputAmountLoaded.d.ts +10 -0
  48. package/dist/modals/CheckoutModal/InputAmount/InputAmountLoading.d.ts +7 -0
  49. package/dist/modals/CheckoutModal/InputAmount/state.d.ts +73 -0
  50. package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +9 -0
  51. package/dist/modals/CheckoutModal/InputAmount/useCheckoutQuote.d.ts +17 -0
  52. package/dist/modals/CheckoutModal/InputAmount/utils.d.ts +23 -0
  53. package/dist/modals/CheckoutModal/InputAmount.d.ts +1 -1
  54. package/dist/modals/CheckoutModal/LoadingAccount.d.ts +1 -1
  55. package/dist/modals/CheckoutModal/SelectBrokerage.d.ts +1 -1
  56. package/dist/modals/CheckoutModal/SelectPaymentMethod.d.ts +2 -5
  57. package/dist/modals/CheckoutModal/TransferToken.d.ts +6 -3
  58. package/dist/modals/CheckoutModal/useAccountBalancePostCheckout.d.ts +1 -1
  59. package/dist/modals/CheckoutModal/useAvailableBalanceForCheckout.d.ts +1 -1
  60. package/dist/modals/CheckoutModal/useSourceAssetConfirm.d.ts +2 -7
  61. package/dist/modals/CheckoutModal/useUpdateSourceAssetForCard.d.ts +1 -1
  62. package/dist/modals/FunCheckoutHistoryModal/FunCheckoutStatus.css.d.ts +2 -0
  63. package/dist/providers/FunkitCheckoutContext.d.ts +37 -60
  64. package/dist/providers/FunkitFlagsProvider.d.ts +2 -2
  65. package/dist/providers/FunkitMoonpayProvider.d.ts +3 -3
  66. package/dist/providers/FunkitThemeProvider.d.ts +4 -4
  67. package/dist/themes/baseTheme.js +1 -1
  68. package/dist/themes/darkTheme.d.ts +1 -1
  69. package/dist/themes/darkTheme.js +2 -2
  70. package/dist/themes/lightTheme.d.ts +1 -1
  71. package/dist/themes/lightTheme.js +2 -2
  72. package/dist/utils/assets.d.ts +2 -1
  73. package/dist/utils/checkout.d.ts +23 -2
  74. package/dist/utils/deposit.d.ts +10 -2
  75. package/dist/utils/flags/config.d.ts +11 -8
  76. package/dist/utils/formatFees.d.ts +12 -0
  77. package/dist/utils/formatNumber.d.ts +1 -1
  78. package/dist/utils/formatTimestamp.d.ts +8 -8
  79. package/dist/utils/mesh.d.ts +9 -54
  80. package/dist/wallets/walletConnectors/index.js +30 -30
  81. package/package.json +4 -4
  82. package/dist/components/FunToast/FunShortToast.css.d.ts +0 -10
  83. package/dist/components/FunToast/FunShortToast.d.ts +0 -3
  84. package/dist/components/FunToast/FunToast.d.ts +0 -18
  85. package/dist/components/Icons/PaymentMethodIcons.d.ts +0 -27
  86. package/dist/providers/FunToastProvider.d.ts +0 -11
  87. package/dist/providers/useAccountBalancePaymentDefaultInfo.d.ts +0 -4
  88. package/dist/wallets/walletConnectors/chunk-2EMZOYQI.js +0 -101
  89. package/dist/wallets/walletConnectors/chunk-5K4DIMYR.js +0 -95
  90. package/dist/wallets/walletConnectors/chunk-AUVBWDIK.js +0 -102
  91. package/dist/wallets/walletConnectors/chunk-AXPQHNUI.js +0 -71
  92. package/dist/wallets/walletConnectors/chunk-B7FHT3CB.js +0 -94
  93. package/dist/wallets/walletConnectors/chunk-EFIENLEE.js +0 -98
  94. package/dist/wallets/walletConnectors/chunk-FLTQRYFS.js +0 -27
  95. package/dist/wallets/walletConnectors/chunk-L7QI6PBN.js +0 -108
  96. package/dist/wallets/walletConnectors/chunk-QP2BIVXD.js +0 -73
  97. package/dist/wallets/walletConnectors/chunk-UWZQZY4S.js +0 -149
  98. package/dist/wallets/walletConnectors/chunk-UZEMNN3Q.js +0 -96
@@ -7,11 +7,14 @@ interface BaseCheckoutFees {
7
7
  marketMakerFeeUsd: number;
8
8
  liquidityProviderFeePercentage: number;
9
9
  totalFeesUsd: number;
10
- totalFeesToken: number;
10
+ /** does not include the gas fee since it can be in a
11
+ * different token than the source token */
12
+ totalFeesTokenWithoutGas: number;
11
13
  }
12
14
  interface WalletCheckoutFees extends BaseCheckoutFees {
13
15
  paymentMethod: PaymentMethod.ACCOUNT_BALANCE;
14
16
  eoaWalletFeeToken: number;
17
+ nativeCurrencySymbol: string;
15
18
  eoaWalletFeeUsd: number;
16
19
  }
17
20
  interface CardCheckoutFees extends BaseCheckoutFees {
@@ -25,7 +28,6 @@ interface BrokerageCheckoutFees extends BaseCheckoutFees {
25
28
  meshCostUsd: number;
26
29
  }
27
30
  export type CheckoutFees = WalletCheckoutFees | CardCheckoutFees | BrokerageCheckoutFees;
28
- export declare const GAS_ESTIMATE_MULTIPLER = 1.2;
29
31
  interface EvaluateFeeBreakdownItem {
30
32
  baseQuote: CheckoutQuoteResponse;
31
33
  selectedSourceAssetInfo: FunkitActiveCheckoutItem['selectedSourceAssetInfo'];
@@ -0,0 +1,37 @@
1
+ /**
2
+ * clientMetadata is a type for FE to store historical state of a checkoutItem
3
+ * It should be mostly derived by backend data but currently we don't have capacity to do it.
4
+ *
5
+ * Make sure it is SERIALIZABLE and BACKWARD COMPATIBLE!!
6
+ */
7
+ import { FunkitActiveCheckoutItem, FunkitCheckoutConfig } from '~/providers/FunkitCheckoutContext';
8
+ /** Historical Checkout Configuration stored in the server
9
+ * This is similar to FunkitCheckoutConfig but with some fields changed to serializable types
10
+ * */
11
+ export type ServerCheckoutConfig = Omit<FunkitCheckoutConfig, 'generateActionsParams'> & {
12
+ generateActionsParams?: string;
13
+ };
14
+ /**
15
+ * HistoricalCheckoutItem stored in the server
16
+ *
17
+ * Make sure it is SERIALIZABLE and BACKWARD COMPATIBLE!!
18
+ **/
19
+ export interface HistoricalCheckoutItem {
20
+ id: FunkitActiveCheckoutItem['id'];
21
+ startTimestampMs: FunkitActiveCheckoutItem['startTimestampMs'];
22
+ draftDollarValue: FunkitActiveCheckoutItem['draftDollarValue'];
23
+ finalDollarValue: FunkitActiveCheckoutItem['finalDollarValue'];
24
+ latestQuote: FunkitActiveCheckoutItem['latestQuote'];
25
+ depositAddress: FunkitActiveCheckoutItem['depositAddress'];
26
+ initSettings: {
27
+ config: ServerCheckoutConfig;
28
+ };
29
+ selectedSourceAssetInfo: FunkitActiveCheckoutItem['selectedSourceAssetInfo'];
30
+ selectedPaymentMethodInfo: FunkitActiveCheckoutItem['selectedPaymentMethodInfo'];
31
+ }
32
+ /**
33
+ * Sanitizes checkoutItem to generate a clientMetadata object to be saved in backend.
34
+ * Ensures that no react components get sent to backend and the object isn't too big as well.
35
+ */
36
+ export declare function generateClientMetadataForBackend(checkoutItem: FunkitActiveCheckoutItem): HistoricalCheckoutItem;
37
+ export declare function generateClientMetadataForTokenTransfer(): HistoricalCheckoutItem;
@@ -1,6 +1,6 @@
1
1
  import { PreviewTransferResult } from '@funkit/api-base';
2
2
  import { LinkPayload } from '@meshconnect/web-link-sdk';
3
- import { ReactNode } from 'react';
3
+ import { MeshExchanges } from '~/consts/mesh';
4
4
  /** Supported payment methods in FunkitConnect. **/
5
5
  export declare enum PaymentMethod {
6
6
  /** Moonpay - Credit / Debit Card **/
@@ -17,33 +17,44 @@ type PaymentMethodInfoMeta = LinkPayload & {
17
17
  previewTransferResult?: PreviewTransferResult;
18
18
  };
19
19
  /** Full payment method information used in frontend during payment flows. **/
20
- export interface PaymentMethodInfo {
20
+ interface PaymentMethodInfoBase {
21
21
  paymentMethod: PaymentMethod;
22
22
  title: string;
23
- titleIcon: (size: number) => ReactNode;
24
23
  description: string;
25
- descriptionIcon?: ReactNode;
26
24
  meta: PaymentMethodInfoMeta;
27
25
  }
28
- export interface PaymentMethodCardInfo extends PaymentMethodInfo {
26
+ export interface PaymentMethodCardInfo extends PaymentMethodInfoBase {
29
27
  paymentMethod: PaymentMethod.CARD;
30
28
  }
31
- export interface PaymentMethodBrokerageInfo extends PaymentMethodInfo {
29
+ export interface PaymentMethodBrokerageInfo extends PaymentMethodInfoBase {
32
30
  paymentMethod: PaymentMethod.BROKERAGE;
33
31
  }
34
- export interface PaymentMethodAccountInfo extends PaymentMethodInfo {
32
+ export interface PaymentMethodAccountInfo extends PaymentMethodInfoBase {
35
33
  paymentMethod: PaymentMethod.ACCOUNT_BALANCE;
36
34
  }
37
- export interface PaymentMethodTransferTokenInfo extends PaymentMethodInfo {
35
+ export interface PaymentMethodTokenTransferInfo extends PaymentMethodInfoBase {
38
36
  paymentMethod: PaymentMethod.TOKEN_TRANSFER;
39
37
  }
40
- /** Shouldn't be used generally. Will most likely be removed once checkoutItem usage is reduced */
41
- export declare const getPartialPaymentMethodInfo: <T extends PaymentMethodInfo>(paymentMethod: T["paymentMethod"]) => {
42
- paymentMethod: T["paymentMethod"];
43
- title: string;
44
- titleIcon: () => null;
45
- description: string;
46
- descriptionIcon: null;
47
- meta: {};
48
- };
38
+ export type PaymentMethodInfo = PaymentMethodCardInfo | PaymentMethodBrokerageInfo | PaymentMethodAccountInfo | PaymentMethodTokenTransferInfo;
39
+ interface CardPaymentMethodParams {
40
+ paymentMethod: PaymentMethod.CARD;
41
+ /** We also store client's customization in our database :( */
42
+ titleCustomization: string;
43
+ }
44
+ interface AccountPaymentMethodParams {
45
+ paymentMethod: PaymentMethod.ACCOUNT_BALANCE;
46
+ walletAddress: string;
47
+ }
48
+ interface BrokeragePaymentMethodParams {
49
+ paymentMethod: PaymentMethod.BROKERAGE;
50
+ meshMeta: LinkPayload;
51
+ brokerage: MeshExchanges;
52
+ }
53
+ interface TokenTransferPaymentMethodParams {
54
+ paymentMethod: PaymentMethod.TOKEN_TRANSFER;
55
+ }
56
+ export declare function createPaymentMethodInfo(params: CardPaymentMethodParams): PaymentMethodCardInfo;
57
+ export declare function createPaymentMethodInfo(params: AccountPaymentMethodParams): PaymentMethodAccountInfo;
58
+ export declare function createPaymentMethodInfo(params: BrokeragePaymentMethodParams): PaymentMethodBrokerageInfo;
59
+ export declare function createPaymentMethodInfo(params: TokenTransferPaymentMethodParams): PaymentMethodTokenTransferInfo;
49
60
  export {};
@@ -0,0 +1,31 @@
1
+ import { CheckoutQuoteResponse } from '@funkit/api-base';
2
+ import { Address } from 'viem';
3
+ import { Config } from 'wagmi';
4
+ import { FunkitActiveCheckoutItem } from '~/providers/FunkitCheckoutContext';
5
+ import { CheckoutFees } from './checkoutFees';
6
+ import { PaymentMethodInfo } from './paymentMethods';
7
+ export type FunkitCheckoutQuoteResult = {
8
+ baseQuote: CheckoutQuoteResponse;
9
+ finalTimeEstimationMs: number;
10
+ finalPaymentTokenAmount: string;
11
+ finalTotalUsd: string;
12
+ finalFeesBreakdown: CheckoutFees;
13
+ };
14
+ export declare function getCheckoutBaseQuote(checkoutItem: FunkitActiveCheckoutItem, userId: string, walletAddress: Address, apiKey: string, sponsorInitialTransferGasLimit: number, wagmiConfig: Config): Promise<CheckoutQuoteResponse>;
15
+ export declare function getQuoteFinalEstimation(baseQuote: CheckoutQuoteResponse, checkoutItem: FunkitActiveCheckoutItem, newPaymentMethodInfo: PaymentMethodInfo, wagmiConfig: Config, apiKey: string, isWeb3Login: boolean): Promise<FunkitCheckoutQuoteResult>;
16
+ export declare function getAvailableAssetAmount(checkoutItem: FunkitActiveCheckoutItem, newPaymentMethodInfo: PaymentMethodInfo, finalEstimation: FunkitCheckoutQuoteResult, wagmiConfig: Config, walletAddress: Address): Promise<number | undefined>;
17
+ export interface CheckoutQuoteParams {
18
+ checkoutItem: FunkitActiveCheckoutItem;
19
+ userId: string;
20
+ walletAddress: Address;
21
+ apiKey: string;
22
+ sponsorInitialTransferGasLimit: number;
23
+ newPaymentMethodInfo: PaymentMethodInfo;
24
+ wagmiConfig: Config;
25
+ isWeb3Login: boolean;
26
+ }
27
+ export declare function getQuoteAndEstimation({ checkoutItem, userId, walletAddress, apiKey, sponsorInitialTransferGasLimit, newPaymentMethodInfo, wagmiConfig, isWeb3Login, }: CheckoutQuoteParams): Promise<{
28
+ baseQuote: CheckoutQuoteResponse;
29
+ finalEstimation: FunkitCheckoutQuoteResult;
30
+ avialableAssetAmount: number | undefined;
31
+ }>;
@@ -1,4 +1,4 @@
1
- export declare function useCheckoutAccountBalanceTransfer(checkoutId: string): {
1
+ export declare function useCheckoutAccountBalanceTransfer(): {
2
2
  generateCheckoutTransferOpItems: (toAddress: string, tokenAmount: number | string) => Promise<{
3
3
  rFunWallet: import("@funkit/core").FunWallet;
4
4
  rFunWalletAuth: import("@funkit/core").Auth;
@@ -1,4 +1,4 @@
1
- export declare function useCheckoutQuoteNotification(checkoutId: string): {
1
+ export declare function useCheckoutQuoteNotification(): {
2
2
  readonly quoteNotification: {
3
3
  readonly messageType: "error";
4
4
  readonly quoteMessage: string;
@@ -1,2 +1,3 @@
1
1
  import { FunAddress } from '@funkit/api-base';
2
- export declare const useCheckoutTransferDepositAddress: (userId: string | undefined, recipientAddress: FunAddress) => `0x${string}` | undefined;
2
+ import { FunkitActiveCheckoutItem } from '~/providers/FunkitCheckoutContext';
3
+ export declare const useCheckoutTransferDepositAddress: (checkoutItem: FunkitActiveCheckoutItem | null, userId: string | undefined, recipientAddr: FunAddress) => `0x${string}` | undefined;
@@ -0,0 +1,2 @@
1
+ import { TokenTransferSourceChainsAndAssets } from '~/modals/CheckoutModal/TransferToken';
2
+ export declare function useEnabledTokenTransferChainTokens(): TokenTransferSourceChainsAndAssets;
@@ -0,0 +1,2 @@
1
+ import { FunkitActiveCheckoutItem } from '~/providers/FunkitCheckoutContext';
2
+ export declare const useIsCheckoutRisky: (checkoutItem: FunkitActiveCheckoutItem | null) => import("@tanstack/react-query").UseQueryResult<boolean, Error>;
@@ -1,41 +1,24 @@
1
1
  import { LinkPayload } from '@meshconnect/web-link-sdk';
2
2
  import React, { ReactNode } from 'react';
3
3
  import { FunSelectOption } from '../components/FunSelect/FunSelect';
4
- import { PaymentMethodBrokerageInfo } from '../domains/paymentMethods';
5
4
  import { MeshExchanges } from '../utils/mesh';
6
5
  export declare const MESH_EXCHANGE_ICON_MAP: Partial<Record<MeshExchanges, (size: number) => ReactNode>>;
7
6
  export declare function getExchangeIcon(exchange: MeshExchanges, size: number): React.ReactNode;
8
7
  export declare const useSupportedExchanges: () => MeshExchanges[];
9
8
  export declare function getExchangeName(exchange: MeshExchanges): string;
10
- export declare const preparePaymentInfo: (meshMeta: LinkPayload, brokerage: MeshExchanges) => PaymentMethodBrokerageInfo;
11
9
  export declare const useMeshExchanges: ({ fullInfo, iconSize, }: {
12
10
  fullInfo?: boolean;
13
11
  iconSize?: number;
14
12
  }) => {
15
13
  options: FunSelectOption[];
16
14
  };
17
- /**
18
- * Fetches mesh-related network information across all chains, given an exchange
19
- * @param exchange The mesh exchange user is currently connected with
20
- */
21
- export declare const useMeshNetworkInfo: (exchange: MeshExchanges) => {
22
- fetchInfo: () => Promise<import("@funkit/api-base").IntegrationNetworkInfo[]>;
23
- };
24
15
  /**
25
16
  * Fetches mesh-related network information based on the active chain user is logged in on, given an exchange
26
17
  * @param exchange The mesh exchange user is currently connected with
27
18
  */
28
- export declare const useMeshActiveNetworkInfo: (exchange?: MeshExchanges) => {
29
- meshNetworkInfo: {
30
- meshSupportedTokens: string[];
31
- meshNetworkId: string | null;
32
- };
33
- fetchInfo: (chainId?: string) => Promise<{
34
- meshSupportedTokens: string[];
35
- meshNetworkId: string | undefined;
36
- } | {
37
- meshSupportedTokens: string[];
38
- meshNetworkId: string | null;
39
- }>;
40
- };
19
+ export declare const useMeshActiveNetworkInfo: (chainId: string | undefined, exchange: MeshExchanges | undefined) => {
20
+ meshSupportedTokens: string[];
21
+ meshNetworkId: string | undefined;
22
+ } | null;
23
+ export declare function useMeshIntegrations(): import("@funkit/api-base").TransferIntegration[] | undefined;
41
24
  export declare function useMeshAccountHoldings(targetChain: string, connection: LinkPayload | null): import("@tanstack/react-query").UseQueryResult<import("../utils/assets").AssetHoldingsMap, Error>;
@@ -0,0 +1,22 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { PaymentMethod, PaymentMethodInfo } from '../domains/paymentMethods';
3
+ export declare const PAYMENT_METHOD_ICONS: {
4
+ brokerage: (size: number) => React.JSX.Element;
5
+ card: (size: number) => React.JSX.Element;
6
+ token_transfer: (size: number) => React.JSX.Element;
7
+ };
8
+ /**
9
+ Reference ENG-716
10
+ * web2 users -> social icon
11
+ * EOA wallet users
12
+ * detect connectors and show builtin icon in SDK
13
+ * if no SDK icons available, show icon from wagmi
14
+ * otherwise show fallback icon EVM
15
+ */
16
+ export declare function usePaymentMethodIcon(paymentMethod: PaymentMethod, iconSize?: number): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
17
+ interface PaymentMethodInfoLabel {
18
+ text: string;
19
+ icon: ReactNode;
20
+ }
21
+ export declare const usePaymentMethodInfoLabel: (methodInfo: PaymentMethodInfo, iconSize?: number) => PaymentMethodInfoLabel;
22
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { KnownAssetBalanceInfo } from '../providers/GeneralWalletProvider';
2
- export declare function useUsableWalletAssetsForCheckout(checkoutId: string): {
2
+ export interface WalletAssets {
3
3
  [assetKey: string]: KnownAssetBalanceInfo;
4
- } | undefined;
4
+ }
5
+ export declare function useUsableWalletAssetsForCheckout(): WalletAssets | undefined;