@funkit/connect 9.11.0 → 9.12.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.
@@ -3,9 +3,25 @@
3
3
  *
4
4
  * Extracted from WithdrawalContent.tsx to keep Lighter-specific logic isolated.
5
5
  */
6
+ import type { LighterAccountIndex } from '@funkit/api-base';
6
7
  import React from 'react';
7
8
  import type { CustomWithdrawalConfig, WalletWithdrawalConfig } from '../../providers/FunkitCheckoutContext';
8
9
  import type { SourceTokenOption } from './WithdrawAmountInput';
10
+ /** Free (withdrawable) balance for a single Lighter asset: balance - locked. */
11
+ export declare function freeBalance(balance: string, lockedBalance: string): string;
12
+ /**
13
+ * Fetches all asset balances for a Lighter account. Returns:
14
+ *
15
+ * - `balances` — `Record<SYMBOL, freeBalance>` (uppercased symbol keys)
16
+ * - `assets` — raw asset list from the API (for building source-token options)
17
+ */
18
+ export declare function useLighterWithdrawalBalances({ accountIndex, }: {
19
+ accountIndex: LighterAccountIndex | undefined;
20
+ }): {
21
+ balances: Record<string, string>;
22
+ assets: import("../../utils/customer").LighterAsset[];
23
+ isLoading: boolean;
24
+ };
9
25
  type FunkitWithdrawalConfig = WalletWithdrawalConfig | CustomWithdrawalConfig;
10
26
  /**
11
27
  * Resolves the Lighter `asset_id` for a selected source token symbol. Returns
@@ -3,7 +3,7 @@ import React, { type ReactNode } from 'react';
3
3
  import type { Address } from 'viem';
4
4
  import { type PaymentMethodInfo } from '../../domains/paymentMethods';
5
5
  import type { AssetHoldingsItem } from '../../utils/assets';
6
- import type { WithdrawalClient } from '../../wallets/Wallet';
6
+ import type { WithdrawalClient, WithdrawalTransaction } from '../../wallets/Wallet';
7
7
  import { type FunkitCheckoutQuoteResult } from '../FunkitHistoryContext';
8
8
  import type { FunkitActiveCheckoutItem, FunkitActiveWithdrawalItem, FunkitCheckoutConfig, FunkitWithdrawalConfig, UseFunkitCheckoutProps, UseFunkitCheckoutPropsWithFullConfig } from './types';
9
9
  export * from './types';
@@ -25,7 +25,7 @@ interface FunkitCheckoutContextInterface {
25
25
  }): void;
26
26
  updateSelectedPaymentMethodInfo(newPaymentMethodInfo: PaymentMethodInfo): void;
27
27
  updateCustomRecipient: (recipient: Address) => void;
28
- confirmCheckout(quote: FunkitCheckoutQuoteResult, stepMessageSetter: (m: string) => void, withdrawalClient?: WithdrawalClient): Promise<Address>;
28
+ confirmCheckout(quote: FunkitCheckoutQuoteResult, stepMessageSetter: (m: string) => void, withdrawalClient?: WithdrawalClient, preWithdrawalTxs?: WithdrawalTransaction[]): Promise<Address>;
29
29
  cancelCheckout(depositAddress: Address): Promise<boolean>;
30
30
  /** @deprecated to be removed after quote migration is finished (historically named setCheckoutQuote) */
31
31
  setCheckout: (checkout: FunkitActiveCheckoutItem) => void;
@@ -4,7 +4,7 @@ import type { ReactNode } from 'react';
4
4
  import type { Address } from 'viem';
5
5
  import type { PaymentMethodInfo } from '../../domains/paymentMethods';
6
6
  import type { CheckoutBlockedReason } from '../../modals/CheckoutModal/CheckoutBlockedReason';
7
- import type { WithdrawalClient } from '../../wallets/Wallet';
7
+ import type { WithdrawalClient, WithdrawalTransaction } from '../../wallets/Wallet';
8
8
  import type { FunkitCheckoutQuoteResult } from '../FunkitHistoryContext';
9
9
  export type FunkitCheckoutActionParams = ApiFunkitCheckoutActionParams;
10
10
  export interface TokenInfo {
@@ -120,6 +120,26 @@ export interface WithdrawalConfigBase {
120
120
  export interface WalletWithdrawalConfig extends WithdrawalConfigBase {
121
121
  /** Wallet instance used to execute the quote */
122
122
  wallet: WithdrawalClient;
123
+ /**
124
+ * Optional async hook that runs **before** the SDK executes the wallet-based
125
+ * withdrawal quote. Return any transactions that must execute as part of the
126
+ * withdrawal flow *prior* to the SDK's withdrawal transaction (e.g. an
127
+ * `approve` and a custom-collateral `unwrap` that produces the source token).
128
+ *
129
+ * The SDK atomically prepends the returned array to the withdrawal txn(s)
130
+ * via the integrator's `wallet.sendTransactions` primitive, so the
131
+ * approve/unwrap and the withdrawal land in a single user signature.
132
+ *
133
+ * Return `[]` if no extra transactions are required — the hook is then
134
+ * purely a side-effect / preflight step.
135
+ *
136
+ * Throw to abort the withdrawal — the thrown error message is surfaced to
137
+ * the user in the standard error UI.
138
+ *
139
+ * Mutually exclusive with {@link CustomWithdrawalConfig['withdrawCallback']}
140
+ * by virtue of living on a different config variant.
141
+ */
142
+ preWithdrawalAction?: (param: WithdrawalParam) => Promise<WithdrawalTransaction[]>;
123
143
  }
124
144
  export interface CustomWithdrawalConfig extends WithdrawalConfigBase {
125
145
  /**
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { ReactNode } from 'react';
3
+ export declare const STATSIG_CLIENT_KEY: "client-UmFd8WIJljA7cLmZuDqs3X25M8sKd5WIQP4BSC2bRbM";
3
4
  interface FunkitStatsigProviderProps {
4
5
  children: ReactNode;
5
6
  isDevelopment?: boolean;
@@ -0,0 +1,19 @@
1
+ import fallbackFeatureGates from '../../__generated__/default_feature_gates';
2
+ type FeatureGateName = keyof typeof fallbackFeatureGates;
3
+ /**
4
+ * Synchronous, non-hook variant of {@link useFeatureGate}. Reads the gate
5
+ * value directly from the connect package's Statsig client singleton.
6
+ *
7
+ * Use this from non-React contexts (event handlers, async callbacks created
8
+ * outside render) where calling a hook is not possible. Behavior:
9
+ * - Returns the live gate value once `FunkitStatsigProvider`'s async init
10
+ * has resolved (typical case for event-driven calls — by the time a user
11
+ * clicks a button, init has long since completed).
12
+ * - Returns the bundled default if called before init completes or if the
13
+ * provider has not been mounted (graceful fallback rather than throw).
14
+ *
15
+ * For render-time consumers, prefer {@link useFeatureGate} so the consumer
16
+ * re-renders when values update mid-session.
17
+ */
18
+ export declare function checkFeatureGate(name: FeatureGateName): boolean;
19
+ export {};
@@ -108,6 +108,17 @@ export interface WithdrawalClient {
108
108
  getChainId: () => Promise<number>;
109
109
  switchChain: (chainId: number) => Promise<void>;
110
110
  sendTransaction: (chainId: number, transaction: WithdrawalTransaction) => Promise<string>;
111
+ /**
112
+ * Optional batched submitter. When provided, the SDK collapses approve +
113
+ * swap/deposit steps into a single user signature via this method (e.g.
114
+ * EIP-5792 `wallet_sendCalls` with `forceAtomic`).
115
+ *
116
+ * Must return a tx hash that {@link confirmTransaction} can wait on.
117
+ * Implementations using `wallet_sendCalls` should map the calls-id back to
118
+ * the underlying tx hash via `waitForCallsStatus` →
119
+ * `receipts[0].transactionHash`.
120
+ */
121
+ sendTransactions?: (chainId: number, transactions: WithdrawalTransaction[]) => Promise<string>;
111
122
  confirmTransaction: (txHash: string, chainId: number) => Promise<TransactionReceipt>;
112
123
  address: () => string;
113
124
  }
@@ -14,9 +14,6 @@ import {
14
14
  import {
15
15
  tokenPocketWallet
16
16
  } from "./chunk-HXWUH73P.js";
17
- import {
18
- tokenaryWallet
19
- } from "./chunk-R7X5RIO7.js";
20
17
  import {
21
18
  trustWallet
22
19
  } from "./chunk-T4ROGPMF.js";
@@ -30,8 +27,11 @@ import {
30
27
  xdefiWallet
31
28
  } from "./chunk-KSNA53EX.js";
32
29
  import {
33
- rabbyWallet
34
- } from "./chunk-7PVUEV4M.js";
30
+ tokenaryWallet
31
+ } from "./chunk-R7X5RIO7.js";
32
+ import {
33
+ frameWallet
34
+ } from "./chunk-MTJIPVYB.js";
35
35
  import {
36
36
  rainbowWallet
37
37
  } from "./chunk-LCIPVVH5.js";
@@ -53,9 +53,6 @@ import {
53
53
  import {
54
54
  subWallet
55
55
  } from "./chunk-APHCF4DT.js";
56
- import {
57
- metaMaskWallet
58
- } from "./chunk-7V33VJAL.js";
59
56
  import {
60
57
  mewWallet
61
58
  } from "./chunk-DP5ICBEB.js";
@@ -77,12 +74,12 @@ import {
77
74
  import {
78
75
  phantomWallet
79
76
  } from "./chunk-57GN4W23.js";
77
+ import {
78
+ rabbyWallet
79
+ } from "./chunk-7PVUEV4M.js";
80
80
  import {
81
81
  foxWallet
82
82
  } from "./chunk-ZPSPK6LH.js";
83
- import {
84
- frameWallet
85
- } from "./chunk-MTJIPVYB.js";
86
83
  import {
87
84
  frontierWallet
88
85
  } from "./chunk-UDTBQV4Q.js";
@@ -102,11 +99,14 @@ import {
102
99
  ledgerWallet
103
100
  } from "./chunk-V4EXM3KB.js";
104
101
  import {
105
- braveWallet
106
- } from "./chunk-XVH4JIXB.js";
102
+ metaMaskWallet
103
+ } from "./chunk-7V33VJAL.js";
107
104
  import {
108
105
  clvWallet
109
106
  } from "./chunk-5TN5Z2WY.js";
107
+ import {
108
+ braveWallet
109
+ } from "./chunk-XVH4JIXB.js";
110
110
  import {
111
111
  coin98Wallet
112
112
  } from "./chunk-XVBSJCW5.js";
@@ -116,24 +116,24 @@ import {
116
116
  import {
117
117
  coreWallet
118
118
  } from "./chunk-V6UOWTEZ.js";
119
- import {
120
- dawnWallet
121
- } from "./chunk-PARFRRNI.js";
122
119
  import {
123
120
  desigWallet
124
121
  } from "./chunk-TNVLCMJD.js";
122
+ import {
123
+ dawnWallet
124
+ } from "./chunk-PARFRRNI.js";
125
125
  import {
126
126
  enkryptWallet
127
127
  } from "./chunk-2DKNXOPL.js";
128
+ import {
129
+ bitgetWallet
130
+ } from "./chunk-YIEASHLS.js";
128
131
  import {
129
132
  argentWallet
130
133
  } from "./chunk-XTD6OMZP.js";
131
134
  import {
132
135
  bifrostWallet
133
136
  } from "./chunk-6DRCY52E.js";
134
- import {
135
- bitgetWallet
136
- } from "./chunk-YIEASHLS.js";
137
137
  import {
138
138
  bitskiWallet
139
139
  } from "./chunk-Y36HPFB3.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funkit/connect",
3
- "version": "9.11.0",
3
+ "version": "9.12.0",
4
4
  "description": "Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.",
5
5
  "files": [
6
6
  "dist",
@@ -47,11 +47,11 @@
47
47
  "devDependencies": {
48
48
  "@aws-sdk/client-cloudfront": "3.1033.0",
49
49
  "@aws-sdk/client-s3": "3.1001.0",
50
- "@chromatic-com/storybook": "^4.1.3",
50
+ "@chromatic-com/storybook": "^5.1.2",
51
51
  "@statsig/statsig-node-core": "^0.11.1",
52
- "@storybook/addon-docs": "^9.1.19",
53
- "@storybook/addon-links": "^10.1.3",
54
- "@storybook/react-vite": "^9.1.19",
52
+ "@storybook/addon-docs": "^10.3.6",
53
+ "@storybook/addon-links": "^10.3.6",
54
+ "@storybook/react-vite": "^10.3.6",
55
55
  "@testing-library/jest-dom": "^6.2.0",
56
56
  "@testing-library/react": "^16.3.2",
57
57
  "@testing-library/user-event": "^14.5.2",
@@ -60,8 +60,8 @@
60
60
  "@vanilla-extract/css-utils": "^0.1.4",
61
61
  "@vanilla-extract/esbuild-plugin": "^2.3.16",
62
62
  "@vanilla-extract/private": "^1.0.7",
63
- "@vanilla-extract/vite-plugin": "^5.0.3",
64
- "@vitejs/plugin-react": "^5.1.2",
63
+ "@vanilla-extract/vite-plugin": "^5.2.2",
64
+ "@vitejs/plugin-react": "^5.2.0",
65
65
  "autoprefixer": "^10.4.27",
66
66
  "buffer": "^6.0.3",
67
67
  "dotenv": "^17.2.3",
@@ -71,13 +71,13 @@
71
71
  "postcss-prefix-selector": "^1.16.0",
72
72
  "process": "^0.11.10",
73
73
  "react": "^19.0.0",
74
- "storybook": "^9.1.19",
74
+ "storybook": "^10.3.6",
75
75
  "stream-browserify": "^3.0.0",
76
76
  "tsc-alias": "1.8.16",
77
77
  "tsx": "^4.19.2",
78
78
  "util": "^0.12.5",
79
- "vite-plugin-node-polyfills": "^0.24.0",
80
- "vitest": "^4.0.18",
79
+ "vite-plugin-node-polyfills": "^0.26.0",
80
+ "vitest": "^4.1.6",
81
81
  "wagmi": "2.17.2"
82
82
  },
83
83
  "dependencies": {
@@ -89,7 +89,7 @@
89
89
  "@radix-ui/react-dropdown-menu": "^2.1.7",
90
90
  "@radix-ui/react-tooltip": "^1.2.0",
91
91
  "@solana/addresses": "^2.1.0",
92
- "@statsig/react-bindings": "^3.25.4",
92
+ "@statsig/react-bindings": "3.25.4",
93
93
  "@types/uuid": "^9.0.8",
94
94
  "@vanilla-extract/css": "1.15.3",
95
95
  "@vanilla-extract/dynamic": "2.1.0",
@@ -105,10 +105,10 @@
105
105
  "ua-parser-js": "^1.0.37",
106
106
  "use-debounce": "^10.0.5",
107
107
  "uuid": "^9.0.1",
108
- "@funkit/api-base": "4.2.1",
109
- "@funkit/chains": "1.1.2",
110
- "@funkit/utils": "3.0.0",
111
- "@funkit/fun-relay": "2.7.0"
108
+ "@funkit/api-base": "4.2.2",
109
+ "@funkit/chains": "1.1.3",
110
+ "@funkit/fun-relay": "2.7.1",
111
+ "@funkit/utils": "3.0.1"
112
112
  },
113
113
  "repository": {
114
114
  "type": "git",