@rhinestone/deposit-modal 0.3.0-alpha.6 → 0.3.0-alpha.8

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 (38) hide show
  1. package/dist/{DepositModalReown-SBSP5ZW2.cjs → DepositModalReown-LWGABUOF.cjs} +12 -9
  2. package/dist/{DepositModalReown-3N7YYGB4.mjs → DepositModalReown-TYHATVOM.mjs} +9 -6
  3. package/dist/{WithdrawModalReown-4B6IMTBB.cjs → WithdrawModalReown-FCWED55P.cjs} +7 -7
  4. package/dist/{WithdrawModalReown-BB3MZAIO.mjs → WithdrawModalReown-H7HA3JP3.mjs} +4 -4
  5. package/dist/{chunk-CTYKQ4B4.mjs → chunk-5ZS4ZJPW.mjs} +272 -145
  6. package/dist/chunk-7JIDIX27.cjs +554 -0
  7. package/dist/{chunk-QI6Q7V6O.mjs → chunk-DW276H63.mjs} +26 -34
  8. package/dist/{chunk-5YXAQB6A.mjs → chunk-E46WOBZQ.mjs} +56 -16
  9. package/dist/{chunk-UVIIWUWP.cjs → chunk-GBFOGYMH.cjs} +1193 -862
  10. package/dist/{chunk-EJH36TH2.mjs → chunk-H7QMSMM5.mjs} +1247 -916
  11. package/dist/{chunk-YQFH2WSW.cjs → chunk-PKD7W5JG.cjs} +54 -14
  12. package/dist/chunk-SZIYS42B.mjs +554 -0
  13. package/dist/{chunk-BB6UVRAV.cjs → chunk-U3OLJZBT.cjs} +110 -118
  14. package/dist/{chunk-DX2D2TRZ.cjs → chunk-UELVNPGE.cjs} +312 -185
  15. package/dist/constants-DqVn968d.d.cts +52 -0
  16. package/dist/constants-DqVn968d.d.ts +52 -0
  17. package/dist/constants.cjs +8 -2
  18. package/dist/constants.d.cts +17 -48
  19. package/dist/constants.d.ts +17 -48
  20. package/dist/constants.mjs +7 -1
  21. package/dist/deposit.cjs +4 -4
  22. package/dist/deposit.d.cts +2 -2
  23. package/dist/deposit.d.ts +2 -2
  24. package/dist/deposit.mjs +3 -3
  25. package/dist/index.cjs +6 -6
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.mjs +5 -5
  29. package/dist/styles.css +180 -34
  30. package/dist/{types-xSHZSlrT.d.cts → types-D8Q4TMk7.d.cts} +17 -5
  31. package/dist/{types-xSHZSlrT.d.ts → types-D8Q4TMk7.d.ts} +17 -5
  32. package/dist/withdraw.cjs +4 -4
  33. package/dist/withdraw.d.cts +2 -2
  34. package/dist/withdraw.d.ts +2 -2
  35. package/dist/withdraw.mjs +3 -3
  36. package/package.json +5 -5
  37. package/dist/chunk-IVTXEYB2.cjs +0 -507
  38. package/dist/chunk-VA3ANS7D.mjs +0 -507
@@ -1,7 +1,7 @@
1
1
  import {
2
- AlertTriangleIcon,
3
2
  BodyHeader,
4
3
  Button,
4
+ Callout,
5
5
  ChevronDownIcon,
6
6
  ChevronLeftIcon,
7
7
  CircleArrowOutUpLeftIcon,
@@ -31,7 +31,7 @@ import {
31
31
  saveSessionOwnerToStorage,
32
32
  toEvmCaip2,
33
33
  useLatestRef
34
- } from "./chunk-CTYKQ4B4.mjs";
34
+ } from "./chunk-5ZS4ZJPW.mjs";
35
35
  import {
36
36
  DEFAULT_BACKEND_URL,
37
37
  DEFAULT_SIGNER_ADDRESS,
@@ -44,7 +44,7 @@ import {
44
44
  getTokenDecimalsByAddress,
45
45
  getTokenIcon,
46
46
  getTokenSymbol
47
- } from "./chunk-VA3ANS7D.mjs";
47
+ } from "./chunk-SZIYS42B.mjs";
48
48
 
49
49
  // src/WithdrawModal.tsx
50
50
  import {
@@ -385,8 +385,8 @@ function WithdrawFormStep({
385
385
  }
386
386
  }, [recipient, amount, balance, asset.decimals, onSubmit]);
387
387
  if (isBalanceLoading) {
388
- return /* @__PURE__ */ jsxs("div", { className: "rs-step", children: [
389
- /* @__PURE__ */ jsxs("div", { className: "rs-step-body rs-withdraw-loading", children: [
388
+ return /* @__PURE__ */ jsxs("div", { className: "rs-screen", children: [
389
+ /* @__PURE__ */ jsxs("div", { className: "rs-screen-body rs-withdraw-loading", children: [
390
390
  /* @__PURE__ */ jsx(Spinner, { className: "rs-spinner--lg" }),
391
391
  /* @__PURE__ */ jsx("div", { className: "rs-withdraw-loading-title", children: "Loading on-chain balance" }),
392
392
  /* @__PURE__ */ jsx("div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${getChainName(asset.chainId)} to continue.` : "Please wait before withdrawing." })
@@ -394,8 +394,8 @@ function WithdrawFormStep({
394
394
  /* @__PURE__ */ jsx(PoweredBy, {})
395
395
  ] });
396
396
  }
397
- return /* @__PURE__ */ jsxs("div", { className: "rs-step", children: [
398
- /* @__PURE__ */ jsxs("div", { className: "rs-step-body rs-withdraw-form", children: [
397
+ return /* @__PURE__ */ jsxs("div", { className: "rs-screen", children: [
398
+ /* @__PURE__ */ jsxs("div", { className: "rs-screen-body", children: [
399
399
  /* @__PURE__ */ jsx(BodyHeader, { icon: /* @__PURE__ */ jsx(CircleArrowOutUpLeftIcon, {}), title: "Withdraw" }),
400
400
  /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-section", children: [
401
401
  /* @__PURE__ */ jsx("label", { className: "rs-withdraw-label", children: "Recipient address" }),
@@ -621,25 +621,19 @@ function WithdrawFormStep({
621
621
  ] })
622
622
  ] }),
623
623
  chainMismatch && /* @__PURE__ */ jsx("div", { className: "rs-chain-switch", children: /* @__PURE__ */ jsx("div", { className: "rs-chain-switch-text", children: isSwitching ? `Switching to ${getChainName(asset.chainId)}...` : `Switch to ${getChainName(asset.chainId)} to continue.` }) }),
624
- error && /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-error", children: [
625
- /* @__PURE__ */ jsx(AlertTriangleIcon, {}),
626
- /* @__PURE__ */ jsx("span", { children: error })
627
- ] }),
628
- !error && registrationError && /* @__PURE__ */ jsxs("div", { className: "rs-withdraw-error", children: [
629
- /* @__PURE__ */ jsx(AlertTriangleIcon, {}),
630
- /* @__PURE__ */ jsx("span", { children: registrationError })
631
- ] })
624
+ error && /* @__PURE__ */ jsx(Callout, { variant: "error", children: error }),
625
+ !error && registrationError && /* @__PURE__ */ jsx(Callout, { variant: "error", children: registrationError }),
626
+ /* @__PURE__ */ jsx(
627
+ Button,
628
+ {
629
+ onClick: handleWithdraw,
630
+ fullWidth: true,
631
+ loading: isBusy,
632
+ disabled: !recipient || !amount || chainMismatch || isBusy || Boolean(registrationError),
633
+ children: isBusy ? "Preparing..." : registrationPending ? "Preparing session..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
634
+ }
635
+ )
632
636
  ] }),
633
- /* @__PURE__ */ jsx("div", { className: "rs-step-footer", children: /* @__PURE__ */ jsx(
634
- Button,
635
- {
636
- onClick: handleWithdraw,
637
- fullWidth: true,
638
- loading: isBusy,
639
- disabled: !recipient || !amount || chainMismatch || isBusy || Boolean(registrationError),
640
- children: isBusy ? "Preparing..." : registrationPending ? "Preparing session..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
641
- }
642
- ) }),
643
637
  /* @__PURE__ */ jsx(PoweredBy, {})
644
638
  ] });
645
639
  }
@@ -743,14 +737,8 @@ function WithdrawReviewStep({
743
737
  /* @__PURE__ */ jsx2("span", { className: "rs-review-detail-value", children: estimatedTime })
744
738
  ] })
745
739
  ] }),
746
- error && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-error", role: "alert", children: [
747
- /* @__PURE__ */ jsx2(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
748
- /* @__PURE__ */ jsx2("span", { children: error })
749
- ] }),
750
- !error && registrationError && /* @__PURE__ */ jsxs2("div", { className: "rs-amount-error", role: "alert", children: [
751
- /* @__PURE__ */ jsx2(AlertTriangleIcon, { style: { width: 16, height: 16, flexShrink: 0 } }),
752
- /* @__PURE__ */ jsx2("span", { children: registrationError })
753
- ] }),
740
+ error && /* @__PURE__ */ jsx2(Callout, { variant: "error", children: error }),
741
+ !error && registrationError && /* @__PURE__ */ jsx2(Callout, { variant: "error", children: registrationError }),
754
742
  /* @__PURE__ */ jsx2(
755
743
  Button,
756
744
  {
@@ -1293,6 +1281,10 @@ function WithdrawFlow({
1293
1281
  txHash,
1294
1282
  destinationTxHash,
1295
1283
  amount: context.amount,
1284
+ // Withdraw targets are always EVM — WithdrawModalProps.targetChain is
1285
+ // Chain | number (never "solana"). The context union is wide only
1286
+ // because ProcessingStep is shared with the deposit flow, so narrow
1287
+ // back here.
1296
1288
  sourceChain: context.sourceChain,
1297
1289
  sourceToken: context.sourceToken,
1298
1290
  targetChain: context.targetChain,
@@ -1493,7 +1485,7 @@ function deriveStepView(step, _registration) {
1493
1485
  // src/WithdrawModal.tsx
1494
1486
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1495
1487
  var ReownWithdrawInner = lazy(
1496
- () => import("./WithdrawModalReown-BB3MZAIO.mjs").then((m) => ({
1488
+ () => import("./WithdrawModalReown-H7HA3JP3.mjs").then((m) => ({
1497
1489
  default: m.WithdrawModalReown
1498
1490
  }))
1499
1491
  );
@@ -1,3 +1,11 @@
1
+ import {
2
+ isUnsupportedChainSwitchError
3
+ } from "./chunk-5ZS4ZJPW.mjs";
4
+ import {
5
+ SUPPORTED_CHAINS,
6
+ getChainName
7
+ } from "./chunk-SZIYS42B.mjs";
8
+
1
9
  // src/core/reown.tsx
2
10
  import { useState } from "react";
3
11
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
@@ -8,29 +16,50 @@ import {
8
16
  createAppKit,
9
17
  useAppKit,
10
18
  useAppKitAccount,
19
+ useAppKitNetwork,
11
20
  useAppKitState,
12
21
  useWalletInfo,
13
22
  modal
14
23
  } from "@reown/appkit/react";
24
+ import { solana } from "@reown/appkit/networks";
25
+ import { useWalletClient, usePublicClient, useSwitchChain } from "wagmi";
26
+
27
+ // src/core/reown-networks.ts
15
28
  import {
16
29
  mainnet,
17
- base,
18
- arbitrum,
19
30
  optimism,
20
31
  polygon,
32
+ arbitrum,
33
+ base,
21
34
  bsc,
22
- solana
35
+ soneium,
36
+ plasma
23
37
  } from "@reown/appkit/networks";
24
- import { useWalletClient, usePublicClient, useSwitchChain } from "wagmi";
38
+ var APPKIT_NETWORK_BY_ID = {
39
+ [mainnet.id]: mainnet,
40
+ [optimism.id]: optimism,
41
+ [polygon.id]: polygon,
42
+ [arbitrum.id]: arbitrum,
43
+ [base.id]: base,
44
+ [bsc.id]: bsc,
45
+ [soneium.id]: soneium,
46
+ [plasma.id]: plasma
47
+ };
48
+ var EVM_NETWORKS = SUPPORTED_CHAINS.map((chain) => {
49
+ const network = APPKIT_NETWORK_BY_ID[chain.id];
50
+ if (!network) {
51
+ throw new Error(
52
+ `[rhinestone] No AppKit network registered for supported chain ${chain.id} (${chain.name}). Add it to APPKIT_NETWORK_BY_ID in reown-networks.ts.`
53
+ );
54
+ }
55
+ return network;
56
+ });
57
+ function getAppKitNetwork(chainId) {
58
+ return APPKIT_NETWORK_BY_ID[chainId];
59
+ }
60
+
61
+ // src/core/reown.tsx
25
62
  import { jsx } from "react/jsx-runtime";
26
- var EVM_NETWORKS = [
27
- mainnet,
28
- base,
29
- arbitrum,
30
- optimism,
31
- polygon,
32
- bsc
33
- ];
34
63
  var cachedAdapter = null;
35
64
  var cachedAdapterKey = null;
36
65
  function mapTheme(theme) {
@@ -94,6 +123,7 @@ function useReownWallet() {
94
123
  const { walletInfo } = useWalletInfo();
95
124
  const { data: walletClient } = useWalletClient();
96
125
  const publicClient = usePublicClient();
126
+ const { switchNetwork } = useAppKitNetwork();
97
127
  const { switchChainAsync } = useSwitchChain();
98
128
  const isSolana = caipAddress?.startsWith("solana:") ?? false;
99
129
  const solanaAddress = isSolana ? caipAddress?.split(":").slice(2).join(":") : void 0;
@@ -116,11 +146,21 @@ function useReownWallet() {
116
146
  void modal?.disconnect();
117
147
  },
118
148
  switchChain: async (chainId) => {
119
- if (walletClient?.switchChain) {
120
- await walletClient.switchChain({ id: chainId });
121
- return;
149
+ const target = getAppKitNetwork(chainId);
150
+ try {
151
+ if (target) {
152
+ await switchNetwork(target);
153
+ } else {
154
+ await switchChainAsync({ chainId });
155
+ }
156
+ } catch (err) {
157
+ if (isUnsupportedChainSwitchError(err)) {
158
+ throw new Error(
159
+ `Switch to ${getChainName(chainId)} in your wallet to continue`
160
+ );
161
+ }
162
+ throw err;
122
163
  }
123
- await switchChainAsync({ chainId });
124
164
  }
125
165
  };
126
166
  }