@rhinestone/deposit-modal 0.4.3 → 0.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.
@@ -1395,31 +1395,49 @@ function formatUserError(raw) {
1395
1395
  return cleaned;
1396
1396
  }
1397
1397
 
1398
+ // src/core/rpc.ts
1399
+ import { createContext, useContext } 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
+
1398
1410
  // src/core/public-client.ts
1399
1411
  import { createPublicClient, http } from "viem";
1400
1412
  import { hyperliquid } from "viem/chains";
1401
1413
  var clientCache = /* @__PURE__ */ new Map();
1402
- function getPublicClient(chainId) {
1403
- let client = clientCache.get(chainId);
1414
+ function getPublicClient(chainId, rpcUrls) {
1415
+ const url = rpcUrlFor(rpcUrls, chainId);
1416
+ const cacheKey = `${chainId}|${url ?? ""}`;
1417
+ let client = clientCache.get(cacheKey);
1404
1418
  if (!client) {
1405
1419
  const chain = CHAIN_BY_ID[chainId];
1406
1420
  client = createPublicClient({
1407
1421
  chain,
1408
- transport: http()
1422
+ transport: http(url)
1409
1423
  });
1410
- clientCache.set(chainId, client);
1424
+ clientCache.set(cacheKey, client);
1411
1425
  }
1412
1426
  return client;
1413
1427
  }
1414
- var hyperEvmClient;
1415
- function getHyperEvmReadClient() {
1416
- if (!hyperEvmClient) {
1417
- hyperEvmClient = createPublicClient({
1428
+ var hyperEvmClientCache = /* @__PURE__ */ new Map();
1429
+ function getHyperEvmReadClient(rpcUrls) {
1430
+ const url = rpcUrlFor(rpcUrls, hyperliquid.id);
1431
+ const cacheKey = url ?? "";
1432
+ let client = hyperEvmClientCache.get(cacheKey);
1433
+ if (!client) {
1434
+ client = createPublicClient({
1418
1435
  chain: hyperliquid,
1419
- transport: http()
1436
+ transport: http(url)
1420
1437
  });
1438
+ hyperEvmClientCache.set(cacheKey, client);
1421
1439
  }
1422
- return hyperEvmClient;
1440
+ return client;
1423
1441
  }
1424
1442
 
1425
1443
  // src/core/theme.ts
@@ -2789,6 +2807,7 @@ FeesAccordion.displayName = "FeesAccordion";
2789
2807
  import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
2790
2808
  function SwappedReceipt({
2791
2809
  onrampMethod,
2810
+ onrampMethodIcon,
2792
2811
  amountPaid,
2793
2812
  depositedAmount,
2794
2813
  depositedIcon,
@@ -2804,14 +2823,17 @@ function SwappedReceipt({
2804
2823
  /* @__PURE__ */ jsxs20("div", { className: "rs-review-details", children: [
2805
2824
  onrampMethod && /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2806
2825
  /* @__PURE__ */ jsx22("span", { children: "Onramp method" }),
2807
- /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-value", children: onrampMethod })
2826
+ /* @__PURE__ */ jsxs20("span", { className: "rs-review-detail-value", children: [
2827
+ /* @__PURE__ */ jsx22("span", { children: onrampMethod }),
2828
+ onrampMethodIcon && /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-icon rs-review-detail-icon--square", children: /* @__PURE__ */ jsx22("img", { src: onrampMethodIcon, alt: "" }) })
2829
+ ] })
2808
2830
  ] }),
2809
2831
  amountPaid && /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2810
2832
  /* @__PURE__ */ jsx22("span", { children: "Amount paid" }),
2811
2833
  /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-value", children: amountPaid })
2812
2834
  ] }),
2813
2835
  /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2814
- /* @__PURE__ */ jsx22("span", { children: "Deposited amount" }),
2836
+ /* @__PURE__ */ jsx22("span", { children: "Receive" }),
2815
2837
  /* @__PURE__ */ jsxs20("span", { className: "rs-review-detail-value", children: [
2816
2838
  /* @__PURE__ */ jsx22("span", { children: depositedAmount }),
2817
2839
  depositedIcon && /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx22("img", { src: depositedIcon, alt: "" }) })
@@ -3327,6 +3349,7 @@ function ProcessingStep({
3327
3349
  quotedFeeSymbol,
3328
3350
  balanceAfterUsd,
3329
3351
  isSwappedOrder,
3352
+ swappedContext,
3330
3353
  onClose,
3331
3354
  onNewDeposit,
3332
3355
  onRetry,
@@ -3437,10 +3460,12 @@ function ProcessingStep({
3437
3460
  if (cancelled || !res) return;
3438
3461
  if (res.transactionId != null) {
3439
3462
  if (res.transactionId.toLowerCase() !== txHash.toLowerCase()) return;
3440
- } else if (!isSwappedOrder) {
3463
+ } else if (!isSwappedOrder || swappedContext?.variant === "connect") {
3441
3464
  return;
3442
3465
  }
3443
3466
  setSwappedFiatContext({
3467
+ orderCrypto: res.orderCrypto,
3468
+ orderCryptoAmount: res.orderCryptoAmount,
3444
3469
  paidAmountUsd: res.paidAmountUsd,
3445
3470
  paidAmountEur: res.paidAmountEur,
3446
3471
  onrampFeeUsd: res.onrampFeeUsd,
@@ -3451,7 +3476,7 @@ function ProcessingStep({
3451
3476
  return () => {
3452
3477
  cancelled = true;
3453
3478
  };
3454
- }, [service, smartAccount, txHash, isSwappedOrder]);
3479
+ }, [service, smartAccount, txHash, isSwappedOrder, swappedContext?.variant]);
3455
3480
  useEffect5(() => {
3456
3481
  if (directTransfer) return;
3457
3482
  if (state.type !== "processing") {
@@ -3727,8 +3752,14 @@ function ProcessingStep({
3727
3752
  /* @__PURE__ */ jsx23("div", { className: "rs-body-header-text", children: /* @__PURE__ */ jsx23("h2", { className: "rs-body-header-title", children: stateTitle }) })
3728
3753
  ] }) : /* @__PURE__ */ jsx23(BodyHeader, { icon: /* @__PURE__ */ jsx23(WalletIcon, {}), title: stateTitle });
3729
3754
  if (isComplete && isSwappedOrder) {
3730
- const onrampMethod = swappedFiatContext?.paymentMethod ? formatPaymentMethod(swappedFiatContext.paymentMethod) : null;
3731
- const amountPaid = swappedFiatContext?.paidAmountUsd != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null;
3755
+ const effectivePaymentMethod = swappedContext?.method ?? swappedFiatContext?.paymentMethod ?? null;
3756
+ const onrampMethod = effectivePaymentMethod ? formatPaymentMethod(effectivePaymentMethod) : null;
3757
+ const onrampMethodIcon = swappedContext?.variant === "connect" && effectivePaymentMethod ? getExchangeLogoSrc(
3758
+ onrampMethod ?? effectivePaymentMethod,
3759
+ effectivePaymentMethod
3760
+ ) : null;
3761
+ const connectPaidAmount = swappedContext?.variant === "connect" ? `${formattedSentAmount} ${sourceSymbol}` : null;
3762
+ const amountPaid = connectPaidAmount ?? (swappedFiatContext?.paidAmountUsd != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null);
3732
3763
  const depositedAmount = receiveDisplay;
3733
3764
  const onrampFeeUsd = swappedFiatContext?.onrampFeeUsd ?? null;
3734
3765
  const networkFeeUsd = quotedFeeAmount !== void 0 && Number.isFinite(Number(quotedFeeAmount)) ? Number(quotedFeeAmount) : null;
@@ -3750,6 +3781,7 @@ function ProcessingStep({
3750
3781
  SwappedReceipt,
3751
3782
  {
3752
3783
  onrampMethod,
3784
+ onrampMethodIcon,
3753
3785
  amountPaid,
3754
3786
  depositedAmount,
3755
3787
  depositedIcon: targetTokenIcon,
@@ -4041,6 +4073,9 @@ export {
4041
4073
  failureMessageForEvent,
4042
4074
  useTokenPrices,
4043
4075
  ProcessingStep,
4076
+ rpcUrlFor,
4077
+ RpcUrlsProvider,
4078
+ useRpcUrls,
4044
4079
  getPublicClient,
4045
4080
  getHyperEvmReadClient,
4046
4081
  loadSessionOwnerFromStorage,
@@ -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,9 @@ import {
29
30
  loadSessionOwnerFromStorage,
30
31
  saveSessionOwnerToStorage,
31
32
  useLatestRef,
33
+ useRpcUrls,
32
34
  useTokenPrices
33
- } from "./chunk-7EQQD7B4.mjs";
35
+ } from "./chunk-PS7HJ62M.mjs";
34
36
  import {
35
37
  buildSafeTransaction,
36
38
  executeSafeErc20Transfer,
@@ -845,6 +847,7 @@ function WithdrawFlow({
845
847
  onError,
846
848
  debug
847
849
  }) {
850
+ const rpcUrls = useRpcUrls();
848
851
  const onStepChangeRef = useLatestRef(onStepChange);
849
852
  const onEventRef = useLatestRef(onEvent);
850
853
  const onLifecycleRef = useLatestRef(onLifecycle);
@@ -941,14 +944,14 @@ function WithdrawFlow({
941
944
  return {
942
945
  ownerAddress: dappAddress,
943
946
  walletClient: dappWalletClient ?? void 0,
944
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
947
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
945
948
  switchChain: dappSwitchChain
946
949
  };
947
950
  }
948
951
  return {
949
952
  ownerAddress: dappWalletClient.account.address,
950
953
  walletClient: dappWalletClient,
951
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
954
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
952
955
  switchChain: dappSwitchChain
953
956
  };
954
957
  }
@@ -959,7 +962,7 @@ function WithdrawFlow({
959
962
  return {
960
963
  ownerAddress: dappWalletClient.account.address,
961
964
  walletClient: dappWalletClient,
962
- publicClient: dappPublicClient ?? getPublicClient(sourceChain),
965
+ publicClient: dappPublicClient ?? getPublicClient(sourceChain, rpcUrls),
963
966
  switchChain: dappSwitchChain
964
967
  };
965
968
  }
@@ -983,7 +986,8 @@ function WithdrawFlow({
983
986
  dappSwitchChain,
984
987
  dappAddress,
985
988
  reownWallet,
986
- sourceChain
989
+ sourceChain,
990
+ rpcUrls
987
991
  ]);
988
992
  const ownerAddress = signerContext?.ownerAddress;
989
993
  const recipientForRegistration = useMemo2(() => {
@@ -1254,7 +1258,7 @@ function WithdrawFlow({
1254
1258
  targetToken
1255
1259
  });
1256
1260
  const amountUnits = parseUnits2(amountValue, asset.decimals);
1257
- const pc = signerContext?.publicClient ?? getPublicClient(sourceChain);
1261
+ const pc = signerContext?.publicClient ?? getPublicClient(sourceChain, rpcUrls);
1258
1262
  let result;
1259
1263
  if (onSignTransaction) {
1260
1264
  const transferTarget = isSameRoute ? recipient : smartAccount;
@@ -1362,7 +1366,8 @@ function WithdrawFlow({
1362
1366
  logFlow,
1363
1367
  logFlowError,
1364
1368
  onLifecycleRef,
1365
- storeApi
1369
+ storeApi,
1370
+ rpcUrls
1366
1371
  ]
1367
1372
  );
1368
1373
  const handleWithdrawComplete = useCallback2(
@@ -1499,7 +1504,7 @@ function WithdrawFlow({
1499
1504
  if (!signerContext) return null;
1500
1505
  if (!onSignTransaction && !signerContext.walletClient) return null;
1501
1506
  const resolvedConnectedRecipient = selectedWalletOption?.kind === "external" ? selectedWalletOption.address : void 0;
1502
- const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain);
1507
+ const formPublicClient = signerContext.publicClient ?? getPublicClient(sourceChain, rpcUrls);
1503
1508
  const depositAddress = registration.kind === "ready" || registration.kind === "stale" ? registration.smartAccount : void 0;
1504
1509
  const stepView = deriveStepView(flowStep, registration);
1505
1510
  return /* @__PURE__ */ jsxs3("div", { className: "rs-modal-body", children: [
@@ -1588,7 +1593,7 @@ function deriveStepView(step, _registration) {
1588
1593
  // src/WithdrawModal.tsx
1589
1594
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1590
1595
  var ReownWithdrawInner = lazy(
1591
- () => import("./WithdrawModalReown-XPB53FKZ.mjs").then((m) => ({
1596
+ () => import("./WithdrawModalReown-FRMD2ACH.mjs").then((m) => ({
1592
1597
  default: m.WithdrawModalReown
1593
1598
  }))
1594
1599
  );
@@ -1617,6 +1622,7 @@ function WithdrawModalInner({
1617
1622
  closeOnOverlayClick,
1618
1623
  allowedRoutes,
1619
1624
  backendUrl = DEFAULT_BACKEND_URL,
1625
+ rpcUrls,
1620
1626
  signerAddress = DEFAULT_SIGNER_ADDRESS,
1621
1627
  sessionChainIds,
1622
1628
  forceRegister = false,
@@ -1675,7 +1681,7 @@ function WithdrawModalInner({
1675
1681
  }, []);
1676
1682
  const showBackButton = uiConfig?.showBackButton ?? true;
1677
1683
  const canGoBack = backHandler !== void 0;
1678
- return /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
1684
+ return /* @__PURE__ */ jsx4(RpcUrlsProvider, { value: rpcUrls, children: /* @__PURE__ */ jsx4(WithdrawStoreProvider, { store, children: /* @__PURE__ */ jsx4(
1679
1685
  Modal,
1680
1686
  {
1681
1687
  isOpen,
@@ -1739,7 +1745,7 @@ function WithdrawModalInner({
1739
1745
  )
1740
1746
  ] })
1741
1747
  }
1742
- ) });
1748
+ ) }) });
1743
1749
  }
1744
1750
 
1745
1751
  export {