@rhinestone/deposit-modal 0.1.61 → 0.1.63

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,11 +1,11 @@
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 _chunkTBUOMWKJcjs = require('./chunk-TBUOMWKJ.cjs');
3
+ var _chunkN3BZTUSJcjs = require('./chunk-N3BZTUSJ.cjs');
4
4
 
5
5
 
6
6
 
7
7
  var _chunkN2Y34LQOcjs = require('./chunk-N2Y34LQO.cjs');
8
- require('./chunk-TQ6IIGRS.cjs');
8
+ require('./chunk-5SR5N75I.cjs');
9
9
  require('./chunk-R6U6BHCV.cjs');
10
10
 
11
11
  // src/DepositModalReown.tsx
@@ -32,7 +32,7 @@ function DepositModalWithReown(props) {
32
32
  reown.disconnect();
33
33
  }, [reown.disconnect]);
34
34
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
35
- _chunkTBUOMWKJcjs.DepositModalInner,
35
+ _chunkN3BZTUSJcjs.DepositModalInner,
36
36
  {
37
37
  ...props,
38
38
  reownWallet: reownWithSolana,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  DepositModalInner
3
- } from "./chunk-IKTHUMGZ.mjs";
3
+ } from "./chunk-XVCPUB6K.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
7
  } from "./chunk-MBURQ26S.mjs";
8
- import "./chunk-7TTEHQBD.mjs";
8
+ import "./chunk-TDTBAZNO.mjs";
9
9
  import "./chunk-CIXHTOO3.mjs";
10
10
 
11
11
  // src/DepositModalReown.tsx
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  WithdrawModalInner
3
- } from "./chunk-RRYC5EZF.mjs";
3
+ } from "./chunk-2IFX6ZEE.mjs";
4
4
  import {
5
5
  ReownWalletProvider,
6
6
  useReownWallet
7
7
  } from "./chunk-MBURQ26S.mjs";
8
- import "./chunk-7TTEHQBD.mjs";
8
+ import "./chunk-TDTBAZNO.mjs";
9
9
  import "./chunk-CIXHTOO3.mjs";
10
10
 
11
11
  // src/WithdrawModalReown.tsx
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkC5TWF4ZEcjs = require('./chunk-C5TWF4ZE.cjs');
3
+ var _chunkOFGBTU45cjs = require('./chunk-OFGBTU45.cjs');
4
4
 
5
5
 
6
6
 
7
7
  var _chunkN2Y34LQOcjs = require('./chunk-N2Y34LQO.cjs');
8
- require('./chunk-TQ6IIGRS.cjs');
8
+ require('./chunk-5SR5N75I.cjs');
9
9
  require('./chunk-R6U6BHCV.cjs');
10
10
 
11
11
  // src/WithdrawModalReown.tsx
@@ -20,7 +20,7 @@ function WithdrawModalWithReown(props) {
20
20
  reown.disconnect();
21
21
  }, [reown.disconnect]);
22
22
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
23
- _chunkC5TWF4ZEcjs.WithdrawModalInner,
23
+ _chunkOFGBTU45cjs.WithdrawModalInner,
24
24
  {
25
25
  ...props,
26
26
  reownWallet: reown,
@@ -19,8 +19,9 @@ import {
19
19
  isNativeAsset,
20
20
  loadSessionOwnerFromStorage,
21
21
  saveSessionOwnerToStorage,
22
- toEvmCaip2
23
- } from "./chunk-7TTEHQBD.mjs";
22
+ toEvmCaip2,
23
+ useLatestRef
24
+ } from "./chunk-TDTBAZNO.mjs";
24
25
  import {
25
26
  DEFAULT_BACKEND_URL,
26
27
  DEFAULT_SIGNER_ADDRESS,
@@ -40,14 +41,14 @@ import {
40
41
  useCallback as useCallback3,
41
42
  useEffect as useEffect3,
42
43
  useMemo as useMemo3,
43
- useRef as useRef2,
44
+ useRef as useRef3,
44
45
  useState as useState3,
45
46
  lazy,
46
47
  Suspense
47
48
  } from "react";
48
49
 
49
50
  // src/WithdrawFlow.tsx
50
- import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
51
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
51
52
 
52
53
  // src/components/steps/WithdrawFormStep.tsx
53
54
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -905,6 +906,9 @@ function WithdrawFlow({
905
906
  onError,
906
907
  debug
907
908
  }) {
909
+ const onStepChangeRef = useLatestRef(onStepChange);
910
+ const onTotalBalanceChangeRef = useLatestRef(onTotalBalanceChange);
911
+ const onEventRef = useLatestRef(onEvent);
908
912
  const [step, setStep] = useState2({ type: "form" });
909
913
  const [isSubmitting, setIsSubmitting] = useState2(false);
910
914
  const [totalBalanceUsd, setTotalBalanceUsd] = useState2(0);
@@ -1036,20 +1040,29 @@ function WithdrawFlow({
1036
1040
  const stepIndex = step.type === "form" ? 0 : 1;
1037
1041
  const currentBackHandler = void 0;
1038
1042
  useEffect2(() => {
1039
- onStepChange?.(stepIndex, currentBackHandler);
1040
- }, [stepIndex, currentBackHandler, onStepChange]);
1043
+ onStepChangeRef.current?.(stepIndex, currentBackHandler);
1044
+ }, [stepIndex, currentBackHandler, onStepChangeRef]);
1045
+ const lastStepOpenEventKeyRef = useRef2(null);
1041
1046
  useEffect2(() => {
1047
+ if (step.type !== "form") {
1048
+ lastStepOpenEventKeyRef.current = null;
1049
+ return;
1050
+ }
1051
+ if (lastStepOpenEventKeyRef.current === "form") {
1052
+ return;
1053
+ }
1054
+ lastStepOpenEventKeyRef.current = "form";
1042
1055
  if (step.type === "form") {
1043
1056
  const tokenSymbol = getTokenSymbol(targetToken, targetChain);
1044
1057
  const chainName = getChainName(targetChain);
1045
- onEvent?.({
1058
+ onEventRef.current?.({
1046
1059
  type: "withdraw_modal_select_amount_open",
1047
1060
  pred_balance: totalBalanceUsd,
1048
1061
  default_token: tokenSymbol,
1049
1062
  default_chain: chainName
1050
1063
  });
1051
1064
  }
1052
- }, [step.type, onEvent]);
1065
+ }, [step.type, targetToken, targetChain, totalBalanceUsd, onEventRef]);
1053
1066
  useEffect2(() => {
1054
1067
  logFlow("state:changed", {
1055
1068
  step: step.type,
@@ -1069,8 +1082,8 @@ function WithdrawFlow({
1069
1082
  targetToken
1070
1083
  ]);
1071
1084
  useEffect2(() => {
1072
- onTotalBalanceChange?.(totalBalanceUsd);
1073
- }, [totalBalanceUsd, onTotalBalanceChange]);
1085
+ onTotalBalanceChangeRef.current?.(totalBalanceUsd);
1086
+ }, [totalBalanceUsd, onTotalBalanceChangeRef]);
1074
1087
  const handleConnected = useCallback2(
1075
1088
  (addr, smartAccount) => {
1076
1089
  logFlow("setup:connected", { address: addr, smartAccount });
@@ -1478,7 +1491,7 @@ function WithdrawFlow({
1478
1491
  // src/WithdrawModal.tsx
1479
1492
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1480
1493
  var ReownWithdrawInner = lazy(
1481
- () => import("./WithdrawModalReown-OHTYDGI5.mjs").then((m) => ({
1494
+ () => import("./WithdrawModalReown-2BW5CM3A.mjs").then((m) => ({
1482
1495
  default: m.WithdrawModalReown
1483
1496
  }))
1484
1497
  );
@@ -1530,10 +1543,11 @@ function WithdrawModalInner({
1530
1543
  onError,
1531
1544
  debug
1532
1545
  }) {
1533
- const modalRef = useRef2(null);
1546
+ const modalRef = useRef3(null);
1547
+ const onReadyRef = useLatestRef(onReady);
1534
1548
  const [currentStepIndex, setCurrentStepIndex] = useState3(0);
1535
1549
  const [totalBalanceUsd, setTotalBalanceUsd] = useState3(null);
1536
- const backHandlerRef = useRef2(void 0);
1550
+ const backHandlerRef = useRef3(void 0);
1537
1551
  const targetChain = getChainId(targetChainProp);
1538
1552
  const sourceChain = getChainId(sourceChainProp);
1539
1553
  const service = useMemo3(
@@ -1545,13 +1559,13 @@ function WithdrawModalInner({
1545
1559
  applyTheme(modalRef.current, theme);
1546
1560
  }
1547
1561
  }, [isOpen, theme]);
1548
- const hasCalledReady = useRef2(false);
1562
+ const hasCalledReady = useRef3(false);
1549
1563
  useEffect3(() => {
1550
1564
  if (isOpen && !hasCalledReady.current) {
1551
1565
  hasCalledReady.current = true;
1552
- onReady?.();
1566
+ onReadyRef.current?.();
1553
1567
  }
1554
- }, [isOpen, onReady]);
1568
+ }, [isOpen, onReadyRef]);
1555
1569
  useEffect3(() => {
1556
1570
  if (!isOpen) {
1557
1571
  setCurrentStepIndex(0);
@@ -809,6 +809,16 @@ function formatUserError(raw) {
809
809
  return cleaned;
810
810
  }
811
811
 
812
+ // src/core/useLatestRef.ts
813
+
814
+ function useLatestRef(value) {
815
+ const ref = _react.useRef.call(void 0, value);
816
+ _react.useEffect.call(void 0, () => {
817
+ ref.current = value;
818
+ }, [value]);
819
+ return ref;
820
+ }
821
+
812
822
  // src/core/theme.ts
813
823
  var RADIUS_SCALE = {
814
824
  none: { sm: "0", md: "0", lg: "0" },
@@ -1348,10 +1358,14 @@ function getEventTxHash(event) {
1348
1358
  const source = isRecord(_optionalChain([event, 'access', _69 => _69.data, 'optionalAccess', _70 => _70.source])) ? event.data.source : void 0;
1349
1359
  return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _71 => _71.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _72 => _72.transactionHash]))));
1350
1360
  }
1361
+ if (event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
1362
+ const deposit = isRecord(_optionalChain([event, 'access', _73 => _73.data, 'optionalAccess', _74 => _74.deposit])) ? event.data.deposit : void 0;
1363
+ return asString(_optionalChain([deposit, 'optionalAccess', _75 => _75.transactionHash]));
1364
+ }
1351
1365
  return void 0;
1352
1366
  }
1353
1367
  function getEventSourceDetails(event) {
1354
- if (!_optionalChain([event, 'optionalAccess', _73 => _73.type]) || !isRecord(event.data)) return {};
1368
+ if (!_optionalChain([event, 'optionalAccess', _76 => _76.type]) || !isRecord(event.data)) return {};
1355
1369
  if (event.type === "deposit-received") {
1356
1370
  return {
1357
1371
  chainId: asNumber(event.data.chain),
@@ -1361,17 +1375,17 @@ function getEventSourceDetails(event) {
1361
1375
  }
1362
1376
  const source = isRecord(event.data.source) ? event.data.source : void 0;
1363
1377
  const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
1364
- if (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error") {
1378
+ if (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error" || event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
1365
1379
  return {
1366
- chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _74 => _74.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _75 => _75.chain])))),
1367
- amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _76 => _76.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _77 => _77.amount])))),
1368
- token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _78 => _78.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _79 => _79.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _80 => _80.token]))))
1380
+ chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _77 => _77.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _78 => _78.chain])))),
1381
+ amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _79 => _79.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _80 => _80.amount])))),
1382
+ token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _81 => _81.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _82 => _82.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _83 => _83.token]))))
1369
1383
  };
1370
1384
  }
1371
1385
  return {};
1372
1386
  }
1373
1387
  function isDepositEvent(event) {
1374
- return _optionalChain([event, 'optionalAccess', _81 => _81.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _82 => _82.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _83 => _83.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _84 => _84.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _85 => _85.type]) === "error";
1388
+ return _optionalChain([event, 'optionalAccess', _84 => _84.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _85 => _85.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _86 => _86.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _87 => _87.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _88 => _88.type]) === "post-bridge-swap-complete" || _optionalChain([event, 'optionalAccess', _89 => _89.type]) === "post-bridge-swap-failed" || _optionalChain([event, 'optionalAccess', _90 => _90.type]) === "error";
1375
1389
  }
1376
1390
  function isHexString(value) {
1377
1391
  return value.startsWith("0x") || value.startsWith("0X");
@@ -1426,7 +1440,7 @@ function isEventForTx(event, txHash) {
1426
1440
  return txRefsMatch(eventTxHash, txHash);
1427
1441
  }
1428
1442
  function formatBridgeFailedMessage(event) {
1429
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _86 => _86.data]), () => ( {}));
1443
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _91 => _91.data]), () => ( {}));
1430
1444
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
1431
1445
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
1432
1446
  function toUserFacingFailure(raw) {
@@ -1458,16 +1472,16 @@ function formatBridgeFailedMessage(event) {
1458
1472
  return { message: "Bridge failed" };
1459
1473
  }
1460
1474
  function parseWebhookTimestamp(event) {
1461
- if (typeof _optionalChain([event, 'optionalAccess', _87 => _87.time]) !== "string") return void 0;
1475
+ if (typeof _optionalChain([event, 'optionalAccess', _92 => _92.time]) !== "string") return void 0;
1462
1476
  const timestamp = Date.parse(event.time);
1463
1477
  return Number.isFinite(timestamp) ? timestamp : void 0;
1464
1478
  }
1465
1479
  function syncPhaseTimings(previous, event) {
1466
- if (!_optionalChain([event, 'optionalAccess', _88 => _88.type])) return previous;
1480
+ if (!_optionalChain([event, 'optionalAccess', _93 => _93.type])) return previous;
1467
1481
  const timestamp = _nullishCoalesce(parseWebhookTimestamp(event), () => ( Date.now()));
1468
- const setReceived = (event.type === "deposit-received" || event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error") && previous.receivedAt === void 0;
1469
- const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete") && previous.bridgingAt === void 0;
1470
- const setCompleted = event.type === "bridge-complete" && previous.completedAt === void 0;
1482
+ const setReceived = (event.type === "deposit-received" || event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed" || event.type === "error") && previous.receivedAt === void 0;
1483
+ const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.bridgingAt === void 0;
1484
+ const setCompleted = (event.type === "bridge-complete" || event.type === "post-bridge-swap-complete") && previous.completedAt === void 0;
1471
1485
  if (!setReceived && !setBridging && !setCompleted) return previous;
1472
1486
  return {
1473
1487
  ...previous,
@@ -1504,8 +1518,9 @@ function getCurrentPhaseId(state, phaseTimings, isEarlyComplete) {
1504
1518
  if (state.type === "complete") {
1505
1519
  return void 0;
1506
1520
  }
1507
- if (_optionalChain([state, 'access', _89 => _89.lastEvent, 'optionalAccess', _90 => _90.type]) === "bridge-started") return "bridging";
1508
- if (_optionalChain([state, 'access', _91 => _91.lastEvent, 'optionalAccess', _92 => _92.type]) === "deposit-received") return "received";
1521
+ if (_optionalChain([state, 'access', _94 => _94.lastEvent, 'optionalAccess', _95 => _95.type]) === "bridge-started" || _optionalChain([state, 'access', _96 => _96.lastEvent, 'optionalAccess', _97 => _97.type]) === "bridge-complete")
1522
+ return "bridging";
1523
+ if (_optionalChain([state, 'access', _98 => _98.lastEvent, 'optionalAccess', _99 => _99.type]) === "deposit-received") return "received";
1509
1524
  return "confirming";
1510
1525
  }
1511
1526
  function ProcessingStep({
@@ -1518,6 +1533,7 @@ function ProcessingStep({
1518
1533
  sourceSymbol: providedSourceSymbol,
1519
1534
  sourceDecimals: providedSourceDecimals,
1520
1535
  waitForFinalTx,
1536
+ hasPostBridgeActions,
1521
1537
  service,
1522
1538
  directTransfer,
1523
1539
  flowLabel = "deposit",
@@ -1558,7 +1574,7 @@ function ProcessingStep({
1558
1574
  txHash,
1559
1575
  flowLabel
1560
1576
  });
1561
- _optionalChain([onDepositComplete, 'optionalCall', _93 => _93(txHash, void 0, {
1577
+ _optionalChain([onDepositComplete, 'optionalCall', _100 => _100(txHash, void 0, {
1562
1578
  amount,
1563
1579
  sourceChain,
1564
1580
  sourceToken,
@@ -1599,7 +1615,7 @@ function ProcessingStep({
1599
1615
  _react.useEffect.call(void 0, () => {
1600
1616
  if (!state.lastEvent) return;
1601
1617
  setPhaseTimings((previous) => syncPhaseTimings(previous, state.lastEvent));
1602
- }, [_optionalChain([state, 'access', _94 => _94.lastEvent, 'optionalAccess', _95 => _95.time]), _optionalChain([state, 'access', _96 => _96.lastEvent, 'optionalAccess', _97 => _97.type])]);
1618
+ }, [_optionalChain([state, 'access', _101 => _101.lastEvent, 'optionalAccess', _102 => _102.time]), _optionalChain([state, 'access', _103 => _103.lastEvent, 'optionalAccess', _104 => _104.type])]);
1603
1619
  _react.useEffect.call(void 0, () => {
1604
1620
  savePhaseTimings(txHash, phaseTimings);
1605
1621
  }, [txHash, phaseTimings]);
@@ -1626,19 +1642,52 @@ function ProcessingStep({
1626
1642
  debugLog(debug, "processing", "poll:event", {
1627
1643
  type: lastEvent2.type,
1628
1644
  matchesTx: eventMatchesTx,
1629
- intentId: _optionalChain([eventData, 'optionalAccess', _98 => _98.intentId])
1645
+ intentId: _optionalChain([eventData, 'optionalAccess', _105 => _105.intentId])
1630
1646
  });
1631
1647
  }
1632
1648
  if (!isMounted) return;
1633
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _99 => _99.type]) === "bridge-complete") {
1649
+ const awaitingPostBridgeSwap = waitForFinalTx && hasPostBridgeActions;
1650
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _106 => _106.type]) === "post-bridge-swap-complete") {
1651
+ setState({ type: "complete", lastEvent: eventForCurrentTx });
1652
+ const swapTxHash = _optionalChain([eventForCurrentTx, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.swap, 'optionalAccess', _109 => _109.transactionHash]);
1653
+ debugLog(debug, "processing", "state:complete", {
1654
+ txHash,
1655
+ destinationTxHash: swapTxHash,
1656
+ event: eventForCurrentTx.type
1657
+ });
1658
+ _optionalChain([onDepositComplete, 'optionalCall', _110 => _110(txHash, swapTxHash, {
1659
+ amount,
1660
+ sourceChain,
1661
+ sourceToken,
1662
+ targetChain,
1663
+ targetToken
1664
+ })]);
1665
+ return;
1666
+ }
1667
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _111 => _111.type]) === "post-bridge-swap-failed") {
1668
+ const formatted = formatBridgeFailedMessage(eventForCurrentTx);
1669
+ setState({
1670
+ type: "failed",
1671
+ message: formatted.message,
1672
+ lastEvent: eventForCurrentTx
1673
+ });
1674
+ debugLog(debug, "processing", "state:failed", {
1675
+ txHash,
1676
+ message: formatted.message,
1677
+ code: formatted.code
1678
+ });
1679
+ _optionalChain([onDepositFailed, 'optionalCall', _112 => _112(txHash, formatted.message)]);
1680
+ return;
1681
+ }
1682
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _113 => _113.type]) === "bridge-complete" && !awaitingPostBridgeSwap) {
1634
1683
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1635
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _100 => _100.data, 'optionalAccess', _101 => _101.destination, 'optionalAccess', _102 => _102.transactionHash]);
1684
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _114 => _114.data, 'optionalAccess', _115 => _115.destination, 'optionalAccess', _116 => _116.transactionHash]);
1636
1685
  debugLog(debug, "processing", "state:complete", {
1637
1686
  txHash,
1638
1687
  destinationTxHash: destinationTxHash2,
1639
1688
  event: eventForCurrentTx.type
1640
1689
  });
1641
- _optionalChain([onDepositComplete, 'optionalCall', _103 => _103(txHash, destinationTxHash2, {
1690
+ _optionalChain([onDepositComplete, 'optionalCall', _117 => _117(txHash, destinationTxHash2, {
1642
1691
  amount,
1643
1692
  sourceChain,
1644
1693
  sourceToken,
@@ -1647,13 +1696,13 @@ function ProcessingStep({
1647
1696
  })]);
1648
1697
  return;
1649
1698
  }
1650
- if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _104 => _104.type]) === "bridge-started") {
1699
+ if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _118 => _118.type]) === "bridge-started") {
1651
1700
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1652
1701
  debugLog(debug, "processing", "state:early-complete", {
1653
1702
  txHash,
1654
1703
  event: eventForCurrentTx.type
1655
1704
  });
1656
- _optionalChain([onDepositComplete, 'optionalCall', _105 => _105(txHash, void 0, {
1705
+ _optionalChain([onDepositComplete, 'optionalCall', _119 => _119(txHash, void 0, {
1657
1706
  amount,
1658
1707
  sourceChain,
1659
1708
  sourceToken,
@@ -1662,7 +1711,7 @@ function ProcessingStep({
1662
1711
  })]);
1663
1712
  return;
1664
1713
  }
1665
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _106 => _106.type]) === "bridge-failed") {
1714
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _120 => _120.type]) === "bridge-failed") {
1666
1715
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
1667
1716
  setState({
1668
1717
  type: "failed",
@@ -1674,11 +1723,11 @@ function ProcessingStep({
1674
1723
  message: formatted.message,
1675
1724
  code: formatted.code
1676
1725
  });
1677
- _optionalChain([onDepositFailed, 'optionalCall', _107 => _107(txHash, formatted.message)]);
1726
+ _optionalChain([onDepositFailed, 'optionalCall', _121 => _121(txHash, formatted.message)]);
1678
1727
  return;
1679
1728
  }
1680
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _108 => _108.type]) === "error") {
1681
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _109 => _109.data, 'optionalAccess', _110 => _110.message]), () => ( "Unknown error"));
1729
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _122 => _122.type]) === "error") {
1730
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _123 => _123.data, 'optionalAccess', _124 => _124.message]), () => ( "Unknown error"));
1682
1731
  setState({
1683
1732
  type: "failed",
1684
1733
  message: errorMessage,
@@ -1688,7 +1737,7 @@ function ProcessingStep({
1688
1737
  txHash,
1689
1738
  message: errorMessage
1690
1739
  });
1691
- _optionalChain([onDepositFailed, 'optionalCall', _111 => _111(txHash, errorMessage)]);
1740
+ _optionalChain([onDepositFailed, 'optionalCall', _125 => _125(txHash, errorMessage)]);
1692
1741
  return;
1693
1742
  }
1694
1743
  setState((previous) => ({
@@ -1729,6 +1778,7 @@ function ProcessingStep({
1729
1778
  amount,
1730
1779
  debug,
1731
1780
  directTransfer,
1781
+ hasPostBridgeActions,
1732
1782
  onDepositComplete,
1733
1783
  onDepositFailed,
1734
1784
  service,
@@ -1752,7 +1802,7 @@ function ProcessingStep({
1752
1802
  txHash,
1753
1803
  timeoutMs: ESCALATED_DELAY_MS
1754
1804
  });
1755
- _optionalChain([onError, 'optionalCall', _112 => _112(message, "PROCESS_TIMEOUT")]);
1805
+ _optionalChain([onError, 'optionalCall', _126 => _126(message, "PROCESS_TIMEOUT")]);
1756
1806
  }, ESCALATED_DELAY_MS);
1757
1807
  return () => clearTimeout(timeoutId);
1758
1808
  }, [debug, directTransfer, onError, state.type, txHash]);
@@ -1761,16 +1811,19 @@ function ProcessingStep({
1761
1811
  const isProcessing = state.type === "processing";
1762
1812
  const lastEvent = state.lastEvent;
1763
1813
  const failureMessage = state.type === "failed" ? state.message : void 0;
1764
- const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _113 => _113.type]) === "bridge-started";
1814
+ const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _127 => _127.type]) === "bridge-started";
1765
1815
  const timelineNowMs = _nullishCoalesce(phaseTimings.endedAt, () => ( Date.now()));
1766
1816
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
1767
1817
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
1768
- const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _114 => _114.data, 'optionalAccess', _115 => _115.destination, 'optionalAccess', _116 => _116.transactionHash]) || null;
1818
+ const isPostBridgeSwapEvent = _optionalChain([lastEvent, 'optionalAccess', _128 => _128.type]) === "post-bridge-swap-complete" || _optionalChain([lastEvent, 'optionalAccess', _129 => _129.type]) === "post-bridge-swap-failed";
1819
+ const destinationTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _130 => _130.data, 'optionalAccess', _131 => _131.swap, 'optionalAccess', _132 => _132.transactionHash]) || null : _optionalChain([lastEvent, 'optionalAccess', _133 => _133.data, 'optionalAccess', _134 => _134.destination, 'optionalAccess', _135 => _135.transactionHash]) || null;
1820
+ const bridgeTxHash = isPostBridgeSwapEvent ? _optionalChain([lastEvent, 'optionalAccess', _136 => _136.data, 'optionalAccess', _137 => _137.bridge, 'optionalAccess', _138 => _138.transactionHash]) || null : null;
1769
1821
  const sourceDetails = getEventSourceDetails(lastEvent);
1770
1822
  const displaySourceChain = _nullishCoalesce(sourceDetails.chainId, () => ( sourceChain));
1771
1823
  const displaySourceToken = _nullishCoalesce(sourceDetails.token, () => ( sourceToken));
1772
1824
  const displayAmount = _nullishCoalesce(sourceDetails.amount, () => ( amount));
1773
1825
  const sourceExplorerUrl = _chunkR6U6BHCVcjs.getExplorerTxUrl.call(void 0, displaySourceChain, txHash);
1826
+ const bridgeExplorerUrl = bridgeTxHash ? _chunkR6U6BHCVcjs.getExplorerTxUrl.call(void 0, targetChain, bridgeTxHash) : null;
1774
1827
  const destExplorerUrl = destinationTxHash ? _chunkR6U6BHCVcjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
1775
1828
  const isEvmSourceToken = /^0x[a-fA-F0-9]{40}$/.test(displaySourceToken);
1776
1829
  const sourceSymbol = displaySourceChain === "solana" ? _nullishCoalesce(providedSourceSymbol, () => ( "SOL")) : isEvmSourceToken ? _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, displaySourceToken, displaySourceChain) : _nullishCoalesce(providedSourceSymbol, () => ( "Token"));
@@ -1795,7 +1848,7 @@ function ProcessingStep({
1795
1848
  const activePhaseElapsedMs = isProcessing && activePhaseStartedAt !== void 0 ? timelineNowMs - activePhaseStartedAt : 0;
1796
1849
  const delayPhaseId = isProcessing && currentPhaseId && activePhaseElapsedMs >= SOFT_DELAY_MS[currentPhaseId] ? currentPhaseId : void 0;
1797
1850
  const headerTitle = isFailed ? `${flowCapitalized} could not be completed` : isComplete ? isEarlyComplete ? `${flowCapitalized} confirmed` : `${flowCapitalized} successful` : delayPhaseId === "received" ? "Bridge pending" : delayPhaseId === "bridging" ? "Bridge delayed" : delayPhaseId === "confirming" ? `Confirming ${flowNoun}` : `Submitting transaction...`;
1798
- const headerDescription = isFailed ? _nullishCoalesce(failureMessage, () => ( "The transfer could not be completed.")) : isComplete ? directTransfer ? "Your transfer is complete." : isEarlyComplete ? "The bridge has started. Funds will arrive shortly." : "Your funds were successfully deposited." : delayPhaseId === "received" ? "Funds are in. We are still waiting for the bridge transaction to begin." : delayPhaseId === "bridging" ? "The bridge has started but settlement is taking longer than expected." : delayPhaseId === "confirming" ? "The source transaction has not been picked up yet, but we are still polling automatically." : _optionalChain([state, 'access', _117 => _117.lastEvent, 'optionalAccess', _118 => _118.type]) === "deposit-received" ? "Transfer received. Preparing bridge execution." : _optionalChain([state, 'access', _119 => _119.lastEvent, 'optionalAccess', _120 => _120.type]) === "bridge-started" ? `Bridge started. Sending funds to ${_chunkR6U6BHCVcjs.getChainName.call(void 0, targetChain)}.` : "Filling your transaction on the blockchain.";
1851
+ const headerDescription = isFailed ? _nullishCoalesce(failureMessage, () => ( "The transfer could not be completed.")) : isComplete ? directTransfer ? "Your transfer is complete." : isEarlyComplete ? "The bridge has started. Funds will arrive shortly." : "Your funds were successfully deposited." : delayPhaseId === "received" ? "Funds are in. We are still waiting for the bridge transaction to begin." : delayPhaseId === "bridging" ? "The bridge has started but settlement is taking longer than expected." : delayPhaseId === "confirming" ? "The source transaction has not been picked up yet, but we are still polling automatically." : _optionalChain([state, 'access', _139 => _139.lastEvent, 'optionalAccess', _140 => _140.type]) === "deposit-received" ? "Transfer received. Preparing bridge execution." : _optionalChain([state, 'access', _141 => _141.lastEvent, 'optionalAccess', _142 => _142.type]) === "bridge-started" ? `Bridge started. Sending funds to ${_chunkR6U6BHCVcjs.getChainName.call(void 0, targetChain)}.` : "Filling your transaction on the blockchain.";
1799
1852
  const showAlert = !isFailed && (delayPhaseId !== void 0 || hasEscalatedDelay);
1800
1853
  const alertMessage = hasEscalatedDelay ? "Taking longer than expected. You can close this window \u2014 processing continues in the background." : "This step is slower than usual but still processing.";
1801
1854
  const fillStatus = isComplete ? "Successful" : isFailed ? "Failed" : "Processing";
@@ -2001,8 +2054,25 @@ function ProcessingStep({
2001
2054
  }
2002
2055
  ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "ui-monospace, SFMono-Regular, monospace", fontSize: 12 }, children: truncateHash(txHash) }) })
2003
2056
  ] }),
2057
+ bridgeTxHash && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
2058
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "Bridge tx" }),
2059
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-value", children: bridgeExplorerUrl ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2060
+ "a",
2061
+ {
2062
+ href: bridgeExplorerUrl,
2063
+ target: "_blank",
2064
+ rel: "noopener noreferrer",
2065
+ className: "rs-card-external-link",
2066
+ style: { gap: 4, fontFamily: "ui-monospace, SFMono-Regular, monospace", fontSize: 12 },
2067
+ children: [
2068
+ truncateHash(bridgeTxHash),
2069
+ txLinkIcon
2070
+ ]
2071
+ }
2072
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "ui-monospace, SFMono-Regular, monospace", fontSize: 12 }, children: truncateHash(bridgeTxHash) }) })
2073
+ ] }),
2004
2074
  destinationTxHash && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-card-row", children: [
2005
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: "Destination tx" }),
2075
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-label", children: bridgeTxHash ? "Swap tx" : "Destination tx" }),
2006
2076
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-card-value", children: destExplorerUrl ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2007
2077
  "a",
2008
2078
  {
@@ -2095,4 +2165,5 @@ function getPublicClient(chainId) {
2095
2165
 
2096
2166
 
2097
2167
 
2098
- exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
2168
+
2169
+ exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; exports.debugLog = debugLog; exports.debugError = debugError; exports.toEvmCaip2 = toEvmCaip2; exports.buildSessionDetails = buildSessionDetails; exports.createDepositService = createDepositService; exports.getAssetId = getAssetId; exports.portfolioToAssets = portfolioToAssets; exports.isNativeAsset = isNativeAsset; exports.loadSessionOwnerFromStorage = loadSessionOwnerFromStorage; exports.saveSessionOwnerToStorage = saveSessionOwnerToStorage; exports.createSessionOwnerKey = createSessionOwnerKey; exports.accountFromPrivateKey = accountFromPrivateKey; exports.PoweredBy = PoweredBy; exports.currencyFormatter = currencyFormatter; exports.tokenFormatter = tokenFormatter; exports.formatUserError = formatUserError; exports.getEventTxHash = getEventTxHash; exports.isDepositEvent = isDepositEvent; exports.txRefsMatch = txRefsMatch; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.useLatestRef = useLatestRef; exports.applyTheme = applyTheme;