@funkit/connect 5.5.11 → 5.5.13-next.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 (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/Dialog/Dialog.d.ts +1 -1
  3. package/dist/components/Dialog/hooks.d.ts +7 -2
  4. package/dist/components/Dropdown/BaseDropdown.css.d.ts +1 -0
  5. package/dist/components/Dropdown/BaseDropdown.d.ts +7 -1
  6. package/dist/components/Dropdown/ChainDropdown.d.ts +3 -1
  7. package/dist/components/Dropdown/TokenAndChainDropdown.d.ts +25 -0
  8. package/dist/components/Dropdown/TokenDropdown.d.ts +3 -1
  9. package/dist/components/FunButton/FunButton.d.ts +1 -1
  10. package/dist/components/FunInput/FunInput.d.ts +9 -4
  11. package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +5 -1
  12. package/dist/components/Icons/New/BlueCircularWalletIcon.d.ts +4 -0
  13. package/dist/components/NewTokenDepositAlert/NewTokenDepositAlert.d.ts +1 -1
  14. package/dist/components/Withdraw/WithdrawContent.d.ts +17 -0
  15. package/dist/components/Withdraw/WithdrawSuccess.d.ts +13 -0
  16. package/dist/domains/quote.d.ts +6 -2
  17. package/dist/domains/relay.d.ts +12 -0
  18. package/dist/hooks/queries/useErc20Asset.d.ts +4 -0
  19. package/dist/hooks/queries/useWithdrawalQuote.d.ts +20 -0
  20. package/dist/hooks/useCheckoutDirectExecution.d.ts +2 -0
  21. package/dist/hooks/useTokenChain.d.ts +18 -0
  22. package/dist/index.css +173 -163
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +20365 -19340
  25. package/dist/modals/CheckoutModal/ConfirmationStep/KatanaBridgeAlert.d.ts +2 -0
  26. package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +2 -1
  27. package/dist/modals/CheckoutModal/InputAmount/useAssetPrice.d.ts +16 -4
  28. package/dist/modals/CheckoutModal/SelectAsset.d.ts +1 -1
  29. package/dist/modals/CheckoutModal/TransferToken/TransferToken.d.ts +1 -4
  30. package/dist/modals/WithdrwalModal/WithdrawalModal.d.ts +13 -0
  31. package/dist/providers/FunkitCheckoutContext.d.ts +36 -2
  32. package/dist/providers/ModalContext.d.ts +6 -0
  33. package/dist/wallets/Wallet.d.ts +13 -0
  34. package/dist/wallets/walletConnectors/index.js +47 -47
  35. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 5.5.13-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - d1133df: support withdrawal
8
+ - Updated dependencies [d1133df]
9
+ - @funkit/api-base@1.9.5-next.0
10
+ - @funkit/chains@0.3.2-next.0
11
+ - @funkit/core@2.3.27-next.0
12
+ - @funkit/fun-relay@0.1.9-next.0
13
+ - @funkit/utils@1.1.4-next.0
14
+ - @funkit/wagmi-tools@3.0.49-next.0
15
+
16
+ ## 5.5.12
17
+
18
+ ### Patch Changes
19
+
20
+ - d6d4de5: feat: katana custom bridge alert
21
+ - c4907c2: feat(connect): gracefully handle empty Meld quotes
22
+
3
23
  ## 5.5.11
4
24
 
5
25
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import { type BoxProps } from '../Box/Box';
3
- export { CHECKOUT_MODAL_BOTTOM_BAR_ID, CHECKOUT_MODAL_TITLE_COUNTDOWN_ID, useBottomSectionRef, useTitleCountdownRef, } from './hooks';
3
+ export { CHECKOUT_MODAL_TITLE_COUNTDOWN_ID, MODAL_BOTTOM_BAR_IDS, useBottomSectionRef, useTitleCountdownRef, } from './hooks';
4
4
  interface DialogProps {
5
5
  open: boolean;
6
6
  onClose: () => void;
@@ -1,4 +1,9 @@
1
- export declare const CHECKOUT_MODAL_BOTTOM_BAR_ID = "checkout-modal-bottom-bar";
2
- export declare function useBottomSectionRef(): HTMLElement | null;
1
+ export declare const MODAL_BOTTOM_BAR_IDS: {
2
+ readonly checkout: "checkout-modal-bottom-bar";
3
+ readonly withdrawal: "withdrawal-modal-bottom-bar";
4
+ };
5
+ type ModalBottomBarIdType = keyof typeof MODAL_BOTTOM_BAR_IDS;
6
+ export declare function useBottomSectionRef(modalBottomBarIdType?: ModalBottomBarIdType): HTMLElement | null;
3
7
  export declare const CHECKOUT_MODAL_TITLE_COUNTDOWN_ID = "checkout-modal-title-countdown";
4
8
  export declare function useTitleCountdownRef(): HTMLElement | null;
9
+ export {};
@@ -1,2 +1,3 @@
1
1
  export declare const BORDER_RADIUS = "dropdown";
2
+ export declare const scrollableDropdownStyles: string;
2
3
  export declare const baseDropdownItemWrapperStyles: string;
@@ -29,6 +29,12 @@ export interface BaseDropdownProps {
29
29
  size?: BaseActiveDropdownItemProps['size'];
30
30
  isLoading?: boolean;
31
31
  label?: string;
32
+ /**
33
+ * If provided, the dropdown will be scrollable and the max height will be set to the provided value.
34
+ * This is useful for dropdowns that have a lot of options and normally would be too tall to fit in the modal and overflow beyond the modal is not supported right now.
35
+ * This values should be set so that the last dropdown item is partially visible to indicate that there are more options.
36
+ */
37
+ maxDropdownHeight?: number;
32
38
  }
33
- declare function BaseDropdown({ activeItemProps, value, options, onOptionSelected, onOpen, renderDropdownOption, searchableOptions, searchPlaceholder, placeholder, resetSearchOnClose, openToTopOnMobile, alwaysOpenToTop, openDropdownFullWidth, isLoading, preloadIconUrls, horizontalIconGap, openDropdownBackgroundColor, size, label, }: BaseDropdownProps): React.JSX.Element;
39
+ declare function BaseDropdown({ activeItemProps, value, options, onOptionSelected, onOpen, renderDropdownOption, searchableOptions, searchPlaceholder, placeholder, resetSearchOnClose, openToTopOnMobile, alwaysOpenToTop, openDropdownFullWidth, isLoading, preloadIconUrls, horizontalIconGap, openDropdownBackgroundColor, size, label, maxDropdownHeight, }: BaseDropdownProps): React.JSX.Element;
34
40
  export default BaseDropdown;
@@ -17,6 +17,8 @@ interface ChainDropdownProps {
17
17
  openDropdownBackgroundColor?: BaseDropdownProps['openDropdownBackgroundColor'];
18
18
  size?: BaseActiveDropdownItemProps['size'];
19
19
  isLoading?: BaseDropdownProps['isLoading'];
20
+ alwaysOpenToTop?: BaseDropdownProps['alwaysOpenToTop'];
21
+ maxDropdownHeight?: BaseDropdownProps['maxDropdownHeight'];
20
22
  }
21
- export declare const ChainDropdown: ({ assets, chainIds: chains, selectedChainId: propSelectedChainId, allowUnselect, onChainSelected, activeItemProps, size, openDropdownBackgroundColor, isLoading, }: ChainDropdownProps) => React.JSX.Element;
23
+ export declare const ChainDropdown: ({ assets, chainIds: chains, selectedChainId: propSelectedChainId, allowUnselect, onChainSelected, activeItemProps, size, openDropdownBackgroundColor, isLoading, alwaysOpenToTop, maxDropdownHeight, }: ChainDropdownProps) => React.JSX.Element;
22
24
  export {};
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import type { TokenTransferSourceChainsAndAssets } from '~/modals/CheckoutModal/TransferToken/TransferToken';
3
+ import type { BaseDropdownProps } from './BaseDropdown';
4
+ interface TokenAndChainDropdownProps {
5
+ isLoading: boolean;
6
+ selectedToken: string;
7
+ selectedChainId: number;
8
+ assets: TokenTransferSourceChainsAndAssets;
9
+ /**
10
+ * Callback fired after token selection
11
+ */
12
+ onTokenSelected: (token: string, chainId?: number, autoUpdate?: boolean) => void;
13
+ /**
14
+ * Callback fired after chain selection
15
+ */
16
+ onChainSelected: (chainId?: number, autoUpdate?: boolean) => void;
17
+ tokenLabel?: string;
18
+ chainLabel?: string;
19
+ alwaysOpenToTop?: boolean;
20
+ maxTokenDropdownHeight?: BaseDropdownProps['maxDropdownHeight'];
21
+ maxChainDropdownHeight?: BaseDropdownProps['maxDropdownHeight'];
22
+ }
23
+ /** Combines together chain and token dropdowns */
24
+ export declare const TokenAndChainDropdown: ({ isLoading, selectedToken, selectedChainId, assets, onTokenSelected, onChainSelected, tokenLabel, chainLabel, alwaysOpenToTop, maxTokenDropdownHeight, maxChainDropdownHeight, }: TokenAndChainDropdownProps) => React.JSX.Element;
25
+ export {};
@@ -11,6 +11,8 @@ interface TokenDropdownProps {
11
11
  autoUpdate?: boolean) => void;
12
12
  selectedToken?: string;
13
13
  isLoading?: BaseDropdownProps['isLoading'];
14
+ alwaysOpenToTop?: BaseDropdownProps['alwaysOpenToTop'];
15
+ maxDropdownHeight?: BaseDropdownProps['maxDropdownHeight'];
14
16
  }
15
- export declare const TokenDropdown: ({ assets, selectedChainId, selectedToken, onTokenSelected, isLoading, }: TokenDropdownProps) => React.JSX.Element;
17
+ export declare const TokenDropdown: ({ assets, selectedChainId, selectedToken, onTokenSelected, isLoading, alwaysOpenToTop, maxDropdownHeight, }: TokenDropdownProps) => React.JSX.Element;
16
18
  export {};
@@ -1,6 +1,6 @@
1
1
  import React, { type MouseEventHandler } from 'react';
2
2
  import { type BoxProps } from '../Box/Box';
3
- export type FunButtonTypes = 'primary' | 'secondary' | 'tertiary';
3
+ export type FunButtonTypes = 'primary' | 'secondary' | 'tertiary' | 'tertiary-small';
4
4
  export interface FunButtonProps {
5
5
  id?: string;
6
6
  title: string;
@@ -1,6 +1,6 @@
1
- import React, { type HTMLInputTypeAttribute, type ReactNode } from 'react';
1
+ import React, { type ChangeEvent, type HTMLInputTypeAttribute, type ReactNode } from 'react';
2
2
  import { type BoxProps } from '../Box/Box';
3
- export interface FunInputProps<T = HTMLInputElement> {
3
+ export interface FunInputProps<T = HTMLInputElement | HTMLTextAreaElement> {
4
4
  prefix?: ReactNode;
5
5
  suffix?: ReactNode;
6
6
  prefixIcon?: 'SearchIcon' | '$';
@@ -8,10 +8,12 @@ export interface FunInputProps<T = HTMLInputElement> {
8
8
  value: string | number | readonly string[] | undefined;
9
9
  label?: string;
10
10
  onChange: (value: React.ChangeEvent<T>) => void;
11
- onKeyDown?: (e: React.KeyboardEvent<T>) => void;
11
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>) => void;
12
12
  onKeySubmit?: () => void;
13
13
  onPaste?: (e: React.ClipboardEvent<T>) => void;
14
14
  onMouseDown?: (e: React.MouseEvent<T>) => void;
15
+ onFocus?: () => void;
16
+ onBlur?: () => void;
15
17
  inputStyle?: React.CSSProperties;
16
18
  inputProps?: React.HTMLProps<T> & {
17
19
  type?: HTMLInputTypeAttribute;
@@ -25,5 +27,8 @@ export interface FunInputProps<T = HTMLInputElement> {
25
27
  overrideBackground?: BoxProps['background'];
26
28
  borderRadius?: BoxProps['borderRadius'];
27
29
  isLoading?: boolean;
30
+ /** Allow multiline input. Defaults to false. This option replaces the internal `input` element with a `textarea` element. */
31
+ allowMultiline?: boolean;
28
32
  }
29
- export declare const FunInput: React.ForwardRefExoticComponent<FunInputProps<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
33
+ export type FunInputChangeEvent = ChangeEvent<HTMLInputElement | HTMLTextAreaElement>;
34
+ export declare const FunInput: React.ForwardRefExoticComponent<FunInputProps<HTMLTextAreaElement | HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
+ import type { CheckoutFees } from '~/domains/fees';
2
3
  import type { FunkitCheckoutQuoteResult } from '~/domains/quote';
3
4
  interface PaymentFeesSummaryProps {
4
5
  isLoading: boolean;
5
6
  quote: FunkitCheckoutQuoteResult | null | undefined;
7
+ /** If set and quote is missing, display fees based on this data */
8
+ fallbackFees?: CheckoutFees;
9
+ showWithdrawalBreakdown?: boolean;
6
10
  }
7
- export declare function PaymentFeesSummary({ isLoading, quote, }: PaymentFeesSummaryProps): React.JSX.Element;
11
+ export declare function PaymentFeesSummary({ isLoading, quote, fallbackFees, showWithdrawalBreakdown, }: PaymentFeesSummaryProps): React.JSX.Element;
8
12
  export {};
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const BlueCircularWalletIcon: ({ size }: {
3
+ size?: number;
4
+ }) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { TransferTokenDefault } from '~/modals/CheckoutModal/TransferToken/TransferToken';
2
+ import type { TransferTokenDefault } from '~/hooks/useTokenChain';
3
3
  interface NewTokenDepositAlertProps {
4
4
  onClick: (value: TransferTokenDefault) => void;
5
5
  }
@@ -0,0 +1,17 @@
1
+ import { type CheckoutQuoteResponse } from '@funkit/utils';
2
+ import React from 'react';
3
+ import type { Address } from 'viem';
4
+ import type { FunkitWithdrawalConfig } from '~/providers/FunkitCheckoutContext';
5
+ export type WithdrawalFormData = {
6
+ destinationAddress: Address;
7
+ amount: string;
8
+ token: string;
9
+ chainId: number;
10
+ quote: CheckoutQuoteResponse;
11
+ };
12
+ interface WithdrawContentProps {
13
+ onContinue: (withdrawal: WithdrawalFormData) => void;
14
+ config: FunkitWithdrawalConfig;
15
+ }
16
+ export declare const WithdrawContent: ({ onContinue, config, }: WithdrawContentProps) => React.JSX.Element;
17
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface WithdrawSuccessProps {
3
+ amount: number;
4
+ token: string;
5
+ tokenIconSrc: string;
6
+ chainId: string;
7
+ txHash: string;
8
+ bottomBarId: string;
9
+ onNewWithdrawal: () => void;
10
+ onClose: () => void;
11
+ }
12
+ export declare const WithdrawSuccess: ({ amount, token, tokenIconSrc, chainId, txHash, bottomBarId, onNewWithdrawal, onClose, }: WithdrawSuccessProps) => React.JSX.Element;
13
+ export {};
@@ -10,7 +10,7 @@ export interface FunkitCheckoutQuoteResult extends Omit<ApiFunkitCheckoutQuoteRe
10
10
  finalSpreadUsd: string;
11
11
  finalFeesBreakdown: CheckoutFees;
12
12
  }
13
- export declare function getCheckoutBaseQuote(checkoutItem: FunkitActiveCheckoutItem, userId: string, walletAddress: Address, apiKey: string, sponsorInitialTransferGasLimit: number, wagmiConfig: Config, directExecutionInfo: FunkitDirectExecutionInfo): Promise<CheckoutQuoteResponse>;
13
+ export declare function getCheckoutBaseQuote(checkoutItem: FunkitActiveCheckoutItem, userId: string, walletAddress: Address, apiKey: string, sponsorInitialTransferGasLimit: number, wagmiConfig: Config, directExecutionInfo: FunkitDirectExecutionInfo, senderAddress?: Address): Promise<CheckoutQuoteResponse>;
14
14
  export declare function getQuoteFinalEstimation(baseQuote: CheckoutQuoteResponse, checkoutItem: FunkitActiveCheckoutItem, newPaymentMethodInfo: PaymentMethodInfo, wagmiConfig: Config, apiKey: string, loginType: LoginType, enableFrogProxyServer?: boolean): Promise<{
15
15
  finalEstimation: FunkitCheckoutQuoteResult;
16
16
  brokerage?: BrokerageDetails;
@@ -33,8 +33,12 @@ export interface CheckoutQuoteParams {
33
33
  loginType: LoginType;
34
34
  enableFrogProxyServer?: boolean;
35
35
  directExecutionInfo: FunkitDirectExecutionInfo;
36
+ /** when sender address is different from wallet address
37
+ * this happens when withdrawing from a different wallet
38
+ **/
39
+ senderAddress?: Address;
36
40
  }
37
- export declare function getQuoteAndEstimation({ checkoutItem, userId, walletAddress, apiKey, sponsorInitialTransferGasLimit, newPaymentMethodInfo, wagmiConfig, loginType, enableFrogProxyServer, directExecutionInfo, }: CheckoutQuoteParams): Promise<{
41
+ export declare function getQuoteAndEstimation({ checkoutItem, userId, walletAddress, apiKey, sponsorInitialTransferGasLimit, newPaymentMethodInfo, wagmiConfig, loginType, enableFrogProxyServer, directExecutionInfo, senderAddress, }: CheckoutQuoteParams): Promise<{
38
42
  baseQuote: CheckoutQuoteResponse;
39
43
  checkedAssetAmount: CheckedAssetAmount;
40
44
  finalEstimation: FunkitCheckoutQuoteResult;
@@ -0,0 +1,12 @@
1
+ import type { RelayQuote } from '@funkit/fun-relay';
2
+ export declare const KATANA_BRIDGE_ALERT_THRESHOLD_PERCENT = 0.5;
3
+ export declare function extractRelayFeeInfo(relayQuote: RelayQuote['metadata']['relayQuote']): {
4
+ gasUsd: number;
5
+ chainName: string | undefined;
6
+ totalImpact: number;
7
+ swapImpact: number;
8
+ relayGas: number;
9
+ appFeePercent: number;
10
+ maxSlippage: number;
11
+ minReceived: number;
12
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useErc20Asset: ({ chainId, symbol, }: {
2
+ chainId: string | undefined;
3
+ symbol: string | undefined;
4
+ }) => import("@tanstack/react-query").UseQueryResult<import("@funkit/api-base").Erc20AssetInfo | null, Error>;
@@ -0,0 +1,20 @@
1
+ import { type Address } from 'viem';
2
+ import type { WithdrawalClient } from '~/wallets/Wallet';
3
+ interface CheckoutQuoteParams {
4
+ recipientAddress: Address;
5
+ sourceAmount: number;
6
+ chainId: string;
7
+ symbol: string;
8
+ targetAsset: Address | undefined;
9
+ targetAssetAmount: number | undefined;
10
+ withdrawalClient: WithdrawalClient;
11
+ }
12
+ /**
13
+ * Simplified quoting logic used for withdrawal UI only.
14
+ */
15
+ export declare function useWithdrawalQuote({ recipientAddress, sourceAmount, chainId, symbol, targetAsset, targetAssetAmount, withdrawalClient, }: CheckoutQuoteParams): import("@tanstack/react-query").UseQueryResult<{
16
+ baseQuote: import("@funkit/utils").CheckoutQuoteResponse;
17
+ checkedAssetAmount: import("~/domains/quote").CheckedAssetAmount;
18
+ finalEstimation: import("~/domains/quote").FunkitCheckoutQuoteResult;
19
+ } | null, Error>;
20
+ export {};
@@ -13,6 +13,7 @@ interface DirectExecutionQuoteRequestParams {
13
13
  fromChainId: string;
14
14
  fromTokenAddress: Address;
15
15
  recipientAddress: Address;
16
+ senderAddress?: Address;
16
17
  }
17
18
  interface DirectExecutionStartParams {
18
19
  checkoutItem: FunkitActiveCheckoutItem;
@@ -28,6 +29,7 @@ export interface FunkitDirectExecutionInfo {
28
29
  }
29
30
  interface UseCheckoutDirectExecutionReturn {
30
31
  getDirectExecutionInfo: (checkoutItem: FunkitActiveCheckoutItem | null) => FunkitDirectExecutionInfo;
32
+ getWithdrawalDirectExecution: () => FunkitDirectExecutionInfo;
31
33
  }
32
34
  export declare function isVertexDirectExecution({ apiKey, config, paymentMethod, sourceAsset, sourceChain, targetAsset, targetChain, }: {
33
35
  apiKey: string;
@@ -0,0 +1,18 @@
1
+ import type { TokenTransferSourceChainsAndAssets } from '~/modals/CheckoutModal/TransferToken/TransferToken';
2
+ export type TransferTokenDefault = {
3
+ token: string;
4
+ chainId: number;
5
+ };
6
+ interface UseTokenChainResult {
7
+ assets: TokenTransferSourceChainsAndAssets;
8
+ selectedChainId: number;
9
+ handleChainChange: (chainId?: number, autoUpdate?: boolean) => void;
10
+ selectedToken: string;
11
+ handleTokenChange: (token: string, chainId?: number, autoUpdate?: boolean) => void;
12
+ }
13
+ /**
14
+ * Semi reusable hook (tied into token transfer configuration)
15
+ * ensures token&chain dropdown preselection logic is reusable
16
+ */
17
+ export declare const useTokenAndChainSelection: (defaultValues?: TransferTokenDefault) => UseTokenChainResult;
18
+ export {};