@funkit/connect 12.8.0 → 12.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 12.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 54a6a79: Polymarket deposit configs can set the direction and amount the Transfer tab opens with.
8
+
9
+ ### Patch Changes
10
+
11
+ - d4de552: Solana withdrawal signing now comes from the shared connect-core client.
12
+ - 400e342: The Polymarket transfer amount field shows dollars to the cent; Max still moves the full balance.
13
+ - Updated dependencies [d4de552]
14
+ - Updated dependencies [28c7128]
15
+ - Updated dependencies [30c01e5]
16
+ - Updated dependencies [d4de552]
17
+ - Updated dependencies [12a70d7]
18
+ - Updated dependencies [c452c25]
19
+ - Updated dependencies [ab41aa7]
20
+ - @funkit/api-base@8.5.0
21
+ - @funkit/connect-core@8.3.0
22
+ - @funkit/fun-relay@3.1.0
23
+
24
+ ## 12.9.0
25
+
26
+ ### Minor Changes
27
+
28
+ - e623ec7: Add a `createConnectedWithdrawalClient` export that adapts the connected wallet into a withdrawal wallet, so integrations no longer need to hand-write one.
29
+
30
+ ### Patch Changes
31
+
32
+ - 3375ad1: The build starts from an empty output directory, so a published or cached bundle never carries files left over from an earlier build.
33
+ - c7ba486: Shadow mode retries a failed stylesheet load before falling back to light DOM, and reports the real cause when it does fall back.
34
+ - Updated dependencies [142dfed]
35
+ - Updated dependencies [1bccb47]
36
+ - Updated dependencies [38e9946]
37
+ - Updated dependencies [d532b7d]
38
+ - Updated dependencies [00e8eae]
39
+ - Updated dependencies [cd5ac82]
40
+ - Updated dependencies [154a1bb]
41
+ - Updated dependencies [f147595]
42
+ - Updated dependencies [c4ea859]
43
+ - Updated dependencies [bc00257]
44
+ - @funkit/connect-core@8.2.0
45
+
3
46
  ## 12.8.0
4
47
 
5
48
  ### Minor Changes
@@ -78,7 +78,8 @@ function createPolymarketDepositConfig({
78
78
  modalTitles,
79
79
  defaultAccount = "predictions",
80
80
  pendingTransfers,
81
- access
81
+ access,
82
+ transferDefaults
82
83
  }) {
83
84
  const isPerpsRoute = (routingId) => routingId === POLYMARKET_PERPS_ROUTING_ID;
84
85
  const resolvedAccess = { ...access ?? FULL_DEPOSIT_ACCESS };
@@ -138,7 +139,9 @@ function createPolymarketDepositConfig({
138
139
  predictions,
139
140
  perps,
140
141
  pending: pendingTransfers,
141
- access: resolvedAccess
142
+ access: resolvedAccess,
143
+ initialDirection: transferDefaults?.direction,
144
+ initialAmountUsd: transferDefaults?.amountUsd
142
145
  }
143
146
  };
144
147
  }
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  createNadoWithdrawalCallback
4
- } from "../../chunk-YD27ZAJB.js";
5
- import "../../chunk-4DBUYTEE.js";
4
+ } from "../../chunk-4OOCXIMA.js";
6
5
  import "../../chunk-B5KCBBSV.js";
6
+ import "../../chunk-4DBUYTEE.js";
7
7
  import "../../chunk-OODIKHYE.js";
8
8
  import "../../chunk-7GPRX32F.js";
9
9
  import "../../chunk-I5GSXPFE.js";
@@ -79,7 +79,7 @@ export interface MallardWithdrawalConfig {
79
79
  /**
80
80
  * React entry point for Mallard withdrawals. Returns a
81
81
  * {@link WalletWithdrawalConfig} (executing wallet = the connected wallet, via
82
- * {@link createConnectedWalletWithdrawalClient}), or `null` until a config is
82
+ * {@link createConnectedWithdrawalClient}), or `null` until a config is
83
83
  * passed and a wallet is connected. Balance isn't read here — the modal sources
84
84
  * it from the checkout config's `withdrawalSourceTokenBalance`, like
85
85
  * Lighter/Polymarket.
@@ -29,6 +29,63 @@ import {
29
29
  getAddress,
30
30
  maxUint256
31
31
  } from "viem";
32
+
33
+ // src/wallets/createConnectedWithdrawalClient.ts
34
+ function createConnectedWithdrawalClient(config, ownerAddress, sourceChainId) {
35
+ const ensureOnChain = async (chainId) => {
36
+ if (getAccount(config).chainId !== chainId) {
37
+ await switchChain(config, { chainId });
38
+ }
39
+ };
40
+ return {
41
+ address: () => ownerAddress,
42
+ getChainId: async () => sourceChainId,
43
+ switchChain: async (chainId) => {
44
+ await ensureOnChain(chainId);
45
+ },
46
+ sendTransaction: async (chainId, transaction) => {
47
+ await ensureOnChain(chainId);
48
+ return sendTransaction(config, {
49
+ to: transaction.to,
50
+ data: transaction.data,
51
+ value: BigInt(transaction.value || "0"),
52
+ chainId
53
+ });
54
+ },
55
+ confirmTransaction: (txHash, chainId) => (
56
+ // wagmi-core's receipt (chain-formatter generics) is the same runtime
57
+ // shape as viem's `TransactionReceipt` but isn't structurally assignable
58
+ // to it; cast at this boundary. Using wagmi (not a viem publicClient) is
59
+ // deliberate — it reuses the connected wallet's configured transport
60
+ // instead of requiring a separate RPC endpoint.
61
+ waitForTransactionReceipt(config, {
62
+ hash: txHash,
63
+ chainId
64
+ })
65
+ ),
66
+ // Gasless (EIP-3009/permit) relay routes return a typed-data signature
67
+ // step instead of a transaction — sign it with the connected wallet.
68
+ signTypedData: async (typedData) => {
69
+ const domainChainId = typedData.domain?.chainId;
70
+ if (domainChainId != null) {
71
+ await ensureOnChain(Number(domainChainId));
72
+ }
73
+ return signTypedData(config, {
74
+ account: ownerAddress,
75
+ domain: typedData.domain,
76
+ types: typedData.types,
77
+ primaryType: typedData.primaryType,
78
+ message: typedData.message
79
+ });
80
+ },
81
+ signMessage: (message) => signMessage(config, {
82
+ account: ownerAddress,
83
+ message: typeof message === "string" ? message : { raw: message.raw }
84
+ })
85
+ };
86
+ }
87
+
88
+ // src/clients/mallard.tsx
32
89
  var MALLARD_DEPOSIT_ADDRESS = getAddress(
33
90
  "0xD42c46c7BaD6A54b38395F846b09981CE75fb8e2"
34
91
  );
@@ -103,59 +160,6 @@ var MALLARD_USDG_ADDRESS = getAddress(
103
160
  "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"
104
161
  );
105
162
  var MALLARD_USDG_ICON_SRC = "https://sdk-cdn.fun.xyz/images/usdg.svg";
106
- function createConnectedWalletWithdrawalClient(config, ownerAddress, sourceChainId) {
107
- const ensureOnChain = async (chainId) => {
108
- if (getAccount(config).chainId !== chainId) {
109
- await switchChain(config, { chainId });
110
- }
111
- };
112
- return {
113
- address: () => ownerAddress,
114
- getChainId: async () => sourceChainId,
115
- switchChain: async (chainId) => {
116
- await ensureOnChain(chainId);
117
- },
118
- sendTransaction: async (chainId, transaction) => {
119
- await ensureOnChain(chainId);
120
- return sendTransaction(config, {
121
- to: transaction.to,
122
- data: transaction.data,
123
- value: BigInt(transaction.value || "0"),
124
- chainId
125
- });
126
- },
127
- confirmTransaction: (txHash, chainId) => (
128
- // wagmi-core's receipt (chain-formatter generics) is the same runtime
129
- // shape as viem's `TransactionReceipt` but isn't structurally assignable
130
- // to it; cast at this boundary. Using wagmi (not a viem publicClient) is
131
- // deliberate — it reuses the connected wallet's configured transport
132
- // instead of requiring a separate RPC endpoint.
133
- waitForTransactionReceipt(config, {
134
- hash: txHash,
135
- chainId
136
- })
137
- ),
138
- // Gasless (EIP-3009/permit) relay routes return a typed-data signature
139
- // step instead of a transaction — sign it with the connected wallet.
140
- signTypedData: async (typedData) => {
141
- const domainChainId = typedData.domain?.chainId;
142
- if (domainChainId != null) {
143
- await ensureOnChain(Number(domainChainId));
144
- }
145
- return signTypedData(config, {
146
- account: ownerAddress,
147
- domain: typedData.domain,
148
- types: typedData.types,
149
- primaryType: typedData.primaryType,
150
- message: typedData.message
151
- });
152
- },
153
- signMessage: (message) => signMessage(config, {
154
- account: ownerAddress,
155
- message: typeof message === "string" ? message : { raw: message.raw }
156
- })
157
- };
158
- }
159
163
  function useMallardWithdrawalConfig(config) {
160
164
  const { t } = useFunkitTranslation();
161
165
  const wagmiConfig = useConfig();
@@ -166,7 +170,7 @@ function useMallardWithdrawalConfig(config) {
166
170
  if (!config || !address) {
167
171
  return null;
168
172
  }
169
- const wallet = createConnectedWalletWithdrawalClient(
173
+ const wallet = createConnectedWithdrawalClient(
170
174
  wagmiConfig,
171
175
  address,
172
176
  sourceChainId
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  createNadoWithdrawalCallback
4
- } from "./chunk-YD27ZAJB.js";
5
- import "./chunk-4DBUYTEE.js";
4
+ } from "./chunk-4OOCXIMA.js";
6
5
  import "./chunk-B5KCBBSV.js";
6
+ import "./chunk-4DBUYTEE.js";
7
7
  import "./chunk-OODIKHYE.js";
8
8
  import {
9
9
  useAccount,
@@ -1,5 +1,5 @@
1
1
  import { POLYMARKET_PERPS_ROUTING_ID, POLYMARKET_PREDICTIONS_ROUTING_ID } from '../../consts/polymarket';
2
- import type { DepositAccess, FunkitCheckoutActionParams, FunkitCheckoutConfig, PolymarketPerpsTransferPending, PolymarketTransferAccount } from '../../providers/FunkitCheckoutContext/types';
2
+ import type { DepositAccess, FunkitCheckoutActionParams, FunkitCheckoutConfig, PerpsTransferDirection, PolymarketPerpsTransferPending, PolymarketTransferAccount } from '../../providers/FunkitCheckoutContext/types';
3
3
  import { type PolymarketPerpsDepositConfig } from './polymarket';
4
4
  export { POLYMARKET_PERPS_ROUTING_ID, POLYMARKET_PREDICTIONS_ROUTING_ID };
5
5
  /**
@@ -22,7 +22,21 @@ export type PolymarketAccount = PolymarketTransferAccount;
22
22
  * reaching outside this entry point — returning the rail's id is what lets a
23
23
  * transfer record be joined to Polymarket's side of the same transfer.
24
24
  */
25
- export type { PolymarketPerpsTransferPending, DepositAccess, PolymarketTransferResult, } from '../../providers/FunkitCheckoutContext/types';
25
+ export type { PolymarketPerpsTransferPending, DepositAccess, PerpsTransferDirection, PolymarketTransferResult, } from '../../providers/FunkitCheckoutContext/types';
26
+ /** What the transfer step opens with. Both fields are optional. */
27
+ export interface PolymarketTransferDefaults {
28
+ /**
29
+ * Direction on open. Defaults to Predictions → Perps. Ignored when `access`
30
+ * leaves only one product fundable — that product is the destination.
31
+ */
32
+ direction?: PerpsTransferDirection;
33
+ /**
34
+ * Amount the field opens with, as a plain USD string with up to 2 decimals
35
+ * and no commas/separators. Examples of acceptable values: `'12.50'`,
36
+ * `'25'`, `'1000.00'`. Anything else is ignored.
37
+ */
38
+ amountUsd?: string;
39
+ }
26
40
  export interface CreatePolymarketDepositConfigParams {
27
41
  /** Predictions account (the user's predictions proxy). */
28
42
  predictions: PolymarketAccount;
@@ -57,6 +71,8 @@ export interface CreatePolymarketDepositConfigParams {
57
71
  * location".
58
72
  */
59
73
  access?: DepositAccess;
74
+ /** Direction and amount the Transfer tab opens with. */
75
+ transferDefaults?: PolymarketTransferDefaults;
60
76
  }
61
77
  /**
62
78
  * Builds the entire Polymarket deposit checkout config from the two accounts.
@@ -66,4 +82,4 @@ export interface CreatePolymarketDepositConfigParams {
66
82
  * step; modal title, min deposit, recipient and on-chain deposit actions are
67
83
  * derived per account. Supersedes the "Deposit to" dropdown.
68
84
  */
69
- export declare function createPolymarketDepositConfig({ predictions, perps, modalTitleMeta, modalTitles, defaultAccount, pendingTransfers, access, }: CreatePolymarketDepositConfigParams): FunkitCheckoutConfig;
85
+ export declare function createPolymarketDepositConfig({ predictions, perps, modalTitleMeta, modalTitles, defaultAccount, pendingTransfers, access, transferDefaults, }: CreatePolymarketDepositConfigParams): FunkitCheckoutConfig;
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createPolymarketDepositConfig,
4
4
  createPredictionsGenerateActionParams
5
- } from "../chunk-RAJJSGNT.js";
5
+ } from "../chunk-U33QNTIA.js";
6
6
  import {
7
7
  POLYMARKET_PERPS_ROUTING_ID,
8
8
  POLYMARKET_PREDICTIONS_ROUTING_ID
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createPolymarketDepositConfig,
4
4
  createPredictionsGenerateActionParams
5
- } from "../chunk-RAJJSGNT.js";
5
+ } from "../chunk-U33QNTIA.js";
6
6
  import {
7
7
  AMOUNT_PLACEHOLDER,
8
8
  COLLATERAL_ONRAMP_ABI,
package/dist/index.d.ts CHANGED
@@ -46,6 +46,7 @@ export { customWallet, type CustomWalletOptions, } from './wallets/walletConnect
46
46
  export type { WalletAdoptionConfig } from './wallets/useWalletAdoption';
47
47
  export type { ConnectorsForWalletsParameters } from './wallets/connectorsForWallets';
48
48
  export type { FunkitConnectWalletConnectParameters, Wallet, WalletDetailsParams, WalletList, WithdrawalClient, WithdrawalTransaction, } from './wallets/Wallet';
49
+ export { createConnectedWithdrawalClient } from './wallets/createConnectedWithdrawalClient';
49
50
  export { useSolanaWithdrawalConfig, type SolanaWithdrawalConfig, } from './wallets/solanaWithdrawal';
50
51
  export { useFunkitAccount, useFunkitDisconnect, useFunkitReconnect, useFunkitSwitchChains, } from './providers/GeneralWalletProvider';
51
52
  export { SelectedHomeTab } from './modals/ProfileDetails/FunProfileViews/Home';
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ function setFunkitConnectVersion({ version }) {
113
113
  localStorage.setItem(storageKey, version);
114
114
  }
115
115
  function getCurrentSdkVersion() {
116
- return "12.8.0";
116
+ return "12.10.0";
117
117
  }
118
118
  function useFingerprint() {
119
119
  const fingerprint = useCallback(() => {
@@ -9861,43 +9861,21 @@ var useSolanaWallet = () => {
9861
9861
  // src/utils/solanaRelayWallet.ts
9862
9862
  import { isSolanaChainId as isSolanaChainId2 } from "@funkit/chains";
9863
9863
  import {
9864
- getSolanaWallet
9865
- } from "@funkit/fun-relay";
9864
+ createSolanaRelayWallet as createSharedSolanaRelayWallet,
9865
+ resolveSolanaSigner
9866
+ } from "@funkit/connect-core/clients/solana";
9866
9867
 
9867
9868
  // src/wallets/Wallet.ts
9868
- function isSolanaWithdrawalClient(client) {
9869
- return "_type" in client && client._type === "solana";
9870
- }
9869
+ import {
9870
+ isSolanaWithdrawalClient
9871
+ } from "@funkit/connect-core/clients/solana";
9871
9872
  function isLighterWithdrawalClient(client) {
9872
9873
  return "_type" in client && client._type === "lighter";
9873
9874
  }
9874
9875
 
9875
9876
  // src/utils/solanaRelayWallet.ts
9876
- function resolveSigner(wallet) {
9877
- if (wallet.signTransaction) {
9878
- logger.info("solanaSigner:resolved", {
9879
- address: wallet.address,
9880
- path: "signTransaction"
9881
- });
9882
- return { signTransaction: wallet.signTransaction.bind(wallet) };
9883
- }
9884
- if (wallet.signAndSendTransaction) {
9885
- logger.info("solanaSigner:resolved", {
9886
- address: wallet.address,
9887
- path: "signAndSendTransaction"
9888
- });
9889
- return {
9890
- signAndSendTransaction: wallet.signAndSendTransaction.bind(wallet)
9891
- };
9892
- }
9893
- throw new Error("Solana wallet supplied no way to sign a transaction");
9894
- }
9895
9877
  function createSolanaRelayWallet(wallet) {
9896
- return getSolanaWallet({
9897
- walletAddress: wallet.address,
9898
- connection: wallet.connection,
9899
- signer: resolveSigner(wallet)
9900
- });
9878
+ return createSharedSolanaRelayWallet(wallet, logger);
9901
9879
  }
9902
9880
  function resolveSolanaRelayWallet({
9903
9881
  sourceChainId,
@@ -12258,20 +12236,60 @@ function useMountShadowHost(shadowCss, themeId) {
12258
12236
  import { useEffect as useEffect16, useState as useState12 } from "react";
12259
12237
 
12260
12238
  // src/shadow/loadShadowCss.ts
12239
+ var RETRY_DELAYS_MS = [0, 1e3];
12240
+ async function importShadowCss() {
12241
+ const mod = await import("@funkit/connect/shadow-css");
12242
+ if (!mod) {
12243
+ throw new Error("shadow stylesheet module resolved to undefined");
12244
+ }
12245
+ if (typeof mod.funkitShadowCss !== "string" || !mod.funkitShadowCss) {
12246
+ throw new Error("shadow stylesheet is empty");
12247
+ }
12248
+ return mod.funkitShadowCss;
12249
+ }
12250
+ function describeError(error) {
12251
+ return error instanceof Error ? error.message : String(error);
12252
+ }
12261
12253
  async function loadShadowCss() {
12262
- try {
12263
- const mod = await import("@funkit/connect/shadow-css");
12264
- if (typeof mod.funkitShadowCss !== "string" || !mod.funkitShadowCss) {
12265
- throw new Error("shadow stylesheet is empty");
12254
+ const startedAt = performance.now();
12255
+ const attempts = RETRY_DELAYS_MS.length + 1;
12256
+ let firstError;
12257
+ let firstAttemptMs = 0;
12258
+ for (let attempt = 1; attempt <= attempts; attempt++) {
12259
+ try {
12260
+ const css = await importShadowCss();
12261
+ if (attempt > 1) {
12262
+ logger.warn("shadowMode:stylesheetLoadRecovered", {
12263
+ message: "Shadow stylesheet loaded on retry after a failed first attempt",
12264
+ firstError: describeError(firstError),
12265
+ firstAttemptMs,
12266
+ recoveredOnAttempt: attempt,
12267
+ elapsedMs: Math.round(performance.now() - startedAt)
12268
+ });
12269
+ }
12270
+ return css;
12271
+ } catch (error) {
12272
+ if (attempt === 1) {
12273
+ firstError = error;
12274
+ firstAttemptMs = Math.round(performance.now() - startedAt);
12275
+ }
12276
+ if (attempt === attempts) {
12277
+ logger.warn("shadowMode:stylesheetLoadFailed", {
12278
+ message: "Shadow mode unavailable: shadow stylesheet failed to load. Staying in light DOM",
12279
+ error: describeError(error),
12280
+ firstError: describeError(firstError),
12281
+ firstAttemptMs,
12282
+ attempts,
12283
+ elapsedMs: Math.round(performance.now() - startedAt)
12284
+ });
12285
+ return null;
12286
+ }
12266
12287
  }
12267
- return mod.funkitShadowCss;
12268
- } catch (error) {
12269
- logger.warn("shadowMode:stylesheetLoadFailed", {
12270
- message: "Shadow mode unavailable: shadow stylesheet failed to load. Staying in light DOM",
12271
- error: error instanceof Error ? error.message : String(error)
12272
- });
12273
- return null;
12288
+ await new Promise(
12289
+ (resolve) => setTimeout(resolve, RETRY_DELAYS_MS[attempt - 1])
12290
+ );
12274
12291
  }
12292
+ return null;
12275
12293
  }
12276
12294
 
12277
12295
  // src/shadow/useShadowCss.ts
@@ -38509,7 +38527,7 @@ function PerpsTransferBody({ form }) {
38509
38527
  /* @__PURE__ */ React229.createElement(
38510
38528
  PerpsTransferAmountInput,
38511
38529
  {
38512
- amount: form.amount,
38530
+ amount: form.displayAmount,
38513
38531
  onAmountChange: form.setAmount
38514
38532
  }
38515
38533
  ),
@@ -38711,9 +38729,13 @@ function parseAmount(amount) {
38711
38729
  return Number(amount.replace(/,/g, ""));
38712
38730
  }
38713
38731
  var MAX_AMOUNT_DECIMALS = 6;
38714
- var VALID_AMOUNT_INPUT = new RegExp(
38715
- `^[\\d,]*\\.?\\d{0,${MAX_AMOUNT_DECIMALS}}$`
38716
- );
38732
+ var MAX_TYPED_DECIMALS = 2;
38733
+ var VALID_FILLED_AMOUNT = buildAmountInputPattern(MAX_AMOUNT_DECIMALS);
38734
+ var VALID_TYPED_AMOUNT = buildAmountInputPattern(MAX_TYPED_DECIMALS);
38735
+ var VALID_PREFILL_AMOUNT = /^\d+(\.\d{1,2})?$/;
38736
+ function buildAmountInputPattern(maxDecimals) {
38737
+ return new RegExp(`^[\\d,]*\\.?\\d{0,${maxDecimals}}$`);
38738
+ }
38717
38739
  function toNumericString(amount) {
38718
38740
  const cleaned = amount.replace(/,/g, "").replace(/\.$/, "");
38719
38741
  return cleaned.startsWith(".") ? `0${cleaned}` : cleaned;
@@ -38723,6 +38745,12 @@ function formatAmountValue(value) {
38723
38745
  maximumFractionDigits: 6
38724
38746
  });
38725
38747
  }
38748
+ function formatDisplayAmount(amount) {
38749
+ return floorToDecimals(parseAmount(amount), 2).toLocaleString("en-US", {
38750
+ minimumFractionDigits: 2,
38751
+ maximumFractionDigits: 2
38752
+ });
38753
+ }
38726
38754
  function getLockedTransferDirection(access) {
38727
38755
  if (!access || access.predictions === access.perps) {
38728
38756
  return void 0;
@@ -38744,8 +38772,14 @@ function usePerpsTransferForm({
38744
38772
  }) {
38745
38773
  const { t } = useFunkitTranslation();
38746
38774
  const { logEvent } = useTrack();
38747
- const [amount, setAmount] = useState62(initialAmountUsd);
38748
- const [amountSelection, setAmountSelection] = useState62(null);
38775
+ const initialAmount = Number(initialAmountUsd);
38776
+ const isInitialAmountUsdValid = VALID_PREFILL_AMOUNT.test(initialAmountUsd) && Number.isFinite(initialAmount) && initialAmount > 0;
38777
+ const [amount, setAmount] = useState62(
38778
+ isInitialAmountUsdValid ? initialAmountUsd : ""
38779
+ );
38780
+ const [amountSelection, setAmountSelection] = useState62(
38781
+ isInitialAmountUsdValid ? "prefill" : null
38782
+ );
38749
38783
  const lockedDirection = getLockedTransferDirection(access);
38750
38784
  const predictionsAccessible = access?.predictions ?? true;
38751
38785
  const perpsAccessible = access?.perps ?? true;
@@ -38761,10 +38795,12 @@ function usePerpsTransferForm({
38761
38795
  },
38762
38796
  initialDirection,
38763
38797
  resolvedDirection: lockedDirection ?? initialDirection,
38764
- isDirectionLocked: Boolean(lockedDirection) || !hasAccessibleDestination
38798
+ isDirectionLocked: Boolean(lockedDirection) || !hasAccessibleDestination,
38799
+ initialAmountUsd
38765
38800
  });
38766
38801
  }, [
38767
38802
  hasAccessibleDestination,
38803
+ initialAmountUsd,
38768
38804
  initialDirection,
38769
38805
  lockedDirection,
38770
38806
  perpsAccessible,
@@ -38782,7 +38818,8 @@ function usePerpsTransferForm({
38782
38818
  }
38783
38819
  }, [status]);
38784
38820
  const applyValidAmount = (next, selection) => {
38785
- if (VALID_AMOUNT_INPUT.test(next)) {
38821
+ const pattern = selection === "manual" ? VALID_TYPED_AMOUNT : VALID_FILLED_AMOUNT;
38822
+ if (pattern.test(next)) {
38786
38823
  setAmount(next);
38787
38824
  setAmountSelection(selection);
38788
38825
  }
@@ -38886,8 +38923,10 @@ function usePerpsTransferForm({
38886
38923
  amountSelection
38887
38924
  });
38888
38925
  };
38926
+ const displayAmount = amountSelection !== null && amountSelection !== "manual" ? formatDisplayAmount(amount) : amount;
38889
38927
  return {
38890
38928
  amount,
38929
+ displayAmount,
38891
38930
  setAmount: handleAmountChange,
38892
38931
  fillMaxAmount,
38893
38932
  fillPercentAmount,
@@ -38999,6 +39038,8 @@ function PerpsTransferStepComponent({
38999
39038
  perpsBalanceUsd,
39000
39039
  predictionsMinTransferUsd: perpsTransfer?.predictions.getMinTopupAmount("pUSD"),
39001
39040
  perpsMinTransferUsd: perpsTransfer?.perps.getMinTopupAmount("pUSD"),
39041
+ initialDirection: perpsTransfer?.initialDirection,
39042
+ initialAmountUsd: perpsTransfer?.initialAmountUsd,
39002
39043
  status,
39003
39044
  isBalanceRefreshing,
39004
39045
  pendingTransfers: perpsTransfer?.pending,
@@ -56483,25 +56524,68 @@ function getDefaultWallets(parameters) {
56483
56524
  };
56484
56525
  }
56485
56526
 
56486
- // src/wallets/solanaWithdrawal.ts
56487
- import { solanaChain as solanaChain8 } from "@funkit/chains";
56488
- import { toValidatedSolanaAddress as toValidatedSolanaAddress2, useLogOnce as useLogOnce6 } from "@funkit/connect-core";
56489
- import { useMemo as useMemo76 } from "react";
56490
- function unsupported(member) {
56491
- throw new Error(`SolanaWithdrawalClient does not support ${member}`);
56492
- }
56493
- function createSolanaWithdrawalClient(wallet) {
56527
+ // src/wallets/createConnectedWithdrawalClient.ts
56528
+ function createConnectedWithdrawalClient(config, ownerAddress, sourceChainId) {
56529
+ const ensureOnChain = async (chainId2) => {
56530
+ if (getAccount(config).chainId !== chainId2) {
56531
+ await switchChain(config, { chainId: chainId2 });
56532
+ }
56533
+ };
56494
56534
  return {
56495
- _type: "solana",
56496
- adaptedWallet: createSolanaRelayWallet(wallet),
56497
- address: () => wallet.address,
56498
- getChainId: async () => solanaChain8.id,
56499
- switchChain: async () => {
56535
+ address: () => ownerAddress,
56536
+ getChainId: async () => sourceChainId,
56537
+ switchChain: async (chainId2) => {
56538
+ await ensureOnChain(chainId2);
56539
+ },
56540
+ sendTransaction: async (chainId2, transaction) => {
56541
+ await ensureOnChain(chainId2);
56542
+ return sendTransaction(config, {
56543
+ to: transaction.to,
56544
+ data: transaction.data,
56545
+ value: BigInt(transaction.value || "0"),
56546
+ chainId: chainId2
56547
+ });
56500
56548
  },
56501
- sendTransaction: () => unsupported("sendTransaction"),
56502
- confirmTransaction: () => unsupported("confirmTransaction")
56549
+ confirmTransaction: (txHash, chainId2) => (
56550
+ // wagmi-core's receipt (chain-formatter generics) is the same runtime
56551
+ // shape as viem's `TransactionReceipt` but isn't structurally assignable
56552
+ // to it; cast at this boundary. Using wagmi (not a viem publicClient) is
56553
+ // deliberate — it reuses the connected wallet's configured transport
56554
+ // instead of requiring a separate RPC endpoint.
56555
+ waitForTransactionReceipt(config, {
56556
+ hash: txHash,
56557
+ chainId: chainId2
56558
+ })
56559
+ ),
56560
+ // Gasless (EIP-3009/permit) relay routes return a typed-data signature
56561
+ // step instead of a transaction — sign it with the connected wallet.
56562
+ signTypedData: async (typedData) => {
56563
+ const domainChainId = typedData.domain?.chainId;
56564
+ if (domainChainId != null) {
56565
+ await ensureOnChain(Number(domainChainId));
56566
+ }
56567
+ return signTypedData(config, {
56568
+ account: ownerAddress,
56569
+ domain: typedData.domain,
56570
+ types: typedData.types,
56571
+ primaryType: typedData.primaryType,
56572
+ message: typedData.message
56573
+ });
56574
+ },
56575
+ signMessage: (message) => signMessage(config, {
56576
+ account: ownerAddress,
56577
+ message: typeof message === "string" ? message : { raw: message.raw }
56578
+ })
56503
56579
  };
56504
56580
  }
56581
+
56582
+ // src/wallets/solanaWithdrawal.ts
56583
+ import { solanaChain as solanaChain8 } from "@funkit/chains";
56584
+ import { toValidatedSolanaAddress as toValidatedSolanaAddress2, useLogOnce as useLogOnce6 } from "@funkit/connect-core";
56585
+ import {
56586
+ createSolanaWithdrawalClient
56587
+ } from "@funkit/connect-core/clients/solana";
56588
+ import { useMemo as useMemo76 } from "react";
56505
56589
  function useSolanaWithdrawalConfig(params) {
56506
56590
  const signer = params?.signer;
56507
56591
  const address = toValidatedSolanaAddress2(signer?.address);
@@ -56523,7 +56607,10 @@ function useSolanaWithdrawalConfig(params) {
56523
56607
  // TODO: Cast until #6751 widens the source address type.
56524
56608
  sourceTokenAddress,
56525
56609
  sourceChainId: String(solanaChain8.id),
56526
- wallet: createSolanaWithdrawalClient({ ...signer, address })
56610
+ wallet: createSolanaWithdrawalClient(
56611
+ signer,
56612
+ logger
56613
+ )
56527
56614
  };
56528
56615
  }, [params, signer, address]);
56529
56616
  }
@@ -56539,6 +56626,7 @@ export {
56539
56626
  SelectedHomeTab,
56540
56627
  __private__,
56541
56628
  createAuthenticationAdapter,
56629
+ createConnectedWithdrawalClient,
56542
56630
  createFunkitWagmiConfig,
56543
56631
  cssObjectFromTheme,
56544
56632
  cssStringFromTheme,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import type { DepositAccess, PolymarketPerpsTransferPending } from '../../providers/FunkitCheckoutContext/types';
2
+ import type { DepositAccess, PerpsTransferDirection, PolymarketPerpsTransferPending } from '../../providers/FunkitCheckoutContext/types';
3
3
  import { type PerpsTransferAmountSelection } from './usePerpsTransferForm';
4
- export type PerpsTransferDirection = 'toPerps' | 'toPredictions';
4
+ export type { PerpsTransferDirection };
5
5
  /**
6
6
  * `pending` and `loading` can be derived by the form from transfer and balance
7
7
  * state. Explicit host-provided statuses are honored as well.