@rhinestone/deposit-modal 0.4.3 → 0.5.1

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.
@@ -1,6 +1,7 @@
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 _chunkEDUWRMQIcjs = require('./chunk-EDUWRMQI.cjs');
3
+
4
+ var _chunkPDFLALUTcjs = require('./chunk-PDFLALUT.cjs');
4
5
 
5
6
 
6
7
 
@@ -23,6 +24,7 @@ var _wagmi = require('wagmi');
23
24
  var _react3 = require('@reown/appkit/react');
24
25
  var _networks = require('@reown/appkit/networks');
25
26
 
27
+ var _viem = require('viem');
26
28
 
27
29
  // src/core/reown-networks.ts
28
30
 
@@ -70,6 +72,20 @@ function getAppKitNetwork(chainId) {
70
72
 
71
73
  // src/core/reown.tsx
72
74
  var _jsxruntime = require('react/jsx-runtime');
75
+ function buildTransports(rpcUrls) {
76
+ const transports = {};
77
+ for (const network of EVM_NETWORKS) {
78
+ const id = Number(network.id);
79
+ transports[id] = _viem.http.call(void 0, _chunkPDFLALUTcjs.rpcUrlFor.call(void 0, rpcUrls, id));
80
+ }
81
+ return transports;
82
+ }
83
+ function getEvmRpcFingerprint(rpcUrls) {
84
+ return EVM_NETWORKS.map((network) => {
85
+ const id = Number(network.id);
86
+ return `${id}=${_nullishCoalesce(_chunkPDFLALUTcjs.rpcUrlFor.call(void 0, rpcUrls, id), () => ( ""))}`;
87
+ }).join("|");
88
+ }
73
89
  var cachedAdapter = null;
74
90
  var cachedAdapterKey = null;
75
91
  function mapTheme(theme) {
@@ -80,12 +96,17 @@ function mapTheme(theme) {
80
96
  }
81
97
  return { themeMode, themeVariables };
82
98
  }
83
- function getOrCreateAdapter(projectId, enableSolana, theme) {
84
- const adapterKey = `${projectId}:${enableSolana ? "solana" : "evm"}`;
99
+ function getOrCreateAdapter(projectId, enableSolana, theme, rpcUrls) {
100
+ const adapterKey = [
101
+ projectId,
102
+ enableSolana ? "solana" : "evm",
103
+ getEvmRpcFingerprint(rpcUrls)
104
+ ].join(":");
85
105
  if (cachedAdapter && cachedAdapterKey === adapterKey) return cachedAdapter;
86
106
  cachedAdapter = new (0, _appkitadapterwagmi.WagmiAdapter)({
87
107
  networks: EVM_NETWORKS,
88
- projectId
108
+ projectId,
109
+ transports: buildTransports(rpcUrls)
89
110
  });
90
111
  cachedAdapterKey = adapterKey;
91
112
  const { themeMode, themeVariables } = mapTheme(theme);
@@ -110,10 +131,11 @@ function ReownWalletProvider({
110
131
  projectId,
111
132
  theme,
112
133
  enableSolana = true,
134
+ rpcUrls,
113
135
  children
114
136
  }) {
115
137
  const [queryClient] = _react.useState.call(void 0, () => new (0, _reactquery.QueryClient)());
116
- const adapter = getOrCreateAdapter(projectId, enableSolana, theme);
138
+ const adapter = getOrCreateAdapter(projectId, enableSolana, theme, rpcUrls);
117
139
  const config = adapter.wagmiConfig;
118
140
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _wagmi.WagmiProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children }) });
119
141
  }
@@ -155,7 +177,7 @@ function useReownWallet() {
155
177
  await switchChainAsync({ chainId });
156
178
  }
157
179
  } catch (err) {
158
- if (_chunkEDUWRMQIcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
180
+ if (_chunkPDFLALUTcjs.isUnsupportedChainSwitchError.call(void 0, err)) {
159
181
  throw new Error(
160
182
  `Switch to ${_chunkABVRVW3Pcjs.getChainName.call(void 0, chainId)} in your wallet to continue`
161
183
  );
@@ -10,6 +10,7 @@ import {
10
10
  Modal,
11
11
  PoweredBy,
12
12
  ProcessingStep,
13
+ RpcUrlsProvider,
13
14
  Spinner,
14
15
  WalletIcon,
15
16
  accountFromPrivateKey,
@@ -29,8 +30,10 @@ import {
29
30
  loadSessionOwnerFromStorage,
30
31
  saveSessionOwnerToStorage,
31
32
  useLatestRef,
33
+ useRpcUrls,
34
+ useStableRpcUrls,
32
35
  useTokenPrices
33
- } from "./chunk-7EQQD7B4.mjs";
36
+ } from "./chunk-4YLVKTSU.mjs";
34
37
  import {
35
38
  buildSafeTransaction,
36
39
  executeSafeErc20Transfer,
@@ -845,6 +848,7 @@ function WithdrawFlow({
845
848
  onError,
846
849
  debug
847
850
  }) {
851
+ const rpcUrls = useRpcUrls();
848
852
  const onStepChangeRef = useLatestRef(onStepChange);
849
853
  const onEventRef = useLatestRef(onEvent);
850
854
  const onLifecycleRef = useLatestRef(onLifecycle);
@@ -941,14 +945,14 @@ function WithdrawFlow({
941
945
  return {
942
946
  ownerAddress: dappAddress,
943
947
  walletClient: dappWalletClient ?? void 0,
944
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
948
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
945
949
  switchChain: dappSwitchChain
946
950
  };
947
951
  }
948
952
  return {
949
953
  ownerAddress: dappWalletClient.account.address,
950
954
  walletClient: dappWalletClient,
951
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
955
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
952
956
  switchChain: dappSwitchChain
953
957
  };
954
958
  }
@@ -959,7 +963,7 @@ function WithdrawFlow({
959
963
  return {
960
964
  ownerAddress: dappWalletClient.account.address,
961
965
  walletClient: dappWalletClient,
962
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
966
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
963
967
  switchChain: dappSwitchChain
964
968
  };
965
969
  }
@@ -983,7 +987,8 @@ function WithdrawFlow({
983
987
  dappSwitchChain,
984
988
  dappAddress,
985
989
  reownWallet,
986
- sourceChain
990
+ sourceChain,
991
+ rpcUrls
987
992
  ]);
988
993
  const ownerAddress = signerContext?.ownerAddress;
989
994
  const recipientForRegistration = useMemo2(() => {
@@ -1254,7 +1259,7 @@ function WithdrawFlow({
1254
1259
  targetToken
1255
1260
  });
1256
1261
  const amountUnits = parseUnits2(amountValue, asset.decimals);
1257
- const pc = signerContext?.publicClient ?? getPublicClient(sourceChain);
1262
+ const pc = signerContext?.publicClient ?? getPublicClient(sourceChain, rpcUrls);
1258
1263
  let result;
1259
1264
  if (onSignTransaction) {
1260
1265
  const transferTarget = isSameRoute ? recipient : smartAccount;
@@ -1362,7 +1367,8 @@ function WithdrawFlow({
1362
1367
  logFlow,
1363
1368
  logFlowError,
1364
1369
  onLifecycleRef,
1365
- storeApi
1370
+ storeApi,
1371
+ rpcUrls
1366
1372
  ]
1367
1373
  );
1368
1374
  const handleWithdrawComplete = useCallback2(
@@ -1499,7 +1505,7 @@ function WithdrawFlow({
1499
1505
  if (!signerContext) return null;
1500
1506
  if (!onSignTransaction && !signerContext.walletClient) return null;
1501
1507
  const resolvedConnectedRecipient = selectedWalletOption?.kind === "external" ? selectedWalletOption.address : void 0;
1502
- const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
1508
+ const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain, rpcUrls);
1503
1509
  const depositAddress = registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : void 0;
1504
1510
  const stepView = deriveStepView(flowStep, registration);
1505
1511
  return /* @__PURE__ */ jsxs3("div", { className: "rs-modal-body", children: [
@@ -1588,7 +1594,7 @@ function deriveStepView(step, _registration) {
1588
1594
  // src/WithdrawModal.tsx
1589
1595
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1590
1596
  var ReownWithdrawInner = lazy(
1591
- () => import("./WithdrawModalReown-XPB53FKZ.mjs").then((m) => ({
1597
+ () => import("./WithdrawModalReown-AQTB4OZN.mjs").then((m) => ({
1592
1598
  default: m.WithdrawModalReown
1593
1599
  }))
1594
1600
  );
@@ -1617,6 +1623,7 @@ function WithdrawModalInner({
1617
1623
  closeOnOverlayClick,
1618
1624
  allowedRoutes,
1619
1625
  backendUrl = DEFAULT_BACKEND_URL,
1626
+ rpcUrls: rpcUrlsProp,
1620
1627
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1621
1628
  sessionChainIds,
1622
1629
  forceRegister = false,
@@ -1641,6 +1648,7 @@ function WithdrawModalInner({
1641
1648
  );
1642
1649
  const targetChain = getChainId(targetChainProp);
1643
1650
  const sourceChain = getChainId(sourceChainProp);
1651
+ const rpcUrls = useStableRpcUrls(rpcUrlsProp);
1644
1652
  const service = useMemo3(
1645
1653
  () => createDepositService(backendUrl, { debug, debugScope: "service:withdraw" }),
1646
1654
  [backendUrl, debug]
@@ -1675,7 +1683,7 @@ function WithdrawModalInner({
1675
1683
  }, []);
1676
1684
  const showBackButton = uiConfig?.showBackButton ?? true;
1677
1685
  const canGoBack = backHandler !== void 0;
1678
- return /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
1686
+ return /* @__PURE__ */ jsx4(RpcUrlsProvider, { value: rpcUrls, children: /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
1679
1687
  Modal,
1680
1688
  {
1681
1689
  isOpen,
@@ -1739,7 +1747,7 @@ function WithdrawModalInner({
1739
1747
  )
1740
1748
  ] })
1741
1749
  }
1742
- ) });
1750
+ ) }) });
1743
1751
  }
1744
1752
 
1745
1753
  export {