@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,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunk36R7XKXPcjs = require('./chunk-36R7XKXP.cjs');
3
+ var _chunkAMEXFHB4cjs = require('./chunk-AMEXFHB4.cjs');
4
4
  require('./chunk-NRNJAQUA.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkPQDHZZ2Bcjs = require('./chunk-PQDHZZ2B.cjs');
9
- require('./chunk-EDUWRMQI.cjs');
8
+ var _chunkHT364QJKcjs = require('./chunk-HT364QJK.cjs');
9
+ require('./chunk-PDFLALUT.cjs');
10
10
  require('./chunk-UEKPBRBY.cjs');
11
11
  require('./chunk-ABVRVW3P.cjs');
12
12
 
@@ -16,7 +16,7 @@ var _react3 = require('@reown/appkit/react');
16
16
  var _react5 = require('@reown/appkit-adapter-solana/react');
17
17
  var _jsxruntime = require('react/jsx-runtime');
18
18
  function DepositModalWithReown(props) {
19
- const reown = _chunkPQDHZZ2Bcjs.useReownWallet.call(void 0, );
19
+ const reown = _chunkHT364QJKcjs.useReownWallet.call(void 0, );
20
20
  const enableSolana = _nullishCoalesce(props.enableSolana, () => ( true));
21
21
  const { walletProvider: solanaWalletProvider } = _react3.useAppKitProvider.call(void 0,
22
22
  enableSolana ? "solana" : "eip155"
@@ -37,7 +37,7 @@ function DepositModalWithReown(props) {
37
37
  reown.disconnect();
38
38
  }, [reown.disconnect]);
39
39
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
40
- _chunk36R7XKXPcjs.DepositModalInner,
40
+ _chunkAMEXFHB4cjs.DepositModalInner,
41
41
  {
42
42
  ...props,
43
43
  reownWallet: reownWithSolana,
@@ -48,11 +48,12 @@ function DepositModalWithReown(props) {
48
48
  }
49
49
  function DepositModalReown(props) {
50
50
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
51
- _chunkPQDHZZ2Bcjs.ReownWalletProvider,
51
+ _chunkHT364QJKcjs.ReownWalletProvider,
52
52
  {
53
53
  projectId: props.reownAppId,
54
54
  theme: props.theme,
55
55
  enableSolana: props.enableSolana,
56
+ rpcUrls: props.rpcUrls,
56
57
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DepositModalWithReown, { ...props })
57
58
  }
58
59
  );
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-ANPDY6NJ.mjs";
3
+ } from "./chunk-XPJJWJPM.mjs";
4
4
  import "./chunk-FJWLC4AM.mjs";
5
5
  import {
6
6
  ReownWalletProvider,
7
7
  useReownWallet
8
- } from "./chunk-V72YVCR6.mjs";
9
- import "./chunk-7EQQD7B4.mjs";
8
+ } from "./chunk-QEW5NAGV.mjs";
9
+ import "./chunk-4YLVKTSU.mjs";
10
10
  import "./chunk-F7P4MV72.mjs";
11
11
  import "./chunk-WJX3TJFK.mjs";
12
12
 
@@ -53,6 +53,7 @@ function DepositModalReown(props) {
53
53
  projectId: props.reownAppId,
54
54
  theme: props.theme,
55
55
  enableSolana: props.enableSolana,
56
+ rpcUrls: props.rpcUrls,
56
57
  children: /* @__PURE__ */ jsx(DepositModalWithReown, { ...props })
57
58
  }
58
59
  );
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  WithdrawModalInner
3
- } from "./chunk-IDJBMNV2.mjs";
3
+ } from "./chunk-KYHPKMTK.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
- } from "./chunk-V72YVCR6.mjs";
8
- import "./chunk-7EQQD7B4.mjs";
7
+ } from "./chunk-QEW5NAGV.mjs";
8
+ import "./chunk-4YLVKTSU.mjs";
9
9
  import "./chunk-F7P4MV72.mjs";
10
10
  import "./chunk-WJX3TJFK.mjs";
11
11
 
@@ -31,7 +31,15 @@ function WithdrawModalWithReown(props) {
31
31
  );
32
32
  }
33
33
  function WithdrawModalReown(props) {
34
- return /* @__PURE__ */ jsx(ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ jsx(WithdrawModalWithReown, { ...props }) });
34
+ return /* @__PURE__ */ jsx(
35
+ ReownWalletProvider,
36
+ {
37
+ projectId: props.reownAppId,
38
+ theme: props.theme,
39
+ rpcUrls: props.rpcUrls,
40
+ children: /* @__PURE__ */ jsx(WithdrawModalWithReown, { ...props })
41
+ }
42
+ );
35
43
  }
36
44
  export {
37
45
  WithdrawModalReown
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk3NZUMDSTcjs = require('./chunk-3NZUMDST.cjs');
3
+ var _chunkV4XVFT25cjs = require('./chunk-V4XVFT25.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkPQDHZZ2Bcjs = require('./chunk-PQDHZZ2B.cjs');
8
- require('./chunk-EDUWRMQI.cjs');
7
+ var _chunkHT364QJKcjs = require('./chunk-HT364QJK.cjs');
8
+ require('./chunk-PDFLALUT.cjs');
9
9
  require('./chunk-UEKPBRBY.cjs');
10
10
  require('./chunk-ABVRVW3P.cjs');
11
11
 
@@ -13,7 +13,7 @@ require('./chunk-ABVRVW3P.cjs');
13
13
  var _react = require('react');
14
14
  var _jsxruntime = require('react/jsx-runtime');
15
15
  function WithdrawModalWithReown(props) {
16
- const reown = _chunkPQDHZZ2Bcjs.useReownWallet.call(void 0, );
16
+ const reown = _chunkHT364QJKcjs.useReownWallet.call(void 0, );
17
17
  const handleConnect = _react.useCallback.call(void 0, () => {
18
18
  reown.openConnect();
19
19
  }, [reown.openConnect]);
@@ -21,7 +21,7 @@ function WithdrawModalWithReown(props) {
21
21
  reown.disconnect();
22
22
  }, [reown.disconnect]);
23
23
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
24
- _chunk3NZUMDSTcjs.WithdrawModalInner,
24
+ _chunkV4XVFT25cjs.WithdrawModalInner,
25
25
  {
26
26
  ...props,
27
27
  reownWallet: reown,
@@ -31,7 +31,15 @@ function WithdrawModalWithReown(props) {
31
31
  );
32
32
  }
33
33
  function WithdrawModalReown(props) {
34
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkPQDHZZ2Bcjs.ReownWalletProvider, { projectId: props.reownAppId, theme: props.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props }) });
34
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
35
+ _chunkHT364QJKcjs.ReownWalletProvider,
36
+ {
37
+ projectId: props.reownAppId,
38
+ theme: props.theme,
39
+ rpcUrls: props.rpcUrls,
40
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WithdrawModalWithReown, { ...props })
41
+ }
42
+ );
35
43
  }
36
44
 
37
45
 
@@ -1395,31 +1395,57 @@ function formatUserError(raw) {
1395
1395
  return cleaned;
1396
1396
  }
1397
1397
 
1398
+ // src/core/rpc.ts
1399
+ import { createContext, useContext, useMemo } from "react";
1400
+ function rpcUrlFor(rpcUrls, chain) {
1401
+ const url = rpcUrls?.[chain]?.trim();
1402
+ return url ? url : void 0;
1403
+ }
1404
+ var RpcUrlsContext = createContext(void 0);
1405
+ var RpcUrlsProvider = RpcUrlsContext.Provider;
1406
+ function useRpcUrls() {
1407
+ return useContext(RpcUrlsContext);
1408
+ }
1409
+ function rpcUrlsKey(rpcUrls) {
1410
+ if (!rpcUrls) return "";
1411
+ return Object.entries(rpcUrls).map(([chain, url]) => [chain, url?.trim() ?? ""]).filter(([, url]) => url !== "").map(([chain, url]) => `${chain}=${url}`).sort().join("|");
1412
+ }
1413
+ function useStableRpcUrls(rpcUrls) {
1414
+ const key = rpcUrlsKey(rpcUrls);
1415
+ return useMemo(() => rpcUrls, [key]);
1416
+ }
1417
+
1398
1418
  // src/core/public-client.ts
1399
1419
  import { createPublicClient, http } from "viem";
1400
1420
  import { hyperliquid } from "viem/chains";
1401
1421
  var clientCache = /* @__PURE__ */ new Map();
1402
- function getPublicClient(chainId) {
1403
- let client = clientCache.get(chainId);
1422
+ function getPublicClient(chainId, rpcUrls) {
1423
+ const url = rpcUrlFor(rpcUrls, chainId);
1424
+ const cacheKey = `${chainId}|${url ?? ""}`;
1425
+ let client = clientCache.get(cacheKey);
1404
1426
  if (!client) {
1405
1427
  const chain = CHAIN_BY_ID[chainId];
1406
1428
  client = createPublicClient({
1407
1429
  chain,
1408
- transport: http()
1430
+ transport: http(url)
1409
1431
  });
1410
- clientCache.set(chainId, client);
1432
+ clientCache.set(cacheKey, client);
1411
1433
  }
1412
1434
  return client;
1413
1435
  }
1414
- var hyperEvmClient;
1415
- function getHyperEvmReadClient() {
1416
- if (!hyperEvmClient) {
1417
- hyperEvmClient = createPublicClient({
1436
+ var hyperEvmClientCache = /* @__PURE__ */ new Map();
1437
+ function getHyperEvmReadClient(rpcUrls) {
1438
+ const url = rpcUrlFor(rpcUrls, hyperliquid.id);
1439
+ const cacheKey = url ?? "";
1440
+ let client = hyperEvmClientCache.get(cacheKey);
1441
+ if (!client) {
1442
+ client = createPublicClient({
1418
1443
  chain: hyperliquid,
1419
- transport: http()
1444
+ transport: http(url)
1420
1445
  });
1446
+ hyperEvmClientCache.set(cacheKey, client);
1421
1447
  }
1422
- return hyperEvmClient;
1448
+ return client;
1423
1449
  }
1424
1450
 
1425
1451
  // src/core/theme.ts
@@ -2789,6 +2815,7 @@ FeesAccordion.displayName = "FeesAccordion";
2789
2815
  import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
2790
2816
  function SwappedReceipt({
2791
2817
  onrampMethod,
2818
+ onrampMethodIcon,
2792
2819
  amountPaid,
2793
2820
  depositedAmount,
2794
2821
  depositedIcon,
@@ -2804,14 +2831,17 @@ function SwappedReceipt({
2804
2831
  /* @__PURE__ */ jsxs20("div", { className: "rs-review-details", children: [
2805
2832
  onrampMethod && /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2806
2833
  /* @__PURE__ */ jsx22("span", { children: "Onramp method" }),
2807
- /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-value", children: onrampMethod })
2834
+ /* @__PURE__ */ jsxs20("span", { className: "rs-review-detail-value", children: [
2835
+ /* @__PURE__ */ jsx22("span", { children: onrampMethod }),
2836
+ onrampMethodIcon && /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-icon rs-review-detail-icon--square", children: /* @__PURE__ */ jsx22("img", { src: onrampMethodIcon, alt: "" }) })
2837
+ ] })
2808
2838
  ] }),
2809
2839
  amountPaid && /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2810
2840
  /* @__PURE__ */ jsx22("span", { children: "Amount paid" }),
2811
2841
  /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-value", children: amountPaid })
2812
2842
  ] }),
2813
2843
  /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2814
- /* @__PURE__ */ jsx22("span", { children: "Deposited amount" }),
2844
+ /* @__PURE__ */ jsx22("span", { children: "Receive" }),
2815
2845
  /* @__PURE__ */ jsxs20("span", { className: "rs-review-detail-value", children: [
2816
2846
  /* @__PURE__ */ jsx22("span", { children: depositedAmount }),
2817
2847
  depositedIcon && /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx22("img", { src: depositedIcon, alt: "" }) })
@@ -3327,6 +3357,7 @@ function ProcessingStep({
3327
3357
  quotedFeeSymbol,
3328
3358
  balanceAfterUsd,
3329
3359
  isSwappedOrder,
3360
+ swappedContext,
3330
3361
  onClose,
3331
3362
  onNewDeposit,
3332
3363
  onRetry,
@@ -3437,10 +3468,12 @@ function ProcessingStep({
3437
3468
  if (cancelled || !res) return;
3438
3469
  if (res.transactionId != null) {
3439
3470
  if (res.transactionId.toLowerCase() !== txHash.toLowerCase()) return;
3440
- } else if (!isSwappedOrder) {
3471
+ } else if (!isSwappedOrder || swappedContext?.variant === "connect") {
3441
3472
  return;
3442
3473
  }
3443
3474
  setSwappedFiatContext({
3475
+ orderCrypto: res.orderCrypto,
3476
+ orderCryptoAmount: res.orderCryptoAmount,
3444
3477
  paidAmountUsd: res.paidAmountUsd,
3445
3478
  paidAmountEur: res.paidAmountEur,
3446
3479
  onrampFeeUsd: res.onrampFeeUsd,
@@ -3451,7 +3484,7 @@ function ProcessingStep({
3451
3484
  return () => {
3452
3485
  cancelled = true;
3453
3486
  };
3454
- }, [service, smartAccount, txHash, isSwappedOrder]);
3487
+ }, [service, smartAccount, txHash, isSwappedOrder, swappedContext?.variant]);
3455
3488
  useEffect5(() => {
3456
3489
  if (directTransfer) return;
3457
3490
  if (state.type !== "processing") {
@@ -3727,8 +3760,14 @@ function ProcessingStep({
3727
3760
  /* @__PURE__ */ jsx23("div", { className: "rs-body-header-text", children: /* @__PURE__ */ jsx23("h2", { className: "rs-body-header-title", children: stateTitle }) })
3728
3761
  ] }) : /* @__PURE__ */ jsx23(BodyHeader, { icon: /* @__PURE__ */ jsx23(WalletIcon, {}), title: stateTitle });
3729
3762
  if (isComplete && isSwappedOrder) {
3730
- const onrampMethod = swappedFiatContext?.paymentMethod ? formatPaymentMethod(swappedFiatContext.paymentMethod) : null;
3731
- const amountPaid = swappedFiatContext?.paidAmountUsd != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null;
3763
+ const effectivePaymentMethod = swappedContext?.method ?? swappedFiatContext?.paymentMethod ?? null;
3764
+ const onrampMethod = effectivePaymentMethod ? formatPaymentMethod(effectivePaymentMethod) : null;
3765
+ const onrampMethodIcon = swappedContext?.variant === "connect" && effectivePaymentMethod ? getExchangeLogoSrc(
3766
+ onrampMethod ?? effectivePaymentMethod,
3767
+ effectivePaymentMethod
3768
+ ) : null;
3769
+ const connectPaidAmount = swappedContext?.variant === "connect" ? `${formattedSentAmount} ${sourceSymbol}` : null;
3770
+ const amountPaid = connectPaidAmount ?? (swappedFiatContext?.paidAmountUsd != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null);
3732
3771
  const depositedAmount = receiveDisplay;
3733
3772
  const onrampFeeUsd = swappedFiatContext?.onrampFeeUsd ?? null;
3734
3773
  const networkFeeUsd = quotedFeeAmount !== void 0 && Number.isFinite(Number(quotedFeeAmount)) ? Number(quotedFeeAmount) : null;
@@ -3750,6 +3789,7 @@ function ProcessingStep({
3750
3789
  SwappedReceipt,
3751
3790
  {
3752
3791
  onrampMethod,
3792
+ onrampMethodIcon,
3753
3793
  amountPaid,
3754
3794
  depositedAmount,
3755
3795
  depositedIcon: targetTokenIcon,
@@ -4041,6 +4081,10 @@ export {
4041
4081
  failureMessageForEvent,
4042
4082
  useTokenPrices,
4043
4083
  ProcessingStep,
4084
+ rpcUrlFor,
4085
+ RpcUrlsProvider,
4086
+ useRpcUrls,
4087
+ useStableRpcUrls,
4044
4088
  getPublicClient,
4045
4089
  getHyperEvmReadClient,
4046
4090
  loadSessionOwnerFromStorage,