@rhinestone/deposit-modal 0.1.38 → 0.1.40

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.
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkHYUITBRVcjs = require('./chunk-HYUITBRV.cjs');
10
+ var _chunkFLXTBFMZcjs = require('./chunk-FLXTBFMZ.cjs');
11
11
 
12
12
  // src/components/ui/Modal.tsx
13
13
 
@@ -360,14 +360,14 @@ function normalizeOrchestratorPortfolio(data) {
360
360
  const unlocked = _nullishCoalesce(_optionalChain([chainBalance, 'access', _4 => _4.balance, 'optionalAccess', _5 => _5.unlocked]), () => ( "0"));
361
361
  const normalizedName = tokenData.tokenName.trim();
362
362
  const isNativeSymbol = normalizedName.toUpperCase() === "ETH" || normalizedName.toUpperCase() === "ETHER";
363
- const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkHYUITBRVcjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
364
- const resolvedTokenAddress = isNativeSymbol ? _chunkHYUITBRVcjs.NATIVE_TOKEN_ADDRESS : tokenAddress;
363
+ const tokenAddress = _nullishCoalesce(_nullishCoalesce(chainBalance.tokenAddress, () => ( extractTokenAddress(tokenData, chainBalance.chainId))), () => ( _chunkFLXTBFMZcjs.getTokenAddress.call(void 0, tokenData.tokenName, chainBalance.chainId)));
364
+ const resolvedTokenAddress = isNativeSymbol ? _chunkFLXTBFMZcjs.NATIVE_TOKEN_ADDRESS : tokenAddress;
365
365
  if (!resolvedTokenAddress) {
366
366
  continue;
367
367
  }
368
- const registrySymbol = _chunkHYUITBRVcjs.getTokenSymbol.call(void 0, resolvedTokenAddress, chainBalance.chainId);
368
+ const registrySymbol = _chunkFLXTBFMZcjs.getTokenSymbol.call(void 0, resolvedTokenAddress, chainBalance.chainId);
369
369
  const symbol = registrySymbol !== "Token" ? registrySymbol : normalizedName || "Token";
370
- const decimals = registrySymbol !== "Token" ? _chunkHYUITBRVcjs.getTokenDecimalsByAddress.call(void 0, resolvedTokenAddress, chainBalance.chainId) : _nullishCoalesce(tokenData.tokenDecimals, () => ( 18));
370
+ const decimals = registrySymbol !== "Token" ? _chunkFLXTBFMZcjs.getTokenDecimalsByAddress.call(void 0, resolvedTokenAddress, chainBalance.chainId) : _nullishCoalesce(tokenData.tokenDecimals, () => ( 18));
371
371
  tokens.push({
372
372
  chainId: chainBalance.chainId,
373
373
  address: resolvedTokenAddress,
@@ -394,14 +394,14 @@ function normalizeDirectToken(token) {
394
394
  const address = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractString(token, "address"), () => ( extractString(token, "tokenAddress"))), () => ( extractString(
395
395
  token.token,
396
396
  "address"
397
- ))), () => ( _chunkHYUITBRVcjs.getTokenAddress.call(void 0, symbol, chainId)));
397
+ ))), () => ( _chunkFLXTBFMZcjs.getTokenAddress.call(void 0, symbol, chainId)));
398
398
  if (!address) return null;
399
399
  const addressAsToken = address;
400
400
  const balanceUsd = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(extractNumber(token, "balanceUsd"), () => ( extractNumber(token, "usdValue"))), () => ( extractNumber(token, "valueUsd"))), () => ( extractNumericString(token, "balanceUsd"))), () => ( extractNumericString(token, "usdValue"))), () => ( extractNumericString(token, "valueUsd"))), () => ( 0));
401
- const registrySymbol = _chunkHYUITBRVcjs.getTokenSymbol.call(void 0, addressAsToken, chainId);
401
+ const registrySymbol = _chunkFLXTBFMZcjs.getTokenSymbol.call(void 0, addressAsToken, chainId);
402
402
  const resolvedSymbol = registrySymbol !== "Token" ? registrySymbol : symbol;
403
403
  const backendDecimals = _nullishCoalesce(extractNumber(token, "decimals"), () => ( extractNumber(token, "tokenDecimals")));
404
- const resolvedDecimals = registrySymbol !== "Token" ? _chunkHYUITBRVcjs.getTokenDecimalsByAddress.call(void 0, addressAsToken, chainId) : _nullishCoalesce(backendDecimals, () => ( 18));
404
+ const resolvedDecimals = registrySymbol !== "Token" ? _chunkFLXTBFMZcjs.getTokenDecimalsByAddress.call(void 0, addressAsToken, chainId) : _nullishCoalesce(backendDecimals, () => ( 18));
405
405
  return {
406
406
  chainId,
407
407
  address: addressAsToken,
@@ -995,25 +995,69 @@ function isRecord(value) {
995
995
  function asString(value) {
996
996
  return typeof value === "string" ? value : void 0;
997
997
  }
998
+ function asNumber(value) {
999
+ if (typeof value === "number" && Number.isFinite(value)) return value;
1000
+ if (typeof value !== "string") return void 0;
1001
+ const trimmed = value.trim();
1002
+ if (!trimmed) return void 0;
1003
+ const caipMatch = trimmed.match(/^eip155:(\d+)$/);
1004
+ if (_optionalChain([caipMatch, 'optionalAccess', _41 => _41[1]])) {
1005
+ const parsed2 = Number(caipMatch[1]);
1006
+ return Number.isFinite(parsed2) ? parsed2 : void 0;
1007
+ }
1008
+ const parsed = Number(trimmed);
1009
+ return Number.isFinite(parsed) ? parsed : void 0;
1010
+ }
1011
+ function asAmount(value) {
1012
+ if (typeof value === "string") return value;
1013
+ if (typeof value === "number" && Number.isFinite(value)) {
1014
+ return value.toString();
1015
+ }
1016
+ return void 0;
1017
+ }
1018
+ function asAddress(value) {
1019
+ if (typeof value !== "string") return void 0;
1020
+ return /^0x[a-fA-F0-9]{40}$/.test(value) ? value : void 0;
1021
+ }
998
1022
  function getEventTxHash(event) {
999
- if (!_optionalChain([event, 'optionalAccess', _41 => _41.type])) return void 0;
1023
+ if (!_optionalChain([event, 'optionalAccess', _42 => _42.type])) return void 0;
1000
1024
  if (event.type === "deposit-received") {
1001
- return asString(_optionalChain([event, 'access', _42 => _42.data, 'optionalAccess', _43 => _43.transactionHash]));
1025
+ return asString(_optionalChain([event, 'access', _43 => _43.data, 'optionalAccess', _44 => _44.transactionHash]));
1002
1026
  }
1003
1027
  if (event.type === "bridge-started" || event.type === "bridge-complete") {
1004
- const deposit = isRecord(_optionalChain([event, 'access', _44 => _44.data, 'optionalAccess', _45 => _45.deposit])) ? event.data.deposit : void 0;
1005
- const source = isRecord(_optionalChain([event, 'access', _46 => _46.data, 'optionalAccess', _47 => _47.source])) ? event.data.source : void 0;
1006
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _48 => _48.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _49 => _49.transactionHash]))));
1028
+ const deposit = isRecord(_optionalChain([event, 'access', _45 => _45.data, 'optionalAccess', _46 => _46.deposit])) ? event.data.deposit : void 0;
1029
+ const source = isRecord(_optionalChain([event, 'access', _47 => _47.data, 'optionalAccess', _48 => _48.source])) ? event.data.source : void 0;
1030
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _49 => _49.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _50 => _50.transactionHash]))));
1007
1031
  }
1008
1032
  if (event.type === "bridge-failed" || event.type === "error") {
1009
- const deposit = isRecord(_optionalChain([event, 'access', _50 => _50.data, 'optionalAccess', _51 => _51.deposit])) ? event.data.deposit : void 0;
1010
- const source = isRecord(_optionalChain([event, 'access', _52 => _52.data, 'optionalAccess', _53 => _53.source])) ? event.data.source : void 0;
1011
- return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _54 => _54.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _55 => _55.transactionHash]))));
1033
+ const deposit = isRecord(_optionalChain([event, 'access', _51 => _51.data, 'optionalAccess', _52 => _52.deposit])) ? event.data.deposit : void 0;
1034
+ const source = isRecord(_optionalChain([event, 'access', _53 => _53.data, 'optionalAccess', _54 => _54.source])) ? event.data.source : void 0;
1035
+ return _nullishCoalesce(asString(_optionalChain([deposit, 'optionalAccess', _55 => _55.transactionHash])), () => ( asString(_optionalChain([source, 'optionalAccess', _56 => _56.transactionHash]))));
1012
1036
  }
1013
1037
  return void 0;
1014
1038
  }
1039
+ function getEventSourceDetails(event) {
1040
+ if (!_optionalChain([event, 'optionalAccess', _57 => _57.type]) || !isRecord(event.data)) return {};
1041
+ if (event.type === "deposit-received") {
1042
+ return {
1043
+ chainId: asNumber(event.data.chain),
1044
+ amount: asAmount(event.data.amount),
1045
+ token: asAddress(event.data.token)
1046
+ };
1047
+ }
1048
+ const source = isRecord(event.data.source) ? event.data.source : void 0;
1049
+ const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
1050
+ if (event.type === "bridge-started" || event.type === "bridge-complete" || event.type === "bridge-failed" || event.type === "error") {
1051
+ return {
1052
+ chainId: _nullishCoalesce(asNumber(_optionalChain([source, 'optionalAccess', _58 => _58.chain])), () => ( asNumber(_optionalChain([deposit, 'optionalAccess', _59 => _59.chain])))),
1053
+ amount: _nullishCoalesce(asAmount(_optionalChain([source, 'optionalAccess', _60 => _60.amount])), () => ( asAmount(_optionalChain([deposit, 'optionalAccess', _61 => _61.amount])))),
1054
+ token: _nullishCoalesce(_nullishCoalesce(asAddress(_optionalChain([source, 'optionalAccess', _62 => _62.asset])), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _63 => _63.asset])))), () => ( asAddress(_optionalChain([deposit, 'optionalAccess', _64 => _64.token]))))
1055
+ };
1056
+ }
1057
+ return {};
1058
+ }
1015
1059
  function isDepositEvent(event) {
1016
- return _optionalChain([event, 'optionalAccess', _56 => _56.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _57 => _57.type]) === "bridge-started";
1060
+ return _optionalChain([event, 'optionalAccess', _65 => _65.type]) === "deposit-received" || _optionalChain([event, 'optionalAccess', _66 => _66.type]) === "bridge-started" || _optionalChain([event, 'optionalAccess', _67 => _67.type]) === "bridge-complete" || _optionalChain([event, 'optionalAccess', _68 => _68.type]) === "bridge-failed" || _optionalChain([event, 'optionalAccess', _69 => _69.type]) === "error";
1017
1061
  }
1018
1062
 
1019
1063
  // src/components/steps/ProcessingStep.tsx
@@ -1028,7 +1072,7 @@ function isEventForTx(event, txHash) {
1028
1072
  return eventTxHash.toLowerCase() === txHash.toLowerCase();
1029
1073
  }
1030
1074
  function formatBridgeFailedMessage(event) {
1031
- const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _58 => _58.data]), () => ( {}));
1075
+ const eventData = _nullishCoalesce(_optionalChain([event, 'optionalAccess', _70 => _70.data]), () => ( {}));
1032
1076
  const code = typeof eventData.errorCode === "string" ? eventData.errorCode : void 0;
1033
1077
  const backendMessage = typeof eventData.message === "string" ? eventData.message.trim() : "";
1034
1078
  if (backendMessage.length > 0) {
@@ -1068,7 +1112,7 @@ function ProcessingStep({
1068
1112
  const intervalRef = _react.useRef.call(void 0, null);
1069
1113
  _react.useEffect.call(void 0, () => {
1070
1114
  if (directTransfer) {
1071
- _optionalChain([onDepositComplete, 'optionalCall', _59 => _59(txHash)]);
1115
+ _optionalChain([onDepositComplete, 'optionalCall', _71 => _71(txHash)]);
1072
1116
  return;
1073
1117
  }
1074
1118
  }, [directTransfer, txHash, onDepositComplete]);
@@ -1111,40 +1155,40 @@ function ProcessingStep({
1111
1155
  console.log("[deposit-modal] status poll", {
1112
1156
  type: lastEvent2.type,
1113
1157
  matchesTx: eventMatchesTx,
1114
- intentId: _optionalChain([eventData, 'optionalAccess', _60 => _60.intentId]),
1158
+ intentId: _optionalChain([eventData, 'optionalAccess', _72 => _72.intentId]),
1115
1159
  data: eventData
1116
1160
  });
1117
1161
  }
1118
1162
  if (!isMounted) return;
1119
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _61 => _61.type]) === "bridge-complete") {
1163
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _73 => _73.type]) === "bridge-complete") {
1120
1164
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1121
- const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _62 => _62.data, 'optionalAccess', _63 => _63.destination, 'optionalAccess', _64 => _64.transactionHash]);
1122
- _optionalChain([onDepositComplete, 'optionalCall', _65 => _65(txHash, destinationTxHash2)]);
1165
+ const destinationTxHash2 = _optionalChain([eventForCurrentTx, 'access', _74 => _74.data, 'optionalAccess', _75 => _75.destination, 'optionalAccess', _76 => _76.transactionHash]);
1166
+ _optionalChain([onDepositComplete, 'optionalCall', _77 => _77(txHash, destinationTxHash2)]);
1123
1167
  return;
1124
1168
  }
1125
- if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _66 => _66.type]) === "bridge-started") {
1169
+ if (!waitForFinalTx && _optionalChain([eventForCurrentTx, 'optionalAccess', _78 => _78.type]) === "bridge-started") {
1126
1170
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1127
- _optionalChain([onDepositComplete, 'optionalCall', _67 => _67(txHash)]);
1171
+ _optionalChain([onDepositComplete, 'optionalCall', _79 => _79(txHash)]);
1128
1172
  return;
1129
1173
  }
1130
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _68 => _68.type]) === "bridge-failed") {
1174
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _80 => _80.type]) === "bridge-failed") {
1131
1175
  const formatted = formatBridgeFailedMessage(eventForCurrentTx);
1132
1176
  setState({
1133
1177
  type: "failed",
1134
1178
  message: formatted.message,
1135
1179
  lastEvent: eventForCurrentTx
1136
1180
  });
1137
- _optionalChain([onDepositFailed, 'optionalCall', _69 => _69(txHash, formatted.message)]);
1181
+ _optionalChain([onDepositFailed, 'optionalCall', _81 => _81(txHash, formatted.message)]);
1138
1182
  return;
1139
1183
  }
1140
- if (_optionalChain([eventForCurrentTx, 'optionalAccess', _70 => _70.type]) === "error") {
1141
- const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _71 => _71.data, 'optionalAccess', _72 => _72.message]), () => ( "Unknown error"));
1184
+ if (_optionalChain([eventForCurrentTx, 'optionalAccess', _82 => _82.type]) === "error") {
1185
+ const errorMessage = _nullishCoalesce(_optionalChain([eventForCurrentTx, 'access', _83 => _83.data, 'optionalAccess', _84 => _84.message]), () => ( "Unknown error"));
1142
1186
  setState({
1143
1187
  type: "failed",
1144
1188
  message: errorMessage,
1145
1189
  lastEvent: eventForCurrentTx
1146
1190
  });
1147
- _optionalChain([onDepositFailed, 'optionalCall', _73 => _73(txHash, errorMessage)]);
1191
+ _optionalChain([onDepositFailed, 'optionalCall', _85 => _85(txHash, errorMessage)]);
1148
1192
  return;
1149
1193
  }
1150
1194
  setState({ type: "processing", lastEvent: eventForCurrentTx });
@@ -1192,7 +1236,7 @@ function ProcessingStep({
1192
1236
  processTimeoutRef.current = setTimeout(() => {
1193
1237
  const message = "We couldn't confirm your transfer. Please contact support if funds do not arrive.";
1194
1238
  setState({ type: "error", message });
1195
- _optionalChain([onError, 'optionalCall', _74 => _74(message, "PROCESS_TIMEOUT")]);
1239
+ _optionalChain([onError, 'optionalCall', _86 => _86(message, "PROCESS_TIMEOUT")]);
1196
1240
  }, PROCESS_TIMEOUT_MS);
1197
1241
  return () => {
1198
1242
  if (processTimeoutRef.current) {
@@ -1205,12 +1249,16 @@ function ProcessingStep({
1205
1249
  const isComplete = state.type === "complete";
1206
1250
  const isProcessing = state.type === "processing";
1207
1251
  const lastEvent = state.type === "processing" || state.type === "complete" || state.type === "failed" ? state.lastEvent : void 0;
1208
- const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _75 => _75.type]) === "bridge-started";
1252
+ const isEarlyComplete = !waitForFinalTx && _optionalChain([lastEvent, 'optionalAccess', _87 => _87.type]) === "bridge-started";
1209
1253
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
1210
1254
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
1211
- const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _76 => _76.data, 'optionalAccess', _77 => _77.destination, 'optionalAccess', _78 => _78.transactionHash]) || null;
1212
- const sourceExplorerUrl = _chunkHYUITBRVcjs.getExplorerTxUrl.call(void 0, sourceChain, txHash);
1213
- const destExplorerUrl = destinationTxHash ? _chunkHYUITBRVcjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
1255
+ const destinationTxHash = _optionalChain([lastEvent, 'optionalAccess', _88 => _88.data, 'optionalAccess', _89 => _89.destination, 'optionalAccess', _90 => _90.transactionHash]) || null;
1256
+ const sourceDetails = getEventSourceDetails(lastEvent);
1257
+ const displaySourceChain = _nullishCoalesce(sourceDetails.chainId, () => ( sourceChain));
1258
+ const displaySourceToken = _nullishCoalesce(sourceDetails.token, () => ( sourceToken));
1259
+ const displayAmount = _nullishCoalesce(sourceDetails.amount, () => ( amount));
1260
+ const sourceExplorerUrl = _chunkFLXTBFMZcjs.getExplorerTxUrl.call(void 0, displaySourceChain, txHash);
1261
+ const destExplorerUrl = destinationTxHash ? _chunkFLXTBFMZcjs.getExplorerTxUrl.call(void 0, targetChain, destinationTxHash) : null;
1214
1262
  const truncateHash = (hash) => `${hash.slice(0, 10)}...${hash.slice(-8)}`;
1215
1263
  const formatElapsedTime = (seconds) => {
1216
1264
  if (seconds < 60) return `${seconds} second${seconds !== 1 ? "s" : ""}`;
@@ -1218,16 +1266,19 @@ function ProcessingStep({
1218
1266
  const secs = seconds % 60;
1219
1267
  return `${mins}m ${secs}s`;
1220
1268
  };
1221
- const sourceSymbol = _chunkHYUITBRVcjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
1222
- const sourceDecimals = _chunkHYUITBRVcjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
1269
+ const sourceSymbol = _chunkFLXTBFMZcjs.getTokenSymbol.call(void 0, displaySourceToken, displaySourceChain);
1270
+ const sourceDecimals = _chunkFLXTBFMZcjs.getTokenDecimalsByAddress.call(void 0,
1271
+ displaySourceToken,
1272
+ displaySourceChain
1273
+ );
1223
1274
  const formattedReceivedAmount = (() => {
1224
1275
  try {
1225
- const raw = _viem.formatUnits.call(void 0, BigInt(amount), sourceDecimals);
1276
+ const raw = _viem.formatUnits.call(void 0, BigInt(displayAmount), sourceDecimals);
1226
1277
  const numeric = Number(raw);
1227
1278
  if (!Number.isFinite(numeric)) return raw;
1228
1279
  return numeric.toLocaleString("en-US", { maximumFractionDigits: 6 });
1229
1280
  } catch (e4) {
1230
- return Number(amount).toLocaleString("en-US", {
1281
+ return Number(displayAmount).toLocaleString("en-US", {
1231
1282
  maximumFractionDigits: 6
1232
1283
  });
1233
1284
  }
@@ -1290,15 +1341,15 @@ function ProcessingStep({
1290
1341
  className: "rs-card-value",
1291
1342
  style: { display: "flex", alignItems: "center", gap: 6 },
1292
1343
  children: [
1293
- _chunkHYUITBRVcjs.getChainIcon.call(void 0, sourceChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1344
+ _chunkFLXTBFMZcjs.getChainIcon.call(void 0, displaySourceChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1294
1345
  "img",
1295
1346
  {
1296
- src: _chunkHYUITBRVcjs.getChainIcon.call(void 0, sourceChain),
1347
+ src: _chunkFLXTBFMZcjs.getChainIcon.call(void 0, displaySourceChain),
1297
1348
  alt: "",
1298
1349
  style: { width: 14, height: 14, borderRadius: "50%" }
1299
1350
  }
1300
1351
  ),
1301
- _chunkHYUITBRVcjs.getChainName.call(void 0, sourceChain)
1352
+ _chunkFLXTBFMZcjs.getChainName.call(void 0, displaySourceChain)
1302
1353
  ]
1303
1354
  }
1304
1355
  )
@@ -1311,15 +1362,15 @@ function ProcessingStep({
1311
1362
  className: "rs-card-value",
1312
1363
  style: { display: "flex", alignItems: "center", gap: 6 },
1313
1364
  children: [
1314
- _chunkHYUITBRVcjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1365
+ _chunkFLXTBFMZcjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1315
1366
  "img",
1316
1367
  {
1317
- src: _chunkHYUITBRVcjs.getChainIcon.call(void 0, targetChain),
1368
+ src: _chunkFLXTBFMZcjs.getChainIcon.call(void 0, targetChain),
1318
1369
  alt: "",
1319
1370
  style: { width: 14, height: 14, borderRadius: "50%" }
1320
1371
  }
1321
1372
  ),
1322
- _chunkHYUITBRVcjs.getChainName.call(void 0, targetChain)
1373
+ _chunkFLXTBFMZcjs.getChainName.call(void 0, targetChain)
1323
1374
  ]
1324
1375
  }
1325
1376
  )
@@ -1441,7 +1492,7 @@ function ProcessingStep({
1441
1492
  {
1442
1493
  className: `rs-step-description ${isError ? "rs-text-error" : "rs-text-secondary"}`,
1443
1494
  children: [
1444
- state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess', _79 => _79.type]) === "deposit-received" ? "Transfer received. Preparing bridge..." : _optionalChain([lastEvent, 'optionalAccess', _80 => _80.type]) === "bridge-started" ? "Transfer confirmed. Funds arriving shortly..." : `Bridging your ${flowNoun} to ${_chunkHYUITBRVcjs.getChainName.call(void 0, targetChain)}.`),
1495
+ state.type === "processing" && (_optionalChain([lastEvent, 'optionalAccess', _91 => _91.type]) === "deposit-received" ? "Transfer received. Preparing bridge..." : _optionalChain([lastEvent, 'optionalAccess', _92 => _92.type]) === "bridge-started" ? "Transfer confirmed. Funds arriving shortly..." : `Bridging your ${flowNoun} to ${_chunkFLXTBFMZcjs.getChainName.call(void 0, targetChain)}.`),
1445
1496
  state.type === "failed" && state.message,
1446
1497
  state.type === "error" && state.message
1447
1498
  ]
@@ -1497,15 +1548,15 @@ function ProcessingStep({
1497
1548
  className: "rs-card-value",
1498
1549
  style: { display: "flex", alignItems: "center", gap: 8 },
1499
1550
  children: [
1500
- _chunkHYUITBRVcjs.getChainIcon.call(void 0, sourceChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1551
+ _chunkFLXTBFMZcjs.getChainIcon.call(void 0, displaySourceChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1501
1552
  "img",
1502
1553
  {
1503
- src: _chunkHYUITBRVcjs.getChainIcon.call(void 0, sourceChain),
1554
+ src: _chunkFLXTBFMZcjs.getChainIcon.call(void 0, displaySourceChain),
1504
1555
  alt: "",
1505
1556
  style: { width: 16, height: 16, borderRadius: "50%" }
1506
1557
  }
1507
1558
  ),
1508
- _chunkHYUITBRVcjs.getChainName.call(void 0, sourceChain)
1559
+ _chunkFLXTBFMZcjs.getChainName.call(void 0, displaySourceChain)
1509
1560
  ]
1510
1561
  }
1511
1562
  )
@@ -1518,15 +1569,15 @@ function ProcessingStep({
1518
1569
  className: "rs-card-value",
1519
1570
  style: { display: "flex", alignItems: "center", gap: 8 },
1520
1571
  children: [
1521
- _chunkHYUITBRVcjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1572
+ _chunkFLXTBFMZcjs.getChainIcon.call(void 0, targetChain) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1522
1573
  "img",
1523
1574
  {
1524
- src: _chunkHYUITBRVcjs.getChainIcon.call(void 0, targetChain),
1575
+ src: _chunkFLXTBFMZcjs.getChainIcon.call(void 0, targetChain),
1525
1576
  alt: "",
1526
1577
  style: { width: 16, height: 16, borderRadius: "50%" }
1527
1578
  }
1528
1579
  ),
1529
- _chunkHYUITBRVcjs.getChainName.call(void 0, targetChain)
1580
+ _chunkFLXTBFMZcjs.getChainName.call(void 0, targetChain)
1530
1581
  ]
1531
1582
  }
1532
1583
  )
@@ -1579,7 +1630,7 @@ var clientCache = /* @__PURE__ */ new Map();
1579
1630
  function getPublicClient(chainId) {
1580
1631
  let client = clientCache.get(chainId);
1581
1632
  if (!client) {
1582
- const chain = _chunkHYUITBRVcjs.CHAIN_BY_ID[chainId];
1633
+ const chain = _chunkFLXTBFMZcjs.CHAIN_BY_ID[chainId];
1583
1634
  client = _viem.createPublicClient.call(void 0, {
1584
1635
  chain,
1585
1636
  transport: _viem.http.call(void 0, )
@@ -1612,4 +1663,5 @@ function getPublicClient(chainId) {
1612
1663
 
1613
1664
 
1614
1665
 
1615
- exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; 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.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
1666
+
1667
+ exports.Modal = Modal; exports.Spinner = Spinner; exports.Button = Button; exports.ConnectStep = ConnectStep; 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.getEventSourceDetails = getEventSourceDetails; exports.isDepositEvent = isDepositEvent; exports.ProcessingStep = ProcessingStep; exports.getPublicClient = getPublicClient; exports.applyTheme = applyTheme;
@@ -17,7 +17,7 @@ import {
17
17
  isNativeAsset,
18
18
  loadSessionOwnerFromStorage,
19
19
  saveSessionOwnerToStorage
20
- } from "./chunk-UBPIPY3L.mjs";
20
+ } from "./chunk-IC2M2DZ7.mjs";
21
21
  import {
22
22
  DEFAULT_BACKEND_URL,
23
23
  DEFAULT_SIGNER_ADDRESS,
@@ -30,7 +30,7 @@ import {
30
30
  getTokenDecimalsByAddress,
31
31
  getTokenIcon,
32
32
  getTokenSymbol
33
- } from "./chunk-ZL4KPLWE.mjs";
33
+ } from "./chunk-I7RYTI4G.mjs";
34
34
 
35
35
  // src/WithdrawModal.tsx
36
36
  import {
@@ -1340,7 +1340,7 @@ function WithdrawFlow({
1340
1340
  // src/WithdrawModal.tsx
1341
1341
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1342
1342
  var ReownWithdrawInner = lazy(
1343
- () => import("./WithdrawModalReown-OIG2DANP.mjs").then((m) => ({
1343
+ () => import("./WithdrawModalReown-XXCOZYVU.mjs").then((m) => ({
1344
1344
  default: m.WithdrawModalReown
1345
1345
  }))
1346
1346
  );
@@ -13,6 +13,7 @@ import {
13
13
  currencyFormatter,
14
14
  formatUserError,
15
15
  getAssetId,
16
+ getEventSourceDetails,
16
17
  getEventTxHash,
17
18
  getPublicClient,
18
19
  isDepositEvent,
@@ -21,7 +22,7 @@ import {
21
22
  portfolioToAssets,
22
23
  saveSessionOwnerToStorage,
23
24
  tokenFormatter
24
- } from "./chunk-UBPIPY3L.mjs";
25
+ } from "./chunk-IC2M2DZ7.mjs";
25
26
  import {
26
27
  DEFAULT_BACKEND_URL,
27
28
  DEFAULT_SIGNER_ADDRESS,
@@ -37,7 +38,7 @@ import {
37
38
  getTokenIcon,
38
39
  getTokenSymbol,
39
40
  isStablecoinSymbol
40
- } from "./chunk-ZL4KPLWE.mjs";
41
+ } from "./chunk-I7RYTI4G.mjs";
41
42
 
42
43
  // src/DepositModal.tsx
43
44
  import {
@@ -1236,46 +1237,6 @@ QRCode.displayName = "QRCode";
1236
1237
  // src/components/steps/DepositAddressStep.tsx
1237
1238
  import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1238
1239
  var POLL_INTERVAL_MS = 4e3;
1239
- function isRecord(value) {
1240
- return typeof value === "object" && value !== null;
1241
- }
1242
- function asNumber(value) {
1243
- if (typeof value === "number" && Number.isFinite(value)) return value;
1244
- if (typeof value === "string" && value.trim() !== "") {
1245
- const parsed = Number(value);
1246
- return Number.isFinite(parsed) ? parsed : void 0;
1247
- }
1248
- return void 0;
1249
- }
1250
- function asAmount(value) {
1251
- if (typeof value === "string") return value;
1252
- if (typeof value === "number" && Number.isFinite(value)) {
1253
- return value.toString();
1254
- }
1255
- return void 0;
1256
- }
1257
- function asAddress(value) {
1258
- if (typeof value !== "string") return void 0;
1259
- return /^0x[a-fA-F0-9]{40}$/.test(value) ? value : void 0;
1260
- }
1261
- function getDepositEventDetails(event) {
1262
- if (!event?.type || !isRecord(event.data)) return {};
1263
- if (event.type === "deposit-received") {
1264
- return {
1265
- chainId: asNumber(event.data.chain),
1266
- amount: asAmount(event.data.amount),
1267
- token: asAddress(event.data.token)
1268
- };
1269
- }
1270
- if (event.type === "bridge-started") {
1271
- const source = isRecord(event.data.source) ? event.data.source : void 0;
1272
- return {
1273
- chainId: asNumber(source?.chain),
1274
- token: asAddress(source?.asset)
1275
- };
1276
- }
1277
- return {};
1278
- }
1279
1240
  function DepositAddressStep({
1280
1241
  smartAccount,
1281
1242
  service,
@@ -1366,7 +1327,7 @@ function DepositAddressStep({
1366
1327
  if (baselineTxHash === void 0) {
1367
1328
  baselineTxHash = eventTxHash;
1368
1329
  } else if (eventTxHash && eventTxHash !== baselineTxHash) {
1369
- const details = getDepositEventDetails(event);
1330
+ const details = getEventSourceDetails(event);
1370
1331
  const fallback = sourceSelectionRef.current;
1371
1332
  const chainId = details.chainId ?? fallback.chainId;
1372
1333
  const amount = details.amount ?? "0";
@@ -1585,6 +1546,9 @@ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1585
1546
  function isSameRoute(sourceChain, sourceToken, targetChain, targetToken) {
1586
1547
  return sourceChain === targetChain && sourceToken.toLowerCase() === targetToken.toLowerCase();
1587
1548
  }
1549
+ function getAddressKey(address) {
1550
+ return address ? address.toLowerCase() : null;
1551
+ }
1588
1552
  function DepositFlow({
1589
1553
  dappWalletClient,
1590
1554
  dappPublicClient,
@@ -1622,6 +1586,9 @@ function DepositFlow({
1622
1586
  const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = useState7(false);
1623
1587
  const [selectedConnectAddress, setSelectedConnectAddress] = useState7(null);
1624
1588
  const portfolioAssetsRef = useRef5([]);
1589
+ const stableWalletSignerRef = useRef5(null);
1590
+ const stableWalletSelectionKeyRef = useRef5(null);
1591
+ const hasNavigatedBackRef = useRef5(false);
1625
1592
  const handleAssetsLoaded = useCallback3((assets) => {
1626
1593
  portfolioAssetsRef.current = assets;
1627
1594
  }, []);
@@ -1644,16 +1611,17 @@ function DepositFlow({
1644
1611
  await dappWalletClient.switchChain?.({ id: chainId });
1645
1612
  };
1646
1613
  }, [dappWalletClient]);
1614
+ const connectedWalletAddress = dappWalletClient?.account?.address ?? null;
1647
1615
  const walletOptions = useMemo5(() => {
1648
1616
  const options = [];
1649
1617
  const seen = /* @__PURE__ */ new Set();
1650
- if (dappWalletClient?.account && dappAddress) {
1618
+ if (connectedWalletAddress && dappAddress) {
1651
1619
  options.push({
1652
- address: dappWalletClient.account.address,
1620
+ address: connectedWalletAddress,
1653
1621
  label: "Connected Wallet",
1654
1622
  kind: "connected"
1655
1623
  });
1656
- seen.add(dappWalletClient.account.address.toLowerCase());
1624
+ seen.add(connectedWalletAddress.toLowerCase());
1657
1625
  }
1658
1626
  if (reownWallet?.address && reownWallet.isConnected && reownWallet.walletClient && reownWallet.publicClient && !seen.has(reownWallet.address.toLowerCase())) {
1659
1627
  options.push({
@@ -1665,7 +1633,7 @@ function DepositFlow({
1665
1633
  }
1666
1634
  return options;
1667
1635
  }, [
1668
- dappWalletClient,
1636
+ connectedWalletAddress,
1669
1637
  dappAddress,
1670
1638
  reownWallet?.address,
1671
1639
  reownWallet?.isConnected,
@@ -1675,17 +1643,27 @@ function DepositFlow({
1675
1643
  ]);
1676
1644
  const canAutoLock = dappWalletClient?.account && dappAddress && !reownWallet;
1677
1645
  const hasWalletOptions = walletOptions.length > 0;
1678
- const hasReownSession = Boolean(reownWallet?.isConnected || reownWallet?.address);
1679
- const showConnectStep = !canAutoLock && !isConnectSelectionConfirmed;
1680
- const signerContext = useMemo5(() => {
1646
+ const hasReownSession = Boolean(
1647
+ reownWallet?.isConnected || reownWallet?.address
1648
+ );
1649
+ const showConnectStep = flowMode === null && !canAutoLock && !isConnectSelectionConfirmed;
1650
+ const walletSelectionKey = useMemo5(() => {
1651
+ if (flowMode !== "wallet") return null;
1652
+ if (canAutoLock) {
1653
+ return getAddressKey(connectedWalletAddress);
1654
+ }
1655
+ if (!isConnectSelectionConfirmed) return null;
1656
+ return getAddressKey(selectedConnectAddress);
1657
+ }, [
1658
+ flowMode,
1659
+ canAutoLock,
1660
+ connectedWalletAddress,
1661
+ isConnectSelectionConfirmed,
1662
+ selectedConnectAddress
1663
+ ]);
1664
+ const walletSignerContext = useMemo5(() => {
1681
1665
  if (flowMode === "deposit-address") {
1682
- if (!dappAddress) return null;
1683
- return {
1684
- ownerAddress: dappAddress,
1685
- walletClient: void 0,
1686
- publicClient: dappPublicClient ?? getPublicClient(targetChain),
1687
- switchChain: void 0
1688
- };
1666
+ return null;
1689
1667
  }
1690
1668
  if (canAutoLock) {
1691
1669
  const fallbackChainId = dappWalletClient?.chain?.id ?? targetChain;
@@ -1716,7 +1694,6 @@ function DepositFlow({
1716
1694
  }
1717
1695
  return null;
1718
1696
  }, [
1719
- flowMode,
1720
1697
  canAutoLock,
1721
1698
  isConnectSelectionConfirmed,
1722
1699
  selectedConnectAddress,
@@ -1727,6 +1704,49 @@ function DepositFlow({
1727
1704
  reownWallet,
1728
1705
  targetChain
1729
1706
  ]);
1707
+ useEffect7(() => {
1708
+ if (flowMode !== "wallet") {
1709
+ stableWalletSelectionKeyRef.current = null;
1710
+ stableWalletSignerRef.current = null;
1711
+ return;
1712
+ }
1713
+ if (walletSelectionKey !== stableWalletSelectionKeyRef.current) {
1714
+ stableWalletSelectionKeyRef.current = walletSelectionKey;
1715
+ stableWalletSignerRef.current = null;
1716
+ }
1717
+ if (walletSignerContext && walletSelectionKey) {
1718
+ stableWalletSelectionKeyRef.current = walletSelectionKey;
1719
+ stableWalletSignerRef.current = walletSignerContext;
1720
+ }
1721
+ }, [flowMode, walletSelectionKey, walletSignerContext]);
1722
+ const signerContext = useMemo5(() => {
1723
+ if (flowMode === "deposit-address") {
1724
+ if (!dappAddress) return null;
1725
+ return {
1726
+ ownerAddress: dappAddress,
1727
+ walletClient: void 0,
1728
+ publicClient: dappPublicClient ?? getPublicClient(targetChain),
1729
+ switchChain: void 0
1730
+ };
1731
+ }
1732
+ if (flowMode !== "wallet") {
1733
+ return null;
1734
+ }
1735
+ if (walletSignerContext) {
1736
+ return walletSignerContext;
1737
+ }
1738
+ if (walletSelectionKey && stableWalletSelectionKeyRef.current === walletSelectionKey) {
1739
+ return stableWalletSignerRef.current;
1740
+ }
1741
+ return null;
1742
+ }, [
1743
+ flowMode,
1744
+ dappAddress,
1745
+ dappPublicClient,
1746
+ targetChain,
1747
+ walletSignerContext,
1748
+ walletSelectionKey
1749
+ ]);
1730
1750
  const sessionKeyAddress = dappAddress ?? signerContext?.ownerAddress ?? null;
1731
1751
  const lastTargetRef = useRef5(null);
1732
1752
  useEffect7(() => {
@@ -1747,6 +1767,7 @@ function DepositFlow({
1747
1767
  const handleBackFromSelectAsset = useCallback3(() => {
1748
1768
  if (hasWalletOptions || reownWallet) {
1749
1769
  hasNavigatedBackRef.current = true;
1770
+ setFlowMode(null);
1750
1771
  setIsConnectSelectionConfirmed(false);
1751
1772
  }
1752
1773
  }, [hasWalletOptions, reownWallet]);
@@ -1784,10 +1805,20 @@ function DepositFlow({
1784
1805
  setFlowMode("deposit-address");
1785
1806
  setStep({ type: "setup" });
1786
1807
  }, []);
1787
- const handleNewDeposit = useCallback3(() => {
1808
+ const handleResetFlow = useCallback3(() => {
1809
+ portfolioAssetsRef.current = [];
1810
+ stableWalletSignerRef.current = null;
1811
+ stableWalletSelectionKeyRef.current = null;
1812
+ hasNavigatedBackRef.current = false;
1813
+ setTotalBalanceUsd(0);
1814
+ setSelectedConnectAddress(null);
1815
+ setIsConnectSelectionConfirmed(false);
1788
1816
  setFlowMode(null);
1789
1817
  setStep({ type: "setup" });
1790
1818
  }, []);
1819
+ const handleNewDeposit = useCallback3(() => {
1820
+ handleResetFlow();
1821
+ }, [handleResetFlow]);
1791
1822
  const handleSetupComplete = useCallback3(
1792
1823
  (smartAccount) => {
1793
1824
  if (isDepositAddressMode) {
@@ -1907,7 +1938,6 @@ function DepositFlow({
1907
1938
  }
1908
1939
  return null;
1909
1940
  }, [selectedConnectAddress, walletOptions]);
1910
- const hasNavigatedBackRef = useRef5(false);
1911
1941
  useEffect7(() => {
1912
1942
  if (!showConnectStep && isConnectSelectionConfirmed && flowMode === "wallet" && !signerContext) {
1913
1943
  setSelectedConnectAddress(null);
@@ -2119,7 +2149,7 @@ function DepositFlow({
2119
2149
  // src/DepositModal.tsx
2120
2150
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
2121
2151
  var ReownDepositInner = lazy(
2122
- () => import("./DepositModalReown-BJWM3JMC.mjs").then((m) => ({ default: m.DepositModalReown }))
2152
+ () => import("./DepositModalReown-3HNOCOOO.mjs").then((m) => ({ default: m.DepositModalReown }))
2123
2153
  );
2124
2154
  function DepositModal(props) {
2125
2155
  const needsReown = !!props.reownAppId;
@@ -2186,6 +2216,9 @@ function DepositModalInner({
2186
2216
  useEffect8(() => {
2187
2217
  if (!isOpen) {
2188
2218
  setCurrentStepIndex(0);
2219
+ setTotalBalanceUsd(null);
2220
+ backHandlerRef.current = void 0;
2221
+ hasCalledReady.current = false;
2189
2222
  }
2190
2223
  }, [isOpen]);
2191
2224
  const handleStepChange = useCallback4(