@funkit/connect 12.21.0 → 12.22.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 (90) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/clients/{chunk-FIJU6HZM.js → chunk-5JVG4MS2.js} +1 -1
  3. package/dist/clients/{chunk-YSQX5Z3F.js → chunk-HGLDKRSQ.js} +40 -8
  4. package/dist/clients/{chunk-6XJV626L.js → chunk-R7I5OO6C.js} +1 -1
  5. package/dist/clients/{chunk-DAMICUCH.js → chunk-UBZOARBX.js} +2 -2
  6. package/dist/clients/{chunk-MTKOZB6U.js → chunk-Y2O77SJO.js} +1 -1
  7. package/dist/clients/fanatics.js +2 -2
  8. package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
  9. package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
  10. package/dist/clients/internal/nado/withdrawalForm.js +3 -3
  11. package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
  12. package/dist/clients/lighter.css +32 -11
  13. package/dist/clients/lighter.js +3 -3
  14. package/dist/clients/mallard.d.ts +34 -1
  15. package/dist/clients/mallard.js +147 -2
  16. package/dist/clients/nado.js +3 -3
  17. package/dist/components/CustomSlot/CustomSlot.d.ts +8 -0
  18. package/dist/components/CustomSlot/CustomSlotBoundary.d.ts +12 -0
  19. package/dist/components/DestinationSelector/DestinationAssetBalanceLabel.d.ts +6 -0
  20. package/dist/components/DestinationSelector/DestinationSelector.css.d.ts +3 -0
  21. package/dist/components/DestinationSelector/DestinationSelector.d.ts +17 -0
  22. package/dist/components/DestinationSelector/DestinationSelectorSkeleton.d.ts +2 -0
  23. package/dist/components/Dropdown/AccountSelectDropdown.d.ts +8 -1
  24. package/dist/components/Dropdown/BaseDropdown.d.ts +3 -1
  25. package/dist/components/Dropdown/BaseDropdownItem.d.ts +3 -1
  26. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +2 -0
  27. package/dist/components/FunTransactionSummary/DestinationLineItems.d.ts +1 -1
  28. package/dist/domains/asset.d.ts +6 -0
  29. package/dist/domains/clientMetadata.d.ts +5 -6
  30. package/dist/domains/convert/balances.d.ts +4 -2
  31. package/dist/domains/destinationAccount.d.ts +14 -0
  32. package/dist/domains/destinationAssetBalance.d.ts +39 -0
  33. package/dist/domains/fees.d.ts +13 -0
  34. package/dist/domains/inputAmountComponentContext.d.ts +11 -0
  35. package/dist/hooks/useConvertBalances.d.ts +3 -1
  36. package/dist/hooks/useDestinationAccountSelector.d.ts +18 -0
  37. package/dist/hooks/useDestinationAssetBalances.d.ts +5 -0
  38. package/dist/hooks/useHighPriceImpactPercent.d.ts +11 -0
  39. package/dist/index.css +32 -11
  40. package/dist/index.d.ts +2 -1
  41. package/dist/index.js +2996 -2298
  42. package/dist/modals/CheckoutModal/InputAmount/InputAmountLayout.d.ts +2 -1
  43. package/dist/modals/CheckoutModal/SourceChange/FlatList.d.ts +2 -8
  44. package/dist/modals/CheckoutModal/SourceChange/SourceList.d.ts +1 -2
  45. package/dist/modals/CheckoutModal/SourceChange/useSourceChangeLayout.d.ts +5 -1
  46. package/dist/providers/FunkitCheckoutContext/types.d.ts +52 -11
  47. package/dist/providers/FunkitConfigContext.d.ts +24 -1
  48. package/dist/shadow-css.js +1 -1
  49. package/dist/utils/checkout.d.ts +1 -0
  50. package/dist/utils/consts.d.ts +1 -0
  51. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  52. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  53. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  54. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  55. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  56. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  57. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  58. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  59. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  60. package/dist/wallets/walletConnectors/index.js +59 -59
  61. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  62. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  63. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  64. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  65. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  66. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  67. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  68. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  69. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  70. package/package.json +7 -7
  71. package/dist/domains/priceImpact.d.ts +0 -14
  72. package/dist/modals/CheckoutModal/SourceChange/PayPal.d.ts +0 -2
  73. package/dist/wallets/walletConnectors/{chunk-CU5J53XR.js → chunk-53MYTA42.js} +3 -3
  74. package/dist/wallets/walletConnectors/{chunk-ZSSSLFQF.js → chunk-65ULY6OC.js} +3 -3
  75. package/dist/wallets/walletConnectors/{chunk-XODA5ESL.js → chunk-A5POD5SV.js} +3 -3
  76. package/dist/wallets/walletConnectors/{chunk-RXRYHMRI.js → chunk-ANODOMIN.js} +3 -3
  77. package/dist/wallets/walletConnectors/{chunk-IWOMSW64.js → chunk-ASTCNVJC.js} +3 -3
  78. package/dist/wallets/walletConnectors/{chunk-U52QO5HF.js → chunk-F45CUFRR.js} +3 -3
  79. package/dist/wallets/walletConnectors/{chunk-YRMBR6NA.js → chunk-FYPQ3HP4.js} +3 -3
  80. package/dist/wallets/walletConnectors/{chunk-BBDNB5TQ.js → chunk-IWPW26AL.js} +3 -3
  81. package/dist/wallets/walletConnectors/{chunk-4FHNLTR3.js → chunk-JJBLW4IU.js} +3 -3
  82. package/dist/wallets/walletConnectors/{chunk-NXWG6FG2.js → chunk-KE4CWI3A.js} +3 -3
  83. package/dist/wallets/walletConnectors/{chunk-BBB2J3US.js → chunk-MWB6LFSG.js} +3 -3
  84. package/dist/wallets/walletConnectors/{chunk-34B7OJNT.js → chunk-OVDCDVFX.js} +3 -3
  85. package/dist/wallets/walletConnectors/{chunk-SR5CZR3L.js → chunk-PPQ6L4K2.js} +3 -3
  86. package/dist/wallets/walletConnectors/{chunk-IA5432IR.js → chunk-RJF2YEZ5.js} +3 -3
  87. package/dist/wallets/walletConnectors/{chunk-RFCZYLNR.js → chunk-RQYEGJKL.js} +3 -3
  88. package/dist/wallets/walletConnectors/{chunk-TRZDAXCQ.js → chunk-TIHTQ3OB.js} +3 -3
  89. package/dist/wallets/walletConnectors/{chunk-ALGPGI6V.js → chunk-TM7UBV3Q.js} +3 -3
  90. package/dist/wallets/walletConnectors/{chunk-HOCKAU5H.js → chunk-USLZMUJ3.js} +3 -3
@@ -5,6 +5,7 @@ interface InputAmountLayoutProps {
5
5
  actionButtonProps: FunButtonProps;
6
6
  fiatCurrencySelector?: ReactNode;
7
7
  amountOptions?: ReactNode;
8
+ customComponent?: ReactNode;
8
9
  amountInput: ReactNode;
9
10
  amountInputSwitch: ReactNode;
10
11
  /** Symbol of the token the switcher displays — mode-dependent (EXACT_IN →
@@ -16,5 +17,5 @@ interface InputAmountLayoutProps {
16
17
  footer?: ReactNode;
17
18
  error?: ErrorNotification;
18
19
  }
19
- export declare function InputAmountLayout({ actionButtonProps, amountOptions, fiatCurrencySelector, amountInput, amountInputSwitch, switcherTokenSymbol, header, footer, error, }: InputAmountLayoutProps): React.JSX.Element;
20
+ export declare function InputAmountLayout({ actionButtonProps, amountOptions, customComponent, fiatCurrencySelector, amountInput, amountInputSwitch, switcherTokenSymbol, header, footer, error, }: InputAmountLayoutProps): React.JSX.Element;
20
21
  export {};
@@ -8,11 +8,6 @@ interface FlatListProps {
8
8
  * doesn't reach into FunkitConfig.
9
9
  */
10
10
  boxClassName: string;
11
- /**
12
- * Label rendered on the `FunDivider` between adjacent groups.
13
- * Omit to render the divider without a label.
14
- */
15
- dividerLabel?: string;
16
11
  /**
17
12
  * Trailing content rendered after the groups, inside the outer Box.
18
13
  * Used by the source-list flat layout to place PayPal at the
@@ -24,8 +19,7 @@ interface FlatListProps {
24
19
  }
25
20
  /**
26
21
  * Pure presentational primitive: a single column of group bodies with
27
- * a divider between adjacent groups and an optional footer. No
28
- * provider/context dependencies — composition lives in the caller.
22
+ * an optional footer. No provider/context dependencies — composition lives in the caller.
29
23
  */
30
- export declare function FlatList({ groups, boxClassName, dividerLabel, footer, testId, }: FlatListProps): React.JSX.Element;
24
+ export declare function FlatList({ groups, boxClassName, footer, testId, }: FlatListProps): React.JSX.Element;
31
25
  export {};
@@ -17,8 +17,7 @@ interface SourceListProps {
17
17
  * Reads translation, funkit config, and the source-list-relevant
18
18
  * Statsig flags directly; runs `buildSourceGroups`; dispatches to the
19
19
  * matching layout primitive — `FlatList` for the non-Swapped path
20
- * (with a PayPal footer + "more" divider label) or `GroupedList` for
21
- * the Swapped path (with optional section labels).
20
+ * or `GroupedList` for the Swapped path (with optional section labels).
22
21
  *
23
22
  * `SourceList` has no DOM of its own; the primitive it returns owns
24
23
  * the outer `data-testid` element.
@@ -1,11 +1,15 @@
1
1
  import type { BoxProps } from '../../../components/Box/Box';
2
+ import { type DestinationAccountSelector } from '../../../hooks/useDestinationAccountSelector';
2
3
  import type { CheckoutModalState } from '../../../modals/CheckoutModal/stepTransition';
3
4
  /**
4
5
  * Layout decisions shared between SourceChange and SourceChangeLoading so the
5
6
  * loading skeleton can't drift from the loaded screen.
6
7
  */
7
- export declare function useSourceChangeLayout(modalState: Pick<CheckoutModalState, 'step' | 'startingStep'>): {
8
+ export declare function useSourceChangeLayout(modalState: Pick<CheckoutModalState, 'step' | 'startingStep'>, { isLoading }?: {
9
+ isLoading?: boolean;
10
+ }): {
8
11
  isTargetAssetSelectable: boolean;
12
+ destinationSelector: DestinationAccountSelector | undefined;
9
13
  showContentDivider: boolean;
10
14
  cryptoCashToggleMarginTop: BoxProps['marginTop'];
11
15
  cryptoCashToggleLabelVariant: 'default' | 'deposit';
@@ -10,8 +10,10 @@ import type { FunCheckoutStep } from '../../modals/CheckoutModal/FunCheckoutStep
10
10
  import type { WithdrawalClient, WithdrawalTransaction } from '../../wallets/Wallet';
11
11
  import type { FunkitCheckoutQuoteResult } from '../FunkitHistoryContext';
12
12
  export type FunkitCheckoutActionParams = ApiFunkitCheckoutActionParams;
13
- import type { AssetClass, DynamicTargetAssetCandidate, TokenInfo } from '@funkit/connect-core';
14
- export type { AssetClass, DynamicTargetAssetCandidate, TokenInfo, } from '@funkit/connect-core';
13
+ import type { AssetClass, DynamicTargetAssetCandidate as CoreDynamicTargetAssetCandidate, TokenInfo } from '@funkit/connect-core';
14
+ export type { AssetClass, TokenInfo } from '@funkit/connect-core';
15
+ export interface DynamicTargetAssetCandidate extends CoreDynamicTargetAssetCandidate {
16
+ }
15
17
  /**
16
18
  * Argument passed to a dynamic {@link FunkitCheckoutConfig.modalTitle} resolver.
17
19
  * Extends {@link TokenInfo} with the active dynamic routing id so titles can be
@@ -22,6 +24,14 @@ export type { AssetClass, DynamicTargetAssetCandidate, TokenInfo, } from '@funki
22
24
  export interface ModalTitleContext extends TokenInfo {
23
25
  dynamicRoutingId?: string;
24
26
  }
27
+ export interface DestinationAccount {
28
+ /** Integrator-defined identity matched by a candidate's destinationAccountId. */
29
+ id: string;
30
+ /** Account label supplied already translated by the integrator. */
31
+ label: string;
32
+ /** Defaults to the SDK account icon when omitted. Not persisted in checkout history. */
33
+ icon?: ReactNode;
34
+ }
25
35
  /**
26
36
  * A token to offer adding to the user's wallet (EIP-747 `wallet_watchAsset`) on
27
37
  * the post-checkout success screen.
@@ -238,18 +248,22 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
238
248
  } | null;
239
249
  /**
240
250
  * Additional rows rendered last in the confirmation screen's payment method
241
- * summary. Called synchronously whenever live amounts change. Read your own
242
- * live data here and set a row's `isLoading` while its data is stale.
243
- * Text is displayed as provided, without translation.
244
- * Return `null` or `[]` to omit rows; only the first 3 are shown.
251
+ * summary. Called synchronously whenever live amounts or the selected target
252
+ * change. Read your own live data here and set a row's `isLoading` while its
253
+ * data is stale. Text is displayed as provided, without translation.
254
+ * Return `null` or `[]` to omit rows; only the first 4 are shown.
245
255
  *
246
256
  * @example
247
- * resolveDestinationLineItems: ({ targetAssetAmount }) => [
257
+ * resolveDestinationLineItems: ({ targetAssetAmount, targetAsset }) => [
248
258
  * {
249
259
  * id: 'initial-margin-usage',
250
260
  * label: { text: 'Initial Margin Usage', tooltip: 'Collateral required to open positions.' },
251
261
  * value: { text: projectInitialMargin(targetAssetAmount), color: 'success' },
252
262
  * },
263
+ * {
264
+ * id: 'margin-balance',
265
+ * component: <MarginBalanceRow symbol={targetAsset.symbol} before="$0" after="$2,000" />,
266
+ * },
253
267
  * ]
254
268
  */
255
269
  resolveDestinationLineItems?: (ctx: DestinationLineItemContext) => DestinationLineItem[] | null;
@@ -683,6 +697,8 @@ interface UseFunkitCheckoutBaseProps {
683
697
  onCheckoutBlocked?: (params: {
684
698
  blockedReason: CheckoutBlockedReason;
685
699
  }) => void;
700
+ /** @deprecated The PayPal source row has been removed, so this callback never fires. This field is ignored. */
701
+ onPolymarketPayPalSwitch?: () => void;
686
702
  /**
687
703
  * @optional fires once the withdrawal has been submitted — after the wallet
688
704
  * transaction is sent or the custom withdrawCallback resolves. `formData`
@@ -776,19 +792,44 @@ export interface LineItemSlot {
776
792
  export interface LineItemValue extends LineItemSlot {
777
793
  color?: LineItemValueColor;
778
794
  }
779
- /** Display-only row rendered in the payment method summary. See `resolveDestinationLineItems`. */
780
- export interface DestinationLineItem {
795
+ /**
796
+ * Display-only row rendered in the payment method summary. See `resolveDestinationLineItems`.
797
+ *
798
+ * Either text styled by the SDK (`label` and `value`), or your own `component`
799
+ * for the whole row, which you style. A component row sits in the same row box,
800
+ * which lays out its top-level children like a label and a value. Shadow DOM mode
801
+ * keeps your page's CSS out of the modal, so style it inline or with the theme's
802
+ * CSS variables (e.g. `var(--rk-colors-secondaryText)`).
803
+ */
804
+ export type DestinationLineItem = {
781
805
  /** Stable identifier — the React key, and the row's `data-testid` as `rk-<id>`. */
782
806
  id: string;
783
807
  label: LineItemSlot;
784
808
  value: LineItemValue;
785
809
  /** Skeletons the value, e.g. while the data behind it is still loading. */
786
810
  isLoading?: boolean;
787
- }
788
- /** Live checkout amounts handed to `resolveDestinationLineItems`. */
811
+ component?: never;
812
+ } | {
813
+ /** Stable identifier — the React key, and the row's `data-testid` as `rk-<id>`. */
814
+ id: string;
815
+ component: ReactNode;
816
+ /** Skeletons the whole row, e.g. while the data behind it is still loading. */
817
+ isLoading?: boolean;
818
+ label?: never;
819
+ value?: never;
820
+ };
821
+ /** Live checkout amounts and the selected target, handed to `resolveDestinationLineItems`. */
789
822
  export interface DestinationLineItemContext {
790
823
  /** Target asset amount in token units (e.g. "1.5" for 1.5 USDC), matching the "You receive" row. */
791
824
  targetAssetAmount: string;
825
+ /** Token the checkout delivers, following the user's pick among dynamic target assets. */
826
+ targetAsset: {
827
+ address: Address;
828
+ chainId: string;
829
+ symbol: string;
830
+ };
831
+ /** ID of the destination account the checkout deposits into, when the checkout offers destination accounts. */
832
+ destinationAccountId?: string;
792
833
  /** Token the user is paying with. `null` fields when no source is selected yet. */
793
834
  sourceTokenSymbol: string | null;
794
835
  sourceTokenAddress: Address | null;
@@ -1,4 +1,5 @@
1
1
  import { type ComponentType, type JSX, type ReactNode } from 'react';
2
+ import type { Address } from 'viem';
2
3
  import type { BluvoExchangeType } from '../consts/bluvo';
3
4
  import type { PaymentMethod } from '../domains/paymentMethods';
4
5
  import type { SourceChangeTopComponentProps } from '../modals/CheckoutModal/stepTransition';
@@ -67,6 +68,21 @@ export interface FunkitTextCustomizationsConfig {
67
68
  virtualFiat?: string;
68
69
  };
69
70
  }
71
+ export interface InputAmountComponentContext {
72
+ /** Plain decimal target-token units, rounded to 5 decimals before fees; '0' when empty. */
73
+ targetAssetAmount: string;
74
+ targetAsset: {
75
+ address: Address;
76
+ chainId: string;
77
+ symbol: string;
78
+ };
79
+ /** ID of the destination account the checkout deposits into, when the checkout offers destination accounts. */
80
+ destinationAccountId?: string;
81
+ /** Selected source token, regardless of payment method; all source fields are null without an address. */
82
+ sourceTokenSymbol: string | null;
83
+ sourceTokenAddress: Address | null;
84
+ sourceChainId: string | null;
85
+ }
70
86
  export interface FunkitUiDestinationConfig {
71
87
  /** What icon (15x15) to show in the `destination` row - defaults to user wallet icon */
72
88
  icon?: ReactNode;
@@ -154,6 +170,13 @@ export interface FunkitUiCustomizationsConfig {
154
170
  inputAmountScreen?: {
155
171
  /** Whether to allow entering an amount of tokens, rather than only USD - defaults to true */
156
172
  allowTokenAmountInput?: boolean;
173
+ /**
174
+ * Renders between quick amounts and You send / You receive on the loaded screen.
175
+ * Called synchronously on every loaded-screen render; return null to hide. Render a child
176
+ * component to use hooks. Style with inline styles or SDK theme CSS variables
177
+ * because host-page styles cannot reach content inside the SDK's shadow DOM.
178
+ */
179
+ customComponent?: (ctx: InputAmountComponentContext) => ReactNode;
157
180
  };
158
181
  selectAssetScreen?: {
159
182
  /** Whether the secondary token symbol is visible - defaults to true */
@@ -248,7 +271,7 @@ export interface FunkitUiCustomizationsConfig {
248
271
  type RequiredExceptCustomComponents<T> = Required<Omit<T & {}, `${string}Component`>>;
249
272
  export type FunkitUiCustomizationsConfigInternal = Required<FunkitUiCustomizationsConfig> & {
250
273
  confirmationScreen: FunkitUiCustomizationsConfig['confirmationScreen'] & Required<Omit<FunkitUiCustomizationsConfig['confirmationScreen'] & {}, 'destinationConfig' | 'selectedRouteConfig' | 'showTokenAmount'>>;
251
- inputAmountScreen: Required<FunkitUiCustomizationsConfig['inputAmountScreen'] & {}>;
274
+ inputAmountScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['inputAmountScreen']>;
252
275
  selectAssetScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['selectAssetScreen']>;
253
276
  transferCryptoScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['transferCryptoScreen']>;
254
277
  withdrawalScreen: RequiredExceptCustomComponents<FunkitUiCustomizationsConfig['withdrawalScreen']>;