@funkit/connect 9.16.0 → 9.18.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 (31) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/__generated__/default_configs.d.ts +42 -0
  3. package/dist/components/AnimatedDollarValue/AnimatedDollarValue.d.ts +1 -1
  4. package/dist/components/CopyAddress/CopyAddressButton.d.ts +1 -1
  5. package/dist/components/CopyAddress/OldCopyAddressButton.d.ts +1 -1
  6. package/dist/components/FunInfoBanner/ChainInfoBanners.d.ts +1 -1
  7. package/dist/components/Icons/StatusIcons.d.ts +1 -1
  8. package/dist/domains/checkoutErrors.d.ts +22 -0
  9. package/dist/domains/dynamicRouting.d.ts +24 -0
  10. package/dist/hooks/queries/useLightningQuote.d.ts +13 -3
  11. package/dist/hooks/useAssetPrice.d.ts +9 -3
  12. package/dist/index.css +5 -3
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +2026 -1610
  15. package/dist/modals/CheckoutModal/CheckoutModalPrefetchedHooks.d.ts +7 -0
  16. package/dist/modals/CheckoutModal/ConfirmationStep/useCheckoutConfirmation.d.ts +1 -22
  17. package/dist/modals/CheckoutModal/InputAmount/useAaveNativeSupply.d.ts +82 -10
  18. package/dist/modals/CheckoutModal/LightningInvoice/LightningInvoice.d.ts +0 -1
  19. package/dist/modals/CheckoutModal/LightningInvoice/LightningInvoiceQrCode.d.ts +8 -0
  20. package/dist/modals/CheckoutModal/SelectAsset/SelectAsset.d.ts +4 -0
  21. package/dist/modals/CheckoutModal/SourceChange/SourceChangeLoading.d.ts +1 -1
  22. package/dist/modals/WithdrawalModal/ErrorMessage.d.ts +1 -1
  23. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +1 -1
  24. package/dist/providers/FunkitCheckoutContext/index.d.ts +2 -6
  25. package/dist/providers/FunkitCheckoutContext/types.d.ts +14 -2
  26. package/dist/providers/FunkitQuoteContext.d.ts +16 -0
  27. package/dist/utils/purifyCheckoutHistoryItem.d.ts +14 -0
  28. package/dist/wagmi/actions.d.ts +1 -1
  29. package/dist/wagmi/chains.d.ts +1 -1
  30. package/dist/wallets/walletConnectors/index.js +20 -20
  31. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 9.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8baaa78: Pass the active `dynamicRoutingId` to dynamic `modalTitle` resolvers. The `modalTitle` callback now receives a `ModalTitleContext` (`TokenInfo` + optional `dynamicRoutingId`) instead of just `TokenInfo`, so integrators can key the checkout title by route/action — not only the target token address. This is required when two routes share a target token (e.g. Lighter USDC perps vs spot, which both deposit mainnet USDC for new users). The change is backwards compatible: existing `(asset: TokenInfo) => string` resolvers remain assignable. The `ModalTitleContext` type is now exported from the package root so integrators can annotate their resolver.
8
+
9
+ ### Patch Changes
10
+
11
+ - deefef3: Aave native supply USDT zero-reset now reads allowance via the public client (not the wallet client) and waits for the `approve(0)` receipt before the SDK's `approve(amount)`, avoiding nonce collisions on `latest`-based RPCs.
12
+ - c5c0183: Translate Aave native-supply wallet errors into human-readable messages
13
+ - 98b196e: fix(connect): make the post-checkout "Add to wallet" chip readable in dark mode by deriving its background from the `modalBackground` theme token via `color-mix()` (with an opaque fallback) instead of a hardcoded translucent white.
14
+ - 0f4c245: fix: adjust lightning qrcode scannability
15
+ - 30a626e: Freeze the amount input while an Aave native-supply transaction is confirming
16
+ - e42f6b0: feat: add min limit for btc lightning path on input screen
17
+ - b10dd58: test(connect): test useMinDeposit
18
+ - dd1c42b: chore: sort named import members via oxlint sort-imports
19
+ - 453c797: test(connect): test WithdrawAmountInput
20
+ - Updated dependencies [8baaa78]
21
+ - @funkit/fun-relay@2.8.0
22
+
23
+ ## 9.17.0
24
+
25
+ ### Minor Changes
26
+
27
+ - d7f8e35: Aave native supply honors the approval-method toggle: `supplyWithPermit` when the user picks "Signed message" and the reserve supports EIP-2612, else `approve + supply` (with USDT zero-reset on stale allowance). The toggle is hidden for native assets that can't permit (USDT, WBTC).
28
+ - 4c7b8b5: Add isWithdrawal and Lighter fast/secure withdrawal type to purified checkout history items
29
+
30
+ ### Patch Changes
31
+
32
+ - 20ed7f5: Record the real supply amount, USD value, and deposit timestamp on Aave native Direct Execution records (was `$0` total and a negative run time in fits).
33
+ - 20ed7f5: Persist the supplied amount on Aave native Direct Execution records so the checkout success screen's "You receive" shows the real amount instead of 0.
34
+ - 3e6c69d: test(connect): test SelectAsset component
35
+ - 0fc5f37: feat: integrate lightning quote prefetch
36
+ - 62c6bab: test(connect): test useCheckoutTimeEstimate
37
+ - dc5f538: test(connect): test useBluvo
38
+ - e9ae127: test(connect): test stepTransition
39
+ - cd5b590: test(connect): test usePostCheckout
40
+ - 59b02dd: test(connect): test useAccountBalancePostCheckout
41
+ - a4d5a9b: Reformat packages with oxfmt
42
+ - aa9f1ee: test(connect): test useAvailableBalanceForCheckout
43
+ - 769bae0: test(connect): stabilize useBluvo with getTokenDecimals mock
44
+ - 3e588fc: test(connect): test useSourceAssetConfirm
45
+ - 7076a2a: test(connect): test useCheckoutQuote
46
+ - 7690c31: test(connect): test useTokenTransfer
47
+ - Updated dependencies [20ed7f5]
48
+ - Updated dependencies [a4d5a9b]
49
+ - @funkit/api-base@4.4.1
50
+ - @funkit/utils@3.0.2
51
+ - @funkit/fun-relay@2.7.4
52
+
3
53
  ## 9.16.0
4
54
 
5
55
  ### Minor Changes
@@ -120,6 +120,31 @@ declare const _default: {
120
120
  readonly path: "RL_TRANSFER";
121
121
  };
122
122
  }];
123
+ }, {
124
+ readonly routeId: "LIGHTER_USDC_SPOT";
125
+ readonly rules: readonly [{
126
+ readonly when: {
127
+ readonly chainId: "1";
128
+ readonly tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
129
+ };
130
+ readonly use: {
131
+ readonly path: "FUN_MAINNET_DEPOSIT";
132
+ readonly badge: "NATIVE";
133
+ };
134
+ }, {
135
+ readonly when: {
136
+ readonly chainId: "1";
137
+ readonly tokenAddress: "*";
138
+ };
139
+ readonly use: {
140
+ readonly path: "FUN_MAINNET_DEPOSIT";
141
+ };
142
+ }, {
143
+ readonly when: "*";
144
+ readonly use: {
145
+ readonly path: "RL_TRANSFER";
146
+ };
147
+ }];
123
148
  }, {
124
149
  readonly routeId: "LIGHTER_USDC_PERPS_NEW_USER";
125
150
  readonly rules: readonly [{
@@ -137,6 +162,23 @@ declare const _default: {
137
162
  readonly path: "FUN_MAINNET_DEPOSIT";
138
163
  };
139
164
  }];
165
+ }, {
166
+ readonly routeId: "LIGHTER_USDC_SPOT_NEW_USER";
167
+ readonly rules: readonly [{
168
+ readonly when: {
169
+ readonly chainId: "1";
170
+ readonly tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
171
+ };
172
+ readonly use: {
173
+ readonly path: "FUN_MAINNET_DEPOSIT";
174
+ readonly badge: "NATIVE";
175
+ };
176
+ }, {
177
+ readonly when: "*";
178
+ readonly use: {
179
+ readonly path: "FUN_MAINNET_DEPOSIT";
180
+ };
181
+ }];
140
182
  }, {
141
183
  readonly routeId: "LIGHTER_ETH_SPOT_NEW_USER";
142
184
  readonly rules: readonly [{
@@ -1,4 +1,4 @@
1
- import { type NumberFlowProps, type NumberFlowElement } from '@number-flow/react';
1
+ import { type NumberFlowElement, type NumberFlowProps } from '@number-flow/react';
2
2
  import React from 'react';
3
3
  type AnimatedDollarValueProps = Omit<NumberFlowProps, 'format'> & {
4
4
  ref?: React.Ref<NumberFlowElement>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  /** Simple button to copy the provided address */
3
- export declare function CopyAddressButton({ address, }: {
3
+ export declare function CopyAddressButton({ address }: {
4
4
  address: string;
5
5
  }): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  /** Use this button only in the old design components, for the future we should use `CopyAddressButton` which has a new design */
3
- export declare function OldCopyAddressButton({ address, }: {
3
+ export declare function OldCopyAddressButton({ address }: {
4
4
  address: string;
5
5
  }): React.JSX.Element;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  /**
3
3
  * Renders only banners for currently selected chain
4
4
  */
5
- export declare const ChainInfoBanners: ({ chainId, }: {
5
+ export declare const ChainInfoBanners: ({ chainId }: {
6
6
  chainId: number;
7
7
  }) => (React.JSX.Element | null)[] | null;
@@ -1,4 +1,4 @@
1
- import React, { type SVGAttributes, type RefObject } from 'react';
1
+ import React, { type RefObject, type SVGAttributes } from 'react';
2
2
  export declare function CompletedStatusIcon(props: StatusIconProps): React.JSX.Element;
3
3
  export declare function FailedStatusIcon(props: StatusIconProps): React.JSX.Element;
4
4
  export declare function DelayedStatusIcon(props: StatusIconProps): React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ import type { TFunction } from 'i18next';
2
+ import type { ErrorNotification } from '../components/FunNotification/FunNotification';
3
+ import type { Config, Connector } from '../wagmi/hooks';
4
+ export interface CheckoutConfirmationError extends ErrorNotification {
5
+ durationMs?: number;
6
+ code: ConfirmationErrorCode;
7
+ }
8
+ export declare enum ConfirmationErrorCode {
9
+ QUOTE_EXPIRED = "QUOTE_EXPIRED",
10
+ GENERIC_ERROR = "GENERIC_ERROR",
11
+ WITHDRAWAL_RATE_LIMIT_EXCEEDED = "WITHDRAWAL_RATE_LIMIT_EXCEEDED",
12
+ RISK_ERROR = "RISK_ERROR",
13
+ SIGNATURE_DENIED = "SIGNATURE_DENIED",
14
+ SWITCH_CHAIN_ERROR = "SWITCH_CHAIN_ERROR",
15
+ WALLET_CLIENT_UNDEFINED = "WALLET_CLIENT_UNDEFINED",
16
+ INSUFFICIENT_GAS = "INSUFFICIENT_GAS",
17
+ POLYGON_RPC_ERROR = "POLYGON_RPC_ERROR"
18
+ }
19
+ export declare function toCheckoutConfirmationError(t: TFunction, error: unknown, wagmiConfig: Config, options?: {
20
+ fromChainId?: string;
21
+ connector?: Connector;
22
+ }): Promise<CheckoutConfirmationError>;
@@ -0,0 +1,24 @@
1
+ import type { DynamicRoutePath } from '@funkit/fun-relay';
2
+ import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
3
+ /**
4
+ * The path shape accepted by {@link mergeDynamicRoutingIntoConfig} /
5
+ * `applyDynamicRouting`. It is a {@link DynamicRoutePath} with the
6
+ * already-bound callbacks (`customRecipient`, `generateActionsParams`) and
7
+ * optional routing context layered on top.
8
+ */
9
+ export type ApplyDynamicRoutingPath = Omit<DynamicRoutePath, 'getCustomRecipient' | 'generateActionsParams'> & {
10
+ customRecipient?: FunkitCheckoutConfig['customRecipient'];
11
+ generateActionsParams?: FunkitCheckoutConfig['generateActionsParams'];
12
+ bridgeOverride?: FunkitCheckoutConfig['bridgeOverride'];
13
+ dynamicRoutingId?: FunkitCheckoutConfig['dynamicRoutingId'];
14
+ };
15
+ /**
16
+ * Merge a resolved dynamic-routing path into a checkout config.
17
+ *
18
+ * The `dynamicRoutingId` is kept in lockstep with the target it selects: when
19
+ * the path carries one it wins, otherwise the config's existing id is
20
+ * preserved. This is what guarantees that anything keyed off
21
+ * `dynamicRoutingId` (e.g. the modal title) can't drift away from the active
22
+ * route when the target asset/chain is rebound.
23
+ */
24
+ export declare function mergeDynamicRoutingIntoConfig(config: FunkitCheckoutConfig, path: ApplyDynamicRoutingPath): FunkitCheckoutConfig;
@@ -1,11 +1,21 @@
1
- import type { Address } from 'viem';
1
+ import { type LightningQuoteResponse } from '@funkit/api-base';
2
+ import { type Address } from 'viem';
2
3
  import type { GeneralWalletContextProps } from '../../providers/GeneralWalletProvider';
4
+ export declare function usdToSats(usd: number | undefined, btcPrice: number | undefined): bigint | undefined;
3
5
  type UseLightningQuoteParams = {
4
6
  depositAddr: Address | undefined;
5
7
  walletAddress: GeneralWalletContextProps['walletAddress'];
6
8
  targetChain: string | undefined;
7
9
  targetAsset: Address | undefined;
8
- fromAmountSats: bigint | undefined;
10
+ fiatAmount: number | undefined;
9
11
  };
10
- export declare const useLightningQuote: ({ depositAddr, walletAddress, targetChain, targetAsset, fromAmountSats, }: UseLightningQuoteParams) => import("@tanstack/react-query").UseQueryResult<import("@funkit/api-base").LightningQuoteResponse, Error>;
12
+ /**
13
+ * Holds the displayed invoice until its real `expiresAtMs`, then reveals the
14
+ * prefetched replacement. `useLightningQuote` prefetches the next invoice early,
15
+ * so revealing it on arrival would reset the QR/timer while the current invoice
16
+ * is still valid.
17
+ *
18
+ */
19
+ export declare function useDeferredQuote(latestQuote: LightningQuoteResponse | undefined): LightningQuoteResponse | undefined;
20
+ export declare const useLightningQuote: ({ depositAddr, walletAddress, targetChain, targetAsset, fiatAmount, }: UseLightningQuoteParams) => import("@tanstack/react-query").UseQueryResult<LightningQuoteResponse, Error>;
11
21
  export {};
@@ -1,9 +1,15 @@
1
- import { type Erc20AssetInfo } from '@funkit/api-base';
1
+ import { type Erc20AssetInfo, type GetAssetPriceInfoResponse } from '@funkit/api-base';
2
2
  import type { Address } from 'viem';
3
+ export declare function getAssetPriceInfoWithFallback({ apiKey, chainId, assetTokenAddress, }: {
4
+ apiKey: string;
5
+ chainId: string;
6
+ assetTokenAddress: Address;
7
+ }): Promise<GetAssetPriceInfoResponse>;
3
8
  interface UseAssetAddressPriceParams {
4
9
  chainId: string | undefined;
5
10
  assetTokenAddress: Address | undefined;
6
- refetchInterval?: number;
11
+ /** Pass `false` to fetch once and disable interval polling. */
12
+ refetchInterval?: number | false;
7
13
  /** defaults to 1 hence price returned is unit price */
8
14
  amount?: number;
9
15
  /** Asset symbol — when provided and the symbol is a stablecoin, price is hardcoded to 1 */
@@ -21,7 +27,7 @@ export declare function useAssetAddressPrice({ chainId, assetTokenAddress, amoun
21
27
  type AssetSymbolPriceParams = {
22
28
  chainId: string | undefined;
23
29
  symbol: string | undefined;
24
- refetchInterval?: number;
30
+ refetchInterval?: number | false;
25
31
  /** Disable the query without changing other inputs. Defaults to true. */
26
32
  enabled?: boolean;
27
33
  };
package/dist/index.css CHANGED
@@ -15346,12 +15346,14 @@
15346
15346
  border-top-width: 0;
15347
15347
  }
15348
15348
 
15349
- /* vanilla-extract-css-ns:src/components/FunCheckoutHistory/AddTokenToWalletButton.css.ts.vanilla.css?source=Ll8xc3R1dWtyMCB7CiAgYmFja2dyb3VuZDogcmdiYSgyNTUsIDI1NSwgMjU1LCAwLjcpOwp9Ci5fMXN0dXVrcjA6aG92ZXIgewogIGJhY2tncm91bmQ6IHJnYmEoMjU1LCAyNTUsIDI1NSwgMC45KTsKfQ== */
15349
+ /* vanilla-extract-css-ns:src/components/FunCheckoutHistory/AddTokenToWalletButton.css.ts.vanilla.css?source=Ll8xc3R1dWtyMCB7CiAgYmFja2dyb3VuZDogdmFyKC0tcmstY29sb3JzLW1vZGFsQmFja2dyb3VuZCk7CiAgYmFja2dyb3VuZDogY29sb3ItbWl4KGluIHNyZ2IsIHZhcigtLXJrLWNvbG9ycy1tb2RhbEJhY2tncm91bmQpIDcwJSwgdHJhbnNwYXJlbnQpOwp9Ci5fMXN0dXVrcjA6aG92ZXIgewogIGJhY2tncm91bmQ6IHZhcigtLXJrLWNvbG9ycy1tb2RhbEJhY2tncm91bmQpOwogIGJhY2tncm91bmQ6IGNvbG9yLW1peChpbiBzcmdiLCB2YXIoLS1yay1jb2xvcnMtbW9kYWxCYWNrZ3JvdW5kKSA5MCUsIHRyYW5zcGFyZW50KTsKfQ== */
15350
15350
  [data-rk] ._1stuukr0 {
15351
- background: rgba(255, 255, 255, 0.7);
15351
+ background: var(--rk-colors-modalBackground);
15352
+ background: color-mix(in srgb, var(--rk-colors-modalBackground) 70%, transparent);
15352
15353
  }
15353
15354
  [data-rk] ._1stuukr0:hover {
15354
- background: rgba(255, 255, 255, 0.9);
15355
+ background: var(--rk-colors-modalBackground);
15356
+ background: color-mix(in srgb, var(--rk-colors-modalBackground) 90%, transparent);
15355
15357
  }
15356
15358
 
15357
15359
  /* vanilla-extract-css-ns:src/components/FunCheckoutHistory/FunCheckoutHistoryTransaction.css.ts.vanilla.css?source=Lm14dmF0aTAgewogIGN1cnNvcjogcG9pbnRlcjsKfQoubXh2YXRpMDpmb2N1cy12aXNpYmxlIHsKICBvdXRsaW5lOiAxcHggc29saWQ7CiAgb3V0bGluZS1jb2xvcjogdmFyKC0tcmstY29sb3JzLXRlcnRpYXJ5VGV4dCk7Cn0= */
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { createAuthenticationAdapter, FunkitConnectAuthenticationProvider, } fro
20
20
  export type { AuthenticationAdapter, FunkitConnectAuthenticationProviderProps, } from './providers/AuthenticationContext';
21
21
  export type { AvatarComponent } from './providers/AvatarContext';
22
22
  export type { CheckoutBlockedReason } from './modals/CheckoutModal/CheckoutBlockedReason';
23
- export type { FunkitCheckoutActionParams, FunkitCheckoutConfig, FunkitCheckoutOnCloseResult, FunkitWithdrawalConfig, WalletWithdrawalConfig, CustomWithdrawalConfig, MultiMethodWithdrawalConfig, WithdrawalMethodOption, WithdrawalParam, UseFunkitCheckoutPropsWithFullConfig, UseFunkitCheckoutProps, FunkitCheckoutValidationResult, FunkitCheckoutResult, DynamicTargetAssetCandidate, AddToWalletToken, TokenInfo, } from './providers/FunkitCheckoutContext';
23
+ export type { FunkitCheckoutActionParams, FunkitCheckoutConfig, FunkitCheckoutOnCloseResult, FunkitWithdrawalConfig, WalletWithdrawalConfig, CustomWithdrawalConfig, MultiMethodWithdrawalConfig, WithdrawalMethodOption, WithdrawalParam, UseFunkitCheckoutPropsWithFullConfig, UseFunkitCheckoutProps, FunkitCheckoutValidationResult, FunkitCheckoutResult, DynamicTargetAssetCandidate, AddToWalletToken, TokenInfo, ModalTitleContext, } from './providers/FunkitCheckoutContext';
24
24
  export { useFunkitCheckout, FunCheckoutStartingStep, } from './providers/FunkitCheckoutContext';
25
25
  export type { FunkitCheckoutQuoteResult } from './domains/quote';
26
26
  export type { FunkitConfig, FunkitUiCustomizationsConfig, FunkitTextCustomizationsConfig, } from './providers/FunkitConfigContext';