@rhinestone/deposit-modal 0.1.62 → 0.1.64

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.
@@ -21,7 +21,7 @@
21
21
 
22
22
 
23
23
 
24
- var _chunkMVFMDKAScjs = require('./chunk-MVFMDKAS.cjs');
24
+ var _chunk5SR5N75Icjs = require('./chunk-5SR5N75I.cjs');
25
25
 
26
26
 
27
27
 
@@ -65,20 +65,10 @@ function useClickOutside(ref, onClose) {
65
65
  return () => document.removeEventListener("mousedown", handleClick);
66
66
  }, [ref, onClose]);
67
67
  }
68
- function resolvePreferredConnectedRecipient(connectedAddress, fallbackAddress, safeAddress) {
69
- const candidates = [connectedAddress, fallbackAddress].filter(
70
- (value) => Boolean(value)
71
- );
72
- const nonSafe = candidates.find(
73
- (value) => value.toLowerCase() !== safeAddress.toLowerCase()
74
- );
75
- return _nullishCoalesce(_nullishCoalesce(nonSafe, () => ( candidates[0])), () => ( ""));
76
- }
77
68
  function WithdrawFormStep({
78
69
  walletClient,
79
70
  publicClient,
80
- address,
81
- connectedAddress,
71
+ connectedRecipient,
82
72
  safeAddress,
83
73
  asset,
84
74
  defaultRecipient,
@@ -95,13 +85,7 @@ function WithdrawFormStep({
95
85
  onSubmit,
96
86
  onBalanceUsdChange
97
87
  }) {
98
- const preferredConnectedRecipient = resolvePreferredConnectedRecipient(
99
- connectedAddress,
100
- address,
101
- safeAddress
102
- );
103
- const seededRecipient = _nullishCoalesce(defaultRecipient, () => ( preferredConnectedRecipient));
104
- const [recipient, setRecipient] = _react.useState.call(void 0, seededRecipient);
88
+ const [recipient, setRecipient] = _react.useState.call(void 0, _nullishCoalesce(defaultRecipient, () => ( "")));
105
89
  const [amount, setAmount] = _react.useState.call(void 0, _nullishCoalesce(defaultAmount, () => ( "")));
106
90
  const [balance, setBalance] = _react.useState.call(void 0, null);
107
91
  const [isBalanceLoading, setIsBalanceLoading] = _react.useState.call(void 0, true);
@@ -116,6 +100,7 @@ function WithdrawFormStep({
116
100
  const publicClientChainId = _optionalChain([publicClient, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]);
117
101
  useClickOutside(chainDropdownRef, () => setShowChainDropdown(false));
118
102
  useClickOutside(tokenDropdownRef, () => setShowTokenDropdown(false));
103
+ const preferredConnectedRecipient = _nullishCoalesce(connectedRecipient, () => ( ""));
119
104
  const isRecipientConnected = Boolean(
120
105
  preferredConnectedRecipient && recipient && recipient.toLowerCase() === preferredConnectedRecipient.toLowerCase()
121
106
  );
@@ -125,9 +110,9 @@ function WithdrawFormStep({
125
110
  const targetSymbol = _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, targetToken, targetChain);
126
111
  const targetChainName = _chunkR6U6BHCVcjs.getChainName.call(void 0, targetChain);
127
112
  const isBusy = submitting || isSubmitting;
128
- const seededRecipientRef = _react.useRef.call(void 0, seededRecipient);
113
+ const seededRecipientRef = _react.useRef.call(void 0, _nullishCoalesce(defaultRecipient, () => ( "")));
129
114
  _react.useEffect.call(void 0, () => {
130
- const nextSeed = _nullishCoalesce(defaultRecipient, () => ( preferredConnectedRecipient));
115
+ const nextSeed = _nullishCoalesce(defaultRecipient, () => ( ""));
131
116
  setRecipient((current) => {
132
117
  if (current === seededRecipientRef.current || current === "") {
133
118
  return nextSeed;
@@ -135,14 +120,14 @@ function WithdrawFormStep({
135
120
  return current;
136
121
  });
137
122
  seededRecipientRef.current = nextSeed;
138
- }, [defaultRecipient, preferredConnectedRecipient]);
123
+ }, [defaultRecipient]);
139
124
  _react.useEffect.call(void 0, () => {
140
125
  if (chainMismatch && switchChain && !hasAttemptedSwitch.current) {
141
126
  hasAttemptedSwitch.current = true;
142
127
  setIsSwitching(true);
143
128
  switchChain(asset.chainId).catch((err) => {
144
129
  const raw = err instanceof Error ? err.message : "Failed to switch chain";
145
- setError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw));
130
+ setError(_chunk5SR5N75Icjs.formatUserError.call(void 0, raw));
146
131
  }).finally(() => {
147
132
  setIsSwitching(false);
148
133
  });
@@ -162,7 +147,7 @@ function WithdrawFormStep({
162
147
  return;
163
148
  }
164
149
  try {
165
- const bal = _chunkMVFMDKAScjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
150
+ const bal = _chunk5SR5N75Icjs.isNativeAsset.call(void 0, asset) ? await publicClient.getBalance({ address: safeAddress }) : await publicClient.readContract({
166
151
  address: asset.token,
167
152
  abi: _viem.erc20Abi,
168
153
  functionName: "balanceOf",
@@ -265,7 +250,7 @@ function WithdrawFormStep({
265
250
  await onSubmit(recipient, amount);
266
251
  } catch (err) {
267
252
  const raw = err instanceof Error ? err.message : "Withdrawal failed";
268
- setError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw));
253
+ setError(_chunk5SR5N75Icjs.formatUserError.call(void 0, raw));
269
254
  } finally {
270
255
  setIsSubmitting(false);
271
256
  }
@@ -273,11 +258,11 @@ function WithdrawFormStep({
273
258
  if (isBalanceLoading) {
274
259
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
275
260
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step-body rs-withdraw-loading", children: [
276
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.Spinner, { className: "rs-spinner--lg" }),
261
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5SR5N75Icjs.Spinner, { className: "rs-spinner--lg" }),
277
262
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-title", children: "Loading on-chain balance" }),
278
263
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-withdraw-loading-subtitle", children: chainMismatch ? `Switch to ${_chunkR6U6BHCVcjs.getChainName.call(void 0, asset.chainId)} to continue.` : "Please wait before withdrawing." })
279
264
  ] }),
280
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.PoweredBy, {})
265
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5SR5N75Icjs.PoweredBy, {})
281
266
  ] });
282
267
  }
283
268
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-step", children: [
@@ -298,7 +283,7 @@ function WithdrawFormStep({
298
283
  }
299
284
  }
300
285
  ),
301
- address && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
286
+ preferredConnectedRecipient && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
302
287
  "button",
303
288
  {
304
289
  type: "button",
@@ -376,7 +361,7 @@ function WithdrawFormStep({
376
361
  ] })
377
362
  ] }),
378
363
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-withdraw-amount-info", children: [
379
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunkMVFMDKAScjs.currencyFormatter.format(amountUsd) : "$0.00" }),
364
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-withdraw-usd", children: amountUsd !== null ? _chunk5SR5N75Icjs.currencyFormatter.format(amountUsd) : "$0.00" }),
380
365
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "rs-withdraw-balance", children: [
381
366
  "Balance: ",
382
367
  formattedBalance,
@@ -570,7 +555,7 @@ function WithdrawFormStep({
570
555
  ] })
571
556
  ] }),
572
557
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-step-footer", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
573
- _chunkMVFMDKAScjs.Button,
558
+ _chunk5SR5N75Icjs.Button,
574
559
  {
575
560
  onClick: handleWithdraw,
576
561
  fullWidth: true,
@@ -579,7 +564,7 @@ function WithdrawFormStep({
579
564
  children: isBusy ? "Preparing..." : !recipient ? "Enter Recipient Address" : !amount ? "Enter Withdraw Amount" : "Withdraw"
580
565
  }
581
566
  ) }),
582
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMVFMDKAScjs.PoweredBy, {})
567
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk5SR5N75Icjs.PoweredBy, {})
583
568
  ] });
584
569
  }
585
570
  WithdrawFormStep.displayName = "WithdrawFormStep";
@@ -906,22 +891,22 @@ function WithdrawFlow({
906
891
  onError,
907
892
  debug
908
893
  }) {
909
- const onStepChangeRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onStepChange);
910
- const onTotalBalanceChangeRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onTotalBalanceChange);
911
- const onEventRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onEvent);
894
+ const onStepChangeRef = _chunk5SR5N75Icjs.useLatestRef.call(void 0, onStepChange);
895
+ const onTotalBalanceChangeRef = _chunk5SR5N75Icjs.useLatestRef.call(void 0, onTotalBalanceChange);
896
+ const onEventRef = _chunk5SR5N75Icjs.useLatestRef.call(void 0, onEvent);
912
897
  const [step, setStep] = _react.useState.call(void 0, { type: "form" });
913
898
  const [isSubmitting, setIsSubmitting] = _react.useState.call(void 0, false);
914
899
  const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, 0);
915
900
  const [isConnectSelectionConfirmed, setIsConnectSelectionConfirmed] = _react.useState.call(void 0, false);
916
901
  const logFlow = _react.useCallback.call(void 0,
917
902
  (message, data) => {
918
- _chunkMVFMDKAScjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
903
+ _chunk5SR5N75Icjs.debugLog.call(void 0, debug, "withdraw-flow", message, data);
919
904
  },
920
905
  [debug]
921
906
  );
922
907
  const logFlowError = _react.useCallback.call(void 0,
923
908
  (message, error, data) => {
924
- _chunkMVFMDKAScjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
909
+ _chunk5SR5N75Icjs.debugError.call(void 0, debug, "withdraw-flow", message, error, data);
925
910
  },
926
911
  [debug]
927
912
  );
@@ -980,14 +965,14 @@ function WithdrawFlow({
980
965
  return {
981
966
  ownerAddress: dappAddress,
982
967
  walletClient: _nullishCoalesce(dappWalletClient, () => ( void 0)),
983
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
968
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunk5SR5N75Icjs.getPublicClient.call(void 0, sourceChain))),
984
969
  switchChain: dappSwitchChain
985
970
  };
986
971
  }
987
972
  return {
988
973
  ownerAddress: dappWalletClient.account.address,
989
974
  walletClient: dappWalletClient,
990
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
975
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunk5SR5N75Icjs.getPublicClient.call(void 0, sourceChain))),
991
976
  switchChain: dappSwitchChain
992
977
  };
993
978
  }
@@ -998,7 +983,7 @@ function WithdrawFlow({
998
983
  return {
999
984
  ownerAddress: dappWalletClient.account.address,
1000
985
  walletClient: dappWalletClient,
1001
- publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain))),
986
+ publicClient: _nullishCoalesce(dappPublicClient, () => ( _chunk5SR5N75Icjs.getPublicClient.call(void 0, sourceChain))),
1002
987
  switchChain: dappSwitchChain
1003
988
  };
1004
989
  }
@@ -1028,7 +1013,7 @@ function WithdrawFlow({
1028
1013
  const symbol = _chunkR6U6BHCVcjs.getTokenSymbol.call(void 0, sourceToken, sourceChain);
1029
1014
  const decimals = _chunkR6U6BHCVcjs.getTokenDecimalsByAddress.call(void 0, sourceToken, sourceChain);
1030
1015
  return {
1031
- id: _chunkMVFMDKAScjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1016
+ id: _chunk5SR5N75Icjs.getAssetId.call(void 0, { chainId: sourceChain, token: sourceToken }),
1032
1017
  chainId: sourceChain,
1033
1018
  token: sourceToken,
1034
1019
  symbol,
@@ -1099,15 +1084,15 @@ function WithdrawFlow({
1099
1084
  [logFlowError, onError]
1100
1085
  );
1101
1086
  const resolveSessionOwner = _react.useCallback.call(void 0, async (eoaAddress) => {
1102
- const localOwner = _chunkMVFMDKAScjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
1087
+ const localOwner = _chunk5SR5N75Icjs.loadSessionOwnerFromStorage.call(void 0, eoaAddress);
1103
1088
  if (localOwner) {
1104
1089
  return {
1105
- account: _chunkMVFMDKAScjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
1090
+ account: _chunk5SR5N75Icjs.accountFromPrivateKey.call(void 0, localOwner.privateKey),
1106
1091
  address: localOwner.address
1107
1092
  };
1108
1093
  }
1109
- const created = _chunkMVFMDKAScjs.createSessionOwnerKey.call(void 0, );
1110
- _chunkMVFMDKAScjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
1094
+ const created = _chunk5SR5N75Icjs.createSessionOwnerKey.call(void 0, );
1095
+ _chunk5SR5N75Icjs.saveSessionOwnerToStorage.call(void 0, eoaAddress, created.privateKey, created.address);
1111
1096
  return {
1112
1097
  account: created.account,
1113
1098
  address: created.address
@@ -1147,7 +1132,7 @@ function WithdrawFlow({
1147
1132
  const setup = await service.setupAccount({
1148
1133
  ownerAddress: ownerAddress2,
1149
1134
  sessionOwnerAddress: sessionOwner.address,
1150
- targetChain: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, targetChain),
1135
+ targetChain: _chunk5SR5N75Icjs.toEvmCaip2.call(void 0, targetChain),
1151
1136
  targetToken,
1152
1137
  signerAddress,
1153
1138
  sessionChainIds,
@@ -1174,7 +1159,7 @@ function WithdrawFlow({
1174
1159
  primaryType: typedData.primaryType,
1175
1160
  message: typedData.message
1176
1161
  });
1177
- const sessionDetails = _chunkMVFMDKAScjs.buildSessionDetails.call(void 0,
1162
+ const sessionDetails = _chunk5SR5N75Icjs.buildSessionDetails.call(void 0,
1178
1163
  setup.sessionDetailsUnsigned,
1179
1164
  signature
1180
1165
  );
@@ -1188,7 +1173,7 @@ function WithdrawFlow({
1188
1173
  eoaAddress: ownerAddress2,
1189
1174
  sessionOwner: sessionOwner.address,
1190
1175
  target: {
1191
- chain: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, targetChain),
1176
+ chain: _chunk5SR5N75Icjs.toEvmCaip2.call(void 0, targetChain),
1192
1177
  token: targetToken,
1193
1178
  recipient
1194
1179
  }
@@ -1197,7 +1182,7 @@ function WithdrawFlow({
1197
1182
  }
1198
1183
  handleConnected(ownerAddress2, smartAccount);
1199
1184
  const amountUnits = _viem.parseUnits.call(void 0, amountValue, asset.decimals);
1200
- const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _31 => _31.publicClient]), () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain)));
1185
+ const pc = _nullishCoalesce(_optionalChain([signerContext, 'optionalAccess', _31 => _31.publicClient]), () => ( _chunk5SR5N75Icjs.getPublicClient.call(void 0, sourceChain)));
1201
1186
  let result;
1202
1187
  if (onSignTransaction) {
1203
1188
  const transferData = isSourceNative ? { to: smartAccount, value: amountUnits, data: "0x" } : {
@@ -1220,7 +1205,7 @@ function WithdrawFlow({
1220
1205
  const { signature } = await onSignTransaction(request);
1221
1206
  const relayResult = await service.relayWithdraw({
1222
1207
  smartAccount,
1223
- chainId: _chunkMVFMDKAScjs.toEvmCaip2.call(void 0, sourceChain),
1208
+ chainId: _chunk5SR5N75Icjs.toEvmCaip2.call(void 0, sourceChain),
1224
1209
  safeAddress,
1225
1210
  safeTransaction: request.typedData.message,
1226
1211
  signature
@@ -1278,7 +1263,7 @@ function WithdrawFlow({
1278
1263
  targetChain,
1279
1264
  targetToken
1280
1265
  });
1281
- handleError(_chunkMVFMDKAScjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1266
+ handleError(_chunk5SR5N75Icjs.formatUserError.call(void 0, raw), "WITHDRAW_FLOW_ERROR");
1282
1267
  throw err;
1283
1268
  } finally {
1284
1269
  setIsSubmitting(false);
@@ -1406,16 +1391,17 @@ function WithdrawFlow({
1406
1391
  }
1407
1392
  }, [showConnectStep, isConnectSelectionConfirmed, signerContext]);
1408
1393
  const ownerAddress = _optionalChain([signerContext, 'optionalAccess', _39 => _39.ownerAddress]);
1394
+ const selectedWalletOption = selectedWalletIdEffective ? _nullishCoalesce(walletOptions.find((option) => option.id === selectedWalletIdEffective), () => ( null)) : null;
1409
1395
  const selectedWalletIcon = _react.useMemo.call(void 0, () => {
1410
- if (!ownerAddress) return _optionalChain([reownWallet, 'optionalAccess', _40 => _40.icon]);
1396
+ if (!ownerAddress) return void 0;
1411
1397
  const selected = walletOptions.find(
1412
- (o) => _optionalChain([o, 'access', _41 => _41.address, 'optionalAccess', _42 => _42.toLowerCase, 'call', _43 => _43()]) === ownerAddress.toLowerCase()
1398
+ (o) => _optionalChain([o, 'access', _40 => _40.address, 'optionalAccess', _41 => _41.toLowerCase, 'call', _42 => _42()]) === ownerAddress.toLowerCase()
1413
1399
  );
1414
- return _nullishCoalesce(_optionalChain([selected, 'optionalAccess', _44 => _44.icon]), () => ( _optionalChain([reownWallet, 'optionalAccess', _45 => _45.icon])));
1415
- }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _46 => _46.icon])]);
1400
+ return _optionalChain([selected, 'optionalAccess', _43 => _43.kind]) === "external" ? _nullishCoalesce(selected.icon, () => ( _optionalChain([reownWallet, 'optionalAccess', _44 => _44.icon]))) : void 0;
1401
+ }, [walletOptions, ownerAddress, _optionalChain([reownWallet, 'optionalAccess', _45 => _45.icon])]);
1416
1402
  if (showConnectStep) {
1417
1403
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1418
- _chunkMVFMDKAScjs.ConnectStep,
1404
+ _chunk5SR5N75Icjs.ConnectStep,
1419
1405
  {
1420
1406
  walletOptions,
1421
1407
  selectedWalletId: selectedWalletIdEffective,
@@ -1435,21 +1421,18 @@ function WithdrawFlow({
1435
1421
  }
1436
1422
  if (!signerContext) return null;
1437
1423
  if (!onSignTransaction && !signerContext.walletClient) return null;
1438
- const resolvedOwnerAddress = signerContext.ownerAddress;
1439
- const resolvedConnectedAddress = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([signerContext, 'access', _47 => _47.walletClient, 'optionalAccess', _48 => _48.account, 'optionalAccess', _49 => _49.address]), () => ( _optionalChain([reownWallet, 'optionalAccess', _50 => _50.address]))), () => ( _optionalChain([dappWalletClient, 'optionalAccess', _51 => _51.account, 'optionalAccess', _52 => _52.address]))), () => ( resolvedOwnerAddress));
1440
- const resolvedDefaultRecipient = _nullishCoalesce(defaultRecipient, () => ( resolvedConnectedAddress));
1441
- const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunkMVFMDKAScjs.getPublicClient.call(void 0, sourceChain)));
1424
+ const resolvedConnectedRecipient = _optionalChain([selectedWalletOption, 'optionalAccess', _46 => _46.kind]) === "external" ? selectedWalletOption.address : void 0;
1425
+ const formPublicClient = _nullishCoalesce(signerContext.publicClient, () => ( _chunk5SR5N75Icjs.getPublicClient.call(void 0, sourceChain)));
1442
1426
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-body", children: [
1443
1427
  step.type === "form" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1444
1428
  WithdrawFormStep,
1445
1429
  {
1446
1430
  walletClient: signerContext.walletClient,
1447
1431
  publicClient: formPublicClient,
1448
- address: resolvedOwnerAddress,
1449
- connectedAddress: resolvedConnectedAddress,
1432
+ connectedRecipient: resolvedConnectedRecipient,
1450
1433
  safeAddress,
1451
1434
  asset,
1452
- defaultRecipient: resolvedDefaultRecipient,
1435
+ defaultRecipient,
1453
1436
  defaultAmount,
1454
1437
  targetChain,
1455
1438
  targetToken,
@@ -1465,7 +1448,7 @@ function WithdrawFlow({
1465
1448
  }
1466
1449
  ),
1467
1450
  step.type === "processing" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1468
- _chunkMVFMDKAScjs.ProcessingStep,
1451
+ _chunk5SR5N75Icjs.ProcessingStep,
1469
1452
  {
1470
1453
  smartAccount: step.smartAccount,
1471
1454
  txHash: step.txHash,
@@ -1491,7 +1474,7 @@ function WithdrawFlow({
1491
1474
  // src/WithdrawModal.tsx
1492
1475
 
1493
1476
  var ReownWithdrawInner = _react.lazy.call(void 0,
1494
- () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-K73XDERE.cjs"))).then((m) => ({
1477
+ () => Promise.resolve().then(() => _interopRequireWildcard(require("./WithdrawModalReown-YBEUOYSV.cjs"))).then((m) => ({
1495
1478
  default: m.WithdrawModalReown
1496
1479
  }))
1497
1480
  );
@@ -1544,26 +1527,26 @@ function WithdrawModalInner({
1544
1527
  debug
1545
1528
  }) {
1546
1529
  const modalRef = _react.useRef.call(void 0, null);
1547
- const onReadyRef = _chunkMVFMDKAScjs.useLatestRef.call(void 0, onReady);
1530
+ const onReadyRef = _chunk5SR5N75Icjs.useLatestRef.call(void 0, onReady);
1548
1531
  const [currentStepIndex, setCurrentStepIndex] = _react.useState.call(void 0, 0);
1549
1532
  const [totalBalanceUsd, setTotalBalanceUsd] = _react.useState.call(void 0, null);
1550
1533
  const backHandlerRef = _react.useRef.call(void 0, void 0);
1551
1534
  const targetChain = _chunkR6U6BHCVcjs.getChainId.call(void 0, targetChainProp);
1552
1535
  const sourceChain = _chunkR6U6BHCVcjs.getChainId.call(void 0, sourceChainProp);
1553
1536
  const service = _react.useMemo.call(void 0,
1554
- () => _chunkMVFMDKAScjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1537
+ () => _chunk5SR5N75Icjs.createDepositService.call(void 0, backendUrl, { debug, debugScope: "service:withdraw" }),
1555
1538
  [backendUrl, debug]
1556
1539
  );
1557
1540
  _react.useEffect.call(void 0, () => {
1558
1541
  if (isOpen && modalRef.current) {
1559
- _chunkMVFMDKAScjs.applyTheme.call(void 0, modalRef.current, theme);
1542
+ _chunk5SR5N75Icjs.applyTheme.call(void 0, modalRef.current, theme);
1560
1543
  }
1561
1544
  }, [isOpen, theme]);
1562
1545
  const hasCalledReady = _react.useRef.call(void 0, false);
1563
1546
  _react.useEffect.call(void 0, () => {
1564
1547
  if (isOpen && !hasCalledReady.current) {
1565
1548
  hasCalledReady.current = true;
1566
- _optionalChain([onReadyRef, 'access', _53 => _53.current, 'optionalCall', _54 => _54()]);
1549
+ _optionalChain([onReadyRef, 'access', _47 => _47.current, 'optionalCall', _48 => _48()]);
1567
1550
  }
1568
1551
  }, [isOpen, onReadyRef]);
1569
1552
  _react.useEffect.call(void 0, () => {
@@ -1582,17 +1565,17 @@ function WithdrawModalInner({
1582
1565
  setTotalBalanceUsd(balance2);
1583
1566
  }, []);
1584
1567
  const handleBack = _react.useCallback.call(void 0, () => {
1585
- _optionalChain([backHandlerRef, 'access', _55 => _55.current, 'optionalCall', _56 => _56()]);
1568
+ _optionalChain([backHandlerRef, 'access', _49 => _49.current, 'optionalCall', _50 => _50()]);
1586
1569
  }, []);
1587
- const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _57 => _57.showLogo]), () => ( false));
1588
- const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _58 => _58.showStepper]), () => ( false));
1589
- const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _59 => _59.showBackButton]), () => ( true));
1590
- const balance = _optionalChain([uiConfig, 'optionalAccess', _60 => _60.balance]);
1591
- const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _61 => _61.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
1592
- const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _62 => _62.title]), () => ( "Withdraw"));
1570
+ const showLogo = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _51 => _51.showLogo]), () => ( false));
1571
+ const showStepper = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _52 => _52.showStepper]), () => ( false));
1572
+ const showBackButton = _nullishCoalesce(_optionalChain([uiConfig, 'optionalAccess', _53 => _53.showBackButton]), () => ( true));
1573
+ const balance = _optionalChain([uiConfig, 'optionalAccess', _54 => _54.balance]);
1574
+ const logoUrl = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _55 => _55.logoUrl]), () => ( "https://github.com/rhinestonewtf.png"));
1575
+ const title = _nullishCoalesce(_optionalChain([branding, 'optionalAccess', _56 => _56.title]), () => ( "Withdraw"));
1593
1576
  const canGoBack = currentStepIndex > 0 && currentStepIndex < 3 && backHandlerRef.current;
1594
1577
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1595
- _chunkMVFMDKAScjs.Modal,
1578
+ _chunk5SR5N75Icjs.Modal,
1596
1579
  {
1597
1580
  isOpen,
1598
1581
  onClose,
@@ -1651,7 +1634,7 @@ function WithdrawModalInner({
1651
1634
  ] }),
1652
1635
  balance && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rs-modal-header-balance", children: [
1653
1636
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-label", children: balance.title }),
1654
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunkMVFMDKAScjs.currencyFormatter.format(totalBalanceUsd) : null))) })
1637
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "rs-modal-header-balance-value", children: _nullishCoalesce(balance.amount, () => ( (totalBalanceUsd !== null ? _chunk5SR5N75Icjs.currencyFormatter.format(totalBalanceUsd) : null))) })
1655
1638
  ] })
1656
1639
  ] }),
1657
1640
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rs-modal-header-nav-right", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1358,6 +1358,10 @@ function getEventTxHash(event) {
1358
1358
  const source = isRecord(event.data?.source) ? event.data.source : void 0;
1359
1359
  return asString(deposit?.transactionHash) ?? asString(source?.transactionHash);
1360
1360
  }
1361
+ if (event.type === "post-bridge-swap-complete" || event.type === "post-bridge-swap-failed") {
1362
+ const deposit = isRecord(event.data?.deposit) ? event.data.deposit : void 0;
1363
+ return asString(deposit?.transactionHash);
1364
+ }
1361
1365
  return void 0;
1362
1366
  }
1363
1367
  function getEventSourceDetails(event) {
@@ -1371,7 +1375,7 @@ function getEventSourceDetails(event) {
1371
1375
  }
1372
1376
  const source = isRecord(event.data.source) ? event.data.source : void 0;
1373
1377
  const deposit = isRecord(event.data.deposit) ? event.data.deposit : void 0;
1374
- 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") {
1375
1379
  return {
1376
1380
  chainId: asNumber(source?.chain) ?? asNumber(deposit?.chain),
1377
1381
  amount: asAmount(source?.amount) ?? asAmount(deposit?.amount),
@@ -1381,7 +1385,7 @@ function getEventSourceDetails(event) {
1381
1385
  return {};
1382
1386
  }
1383
1387
  function isDepositEvent(event) {
1384
- return event?.type === "deposit-received" || event?.type === "bridge-started" || event?.type === "bridge-complete" || event?.type === "bridge-failed" || event?.type === "error";
1388
+ return 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";
1385
1389
  }
1386
1390
  function isHexString(value) {
1387
1391
  return value.startsWith("0x") || value.startsWith("0X");
@@ -1475,9 +1479,9 @@ function parseWebhookTimestamp(event) {
1475
1479
  function syncPhaseTimings(previous, event) {
1476
1480
  if (!event?.type) return previous;
1477
1481
  const timestamp = parseWebhookTimestamp(event) ?? Date.now();
1478
- 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;
1479
- const setBridging = (event.type === "bridge-started" || event.type === "bridge-complete") && previous.bridgingAt === void 0;
1480
- 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;
1481
1485
  if (!setReceived && !setBridging && !setCompleted) return previous;
1482
1486
  return {
1483
1487
  ...previous,
@@ -1514,7 +1518,8 @@ function getCurrentPhaseId(state, phaseTimings, isEarlyComplete) {
1514
1518
  if (state.type === "complete") {
1515
1519
  return void 0;
1516
1520
  }
1517
- if (state.lastEvent?.type === "bridge-started") return "bridging";
1521
+ if (state.lastEvent?.type === "bridge-started" || state.lastEvent?.type === "bridge-complete")
1522
+ return "bridging";
1518
1523
  if (state.lastEvent?.type === "deposit-received") return "received";
1519
1524
  return "confirming";
1520
1525
  }
@@ -1528,6 +1533,7 @@ function ProcessingStep({
1528
1533
  sourceSymbol: providedSourceSymbol,
1529
1534
  sourceDecimals: providedSourceDecimals,
1530
1535
  waitForFinalTx,
1536
+ hasPostBridgeActions,
1531
1537
  service,
1532
1538
  directTransfer,
1533
1539
  flowLabel = "deposit",
@@ -1640,7 +1646,40 @@ function ProcessingStep({
1640
1646
  });
1641
1647
  }
1642
1648
  if (!isMounted) return;
1643
- if (eventForCurrentTx?.type === "bridge-complete") {
1649
+ const awaitingPostBridgeSwap = waitForFinalTx && hasPostBridgeActions;
1650
+ if (eventForCurrentTx?.type === "post-bridge-swap-complete") {
1651
+ setState({ type: "complete", lastEvent: eventForCurrentTx });
1652
+ const swapTxHash = eventForCurrentTx.data?.swap?.transactionHash;
1653
+ debugLog(debug, "processing", "state:complete", {
1654
+ txHash,
1655
+ destinationTxHash: swapTxHash,
1656
+ event: eventForCurrentTx.type
1657
+ });
1658
+ onDepositComplete?.(txHash, swapTxHash, {
1659
+ amount,
1660
+ sourceChain,
1661
+ sourceToken,
1662
+ targetChain,
1663
+ targetToken
1664
+ });
1665
+ return;
1666
+ }
1667
+ if (eventForCurrentTx?.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
+ onDepositFailed?.(txHash, formatted.message);
1680
+ return;
1681
+ }
1682
+ if (eventForCurrentTx?.type === "bridge-complete" && !awaitingPostBridgeSwap) {
1644
1683
  setState({ type: "complete", lastEvent: eventForCurrentTx });
1645
1684
  const destinationTxHash2 = eventForCurrentTx.data?.destination?.transactionHash;
1646
1685
  debugLog(debug, "processing", "state:complete", {
@@ -1739,6 +1778,7 @@ function ProcessingStep({
1739
1778
  amount,
1740
1779
  debug,
1741
1780
  directTransfer,
1781
+ hasPostBridgeActions,
1742
1782
  onDepositComplete,
1743
1783
  onDepositFailed,
1744
1784
  service,
@@ -1775,12 +1815,15 @@ function ProcessingStep({
1775
1815
  const timelineNowMs = phaseTimings.endedAt ?? Date.now();
1776
1816
  const flowNoun = flowLabel === "withdraw" ? "withdrawal" : "deposit";
1777
1817
  const flowCapitalized = flowLabel === "withdraw" ? "Withdrawal" : "Deposit";
1778
- const destinationTxHash = lastEvent?.data?.destination?.transactionHash || null;
1818
+ const isPostBridgeSwapEvent = lastEvent?.type === "post-bridge-swap-complete" || lastEvent?.type === "post-bridge-swap-failed";
1819
+ const destinationTxHash = isPostBridgeSwapEvent ? lastEvent?.data?.swap?.transactionHash || null : lastEvent?.data?.destination?.transactionHash || null;
1820
+ const bridgeTxHash = isPostBridgeSwapEvent ? lastEvent?.data?.bridge?.transactionHash || null : null;
1779
1821
  const sourceDetails = getEventSourceDetails(lastEvent);
1780
1822
  const displaySourceChain = sourceDetails.chainId ?? sourceChain;
1781
1823
  const displaySourceToken = sourceDetails.token ?? sourceToken;
1782
1824
  const displayAmount = sourceDetails.amount ?? amount;
1783
1825
  const sourceExplorerUrl = getExplorerTxUrl(displaySourceChain, txHash);
1826
+ const bridgeExplorerUrl = bridgeTxHash ? getExplorerTxUrl(targetChain, bridgeTxHash) : null;
1784
1827
  const destExplorerUrl = destinationTxHash ? getExplorerTxUrl(targetChain, destinationTxHash) : null;
1785
1828
  const isEvmSourceToken = /^0x[a-fA-F0-9]{40}$/.test(displaySourceToken);
1786
1829
  const sourceSymbol = displaySourceChain === "solana" ? providedSourceSymbol ?? "SOL" : isEvmSourceToken ? getTokenSymbol(displaySourceToken, displaySourceChain) : providedSourceSymbol ?? "Token";
@@ -2011,8 +2054,25 @@ function ProcessingStep({
2011
2054
  }
2012
2055
  ) : /* @__PURE__ */ jsx7("span", { style: { fontFamily: "ui-monospace, SFMono-Regular, monospace", fontSize: 12 }, children: truncateHash(txHash) }) })
2013
2056
  ] }),
2057
+ bridgeTxHash && /* @__PURE__ */ jsxs6("div", { className: "rs-card-row", children: [
2058
+ /* @__PURE__ */ jsx7("span", { className: "rs-card-label", children: "Bridge tx" }),
2059
+ /* @__PURE__ */ jsx7("span", { className: "rs-card-value", children: bridgeExplorerUrl ? /* @__PURE__ */ jsxs6(
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__ */ jsx7("span", { style: { fontFamily: "ui-monospace, SFMono-Regular, monospace", fontSize: 12 }, children: truncateHash(bridgeTxHash) }) })
2073
+ ] }),
2014
2074
  destinationTxHash && /* @__PURE__ */ jsxs6("div", { className: "rs-card-row", children: [
2015
- /* @__PURE__ */ jsx7("span", { className: "rs-card-label", children: "Destination tx" }),
2075
+ /* @__PURE__ */ jsx7("span", { className: "rs-card-label", children: bridgeTxHash ? "Swap tx" : "Destination tx" }),
2016
2076
  /* @__PURE__ */ jsx7("span", { className: "rs-card-value", children: destExplorerUrl ? /* @__PURE__ */ jsxs6(
2017
2077
  "a",
2018
2078
  {
@@ -26,7 +26,7 @@ import {
26
26
  tokenFormatter,
27
27
  txRefsMatch,
28
28
  useLatestRef
29
- } from "./chunk-NDTY5AUU.mjs";
29
+ } from "./chunk-TDTBAZNO.mjs";
30
30
  import {
31
31
  DEFAULT_BACKEND_URL,
32
32
  DEFAULT_SIGNER_ADDRESS,
@@ -3408,6 +3408,7 @@ function DepositFlow({
3408
3408
  sourceSymbol: step.sourceSymbol,
3409
3409
  sourceDecimals: step.sourceDecimals,
3410
3410
  waitForFinalTx,
3411
+ hasPostBridgeActions: Boolean(postBridgeActions?.length),
3411
3412
  service,
3412
3413
  directTransfer: step.directTransfer,
3413
3414
  onClose,
@@ -3531,6 +3532,7 @@ function DepositFlow({
3531
3532
  sourceSymbol: step.sourceSymbol,
3532
3533
  sourceDecimals: step.sourceDecimals,
3533
3534
  waitForFinalTx,
3535
+ hasPostBridgeActions: Boolean(postBridgeActions?.length),
3534
3536
  service,
3535
3537
  directTransfer: step.directTransfer,
3536
3538
  onClose,
@@ -3646,6 +3648,7 @@ function DepositFlow({
3646
3648
  sourceSymbol: step.sourceSymbol,
3647
3649
  sourceDecimals: step.sourceDecimals,
3648
3650
  waitForFinalTx,
3651
+ hasPostBridgeActions: Boolean(postBridgeActions?.length),
3649
3652
  service,
3650
3653
  directTransfer: step.directTransfer,
3651
3654
  onClose,
@@ -3662,7 +3665,7 @@ function DepositFlow({
3662
3665
  // src/DepositModal.tsx
3663
3666
  import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
3664
3667
  var ReownDepositInner = lazy(
3665
- () => import("./DepositModalReown-5CFJIJO5.mjs").then((m) => ({ default: m.DepositModalReown }))
3668
+ () => import("./DepositModalReown-XOLZ62BQ.mjs").then((m) => ({ default: m.DepositModalReown }))
3666
3669
  );
3667
3670
  function DepositModal(props) {
3668
3671
  const needsReown = !!props.reownAppId;
package/dist/deposit.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk6UBIFHRVcjs = require('./chunk-6UBIFHRV.cjs');
4
- require('./chunk-MVFMDKAS.cjs');
3
+ var _chunkN3BZTUSJcjs = require('./chunk-N3BZTUSJ.cjs');
4
+ require('./chunk-5SR5N75I.cjs');
5
5
  require('./chunk-R6U6BHCV.cjs');
6
6
 
7
7
 
8
- exports.DepositModal = _chunk6UBIFHRVcjs.DepositModal;
8
+ exports.DepositModal = _chunkN3BZTUSJcjs.DepositModal;
package/dist/deposit.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DepositModal
3
- } from "./chunk-QME5ZAI6.mjs";
4
- import "./chunk-NDTY5AUU.mjs";
3
+ } from "./chunk-XVCPUB6K.mjs";
4
+ import "./chunk-TDTBAZNO.mjs";
5
5
  import "./chunk-CIXHTOO3.mjs";
6
6
  export {
7
7
  DepositModal