@rhinestone/deposit-modal 0.0.0-dev-20260727175848 → 0.0.0-dev-20260728133107

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 (30) hide show
  1. package/dist/{DepositModalReown-U3YSVVNC.mjs → DepositModalReown-5OJ5W7UF.mjs} +5 -5
  2. package/dist/{DepositModalReown-33D36CMP.cjs → DepositModalReown-ITBBFOT5.cjs} +9 -9
  3. package/dist/{chunk-GDYWSTQK.mjs → chunk-3HNPIAZ2.mjs} +126 -10
  4. package/dist/{chunk-N5226HLL.mjs → chunk-3RS2MAZQ.mjs} +1 -1
  5. package/dist/{chunk-VHKTHX3U.mjs → chunk-73ONCSU4.mjs} +2 -2
  6. package/dist/{chunk-44HXNZSA.cjs → chunk-ADZHPRS6.cjs} +55 -55
  7. package/dist/{chunk-UD6JF6ME.mjs → chunk-DVGQIPR3.mjs} +1 -1
  8. package/dist/{chunk-UWRBNFZX.cjs → chunk-MGY6ZIRN.cjs} +60 -60
  9. package/dist/{chunk-IWAI6VZ2.mjs → chunk-NGHW6KWC.mjs} +24 -4
  10. package/dist/{chunk-R3XTKCJD.mjs → chunk-NNMMD33D.mjs} +2 -2
  11. package/dist/{chunk-YMV3HHPR.cjs → chunk-OO3YA7KN.cjs} +3 -3
  12. package/dist/{chunk-CLR3HPCT.mjs → chunk-OVBGVQ3N.mjs} +1 -1
  13. package/dist/{chunk-VDKPQKAE.cjs → chunk-UIZAZSPM.cjs} +474 -358
  14. package/dist/{chunk-LMBTPDLB.cjs → chunk-WS5LFG34.cjs} +1 -1
  15. package/dist/{chunk-O4CZI63F.cjs → chunk-XBT6WQYZ.cjs} +49 -49
  16. package/dist/{chunk-QRRL4SL5.cjs → chunk-YK7VHKW7.cjs} +26 -6
  17. package/dist/claim.cjs +5 -5
  18. package/dist/claim.mjs +4 -4
  19. package/dist/constants.cjs +2 -2
  20. package/dist/constants.d.cts +1 -1
  21. package/dist/constants.d.ts +1 -1
  22. package/dist/constants.mjs +1 -1
  23. package/dist/deposit.cjs +6 -6
  24. package/dist/deposit.mjs +5 -5
  25. package/dist/index.cjs +8 -8
  26. package/dist/index.mjs +7 -7
  27. package/dist/styles.css +10 -0
  28. package/dist/withdraw.cjs +5 -5
  29. package/dist/withdraw.mjs +4 -4
  30. package/package.json +1 -1
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-GDYWSTQK.mjs";
4
- import "./chunk-N5226HLL.mjs";
5
- import "./chunk-UD6JF6ME.mjs";
3
+ } from "./chunk-3HNPIAZ2.mjs";
4
+ import "./chunk-3RS2MAZQ.mjs";
5
+ import "./chunk-DVGQIPR3.mjs";
6
6
  import {
7
7
  isUnsupportedChainSwitchError,
8
8
  rpcUrlFor
9
- } from "./chunk-IWAI6VZ2.mjs";
10
- import "./chunk-CLR3HPCT.mjs";
9
+ } from "./chunk-NGHW6KWC.mjs";
10
+ import "./chunk-OVBGVQ3N.mjs";
11
11
  import "./chunk-YJP274QC.mjs";
12
12
  import {
13
13
  SUPPORTED_CHAINS,
@@ -1,13 +1,13 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkVDKPQKAEcjs = require('./chunk-VDKPQKAE.cjs');
4
- require('./chunk-UWRBNFZX.cjs');
5
- require('./chunk-YMV3HHPR.cjs');
3
+ var _chunkUIZAZSPMcjs = require('./chunk-UIZAZSPM.cjs');
4
+ require('./chunk-MGY6ZIRN.cjs');
5
+ require('./chunk-OO3YA7KN.cjs');
6
6
 
7
7
 
8
8
 
9
- var _chunkQRRL4SL5cjs = require('./chunk-QRRL4SL5.cjs');
10
- require('./chunk-LMBTPDLB.cjs');
9
+ var _chunkYK7VHKW7cjs = require('./chunk-YK7VHKW7.cjs');
10
+ require('./chunk-WS5LFG34.cjs');
11
11
  require('./chunk-W3WWC4LD.cjs');
12
12
 
13
13
 
@@ -88,14 +88,14 @@ function buildTransports(rpcUrls) {
88
88
  const transports = {};
89
89
  for (const network of EVM_NETWORKS) {
90
90
  const id = Number(network.id);
91
- transports[id] = _viem.http.call(void 0, _chunkQRRL4SL5cjs.rpcUrlFor.call(void 0, rpcUrls, id));
91
+ transports[id] = _viem.http.call(void 0, _chunkYK7VHKW7cjs.rpcUrlFor.call(void 0, rpcUrls, id));
92
92
  }
93
93
  return transports;
94
94
  }
95
95
  function getEvmRpcFingerprint(rpcUrls) {
96
96
  return EVM_NETWORKS.map((network) => {
97
97
  const id = Number(network.id);
98
- return `${id}=${_nullishCoalesce(_chunkQRRL4SL5cjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
98
+ return `${id}=${_nullishCoalesce(_chunkYK7VHKW7cjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
99
99
  }).join("|");
100
100
  }
101
101
  var cachedAdapter = null;
@@ -189,7 +189,7 @@ function useReownWallet() {
189
189
  await switchChainAsync({ chainId });
190
190
  }
191
191
  } catch (err) {
192
- if (_chunkQRRL4SL5cjs.isUnsupportedChainSwitchError.call(void 0, err)) {
192
+ if (_chunkYK7VHKW7cjs.isUnsupportedChainSwitchError.call(void 0, err)) {
193
193
  throw new Error(
194
194
  `Switch to ${_chunkEGB3NWMLcjs.getChainName.call(void 0, chainId)} in your wallet to continue`
195
195
  );
@@ -226,7 +226,7 @@ function DepositModalWithReown(props) {
226
226
  reown.disconnect();
227
227
  }, [reown.disconnect]);
228
228
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
229
- _chunkVDKPQKAEcjs.DepositModalInner,
229
+ _chunkUIZAZSPMcjs.DepositModalInner,
230
230
  {
231
231
  ...props,
232
232
  reownWallet: reownWithSolana,
@@ -18,10 +18,10 @@ import {
18
18
  readDedupedAccountSetupResult,
19
19
  runAccountSetupDeduped,
20
20
  txRefsMatch
21
- } from "./chunk-N5226HLL.mjs";
21
+ } from "./chunk-3RS2MAZQ.mjs";
22
22
  import {
23
23
  ListRow
24
- } from "./chunk-UD6JF6ME.mjs";
24
+ } from "./chunk-DVGQIPR3.mjs";
25
25
  import {
26
26
  AlertTriangleIcon,
27
27
  AppleIcon,
@@ -49,6 +49,7 @@ import {
49
49
  PoweredBy,
50
50
  RpcUrlsProvider,
51
51
  Spinner,
52
+ SwappedConnectFeeChangedError,
52
53
  TokenIcon,
53
54
  TransferCryptoIcon,
54
55
  UnplugIcon,
@@ -73,7 +74,7 @@ import {
73
74
  useLatestRef,
74
75
  useRpcUrls,
75
76
  useStableRpcUrls
76
- } from "./chunk-IWAI6VZ2.mjs";
77
+ } from "./chunk-NGHW6KWC.mjs";
77
78
  import {
78
79
  POLYMARKET_COLLATERAL_OFFRAMP_ADDRESS,
79
80
  POLYMARKET_ICON_URL,
@@ -3210,6 +3211,7 @@ function ExchangeConnectStep({
3210
3211
  smartAccount,
3211
3212
  service,
3212
3213
  connection,
3214
+ loadUrl: loadPreparedUrl,
3213
3215
  onSwappedComplete,
3214
3216
  onSwappedFailed,
3215
3217
  onClose,
@@ -3218,12 +3220,13 @@ function ExchangeConnectStep({
3218
3220
  onImmersiveChange
3219
3221
  }) {
3220
3222
  const loadUrl = useCallback4(async () => {
3223
+ if (loadPreparedUrl) return loadPreparedUrl();
3221
3224
  const res = await service.getSwappedConnectUrl({
3222
3225
  smartAccount,
3223
3226
  connection
3224
3227
  });
3225
3228
  return res;
3226
- }, [service, smartAccount, connection]);
3229
+ }, [loadPreparedUrl, service, smartAccount, connection]);
3227
3230
  return /* @__PURE__ */ jsx16(
3228
3231
  SwappedIframeStep,
3229
3232
  {
@@ -3263,6 +3266,9 @@ function ExchangeLogo({ exchange }) {
3263
3266
  }
3264
3267
  );
3265
3268
  }
3269
+ function formatFeeRate(bps) {
3270
+ return `${(bps / 100).toFixed(2).replace(/\.?0+$/, "")}%`;
3271
+ }
3266
3272
  function ExchangeSelectStep({
3267
3273
  service,
3268
3274
  onSelectExchange,
@@ -3272,6 +3278,11 @@ function ExchangeSelectStep({
3272
3278
  const [loading, setLoading] = useState8(true);
3273
3279
  const [error, setError] = useState8(null);
3274
3280
  const [retryToken, setRetryToken] = useState8(0);
3281
+ const [exchangeFeeBps, setExchangeFeeBps] = useState8(0);
3282
+ const [selectingConnection, setSelectingConnection] = useState8(
3283
+ null
3284
+ );
3285
+ const [selectionNotice, setSelectionNotice] = useState8(null);
3275
3286
  const retry = useCallback5(() => {
3276
3287
  setRetryToken((n) => n + 1);
3277
3288
  }, []);
@@ -3282,10 +3293,12 @@ function ExchangeSelectStep({
3282
3293
  service.getSwappedConnectExchanges().then((res) => {
3283
3294
  if (cancelled) return;
3284
3295
  setExchanges(res.exchanges);
3296
+ setExchangeFeeBps(res.exchangeFeeBps ?? 0);
3285
3297
  }).catch((err) => {
3286
3298
  if (cancelled) return;
3287
3299
  const message = err instanceof Error ? err.message : "Failed to load exchanges";
3288
3300
  setExchanges([]);
3301
+ setExchangeFeeBps(0);
3289
3302
  setError(message);
3290
3303
  onError?.(message, "SWAPPED_CONNECT_EXCHANGES_FAILED");
3291
3304
  }).finally(() => {
@@ -3295,6 +3308,31 @@ function ExchangeSelectStep({
3295
3308
  cancelled = true;
3296
3309
  };
3297
3310
  }, [service, retryToken, onError]);
3311
+ const selectExchange = useCallback5(
3312
+ async (connection) => {
3313
+ setSelectingConnection(connection);
3314
+ setSelectionNotice(null);
3315
+ try {
3316
+ const actualFeeBps = await onSelectExchange(
3317
+ connection,
3318
+ exchangeFeeBps
3319
+ );
3320
+ if (actualFeeBps !== exchangeFeeBps) {
3321
+ setExchangeFeeBps(actualFeeBps);
3322
+ setSelectionNotice(
3323
+ "The Exchange Fee changed. Review the updated rate and select your exchange again."
3324
+ );
3325
+ }
3326
+ } catch (err) {
3327
+ const message = err instanceof Error ? err.message : "Failed to prepare Connect";
3328
+ setSelectionNotice(message);
3329
+ onError?.(message, "SWAPPED_CONNECT_URL_FAILED");
3330
+ } finally {
3331
+ setSelectingConnection(null);
3332
+ }
3333
+ },
3334
+ [exchangeFeeBps, onError, onSelectExchange]
3335
+ );
3298
3336
  return /* @__PURE__ */ jsxs14("div", { className: "rs-screen rs-exchange-select", children: [
3299
3337
  /* @__PURE__ */ jsxs14("div", { className: "rs-screen-body rs-screen-body--gap-32", children: [
3300
3338
  /* @__PURE__ */ jsx17(
@@ -3337,7 +3375,9 @@ function ExchangeSelectStep({
3337
3375
  {
3338
3376
  type: "button",
3339
3377
  className: "rs-exchange-card",
3340
- onClick: () => onSelectExchange(exchange.connection),
3378
+ onClick: () => void selectExchange(exchange.connection),
3379
+ disabled: selectingConnection !== null,
3380
+ "aria-busy": selectingConnection === exchange.connection,
3341
3381
  "aria-label": `Select ${exchange.name}`,
3342
3382
  children: [
3343
3383
  /* @__PURE__ */ jsx17(
@@ -3354,7 +3394,13 @@ function ExchangeSelectStep({
3354
3394
  );
3355
3395
  }) })
3356
3396
  ] }),
3357
- /* @__PURE__ */ jsx17(PoweredBy, {})
3397
+ /* @__PURE__ */ jsx17(PoweredBy, {}),
3398
+ exchangeFeeBps > 0 && /* @__PURE__ */ jsxs14("p", { className: "rs-exchange-select-fee-note", children: [
3399
+ "A ",
3400
+ formatFeeRate(exchangeFeeBps),
3401
+ " Exchange Fee applies to your deposit."
3402
+ ] }),
3403
+ selectionNotice && /* @__PURE__ */ jsx17("p", { className: "rs-exchange-select-fee-note", role: "status", children: selectionNotice })
3358
3404
  ] });
3359
3405
  }
3360
3406
  ExchangeSelectStep.displayName = "ExchangeSelectStep";
@@ -6819,14 +6865,79 @@ function DepositFlow({
6819
6865
  const handleSelectExchange = useCallback7(() => {
6820
6866
  storeApi.dispatch({ type: "connect/exchange-selected" });
6821
6867
  }, [storeApi]);
6868
+ const swappedConnectUrlRef = useRef8(/* @__PURE__ */ new Map());
6869
+ const acknowledgedConnectFeeRef = useRef8(/* @__PURE__ */ new Map());
6822
6870
  const handleSelectExchangeConnection = useCallback7(
6823
- (connection) => {
6871
+ async (connection, disclosedFeeBps) => {
6872
+ if (setupSlice.status !== "ready" || !setupSlice.smartAccount) {
6873
+ throw new Error("Deposit account is not ready");
6874
+ }
6875
+ const smartAccount = setupSlice.smartAccount;
6876
+ const owner = smartAccount.toLowerCase();
6877
+ const key = `${owner}:${connection}`;
6878
+ let entry = swappedConnectUrlRef.current.get(key);
6879
+ if (!entry) {
6880
+ let response;
6881
+ try {
6882
+ response = await service.getSwappedConnectUrl({
6883
+ smartAccount,
6884
+ connection,
6885
+ acceptedExchangeFeeBps: disclosedFeeBps
6886
+ });
6887
+ } catch (error) {
6888
+ if (error instanceof SwappedConnectFeeChangedError) {
6889
+ return error.exchangeFeeBps;
6890
+ }
6891
+ throw error;
6892
+ }
6893
+ entry = { smartAccount: owner, response };
6894
+ }
6895
+ const currentAccount = storeApi.getState().setup.smartAccount;
6896
+ if (currentAccount?.toLowerCase() !== owner) {
6897
+ swappedConnectUrlRef.current.delete(key);
6898
+ throw new Error("Deposit account changed. Select your exchange again.");
6899
+ }
6900
+ const actualFeeBps = entry.response.exchangeFeeBps ?? 0;
6901
+ if (actualFeeBps !== disclosedFeeBps) {
6902
+ swappedConnectUrlRef.current.delete(key);
6903
+ acknowledgedConnectFeeRef.current.delete(key);
6904
+ return actualFeeBps;
6905
+ }
6906
+ swappedConnectUrlRef.current.set(key, entry);
6907
+ acknowledgedConnectFeeRef.current.set(key, actualFeeBps);
6824
6908
  storeApi.dispatch({
6825
6909
  type: "exchange/connection-selected",
6826
6910
  connection
6827
6911
  });
6912
+ return actualFeeBps;
6828
6913
  },
6829
- [storeApi]
6914
+ [service, setupSlice.status, setupSlice.smartAccount, storeApi]
6915
+ );
6916
+ const loadSwappedConnectUrl = useCallback7(
6917
+ async (smartAccount, connection) => {
6918
+ const key = `${smartAccount.toLowerCase()}:${connection}`;
6919
+ const entry = swappedConnectUrlRef.current.get(key);
6920
+ const expectedFeeBps = acknowledgedConnectFeeRef.current.get(key);
6921
+ if (expectedFeeBps === void 0) {
6922
+ throw new Error(
6923
+ "The Exchange Fee changed. Go back and select your exchange again."
6924
+ );
6925
+ }
6926
+ swappedConnectUrlRef.current.delete(key);
6927
+ const response = entry?.smartAccount === smartAccount.toLowerCase() ? entry.response : await service.getSwappedConnectUrl({
6928
+ smartAccount,
6929
+ connection,
6930
+ acceptedExchangeFeeBps: expectedFeeBps
6931
+ });
6932
+ const actualFeeBps = response.exchangeFeeBps ?? 0;
6933
+ if (actualFeeBps !== expectedFeeBps) {
6934
+ throw new Error(
6935
+ "The Exchange Fee changed. Go back and select your exchange again."
6936
+ );
6937
+ }
6938
+ return response;
6939
+ },
6940
+ [service]
6830
6941
  );
6831
6942
  const swappedUrlPrefetchRef = useRef8(/* @__PURE__ */ new Map());
6832
6943
  const prefetchSwappedWidgetUrl = useCallback7(
@@ -6866,7 +6977,9 @@ function DepositFlow({
6866
6977
  );
6867
6978
  useEffect11(() => {
6868
6979
  swappedUrlPrefetchRef.current.clear();
6869
- }, [dappAddress]);
6980
+ swappedConnectUrlRef.current.clear();
6981
+ acknowledgedConnectFeeRef.current.clear();
6982
+ }, [dappAddress, setupSlice.smartAccount]);
6870
6983
  const handleNewDeposit = useCallback7(() => {
6871
6984
  onLifecycleRef.current?.({
6872
6985
  type: "smart-account-changed",
@@ -6877,6 +6990,8 @@ function DepositFlow({
6877
6990
  stableWalletSignerRef.current = null;
6878
6991
  stableWalletSelectionKeyRef.current = null;
6879
6992
  swappedUrlPrefetchRef.current.clear();
6993
+ swappedConnectUrlRef.current.clear();
6994
+ acknowledgedConnectFeeRef.current.clear();
6880
6995
  lastSmartAccountLifecycleKeyRef.current = null;
6881
6996
  }, [onLifecycleRef, storeApi]);
6882
6997
  const setupInput = useMemo7(
@@ -7504,6 +7619,7 @@ function DepositFlow({
7504
7619
  smartAccount: step.smartAccount,
7505
7620
  service,
7506
7621
  connection: step.connection,
7622
+ loadUrl: () => loadSwappedConnectUrl(step.smartAccount, step.connection),
7507
7623
  onSwappedComplete: handleSwappedComplete,
7508
7624
  onSwappedFailed: handleDepositFailed,
7509
7625
  onClose: onClose ?? (() => {
@@ -8159,7 +8275,7 @@ DepositHistoryPanel.displayName = "DepositHistoryPanel";
8159
8275
  // src/DepositModal.tsx
8160
8276
  import { jsx as jsx27, jsxs as jsxs24 } from "react/jsx-runtime";
8161
8277
  var ReownDepositInner = lazy2(
8162
- () => import("./DepositModalReown-U3YSVVNC.mjs").then((m) => ({ default: m.DepositModalReown }))
8278
+ () => import("./DepositModalReown-5OJ5W7UF.mjs").then((m) => ({ default: m.DepositModalReown }))
8163
8279
  );
8164
8280
  function sortByCreatedAtDesc(items) {
8165
8281
  return [...items].sort((a, b) => {
@@ -20,7 +20,7 @@ import {
20
20
  rpcUrlFor,
21
21
  tokenAmountToNumber,
22
22
  useLatestRef
23
- } from "./chunk-IWAI6VZ2.mjs";
23
+ } from "./chunk-NGHW6KWC.mjs";
24
24
  import {
25
25
  CHAIN_BY_ID,
26
26
  NATIVE_TOKEN_ADDRESS,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ListRow
3
- } from "./chunk-UD6JF6ME.mjs";
3
+ } from "./chunk-DVGQIPR3.mjs";
4
4
  import {
5
5
  AlertTriangleIcon,
6
6
  BodyHeader,
@@ -25,7 +25,7 @@ import {
25
25
  formatUserError,
26
26
  useLatestRef,
27
27
  useStableRpcUrls
28
- } from "./chunk-IWAI6VZ2.mjs";
28
+ } from "./chunk-NGHW6KWC.mjs";
29
29
  import {
30
30
  DEFAULT_BACKEND_URL,
31
31
  getChainIcon,