@funkit/connect 10.3.0 → 10.5.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 (107) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/clients/chunk-2YWQL3AO.js +46 -0
  3. package/dist/clients/chunk-A4WQS6QG.js +207 -0
  4. package/dist/clients/chunk-BNMZM23Q.js +42 -0
  5. package/dist/clients/{chunk-HOORQPSY.js → chunk-F6P4CN27.js} +24 -8
  6. package/dist/clients/chunk-FJ6GCMJ4.js +29 -0
  7. package/dist/clients/chunk-II5CZTBC.js +18 -0
  8. package/dist/clients/chunk-L2KSNS7H.js +112 -0
  9. package/dist/clients/chunk-OZ3KD24N.js +107 -0
  10. package/dist/clients/{chunk-3STGJU6Z.js → chunk-QHS5N7GP.js} +2 -2
  11. package/dist/clients/{chunk-RWCJ4XGX.js → chunk-WRS7AFM2.js} +31 -2
  12. package/dist/clients/fanatics.js +1 -1
  13. package/dist/clients/internal/nado/consts.d.ts +16 -0
  14. package/dist/clients/internal/nado/consts.js +13 -0
  15. package/dist/clients/internal/nado/encoding.d.ts +22 -0
  16. package/dist/clients/internal/nado/encoding.js +32 -0
  17. package/dist/clients/internal/nado/errors.d.ts +55 -0
  18. package/dist/clients/internal/nado/errors.js +15 -0
  19. package/dist/clients/internal/nado/fetch.d.ts +15 -0
  20. package/dist/clients/internal/nado/fetch.js +9 -0
  21. package/dist/clients/internal/nado/gateway.d.ts +83 -0
  22. package/dist/clients/internal/nado/gateway.js +23 -0
  23. package/dist/clients/internal/nado/hooks.d.ts +360 -0
  24. package/dist/clients/internal/nado/hooks.js +132 -0
  25. package/dist/clients/internal/nado/indexer.d.ts +43 -0
  26. package/dist/clients/internal/nado/indexer.js +13 -0
  27. package/dist/clients/internal/nado/products.d.ts +36 -0
  28. package/dist/clients/internal/nado/products.js +19 -0
  29. package/dist/clients/internal/nado/typedData.d.ts +80 -0
  30. package/dist/clients/internal/nado/typedData.js +43 -0
  31. package/dist/clients/internal/nado/withdrawalConfig.d.ts +11 -0
  32. package/dist/clients/internal/nado/withdrawalConfig.js +17 -0
  33. package/dist/clients/internal/nado/withdrawalTypes.d.ts +30 -0
  34. package/dist/clients/internal/nado/withdrawalTypes.js +1 -0
  35. package/dist/clients/lighter.d.ts +1 -0
  36. package/dist/clients/lighter.js +202 -57
  37. package/dist/clients/mallard.js +9 -24
  38. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  39. package/dist/clients/polymarket/index.js +3 -3
  40. package/dist/components/ChainIcon/ChainIcon.d.ts +16 -0
  41. package/dist/components/FreeUsdcBanner/FreeUsdcBanner.d.ts +1 -1
  42. package/dist/components/FunAssetAvatar/FunAssetAvatar.d.ts +1 -2
  43. package/dist/hooks/useChainMetadata.d.ts +11 -0
  44. package/dist/hooks/useCheckoutDirectExecutionHistory.d.ts +2 -1
  45. package/dist/hooks/usePaymentMethodTabs.d.ts +8 -2
  46. package/dist/hooks/useSwappedIframeLifecycle.d.ts +5 -2
  47. package/dist/hooks/useSwappedPreload.d.ts +7 -11
  48. package/dist/hooks/useUserIpInfo.d.ts +1 -19
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.js +3700 -3299
  51. package/dist/modals/CheckoutModal/SourceChange/SourceChange.d.ts +3 -0
  52. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframe.d.ts +4 -1
  53. package/dist/modals/CheckoutModal/SwappedIframe/SwappedIframeController.d.ts +3 -0
  54. package/dist/modals/CheckoutModal/isWithdrawalStep.d.ts +3 -2
  55. package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +46 -2
  56. package/dist/modals/WithdrawalModal/useFiatWithdrawal.d.ts +1 -1
  57. package/dist/modals/WithdrawalModal/useWithdrawal.d.ts +3 -15
  58. package/dist/providers/FunkitCheckoutContext/types.d.ts +73 -14
  59. package/dist/providers/FunkitConfigContext.d.ts +11 -0
  60. package/dist/providers/GeneralWalletProvider.d.ts +1 -4
  61. package/dist/providers/SwappedProvider.d.ts +5 -3
  62. package/dist/utils/lighter.d.ts +68 -1
  63. package/dist/utils/purifyCheckoutHistoryItem.d.ts +2 -41
  64. package/dist/utils/swapped.d.ts +1 -1
  65. package/dist/utils/tokenIconUrl.d.ts +5 -0
  66. package/dist/utils/userInfo.d.ts +8 -0
  67. package/dist/utils/withdrawal.d.ts +2 -1
  68. package/dist/wagmi/actions.d.ts +1 -1
  69. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  70. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  71. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  72. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  73. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  74. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  75. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  76. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  77. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  78. package/dist/wallets/walletConnectors/index.js +33 -33
  79. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  80. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  81. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  82. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  83. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  84. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  85. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  86. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  87. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  88. package/package.json +3 -2
  89. package/dist/hooks/useSkipSwappedPreload.d.ts +0 -7
  90. package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
  91. package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
  92. package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
  93. package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
  94. package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
  95. package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
  96. package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
  97. package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
  98. package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
  99. package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
  100. package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
  101. package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
  102. package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
  103. package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
  104. package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
  105. package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
  106. package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
  107. package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @funkit/connect
2
2
 
3
+ ## 10.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - abd36bd: Add an optional `source` to `funkitConfig` to attribute your onchain activity and silence the automatic-source console warning.
8
+ - a6c1fbc: Add explicit L1 on-chain withdrawal fallback for Lighter Secure when the L2 withdraw is rate-limited (error 23004)
9
+ - 0d75178: Add Lighter L1 on-chain withdrawal helpers (withdraw ABI, calldata builder, base-unit conversion, rate-limit detector)
10
+ - 85e73fc: Add Nado withdrawal support to the withdrawal config types.
11
+ - 565d999: `onWithdrawalConfirmation` now receives the withdrawal's form data (destination chain, token, recipient, amounts) as a second argument.
12
+
13
+ ### Patch Changes
14
+
15
+ - 3a2e779: Share the form-of-payment display-name logic and harden the saved-card guard.
16
+ - edf9e78: fix(connect): fix undefined walletAddress
17
+ - 8ad34fe: Pass Mallard externalUserId through as userId unprefixed (no apiKey prefix), matching connect-rn
18
+ - 186c230: test(connect): test ConfirmationStep
19
+ - 8ac239a: refactor(connect-core): promote checkout-history purify layer into core
20
+ - 4b2180b: fix(connect): require wagmi address for web3 isUserLoggedIn
21
+ - 88a1485: Clamp Swapped fiat withdrawals to the user's available balance (EXACT_IN fallback) instead of failing on-chain.
22
+ - Updated dependencies [3a2e779]
23
+ - Updated dependencies [8ac239a]
24
+ - @funkit/connect-core@2.2.0
25
+
26
+ ## 10.4.0
27
+
28
+ ### Minor Changes
29
+
30
+ - b2dadf3: Add `uiCustomizations.confirmationScreen.autoExpandFeesSummary` and `uiCustomizations.withdrawalScreen.autoExpandFeesSummary` config flags to auto-expand the transaction fee breakdown on the deposit and withdrawal screens.
31
+ - 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.
32
+ - 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.
33
+
34
+ ### Patch Changes
35
+
36
+ - ce3422f: fix(connect): preserve cashier formFactor when entering the withdraw tab (fixes React #185 render loop)
37
+ - ce3422f: fix(connect): keep the cashier withdraw tab after "New deposit"
38
+ - 5aedc00: feat(connect): add explicit formFactor:'cashier' checkout discriminant (requires withdrawalConfig)
39
+ - 0755d6b: Automatically fall back to CDN-derived chain icons when local chain metadata is missing
40
+ - 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.
41
+ - 1aaec91: Split the Swapped iframe context into independent deposit and withdrawal slots so both flows can co-exist without clobbering each other.
42
+ - 7d52158: Automatically fall back to CDN-derived token icons when the asset is missing from the SDK's bundled logos
43
+ - 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.
44
+ - Updated dependencies [0755d6b]
45
+ - Updated dependencies [96f35d1]
46
+ - Updated dependencies [dad6cb2]
47
+ - @funkit/connect-core@2.1.0
48
+
3
49
  ## 10.3.0
4
50
 
5
51
  ### 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-FJ6GCMJ4.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
+ };
@@ -417,7 +417,9 @@ var en_default = {
417
417
  lighterSecureAddressTooltip: "You can only withdraw to your connected wallet",
418
418
  lighterSecureTokenTooltip: "You can only receive the token you are choosing to withdraw",
419
419
  lighterSecureChainTooltip: "Secure withdrawals are only available on Ethereum",
420
- lighterFastTokenTooltip: "Fast withdrawals are only available for your USDC (Perps) balance"
420
+ lighterFastTokenTooltip: "Fast withdrawals are only available for your USDC (Perps) balance",
421
+ lighterWithdrawOnChain: "Withdraw on-chain",
422
+ lighterL1FallbackNotice: "You've reached Lighter's secure withdrawal rate limit. You can withdraw directly on-chain instead."
421
423
  },
422
424
  directExecution: {
423
425
  fillStatus: "Fill status",
@@ -982,7 +984,9 @@ var es_default = {
982
984
  lighterSecureAddressTooltip: "Solo puedes retirar a tu billetera conectada",
983
985
  lighterSecureTokenTooltip: "Solo puedes recibir el token que eliges retirar",
984
986
  lighterSecureChainTooltip: "Los retiros seguros solo est\xE1n disponibles en Ethereum",
985
- lighterFastTokenTooltip: "Los retiros r\xE1pidos solo est\xE1n disponibles para tu saldo de USDC (Perps)"
987
+ lighterFastTokenTooltip: "Los retiros r\xE1pidos solo est\xE1n disponibles para tu saldo de USDC (Perps)",
988
+ lighterWithdrawOnChain: "Retirar on-chain",
989
+ lighterL1FallbackNotice: "Has alcanzado el l\xEDmite de retiros seguros de Lighter. Puedes retirar directamente on-chain."
986
990
  },
987
991
  directExecution: {
988
992
  fillStatus: "Estado de completado",
@@ -1547,7 +1551,9 @@ var fr_default = {
1547
1551
  lighterSecureAddressTooltip: "Vous ne pouvez retirer que vers votre portefeuille connect\xE9",
1548
1552
  lighterSecureTokenTooltip: "Vous ne pouvez recevoir que le jeton que vous choisissez de retirer",
1549
1553
  lighterSecureChainTooltip: "Les retraits s\xE9curis\xE9s ne sont disponibles que sur Ethereum",
1550
- lighterFastTokenTooltip: "Les retraits rapides ne sont disponibles que pour votre solde USDC (Perps)"
1554
+ lighterFastTokenTooltip: "Les retraits rapides ne sont disponibles que pour votre solde USDC (Perps)",
1555
+ lighterWithdrawOnChain: "Retirer on-chain",
1556
+ lighterL1FallbackNotice: "Vous avez atteint la limite de retraits s\xE9curis\xE9s de Lighter. Vous pouvez retirer directement on-chain."
1551
1557
  },
1552
1558
  directExecution: {
1553
1559
  fillStatus: "Statut d'ex\xE9cution",
@@ -2112,7 +2118,9 @@ var ja_default = {
2112
2118
  lighterSecureAddressTooltip: "\u63A5\u7D9A\u4E2D\u306E\u30A6\u30A9\u30EC\u30C3\u30C8\u306B\u306E\u307F\u51FA\u91D1\u3067\u304D\u307E\u3059",
2113
2119
  lighterSecureTokenTooltip: "\u51FA\u91D1\u3059\u308B\u901A\u8CA8\u306E\u307F\u53D7\u3051\u53D6\u308C\u307E\u3059",
2114
2120
  lighterSecureChainTooltip: "\u30BB\u30AD\u30E5\u30A2\u51FA\u91D1\u306F\u30A4\u30FC\u30B5\u30EA\u30A2\u30E0\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059",
2115
- lighterFastTokenTooltip: "\u9AD8\u901F\u51FA\u91D1\u306FUSDC (Perps)\u6B8B\u9AD8\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059"
2121
+ lighterFastTokenTooltip: "\u9AD8\u901F\u51FA\u91D1\u306FUSDC (Perps)\u6B8B\u9AD8\u3067\u306E\u307F\u5229\u7528\u3067\u304D\u307E\u3059",
2122
+ lighterWithdrawOnChain: "\u30AA\u30F3\u30C1\u30A7\u30FC\u30F3\u3067\u51FA\u91D1",
2123
+ lighterL1FallbackNotice: "Lighter\u306E\u30BB\u30AD\u30E5\u30A2\u51FA\u91D1\u306E\u30EC\u30FC\u30C8\u5236\u9650\u306B\u9054\u3057\u307E\u3057\u305F\u3002\u4EE3\u308F\u308A\u306B\u30AA\u30F3\u30C1\u30A7\u30FC\u30F3\u3067\u76F4\u63A5\u51FA\u91D1\u3067\u304D\u307E\u3059\u3002"
2116
2124
  },
2117
2125
  directExecution: {
2118
2126
  fillStatus: "\u51E6\u7406\u72B6\u6CC1",
@@ -2677,7 +2685,9 @@ var ko_default = {
2677
2685
  lighterSecureAddressTooltip: "\uC5F0\uACB0\uB41C \uC9C0\uAC11\uC73C\uB85C\uB9CC \uCD9C\uAE08\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4",
2678
2686
  lighterSecureTokenTooltip: "\uCD9C\uAE08\uD558\uB824\uB294 \uD1A0\uD070\uB9CC \uBC1B\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4",
2679
2687
  lighterSecureChainTooltip: "\uBCF4\uC548 \uCD9C\uAE08\uC740 \uC774\uB354\uB9AC\uC6C0\uC5D0\uC11C\uB9CC \uAC00\uB2A5\uD569\uB2C8\uB2E4",
2680
- lighterFastTokenTooltip: "\uBE60\uB978 \uCD9C\uAE08\uC740 USDC (Perps) \uC794\uC561\uC5D0\uC11C\uB9CC \uC774\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4"
2688
+ lighterFastTokenTooltip: "\uBE60\uB978 \uCD9C\uAE08\uC740 USDC (Perps) \uC794\uC561\uC5D0\uC11C\uB9CC \uC774\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4",
2689
+ lighterWithdrawOnChain: "\uC628\uCCB4\uC778\uC73C\uB85C \uCD9C\uAE08",
2690
+ lighterL1FallbackNotice: "Lighter\uC758 \uBCF4\uC548 \uCD9C\uAE08 \uD55C\uB3C4\uC5D0 \uB3C4\uB2EC\uD588\uC2B5\uB2C8\uB2E4. \uB300\uC2E0 \uC628\uCCB4\uC778\uC5D0\uC11C \uC9C1\uC811 \uCD9C\uAE08\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."
2681
2691
  },
2682
2692
  directExecution: {
2683
2693
  fillStatus: "\uCC98\uB9AC \uC0C1\uD0DC",
@@ -3242,7 +3252,9 @@ var ru_default = {
3242
3252
  lighterSecureAddressTooltip: "\u0412\u044B\u0432\u043E\u0434 \u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0451\u043D\u043D\u044B\u0439 \u043A\u043E\u0448\u0435\u043B\u0451\u043A",
3243
3253
  lighterSecureTokenTooltip: "\u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0442\u043E\u0442 \u0442\u043E\u043A\u0435\u043D, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u0432\u044B\u0432\u043E\u0434\u0438\u0442\u0435",
3244
3254
  lighterSecureChainTooltip: "\u0411\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u044B\u0439 \u0432\u044B\u0432\u043E\u0434 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u0441\u0435\u0442\u0438 Ethereum",
3245
- lighterFastTokenTooltip: "\u0411\u044B\u0441\u0442\u0440\u044B\u0439 \u0432\u044B\u0432\u043E\u0434 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0432\u0430\u0448\u0435\u0433\u043E \u0431\u0430\u043B\u0430\u043D\u0441\u0430 USDC (Perps)"
3255
+ lighterFastTokenTooltip: "\u0411\u044B\u0441\u0442\u0440\u044B\u0439 \u0432\u044B\u0432\u043E\u0434 \u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0432\u0430\u0448\u0435\u0433\u043E \u0431\u0430\u043B\u0430\u043D\u0441\u0430 USDC (Perps)",
3256
+ lighterWithdrawOnChain: "\u0412\u044B\u0432\u0435\u0441\u0442\u0438 \u0432 \u0441\u0435\u0442\u0438",
3257
+ lighterL1FallbackNotice: "\u0412\u044B \u0434\u043E\u0441\u0442\u0438\u0433\u043B\u0438 \u043B\u0438\u043C\u0438\u0442\u0430 \u0431\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u044B\u0445 \u0432\u044B\u0432\u043E\u0434\u043E\u0432 Lighter. \u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0432\u044B\u0432\u0435\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043D\u0430\u043F\u0440\u044F\u043C\u0443\u044E \u0432 \u0441\u0435\u0442\u0438."
3246
3258
  },
3247
3259
  directExecution: {
3248
3260
  fillStatus: "\u0421\u0442\u0430\u0442\u0443\u0441 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F",
@@ -3807,7 +3819,9 @@ var tr_default = {
3807
3819
  lighterSecureAddressTooltip: "Yaln\u0131zca ba\u011Fl\u0131 c\xFCzdan\u0131n\u0131za para \xE7ekebilirsiniz",
3808
3820
  lighterSecureTokenTooltip: "Yaln\u0131zca \xE7ekmeyi se\xE7ti\u011Finiz tokeni alabilirsiniz",
3809
3821
  lighterSecureChainTooltip: "G\xFCvenli \xE7ekimler yaln\u0131zca Ethereum'da kullan\u0131labilir",
3810
- lighterFastTokenTooltip: "H\u0131zl\u0131 \xE7ekimler yaln\u0131zca USDC (Perps) bakiyeniz i\xE7in kullan\u0131labilir"
3822
+ lighterFastTokenTooltip: "H\u0131zl\u0131 \xE7ekimler yaln\u0131zca USDC (Perps) bakiyeniz i\xE7in kullan\u0131labilir",
3823
+ lighterWithdrawOnChain: "Zincir \xFCzerinde \xE7ek",
3824
+ lighterL1FallbackNotice: "Lighter'\u0131n g\xFCvenli \xE7ekim h\u0131z s\u0131n\u0131r\u0131na ula\u015Ft\u0131n\u0131z. Bunun yerine do\u011Frudan zincir \xFCzerinden \xE7ekebilirsiniz."
3811
3825
  },
3812
3826
  directExecution: {
3813
3827
  fillStatus: "\u0130\u015Flem durumu",
@@ -4372,7 +4386,9 @@ var zh_default = {
4372
4386
  lighterSecureAddressTooltip: "\u60A8\u53EA\u80FD\u63D0\u73B0\u5230\u5DF2\u8FDE\u63A5\u7684\u94B1\u5305",
4373
4387
  lighterSecureTokenTooltip: "\u60A8\u53EA\u80FD\u63A5\u6536\u6240\u9009\u62E9\u63D0\u73B0\u7684\u4EE3\u5E01",
4374
4388
  lighterSecureChainTooltip: "\u5B89\u5168\u63D0\u73B0\u4EC5\u652F\u6301\u4EE5\u592A\u574A",
4375
- lighterFastTokenTooltip: "\u5FEB\u901F\u63D0\u73B0\u4EC5\u652F\u6301\u60A8\u7684 USDC (Perps) \u4F59\u989D"
4389
+ lighterFastTokenTooltip: "\u5FEB\u901F\u63D0\u73B0\u4EC5\u652F\u6301\u60A8\u7684 USDC (Perps) \u4F59\u989D",
4390
+ lighterWithdrawOnChain: "\u94FE\u4E0A\u63D0\u73B0",
4391
+ lighterL1FallbackNotice: "\u60A8\u5DF2\u8FBE\u5230 Lighter \u7684\u5B89\u5168\u63D0\u73B0\u9891\u7387\u9650\u5236\u3002\u60A8\u53EF\u4EE5\u6539\u4E3A\u76F4\u63A5\u5728\u94FE\u4E0A\u63D0\u73B0\u3002"
4376
4392
  },
4377
4393
  directExecution: {
4378
4394
  fillStatus: "\u586B\u5145\u72B6\u6001",
@@ -0,0 +1,29 @@
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
+ signTypedData,
19
+ switchChain,
20
+ waitForTransactionReceipt
21
+ } from "wagmi/actions";
22
+
23
+ export {
24
+ getAccount,
25
+ multicall,
26
+ sendTransaction,
27
+ switchChain,
28
+ waitForTransactionReceipt
29
+ };
@@ -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,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
+ };