@funkit/connect 10.3.0 → 10.4.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 (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/clients/chunk-2YWQL3AO.js +46 -0
  3. package/dist/clients/chunk-APQYFP6X.js +207 -0
  4. package/dist/clients/chunk-BNMZM23Q.js +42 -0
  5. package/dist/clients/chunk-II5CZTBC.js +18 -0
  6. package/dist/clients/chunk-KNHO756P.js +28 -0
  7. package/dist/clients/chunk-L2KSNS7H.js +112 -0
  8. package/dist/clients/{chunk-3STGJU6Z.js → chunk-M6C7MBQN.js} +1 -1
  9. package/dist/clients/chunk-OZ3KD24N.js +107 -0
  10. package/dist/clients/{chunk-RWCJ4XGX.js → chunk-RCMAGKMG.js} +30 -1
  11. package/dist/clients/internal/nado/consts.d.ts +16 -0
  12. package/dist/clients/internal/nado/consts.js +13 -0
  13. package/dist/clients/internal/nado/encoding.d.ts +22 -0
  14. package/dist/clients/internal/nado/encoding.js +32 -0
  15. package/dist/clients/internal/nado/errors.d.ts +55 -0
  16. package/dist/clients/internal/nado/errors.js +15 -0
  17. package/dist/clients/internal/nado/fetch.d.ts +15 -0
  18. package/dist/clients/internal/nado/fetch.js +9 -0
  19. package/dist/clients/internal/nado/gateway.d.ts +83 -0
  20. package/dist/clients/internal/nado/gateway.js +23 -0
  21. package/dist/clients/internal/nado/hooks.d.ts +360 -0
  22. package/dist/clients/internal/nado/hooks.js +132 -0
  23. package/dist/clients/internal/nado/indexer.d.ts +43 -0
  24. package/dist/clients/internal/nado/indexer.js +13 -0
  25. package/dist/clients/internal/nado/products.d.ts +36 -0
  26. package/dist/clients/internal/nado/products.js +19 -0
  27. package/dist/clients/internal/nado/typedData.d.ts +80 -0
  28. package/dist/clients/internal/nado/typedData.js +43 -0
  29. package/dist/clients/lighter.js +117 -40
  30. package/dist/clients/mallard.js +8 -23
  31. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +2 -2
  32. package/dist/clients/polymarket/index.js +2 -2
  33. package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
  34. package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
  35. package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
  36. package/dist/hooks/useChainMetadata.d.ts +11 -0
  37. package/dist/hooks/usePaymentMethodTabs.d.ts +8 -2
  38. package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
  39. package/dist/hooks/useSwappedPreload.d.ts +7 -11
  40. package/dist/hooks/useUserIpInfo.d.ts +1 -19
  41. package/dist/index.js +2710 -2638
  42. package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +3 -0
  43. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframe.d.ts +4 -1
  44. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +3 -0
  45. package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +3 -2
  46. package/dist/providers/FunkitCheckoutContext/types.d.ts +34 -13
  47. package/dist/providers/FunkitConfigContext.d.ts +4 -0
  48. package/dist/providers/SwappedProvider.d.ts +5 -3
  49. package/dist/utils/tokenIconUrl.d.ts +5 -0
  50. package/dist/wallets/walletConnectors/index.js +28 -28
  51. package/package.json +3 -2
  52. package/dist/hooks/useSkipSwappedPreload.d.ts +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 10.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b2dadf3: Add `uiCustomizations.confirmationScreen.autoExpandFeesSummary` and `uiCustomizations.withdrawalScreen.autoExpandFeesSummary` config flags to auto-expand the transaction fee breakdown on the deposit and withdrawal screens.
8
+ - 446bc6b: Add the Nado network layer under the SDK-private `clients/internal/nado/` directory: gateway/indexer client, live product list, and react-query hooks for the withdrawal flow.
9
+ - a7215d9: Add the Nado protocol core (subaccount encoding, x18 amount conversions, and the `withdraw_collateral_v2` EIP-712 typed-data builder) under the SDK-private `clients/internal/` directory, which is blocked from consumer imports via a `null` exports-map entry.
10
+
11
+ ### Patch Changes
12
+
13
+ - ce3422f: fix(connect): preserve cashier formFactor when entering the withdraw tab (fixes React #185 render loop)
14
+ - ce3422f: fix(connect): keep the cashier withdraw tab after "New deposit"
15
+ - 5aedc00: feat(connect): add explicit formFactor:'cashier' checkout discriminant (requires withdrawalConfig)
16
+ - 0755d6b: Automatically fall back to CDN-derived chain icons when local chain metadata is missing
17
+ - 96f35d1: Gate the Free USDC banner per direction — the banner self-gates on `depositEnabled`/`withdrawalEnabled` so deposits show it while withdrawals stay off after subsidy shutoff.
18
+ - 1aaec91: Split the Swapped iframe context into independent deposit and withdrawal slots so both flows can co-exist without clobbering each other.
19
+ - 7d52158: Automatically fall back to CDN-derived token icons when the asset is missing from the SDK's bundled logos
20
+ - dad6cb2: Move the duplicated Moonpay→ipapi IP-country lookup into a shared `useUserIpInfo` hook in `@funkit/connect-core`; web and RN keep thin wrappers injecting their `logger`, `enabled` gate, and `staleTime`. Public API and web behavior unchanged.
21
+ - Updated dependencies [0755d6b]
22
+ - Updated dependencies [96f35d1]
23
+ - Updated dependencies [dad6cb2]
24
+ - @funkit/connect-core@2.1.0
25
+
3
26
  ## 10.3.0
4
27
 
5
28
  ### Minor Changes
@@ -0,0 +1,46 @@
1
+ "use client";
2
+
3
+ // src/clients/internal/nado/errors.ts
4
+ var NADO_ERROR_CODES = {
5
+ /** Amount would open a borrow with `spot_leverage: "false"`. */
6
+ SPOT_EXECUTE_EXCEEDS_BORROW_LIMIT: 2017,
7
+ /** Stale `tx_nonce` — refetch and retry once. */
8
+ INVALID_NONCE: 2022,
9
+ /** Subaccount has never deposited, so it doesn't exist on Nado yet. */
10
+ NO_PRIOR_DEPOSIT: 2024,
11
+ /** Withdrawal tx not found at the given submission index. */
12
+ INVALID_WITHDRAWAL_IDX: 3004,
13
+ /** Fast-withdrawal validator signatures not aggregated yet. */
14
+ NOT_ENOUGH_FAST_WITHDRAWAL_SIGNATURES: 3005,
15
+ /** Protocol 24h withdrawal limit exceeded. */
16
+ WITHDRAW_RISK: 4004
17
+ };
18
+ var NadoGatewayError = class extends Error {
19
+ constructor(message, options) {
20
+ super(message);
21
+ this.name = "NadoGatewayError";
22
+ this.kind = options.kind;
23
+ this.errorCode = options.errorCode;
24
+ this.httpStatus = options.httpStatus;
25
+ }
26
+ };
27
+ function isNadoTransportError(error) {
28
+ return error instanceof NadoGatewayError && error.kind === "transport";
29
+ }
30
+ function createNadoGatewayError(response, fallbackMessage) {
31
+ return new NadoGatewayError(response.error ?? fallbackMessage, {
32
+ kind: "api",
33
+ errorCode: response.error_code
34
+ });
35
+ }
36
+ function isNadoErrorCode(error, code) {
37
+ return error instanceof NadoGatewayError && error.errorCode === code;
38
+ }
39
+
40
+ export {
41
+ NADO_ERROR_CODES,
42
+ NadoGatewayError,
43
+ isNadoTransportError,
44
+ createNadoGatewayError,
45
+ isNadoErrorCode
46
+ };
@@ -0,0 +1,207 @@
1
+ "use client";
2
+ import {
3
+ getNadoAllProducts,
4
+ getNadoSymbols
5
+ } from "./chunk-OZ3KD24N.js";
6
+ import {
7
+ INK_CHAIN_ID
8
+ } from "./chunk-II5CZTBC.js";
9
+ import {
10
+ multicall
11
+ } from "./chunk-KNHO756P.js";
12
+ import {
13
+ logger
14
+ } from "./chunk-AHYOV7AV.js";
15
+
16
+ // src/clients/internal/nado/products.ts
17
+ import { erc20Abi, getAddress, isAddress } from "viem";
18
+ var NADO_XSTOCK_WITHDRAWALS_ENABLED = false;
19
+ var XSTOCK_SYMBOL_PATTERN = /^w\w+x$/;
20
+ var NADO_SUPPORTED_PRODUCTS = [
21
+ {
22
+ productId: 0,
23
+ symbol: "USDT0",
24
+ tokenAddress: getAddress("0x0200C29006150606B650577BBE7B6248F58470c1"),
25
+ decimals: 6,
26
+ isXstock: false,
27
+ isTradable: true,
28
+ withdrawFeeX18: "1000000000000000000"
29
+ },
30
+ {
31
+ productId: 1,
32
+ symbol: "KBTC",
33
+ tokenAddress: getAddress("0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98"),
34
+ decimals: 8,
35
+ isXstock: false,
36
+ isTradable: true,
37
+ withdrawFeeX18: "10000000000000"
38
+ },
39
+ {
40
+ productId: 3,
41
+ symbol: "WETH",
42
+ tokenAddress: getAddress("0x4200000000000000000000000000000000000006"),
43
+ decimals: 18,
44
+ isXstock: false,
45
+ isTradable: true,
46
+ withdrawFeeX18: "300000000000000"
47
+ },
48
+ {
49
+ productId: 5,
50
+ symbol: "USDC",
51
+ tokenAddress: getAddress("0x2D270e6886d130D724215A266106e6832161EAEd"),
52
+ decimals: 6,
53
+ isXstock: false,
54
+ isTradable: true,
55
+ withdrawFeeX18: "1000000000000000000"
56
+ },
57
+ {
58
+ productId: 115,
59
+ symbol: "wQQQx",
60
+ tokenAddress: getAddress("0x4C1AE29c159838fC1b224636E28E086EB69101f7"),
61
+ decimals: 18,
62
+ isXstock: true,
63
+ isTradable: true,
64
+ withdrawFeeX18: "2000000000000000"
65
+ },
66
+ {
67
+ productId: 117,
68
+ symbol: "wSPYx",
69
+ tokenAddress: getAddress("0xe7e553cd128f0011777323a0b44a7b96ea1cb540"),
70
+ decimals: 18,
71
+ isXstock: true,
72
+ isTradable: true,
73
+ withdrawFeeX18: "2000000000000000"
74
+ },
75
+ {
76
+ productId: 143,
77
+ symbol: "wAAPLx",
78
+ tokenAddress: getAddress("0x943bf64d566c32a2bcd41ac92fb63c111cc9de8f"),
79
+ decimals: 18,
80
+ isXstock: true,
81
+ isTradable: true,
82
+ withdrawFeeX18: "2000000000000000"
83
+ },
84
+ {
85
+ productId: 145,
86
+ symbol: "wAMZNx",
87
+ tokenAddress: getAddress("0x910cabde3eba7fc1ce64fd14bd680b9f60fa0f90"),
88
+ decimals: 18,
89
+ isXstock: true,
90
+ isTradable: false,
91
+ withdrawFeeX18: "2000000000000000"
92
+ },
93
+ {
94
+ productId: 147,
95
+ symbol: "wGOOGLx",
96
+ tokenAddress: getAddress("0xf8c5308f80e459bb53d9ebe689854d9cbb2caa6f"),
97
+ decimals: 18,
98
+ isXstock: true,
99
+ isTradable: true,
100
+ withdrawFeeX18: "2000000000000000"
101
+ },
102
+ {
103
+ productId: 149,
104
+ symbol: "wMETAx",
105
+ tokenAddress: getAddress("0xe840946ffebcd66b7c4e95095effafadfa0d0e56"),
106
+ decimals: 18,
107
+ isXstock: true,
108
+ isTradable: true,
109
+ withdrawFeeX18: "2000000000000000"
110
+ },
111
+ {
112
+ productId: 151,
113
+ symbol: "wMSFTx",
114
+ tokenAddress: getAddress("0x166fbe68274b6a47e025f4ba17388c539f1fa1d0"),
115
+ decimals: 18,
116
+ isXstock: true,
117
+ isTradable: false,
118
+ withdrawFeeX18: "2000000000000000"
119
+ },
120
+ {
121
+ productId: 153,
122
+ symbol: "wNVDAx",
123
+ tokenAddress: getAddress("0xa8ddb5cd96b5222afe198316e9a57caa642850d5"),
124
+ decimals: 18,
125
+ isXstock: true,
126
+ isTradable: true,
127
+ withdrawFeeX18: "2000000000000000"
128
+ },
129
+ {
130
+ productId: 155,
131
+ symbol: "wTSLAx",
132
+ tokenAddress: getAddress("0xc3FdBe3A68EE5dE461D30415a8165cf9Aefe1171"),
133
+ decimals: 18,
134
+ isXstock: true,
135
+ isTradable: true,
136
+ withdrawFeeX18: "2000000000000000"
137
+ }
138
+ ];
139
+ var SUPPORTED_BY_PRODUCT_ID = new Map(
140
+ NADO_SUPPORTED_PRODUCTS.map((p) => [p.productId, p])
141
+ );
142
+ function isWithdrawableNadoProduct(product) {
143
+ return !product.isXstock || NADO_XSTOCK_WITHDRAWALS_ENABLED;
144
+ }
145
+ async function fetchNadoProducts(wagmiConfig, signal) {
146
+ const [{ spot_products }, { symbols }] = await Promise.all([
147
+ getNadoAllProducts(signal),
148
+ getNadoSymbols(signal)
149
+ ]);
150
+ const symbolByProductId = new Map(
151
+ Object.values(symbols).filter((s) => s.type === "spot").map((s) => [s.product_id, s])
152
+ );
153
+ const supported = spot_products.flatMap((product) => {
154
+ const fallback = SUPPORTED_BY_PRODUCT_ID.get(product.product_id);
155
+ if (!fallback) {
156
+ return [];
157
+ }
158
+ if (!isAddress(product.config.token)) {
159
+ logger.warn("nado:products_invalid_token", {
160
+ productId: product.product_id,
161
+ token: product.config.token
162
+ });
163
+ return [];
164
+ }
165
+ return [{ product, fallback }];
166
+ });
167
+ if (supported.length === 0) {
168
+ logger.warn("nado:products_fallback", { message: "empty_join" });
169
+ return NADO_SUPPORTED_PRODUCTS;
170
+ }
171
+ const decimalResults = await multicall(wagmiConfig, {
172
+ chainId: INK_CHAIN_ID,
173
+ allowFailure: true,
174
+ contracts: supported.map(({ product }) => ({
175
+ address: getAddress(product.config.token),
176
+ abi: erc20Abi,
177
+ functionName: "decimals"
178
+ }))
179
+ }).catch((error) => {
180
+ logger.warn("nado:products_decimals_multicall_failed", {
181
+ errorMessage: error instanceof Error ? error.message : String(error)
182
+ });
183
+ return void 0;
184
+ });
185
+ return supported.map(({ product, fallback }, i) => {
186
+ const symbolInfo = symbolByProductId.get(product.product_id);
187
+ const decimals = decimalResults?.[i];
188
+ return {
189
+ productId: product.product_id,
190
+ symbol: symbolInfo?.symbol ?? fallback.symbol,
191
+ tokenAddress: getAddress(product.config.token),
192
+ decimals: decimals?.status === "success" ? decimals.result : fallback.decimals,
193
+ isXstock: symbolInfo ? XSTOCK_SYMBOL_PATTERN.test(symbolInfo.symbol) : fallback.isXstock,
194
+ // Withdrawals don't depend on market status (post_only/soft_reduce_only
195
+ // are routine weekend states) — only fully disabled products are out
196
+ isTradable: symbolInfo ? symbolInfo.trading_status !== "not_tradable" : fallback.isTradable,
197
+ withdrawFeeX18: product.config.withdraw_fee_x18 ?? fallback.withdrawFeeX18
198
+ };
199
+ });
200
+ }
201
+
202
+ export {
203
+ NADO_XSTOCK_WITHDRAWALS_ENABLED,
204
+ NADO_SUPPORTED_PRODUCTS,
205
+ isWithdrawableNadoProduct,
206
+ fetchNadoProducts
207
+ };
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import {
3
+ NADO_INDEXER_URL
4
+ } from "./chunk-II5CZTBC.js";
5
+ import {
6
+ nadoFetch
7
+ } from "./chunk-L2KSNS7H.js";
8
+ import {
9
+ createNadoGatewayError
10
+ } from "./chunk-2YWQL3AO.js";
11
+
12
+ // src/clients/internal/nado/indexer.ts
13
+ async function getNadoWithdrawalEvents(params, signal) {
14
+ const response = await nadoFetch({
15
+ uri: NADO_INDEXER_URL,
16
+ method: "POST",
17
+ body: {
18
+ events: {
19
+ subaccounts: [params.subaccount],
20
+ // v2 is a distinct indexer event type — our executes are all v2
21
+ event_types: ["withdraw_collateral", "withdraw_collateral_v2"],
22
+ limit: { raw: params.limit ?? 10 }
23
+ }
24
+ },
25
+ signal
26
+ });
27
+ if ("status" in response && response.status === "failure") {
28
+ throw createNadoGatewayError(response, "Nado indexer request failed");
29
+ }
30
+ return response;
31
+ }
32
+ function findSettlementForNonce(txs, nonce) {
33
+ return txs.find((entry) => {
34
+ const payload = entry.tx.withdraw_collateral_v2 ?? entry.tx.withdraw_collateral;
35
+ return payload !== void 0 && BigInt(payload.nonce) === nonce;
36
+ });
37
+ }
38
+
39
+ export {
40
+ getNadoWithdrawalEvents,
41
+ findSettlementForNonce
42
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+
3
+ // src/clients/internal/nado/consts.ts
4
+ import { getAddress } from "viem";
5
+ import { ink } from "viem/chains";
6
+ var INK_CHAIN_ID = ink.id;
7
+ var NADO_GATEWAY_URL = "https://gateway.prod.nado.xyz/v1";
8
+ var NADO_INDEXER_URL = "https://archive.prod.nado.xyz/v1";
9
+ var NADO_EIP712_VERIFYING_CONTRACT_ADDRESS = getAddress(
10
+ "0x05ec92D78ED421f3D3Ada77FFdE167106565974E"
11
+ );
12
+
13
+ export {
14
+ INK_CHAIN_ID,
15
+ NADO_GATEWAY_URL,
16
+ NADO_INDEXER_URL,
17
+ NADO_EIP712_VERIFYING_CONTRACT_ADDRESS
18
+ };
@@ -0,0 +1,28 @@
1
+ "use client";
2
+
3
+ // src/wagmi/actions.ts
4
+ import { erc20Abi, formatUnits } from "viem";
5
+ import {
6
+ getBalance as getBalanceCore,
7
+ multicall as multicallCore
8
+ } from "wagmi/actions";
9
+ import {
10
+ estimateGas,
11
+ getAccount,
12
+ getGasPrice,
13
+ getTransaction,
14
+ getWalletClient,
15
+ multicall,
16
+ readContract,
17
+ sendTransaction,
18
+ switchChain,
19
+ waitForTransactionReceipt
20
+ } from "wagmi/actions";
21
+
22
+ export {
23
+ getAccount,
24
+ multicall,
25
+ sendTransaction,
26
+ switchChain,
27
+ waitForTransactionReceipt
28
+ };
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import {
3
+ NadoGatewayError
4
+ } from "./chunk-2YWQL3AO.js";
5
+ import {
6
+ logger
7
+ } from "./chunk-AHYOV7AV.js";
8
+
9
+ // src/clients/internal/nado/fetch.ts
10
+ var DEFAULT_TIMEOUT_MS = 3e4;
11
+ var LOGGED_BODY_MAX_CHARS = 500;
12
+ function isTimeoutError(error) {
13
+ return error instanceof DOMException && error.name === "TimeoutError";
14
+ }
15
+ function createAbortWithTimeout(callerSignal, ms) {
16
+ const controller = new AbortController();
17
+ const id = setTimeout(
18
+ () => controller.abort(
19
+ new DOMException("Nado request timed out", "TimeoutError")
20
+ ),
21
+ ms
22
+ );
23
+ const propagateAbort = () => controller.abort(callerSignal?.reason);
24
+ if (callerSignal?.aborted) {
25
+ propagateAbort();
26
+ } else {
27
+ callerSignal?.addEventListener("abort", propagateAbort);
28
+ }
29
+ return {
30
+ signal: controller.signal,
31
+ cleanup: () => {
32
+ clearTimeout(id);
33
+ callerSignal?.removeEventListener("abort", propagateAbort);
34
+ }
35
+ };
36
+ }
37
+ async function nadoFetch(params) {
38
+ const { uri, method, body, signal } = params;
39
+ const startTimeMs = Date.now();
40
+ const abort = createAbortWithTimeout(signal, DEFAULT_TIMEOUT_MS);
41
+ let response;
42
+ let responseText;
43
+ try {
44
+ response = await fetch(uri, {
45
+ method,
46
+ signal: abort.signal,
47
+ ...body !== void 0 && {
48
+ headers: { "Content-Type": "application/json" },
49
+ body: JSON.stringify(body)
50
+ }
51
+ });
52
+ responseText = await response.text();
53
+ } catch (error) {
54
+ if (!signal?.aborted) {
55
+ logger.warn("nado:fetch_error", {
56
+ uri,
57
+ method,
58
+ durationMs: Date.now() - startTimeMs,
59
+ error
60
+ });
61
+ }
62
+ throw new NadoGatewayError(
63
+ `An error occurred trying to reach Nado: ${error}`,
64
+ { kind: isTimeoutError(error) ? "timeout" : "transport" }
65
+ );
66
+ } finally {
67
+ abort.cleanup();
68
+ }
69
+ if (!response.ok) {
70
+ logger.warn("nado:fetch_failed", {
71
+ uri,
72
+ method,
73
+ status: response.status,
74
+ durationMs: Date.now() - startTimeMs,
75
+ bodyPreview: responseText.slice(0, LOGGED_BODY_MAX_CHARS)
76
+ });
77
+ throw new NadoGatewayError(
78
+ response.status === 429 ? "Nado rate limit exceeded" : `Nado request failed with status ${response.status}`,
79
+ { kind: "http", httpStatus: response.status }
80
+ );
81
+ }
82
+ let json;
83
+ try {
84
+ json = JSON.parse(responseText);
85
+ } catch {
86
+ json = void 0;
87
+ }
88
+ if (json == null) {
89
+ logger.warn("nado:fetch_failed", {
90
+ uri,
91
+ method,
92
+ status: response.status,
93
+ bodyPreview: responseText.slice(0, LOGGED_BODY_MAX_CHARS)
94
+ });
95
+ throw new NadoGatewayError("Nado returned an invalid success response", {
96
+ kind: "transport",
97
+ httpStatus: response.status
98
+ });
99
+ }
100
+ logger.debug("nado:fetch", {
101
+ uri,
102
+ method,
103
+ status: response.status,
104
+ durationMs: Date.now() - startTimeMs,
105
+ bytes: responseText.length
106
+ });
107
+ return json;
108
+ }
109
+
110
+ export {
111
+ nadoFetch
112
+ };
@@ -3,7 +3,7 @@ import {
3
3
  FunInput,
4
4
  FunSkeletonBlock,
5
5
  TooltipAnchorRefContext
6
- } from "./chunk-RWCJ4XGX.js";
6
+ } from "./chunk-RCMAGKMG.js";
7
7
  import {
8
8
  Box,
9
9
  Text,
@@ -0,0 +1,107 @@
1
+ "use client";
2
+ import {
3
+ NADO_GATEWAY_URL
4
+ } from "./chunk-II5CZTBC.js";
5
+ import {
6
+ nadoFetch
7
+ } from "./chunk-L2KSNS7H.js";
8
+ import {
9
+ NadoGatewayError,
10
+ createNadoGatewayError,
11
+ isNadoTransportError
12
+ } from "./chunk-2YWQL3AO.js";
13
+
14
+ // src/clients/internal/nado/gateway.ts
15
+ function parseNadoGatewayResponse(response) {
16
+ if (response.status !== "success") {
17
+ throw createNadoGatewayError(response, "Nado gateway request failed");
18
+ }
19
+ return response.data;
20
+ }
21
+ async function nadoQuery(params, signal) {
22
+ const response = await nadoFetch({
23
+ uri: `${NADO_GATEWAY_URL}/query?${new URLSearchParams(params)}`,
24
+ method: "GET",
25
+ signal
26
+ });
27
+ const data = parseNadoGatewayResponse(response);
28
+ if (data === void 0) {
29
+ throw new NadoGatewayError("Nado returned success without data", {
30
+ kind: "api"
31
+ });
32
+ }
33
+ return data;
34
+ }
35
+ async function getNadoMaxWithdrawable(params, signal) {
36
+ const data = await nadoQuery(
37
+ {
38
+ type: "max_withdrawable",
39
+ product_id: params.productId.toString(),
40
+ sender: params.sender,
41
+ spot_leverage: params.spotLeverage ? "true" : "false"
42
+ },
43
+ signal
44
+ );
45
+ return data.max_withdrawable;
46
+ }
47
+ async function getNadoTxNonce(address) {
48
+ const query = () => nadoQuery({ type: "nonces", address });
49
+ let data;
50
+ try {
51
+ data = await query();
52
+ } catch (error) {
53
+ if (!isNadoTransportError(error)) {
54
+ throw error;
55
+ }
56
+ data = await query();
57
+ }
58
+ return BigInt(data.tx_nonce);
59
+ }
60
+ async function getNadoFeeRates(sender, signal) {
61
+ return nadoQuery({ type: "fee_rates", sender }, signal);
62
+ }
63
+ async function getNadoSubaccountInfo(subaccount, signal) {
64
+ return nadoQuery(
65
+ { type: "subaccount_info", subaccount },
66
+ signal
67
+ );
68
+ }
69
+ async function getNadoAllProducts(signal) {
70
+ return nadoQuery({ type: "all_products" }, signal);
71
+ }
72
+ async function getNadoSymbols(signal) {
73
+ return nadoQuery({ type: "symbols" }, signal);
74
+ }
75
+ async function executeNadoWithdrawCollateralV2(params) {
76
+ const response = await nadoFetch({
77
+ uri: `${NADO_GATEWAY_URL}/execute`,
78
+ method: "POST",
79
+ body: {
80
+ // spot_leverage sits INSIDE the execute object (sibling of tx/signature),
81
+ // matching @nadohq's EngineBaseClient — top-level is silently ignored.
82
+ withdraw_collateral_v2: {
83
+ tx: {
84
+ sender: params.sender,
85
+ productId: params.productId,
86
+ amount: params.amount.toString(),
87
+ nonce: params.nonce.toString(),
88
+ sendTo: params.sendTo,
89
+ appendix: "0"
90
+ },
91
+ signature: params.signature,
92
+ spot_leverage: params.spotLeverage
93
+ }
94
+ }
95
+ });
96
+ parseNadoGatewayResponse(response);
97
+ }
98
+
99
+ export {
100
+ getNadoMaxWithdrawable,
101
+ getNadoTxNonce,
102
+ getNadoFeeRates,
103
+ getNadoSubaccountInfo,
104
+ getNadoAllProducts,
105
+ getNadoSymbols,
106
+ executeNadoWithdrawCollateralV2
107
+ };
@@ -46,6 +46,7 @@ var DEFAULT_UI_CUSTOMIZATIONS = {
46
46
  simplifiedUi: false
47
47
  },
48
48
  confirmationScreen: {
49
+ autoExpandFeesSummary: false,
49
50
  preferDestinationWhenSame: false,
50
51
  showAmountSummaryAbovePaymentMethod: false,
51
52
  showDisclaimerAsAlert: true,
@@ -79,7 +80,9 @@ var DEFAULT_UI_CUSTOMIZATIONS = {
79
80
  transferCryptoScreen: {
80
81
  showYouSendYouReceive: false
81
82
  },
82
- withdrawalScreen: {},
83
+ withdrawalScreen: {
84
+ autoExpandFeesSummary: false
85
+ },
83
86
  selectBrokerageScreen: {},
84
87
  connectExchangeScreen: {},
85
88
  customIcons: {},
@@ -1466,7 +1469,33 @@ var DecimalSpan = ({
1466
1469
  children
1467
1470
  );
1468
1471
 
1472
+ // src/providers/provideFunkitConnectChains.ts
1473
+ import { chainMetadataById } from "@funkit/chains";
1474
+ var groupChainsById = (chains) => {
1475
+ const chainsById = {};
1476
+ for (const chainItem of chains) {
1477
+ chainsById[chainItem.id] = chainItem;
1478
+ }
1479
+ return chainsById;
1480
+ };
1481
+
1482
+ // src/providers/FunkitConnectChainContext.tsx
1483
+ import React6, {
1484
+ createContext as createContext4,
1485
+ useContext as useContext4,
1486
+ useMemo as useMemo2
1487
+ } from "react";
1488
+ var FunkitConnectChainContext = createContext4(
1489
+ {
1490
+ chains: []
1491
+ }
1492
+ );
1493
+ var useFunkitConnectChains = () => useContext4(FunkitConnectChainContext).chains;
1494
+ var useFunkitConnectChainsById = () => groupChainsById(useFunkitConnectChains());
1495
+
1469
1496
  export {
1497
+ chainMetadataById,
1498
+ useFunkitConnectChainsById,
1470
1499
  useFunkitConfig,
1471
1500
  TooltipAnchorRefContext,
1472
1501
  FunSkeletonBlock,
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Nado deployment constants: prod endpoints and on-chain contract addresses.
3
+ *
4
+ * @see {@link https://docs.nado.xyz/developer-resources/api/endpoints | Nado API endpoints}
5
+ * @see {@link https://docs.nado.xyz/more/contracts | Nado contract addresses}
6
+ */
7
+ /** Nado settles exclusively on Ink. */
8
+ export declare const INK_CHAIN_ID: 57073;
9
+ export declare const NADO_GATEWAY_URL = "https://gateway.prod.nado.xyz/v1";
10
+ export declare const NADO_INDEXER_URL = "https://archive.prod.nado.xyz/v1";
11
+ /**
12
+ * Nado's Endpoint contract on Ink. Never called by this flow — it's the
13
+ * EIP-712 domain `verifyingContract` both we and Nado's gateway hash
14
+ * signatures over (orders verify against the product address instead).
15
+ */
16
+ export declare const NADO_EIP712_VERIFYING_CONTRACT_ADDRESS: `0x${string}`;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import {
3
+ INK_CHAIN_ID,
4
+ NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
5
+ NADO_GATEWAY_URL,
6
+ NADO_INDEXER_URL
7
+ } from "../../chunk-II5CZTBC.js";
8
+ export {
9
+ INK_CHAIN_ID,
10
+ NADO_EIP712_VERIFYING_CONTRACT_ADDRESS,
11
+ NADO_GATEWAY_URL,
12
+ NADO_INDEXER_URL
13
+ };