@rhinestone/deposit-modal 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{DepositModalReown-J3KYAOD3.cjs → DepositModalReown-CHVDFNEX.cjs} +9 -9
  2. package/dist/{DepositModalReown-YD7TLEAA.mjs → DepositModalReown-T4RRW5FM.mjs} +6 -6
  3. package/dist/{WithdrawModalReown-ZPDMX47Z.mjs → WithdrawModalReown-Q6MUMZTX.mjs} +5 -5
  4. package/dist/{WithdrawModalReown-QSQUV6HX.cjs → WithdrawModalReown-YZMZTN6E.cjs} +8 -8
  5. package/dist/{chunk-FJWLC4AM.mjs → chunk-4JLYWRQA.mjs} +1 -1
  6. package/dist/{chunk-YYIE5U5K.cjs → chunk-6P3WNDED.cjs} +10 -8
  7. package/dist/{chunk-3JVGI7FC.mjs → chunk-CLUR2J72.mjs} +4 -4
  8. package/dist/{chunk-WJX3TJFK.mjs → chunk-CPMHRMPH.mjs} +36 -7
  9. package/dist/{chunk-ABVRVW3P.cjs → chunk-HH46H6ZI.cjs} +37 -8
  10. package/dist/{chunk-DXGM6YET.mjs → chunk-J52W34Y7.mjs} +6 -4
  11. package/dist/{chunk-F7P4MV72.mjs → chunk-K6J3RDDK.mjs} +1 -1
  12. package/dist/{chunk-DASS33PJ.cjs → chunk-KUURQOTT.cjs} +100 -100
  13. package/dist/{chunk-GQDVHMOT.mjs → chunk-OYPFPEIT.mjs} +333 -54
  14. package/dist/{chunk-7LVI3VAL.cjs → chunk-QSMPJQTX.cjs} +698 -529
  15. package/dist/{chunk-UEKPBRBY.cjs → chunk-RLMXWLF4.cjs} +3 -3
  16. package/dist/{chunk-ZDYV536Q.cjs → chunk-UN6MEOOA.cjs} +382 -103
  17. package/dist/{chunk-NSAODZSS.mjs → chunk-UZENNYHS.mjs} +242 -73
  18. package/dist/{chunk-NRNJAQUA.cjs → chunk-XOBLFIGV.cjs} +4 -4
  19. package/dist/constants.cjs +2 -2
  20. package/dist/constants.mjs +1 -1
  21. package/dist/deposit.cjs +6 -6
  22. package/dist/deposit.mjs +5 -5
  23. package/dist/index.cjs +7 -7
  24. package/dist/index.mjs +6 -6
  25. package/dist/polymarket.cjs +6 -6
  26. package/dist/polymarket.mjs +3 -3
  27. package/dist/styles.css +103 -31
  28. package/dist/withdraw.cjs +5 -5
  29. package/dist/withdraw.mjs +4 -4
  30. package/package.json +1 -1
@@ -13,7 +13,7 @@ import {
13
13
  getTokenSymbol,
14
14
  isSolanaCaip2,
15
15
  parseEvmChainId
16
- } from "./chunk-WJX3TJFK.mjs";
16
+ } from "./chunk-CPMHRMPH.mjs";
17
17
 
18
18
  // src/components/ui/Modal.tsx
19
19
  import {
@@ -538,6 +538,7 @@ function createDepositService(baseUrl, options) {
538
538
  }
539
539
  const PORTFOLIO_CACHE_TTL_MS = 3e4;
540
540
  const portfolioCache = /* @__PURE__ */ new Map();
541
+ let topTokensPromise = null;
541
542
  function cachedPortfolio(key, fetcher, forceRefresh = false) {
542
543
  const now = Date.now();
543
544
  const entry = portfolioCache.get(key);
@@ -642,7 +643,7 @@ function createDepositService(baseUrl, options) {
642
643
  },
643
644
  async fetchPortfolio(address, options2) {
644
645
  return cachedPortfolio(`evm:${address.toLowerCase()}`, async () => {
645
- const url = apiUrl(`/portfolio/${address}`);
646
+ const url = apiUrl(`/portfolio/${address}?includeUnsupported=true`);
646
647
  debugLog(debug, scope, "fetchPortfolio:request", { url, address });
647
648
  const response = await fetch(url, {
648
649
  method: "GET",
@@ -1178,6 +1179,60 @@ function createDepositService(baseUrl, options) {
1178
1179
  stale: body.stale === true ? true : void 0
1179
1180
  };
1180
1181
  },
1182
+ getTopTokens() {
1183
+ if (!topTokensPromise) {
1184
+ topTokensPromise = (async () => {
1185
+ try {
1186
+ const response = await fetch(apiUrl("/tokens"), {
1187
+ method: "GET",
1188
+ headers: { "Content-Type": "application/json" }
1189
+ });
1190
+ if (!response.ok) {
1191
+ debugLog(debug, scope, "getTopTokens:unavailable", {
1192
+ status: response.status
1193
+ });
1194
+ return null;
1195
+ }
1196
+ const data = await response.json();
1197
+ const tokens = data.tokens ?? null;
1198
+ debugLog(debug, scope, "getTopTokens:success", {
1199
+ chains: tokens ? Object.keys(tokens).length : 0
1200
+ });
1201
+ return tokens;
1202
+ } catch (error) {
1203
+ debugError(debug, scope, "getTopTokens:error", error);
1204
+ return null;
1205
+ }
1206
+ })();
1207
+ }
1208
+ return topTokensPromise;
1209
+ },
1210
+ async getSetup() {
1211
+ const url = apiUrl("/setup");
1212
+ try {
1213
+ const response = await fetch(url, {
1214
+ method: "GET",
1215
+ headers: { "Content-Type": "application/json" },
1216
+ cache: "no-store"
1217
+ });
1218
+ if (!response.ok) {
1219
+ debugLog(debug, scope, "getSetup:unavailable", {
1220
+ status: response.status
1221
+ });
1222
+ return null;
1223
+ }
1224
+ const data = await response.json();
1225
+ debugLog(debug, scope, "getSetup:success", {
1226
+ hasWhitelist: Boolean(data.depositWhitelist),
1227
+ whitelistChains: data.depositWhitelist ? Object.keys(data.depositWhitelist).length : 0,
1228
+ minDepositUsd: data.minDepositUsd
1229
+ });
1230
+ return data;
1231
+ } catch (error) {
1232
+ debugError(debug, scope, "getSetup:error", error);
1233
+ return null;
1234
+ }
1235
+ },
1181
1236
  async fetchSwappedOrderStatus(smartAccount) {
1182
1237
  const url = apiUrl(
1183
1238
  `/onramp/swapped/status/${encodeURIComponent(smartAccount)}`
@@ -1198,7 +1253,16 @@ function createDepositService(baseUrl, options) {
1198
1253
  const status = typeof body.status === "string" ? body.status : null;
1199
1254
  const orderId = typeof body.orderId === "string" ? body.orderId : null;
1200
1255
  if (!status || !orderId) return null;
1201
- const numericOrNull = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
1256
+ const numericOrNull = (v) => {
1257
+ if (typeof v === "number") {
1258
+ return Number.isFinite(v) ? v : null;
1259
+ }
1260
+ if (typeof v === "string" && v.trim().length > 0) {
1261
+ const parsed = Number(v);
1262
+ return Number.isFinite(parsed) ? parsed : null;
1263
+ }
1264
+ return null;
1265
+ };
1202
1266
  return {
1203
1267
  orderId,
1204
1268
  status,
@@ -2231,7 +2295,7 @@ function VisaMark() {
2231
2295
  xmlns: "http://www.w3.org/2000/svg",
2232
2296
  "aria-hidden": "true",
2233
2297
  children: [
2234
- /* @__PURE__ */ jsx17("rect", { width: "37.2537", height: "24", rx: "4.2985", fill: "white" }),
2298
+ /* @__PURE__ */ jsx17("rect", { width: "38", height: "24", rx: "4.2985", fill: "white" }),
2235
2299
  /* @__PURE__ */ jsx17(
2236
2300
  "path",
2237
2301
  {
@@ -2254,7 +2318,7 @@ function MastercardMark() {
2254
2318
  xmlns: "http://www.w3.org/2000/svg",
2255
2319
  "aria-hidden": "true",
2256
2320
  children: [
2257
- /* @__PURE__ */ jsx17("rect", { width: "37.2537", height: "24", rx: "4.2985", fill: "white" }),
2321
+ /* @__PURE__ */ jsx17("rect", { width: "38", height: "24", rx: "4.2985", fill: "white" }),
2258
2322
  /* @__PURE__ */ jsx17(
2259
2323
  "path",
2260
2324
  {
@@ -2298,7 +2362,7 @@ function AmexMark() {
2298
2362
  xmlns: "http://www.w3.org/2000/svg",
2299
2363
  "aria-hidden": "true",
2300
2364
  children: [
2301
- /* @__PURE__ */ jsx17("rect", { width: "37.2537", height: "24", rx: "4.2985", fill: "#006FCF" }),
2365
+ /* @__PURE__ */ jsx17("rect", { width: "38", height: "24", rx: "4.2985", fill: "#006FCF" }),
2302
2366
  /* @__PURE__ */ jsx17(
2303
2367
  "path",
2304
2368
  {
@@ -2346,12 +2410,12 @@ function rankCryptoRows(descriptors) {
2346
2410
  return descriptors.map((descriptor, index) => ({ descriptor, index })).sort((a, b) => {
2347
2411
  const first = a.descriptor;
2348
2412
  const second = b.descriptor;
2349
- if (first.isBalanceSource !== second.isBalanceSource) {
2350
- return first.isBalanceSource ? -1 : 1;
2351
- }
2352
- if (!first.isBalanceSource) return a.index - b.index;
2353
- if (first.resolved !== second.resolved) return first.resolved ? -1 : 1;
2354
- if (first.resolved && first.balanceUsd !== second.balanceUsd) {
2413
+ const firstHasFunds = first.isBalanceSource && first.resolved && first.balanceUsd > 0;
2414
+ const secondHasFunds = second.isBalanceSource && second.resolved && second.balanceUsd > 0;
2415
+ const firstTier = firstHasFunds ? 0 : first.isBalanceSource ? 2 : 1;
2416
+ const secondTier = secondHasFunds ? 0 : second.isBalanceSource ? 2 : 1;
2417
+ if (firstTier !== secondTier) return firstTier - secondTier;
2418
+ if (firstTier === 0 && first.balanceUsd !== second.balanceUsd) {
2355
2419
  return second.balanceUsd - first.balanceUsd;
2356
2420
  }
2357
2421
  return a.index - b.index;
@@ -2826,21 +2890,25 @@ Tooltip.displayName = "Tooltip";
2826
2890
  // src/components/ui/FeesAccordion.tsx
2827
2891
  import { useState as useState3 } from "react";
2828
2892
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
2829
- function FeesAccordion({ total, rows }) {
2893
+ function FeesAccordion({ total, rows, tooltip }) {
2830
2894
  const [open, setOpen] = useState3(false);
2831
2895
  const expandable = rows.length > 0;
2832
2896
  return /* @__PURE__ */ jsxs19("div", { className: "rs-fees-accordion", children: [
2833
- /* @__PURE__ */ jsxs19(
2834
- "button",
2835
- {
2836
- type: "button",
2837
- className: "rs-fees-accordion-summary",
2838
- "aria-expanded": expandable ? open : void 0,
2839
- disabled: !expandable,
2840
- onClick: () => expandable && setOpen((o) => !o),
2841
- children: [
2842
- /* @__PURE__ */ jsx21("span", { children: "Fees" }),
2843
- /* @__PURE__ */ jsxs19("span", { className: "rs-review-detail-value", children: [
2897
+ /* @__PURE__ */ jsxs19("div", { className: "rs-fees-accordion-summary", children: [
2898
+ /* @__PURE__ */ jsxs19("span", { className: "rs-fees-accordion-label", children: [
2899
+ /* @__PURE__ */ jsx21("span", { children: "Fees" }),
2900
+ tooltip && /* @__PURE__ */ jsx21(Tooltip, { content: tooltip, children: /* @__PURE__ */ jsx21("span", { className: "rs-review-detail-info", "aria-label": "Fees info", children: /* @__PURE__ */ jsx21(InfoIcon, {}) }) })
2901
+ ] }),
2902
+ /* @__PURE__ */ jsxs19(
2903
+ "button",
2904
+ {
2905
+ type: "button",
2906
+ className: "rs-fees-accordion-toggle",
2907
+ "aria-label": "Fees",
2908
+ "aria-expanded": expandable ? open : void 0,
2909
+ disabled: !expandable,
2910
+ onClick: () => expandable && setOpen((o) => !o),
2911
+ children: [
2844
2912
  /* @__PURE__ */ jsx21("span", { children: total }),
2845
2913
  expandable && /* @__PURE__ */ jsx21(
2846
2914
  "span",
@@ -2850,13 +2918,29 @@ function FeesAccordion({ total, rows }) {
2850
2918
  children: /* @__PURE__ */ jsx21(ChevronDownIcon, {})
2851
2919
  }
2852
2920
  )
2853
- ] })
2854
- ]
2855
- }
2856
- ),
2921
+ ]
2922
+ }
2923
+ )
2924
+ ] }),
2857
2925
  expandable && open && /* @__PURE__ */ jsx21("div", { className: "rs-fees-accordion-rows", children: rows.map((row, i) => /* @__PURE__ */ jsxs19("div", { className: "rs-fees-accordion-row", children: [
2858
2926
  /* @__PURE__ */ jsx21("span", { children: row.label }),
2859
- /* @__PURE__ */ jsx21("span", { className: "rs-review-detail-value", children: row.value })
2927
+ /* @__PURE__ */ jsxs19("span", { className: "rs-review-detail-value", children: [
2928
+ /* @__PURE__ */ jsx21(
2929
+ "span",
2930
+ {
2931
+ className: row.strike ? "rs-review-detail-value--strike" : void 0,
2932
+ children: row.value
2933
+ }
2934
+ ),
2935
+ row.tooltip && /* @__PURE__ */ jsx21(Tooltip, { content: row.tooltip, children: /* @__PURE__ */ jsx21(
2936
+ "span",
2937
+ {
2938
+ className: "rs-review-detail-info",
2939
+ "aria-label": `${row.label} info`,
2940
+ children: /* @__PURE__ */ jsx21(InfoIcon, {})
2941
+ }
2942
+ ) })
2943
+ ] })
2860
2944
  ] }, `${row.label}-${i}`)) })
2861
2945
  ] });
2862
2946
  }
@@ -2872,6 +2956,7 @@ function SwappedReceipt({
2872
2956
  depositedIcon,
2873
2957
  feesTotal,
2874
2958
  feeRows,
2959
+ feesTooltip,
2875
2960
  newLabel,
2876
2961
  onNewDeposit,
2877
2962
  onClose
@@ -2892,13 +2977,20 @@ function SwappedReceipt({
2892
2977
  /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-value", children: amountPaid })
2893
2978
  ] }),
2894
2979
  /* @__PURE__ */ jsxs20("div", { className: "rs-review-detail-row", children: [
2895
- /* @__PURE__ */ jsx22("span", { children: "Receive" }),
2980
+ /* @__PURE__ */ jsx22("span", { children: "Deposited amount" }),
2896
2981
  /* @__PURE__ */ jsxs20("span", { className: "rs-review-detail-value", children: [
2897
2982
  /* @__PURE__ */ jsx22("span", { children: depositedAmount }),
2898
2983
  depositedIcon && /* @__PURE__ */ jsx22("span", { className: "rs-review-detail-icon", children: /* @__PURE__ */ jsx22("img", { src: depositedIcon, alt: "" }) })
2899
2984
  ] })
2900
2985
  ] }),
2901
- feesTotal != null && /* @__PURE__ */ jsx22(FeesAccordion, { total: feesTotal, rows: feeRows ?? [] })
2986
+ feesTotal != null && /* @__PURE__ */ jsx22(
2987
+ FeesAccordion,
2988
+ {
2989
+ total: feesTotal,
2990
+ rows: feeRows ?? [],
2991
+ tooltip: feesTooltip ?? void 0
2992
+ }
2993
+ )
2902
2994
  ] }),
2903
2995
  /* @__PURE__ */ jsxs20("div", { className: "rs-screen-button-row", children: [
2904
2996
  onNewDeposit && /* @__PURE__ */ jsx22(Button, { variant: "outline", onClick: onNewDeposit, fullWidth: true, children: newLabel }),
@@ -3252,6 +3344,8 @@ function FailedBadge() {
3252
3344
  var INITIAL_POLL_INTERVAL = 3e3;
3253
3345
  var MAX_POLL_INTERVAL = 3e4;
3254
3346
  var BACKOFF_MULTIPLIER = 1.5;
3347
+ var SWAPPED_RECEIPT_STATUS_RETRY_INTERVAL_MS = 1e3;
3348
+ var SWAPPED_FIAT_STATUS_MAX_ATTEMPTS = 12;
3255
3349
  var ESCALATED_DELAY_MS = 10 * 60 * 1e3;
3256
3350
  var SOFT_DELAY_MS = {
3257
3351
  confirming: 90 * 1e3,
@@ -3282,6 +3376,36 @@ function formatPaymentMethod(method) {
3282
3376
  if (PAYMENT_METHOD_LABELS[key]) return PAYMENT_METHOD_LABELS[key];
3283
3377
  return key.replace(/[-_]+/g, " ").split(" ").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
3284
3378
  }
3379
+ function normalizeFeeUsd(value) {
3380
+ return Number.isFinite(value) ? Math.max(0, value) : null;
3381
+ }
3382
+ function formatUsdFee(value) {
3383
+ return `$${normalizeFeeUsd(value)?.toFixed(2) ?? "0.00"}`;
3384
+ }
3385
+ function getMarketNetworkFees(breakdown) {
3386
+ if (!breakdown) return null;
3387
+ const gasUsd = normalizeFeeUsd(breakdown.gasUsd);
3388
+ const bridgeUsd = normalizeFeeUsd(breakdown.bridgeUsd);
3389
+ const swapUsd = normalizeFeeUsd(breakdown.swapUsd);
3390
+ if (gasUsd === null || bridgeUsd === null || swapUsd === null) return null;
3391
+ return {
3392
+ marketUsd: bridgeUsd + swapUsd,
3393
+ networkUsd: gasUsd
3394
+ };
3395
+ }
3396
+ function toSwappedFiatContext(status) {
3397
+ return {
3398
+ orderCrypto: status.orderCrypto,
3399
+ orderCryptoAmount: status.orderCryptoAmount,
3400
+ paidAmountUsd: status.paidAmountUsd,
3401
+ paidAmountEur: status.paidAmountEur,
3402
+ onrampFeeUsd: status.onrampFeeUsd,
3403
+ paymentMethod: status.paymentMethod
3404
+ };
3405
+ }
3406
+ function hasFiatReceiptPricing(status) {
3407
+ return status.paidAmountUsd != null && status.onrampFeeUsd != null;
3408
+ }
3285
3409
  function loadPhaseTimings(txHash) {
3286
3410
  if (typeof window === "undefined") return null;
3287
3411
  try {
@@ -3382,6 +3506,59 @@ function getCurrentPhaseId(state, phaseTimings) {
3382
3506
  if (state.lastEvent?.type === "deposit-received") return "received";
3383
3507
  return "confirming";
3384
3508
  }
3509
+ function getCompletionDestinationTxHash(event) {
3510
+ const eventData = event?.data;
3511
+ const swapTxHash = eventData?.swap?.transactionHash;
3512
+ const destinationTxHash = eventData?.destination?.transactionHash;
3513
+ return swapTxHash ?? destinationTxHash;
3514
+ }
3515
+ function getTerminalProcessingOutcome(event) {
3516
+ if (event?.type === "post-bridge-swap-complete") {
3517
+ return {
3518
+ type: "complete",
3519
+ destinationTxHash: getCompletionDestinationTxHash(event)
3520
+ };
3521
+ }
3522
+ if (event?.type === "post-bridge-swap-failed") {
3523
+ return {
3524
+ type: "failed",
3525
+ message: formatBridgeFailedMessage(event).message
3526
+ };
3527
+ }
3528
+ if (event?.type === "bridge-complete") {
3529
+ return {
3530
+ type: "complete",
3531
+ destinationTxHash: getCompletionDestinationTxHash(event)
3532
+ };
3533
+ }
3534
+ if (event?.type === "bridge-failed") {
3535
+ return {
3536
+ type: "failed",
3537
+ message: formatBridgeFailedMessage(event).message
3538
+ };
3539
+ }
3540
+ if (event?.type === "error") {
3541
+ return {
3542
+ type: "failed",
3543
+ message: event.data?.message ?? "Unknown error"
3544
+ };
3545
+ }
3546
+ return null;
3547
+ }
3548
+ function getInitialProcessingState(event, txHash) {
3549
+ if (!event || !isEventForTx(event, txHash)) return null;
3550
+ const terminal = getTerminalProcessingOutcome(event);
3551
+ if (terminal?.type === "complete") {
3552
+ return { type: "complete", lastEvent: event };
3553
+ }
3554
+ if (terminal?.type === "failed") {
3555
+ return { type: "failed", message: terminal.message, lastEvent: event };
3556
+ }
3557
+ if (isDepositEvent(event)) {
3558
+ return { type: "processing", lastEvent: event };
3559
+ }
3560
+ return null;
3561
+ }
3385
3562
  function ProcessingStep({
3386
3563
  smartAccount,
3387
3564
  solanaDepositAddress,
@@ -3395,12 +3572,14 @@ function ProcessingStep({
3395
3572
  amountUsd,
3396
3573
  service,
3397
3574
  directTransfer,
3575
+ initialEvent,
3398
3576
  flowLabel = "deposit",
3399
3577
  debug,
3400
3578
  targetToken,
3401
3579
  uiConfig,
3402
3580
  quotedFeeAmount,
3403
3581
  quotedFeeSymbol,
3582
+ quoteFeeBreakdown,
3404
3583
  balanceAfterUsd,
3405
3584
  isSwappedOrder,
3406
3585
  swappedContext,
@@ -3427,9 +3606,21 @@ function ProcessingStep({
3427
3606
  const onDepositCompleteRef = useLatestRef(onDepositComplete);
3428
3607
  const onDepositFailedRef = useLatestRef(onDepositFailed);
3429
3608
  const onErrorRef = useLatestRef(onError);
3430
- const [state, setState] = useState5(
3431
- directTransfer ? { type: "complete" } : { type: "processing" }
3432
- );
3609
+ const initialTerminalEventRef = useRef4(null);
3610
+ const [state, setState] = useState5(() => {
3611
+ if (directTransfer) return { type: "complete" };
3612
+ const initial = getInitialProcessingState(
3613
+ initialEvent,
3614
+ txHash
3615
+ );
3616
+ if (initial) {
3617
+ if (initial.type !== "processing") {
3618
+ initialTerminalEventRef.current = initial.lastEvent ?? null;
3619
+ }
3620
+ return initial;
3621
+ }
3622
+ return { type: "processing" };
3623
+ });
3433
3624
  const [elapsedSeconds, setElapsedSeconds] = useState5(0);
3434
3625
  const [phaseTimings, setPhaseTimings] = useState5(() => {
3435
3626
  const saved = loadPhaseTimings(txHash);
@@ -3481,6 +3672,43 @@ function ProcessingStep({
3481
3672
  txHash,
3482
3673
  updatePhaseTimings
3483
3674
  ]);
3675
+ useEffect6(() => {
3676
+ const event = initialTerminalEventRef.current;
3677
+ if (!event) return;
3678
+ initialTerminalEventRef.current = null;
3679
+ const outcome = getTerminalProcessingOutcome(event);
3680
+ if (!outcome) return;
3681
+ if (outcome.type === "complete") {
3682
+ const context = processingContextRef.current;
3683
+ debugLog(debug, "processing", "initial-event:complete", {
3684
+ txHash,
3685
+ destinationTxHash: outcome.destinationTxHash,
3686
+ event: event.type
3687
+ });
3688
+ onDepositCompleteRef.current?.(txHash, outcome.destinationTxHash, {
3689
+ amount: context.amount,
3690
+ sourceChain: context.sourceChain,
3691
+ sourceToken: context.sourceToken,
3692
+ sourceDecimals: context.sourceDecimals,
3693
+ amountUsd: context.amountUsd,
3694
+ targetChain: context.targetChain,
3695
+ targetToken: context.targetToken
3696
+ });
3697
+ return;
3698
+ }
3699
+ debugLog(debug, "processing", "initial-event:failed", {
3700
+ txHash,
3701
+ message: outcome.message,
3702
+ event: event.type
3703
+ });
3704
+ onDepositFailedRef.current?.(txHash, outcome.message);
3705
+ }, [
3706
+ debug,
3707
+ onDepositCompleteRef,
3708
+ onDepositFailedRef,
3709
+ processingContextRef,
3710
+ txHash
3711
+ ]);
3484
3712
  useEffect6(() => {
3485
3713
  if (directTransfer || state.type !== "processing") return;
3486
3714
  const updateElapsed = () => {
@@ -3509,27 +3737,61 @@ function ProcessingStep({
3509
3737
  const [swappedFiatContext, setSwappedFiatContext] = useState5(null);
3510
3738
  useEffect6(() => {
3511
3739
  let cancelled = false;
3512
- service.fetchSwappedOrderStatus(smartAccount).then((res) => {
3513
- if (cancelled || !res) return;
3514
- if (res.transactionId != null) {
3515
- if (res.transactionId.toLowerCase() !== txHash.toLowerCase()) return;
3516
- } else if (!isSwappedOrder || swappedContext?.variant === "connect") {
3740
+ let timeoutId;
3741
+ const isFiatSwappedOrder = isSwappedOrder && swappedContext?.variant === "fiat";
3742
+ const expectedOrderUuid = swappedContext?.expectedOrderUuid ?? null;
3743
+ setSwappedFiatContext(null);
3744
+ if (isFiatSwappedOrder && !expectedOrderUuid) {
3745
+ return () => {
3746
+ cancelled = true;
3747
+ };
3748
+ }
3749
+ let attempts = 0;
3750
+ const matchesCurrentDeposit = (res) => {
3751
+ if (isFiatSwappedOrder) {
3752
+ return res.orderId === expectedOrderUuid;
3753
+ }
3754
+ return res.transactionId != null && res.transactionId.toLowerCase() === txHash.toLowerCase();
3755
+ };
3756
+ const scheduleRetry = () => {
3757
+ if (cancelled || !isFiatSwappedOrder || attempts >= SWAPPED_FIAT_STATUS_MAX_ATTEMPTS) {
3517
3758
  return;
3518
3759
  }
3519
- setSwappedFiatContext({
3520
- orderCrypto: res.orderCrypto,
3521
- orderCryptoAmount: res.orderCryptoAmount,
3522
- paidAmountUsd: res.paidAmountUsd,
3523
- paidAmountEur: res.paidAmountEur,
3524
- onrampFeeUsd: res.onrampFeeUsd,
3525
- paymentMethod: res.paymentMethod
3526
- });
3527
- }).catch(() => {
3528
- });
3760
+ timeoutId = setTimeout(
3761
+ fetchContext,
3762
+ SWAPPED_RECEIPT_STATUS_RETRY_INTERVAL_MS
3763
+ );
3764
+ };
3765
+ async function fetchContext() {
3766
+ attempts += 1;
3767
+ try {
3768
+ const res = await service.fetchSwappedOrderStatus(smartAccount);
3769
+ if (cancelled) return;
3770
+ if (!res || !matchesCurrentDeposit(res)) {
3771
+ scheduleRetry();
3772
+ return;
3773
+ }
3774
+ setSwappedFiatContext(toSwappedFiatContext(res));
3775
+ if (isFiatSwappedOrder && !hasFiatReceiptPricing(res)) {
3776
+ scheduleRetry();
3777
+ }
3778
+ } catch {
3779
+ scheduleRetry();
3780
+ }
3781
+ }
3782
+ fetchContext();
3529
3783
  return () => {
3530
3784
  cancelled = true;
3785
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
3531
3786
  };
3532
- }, [service, smartAccount, txHash, isSwappedOrder, swappedContext?.variant]);
3787
+ }, [
3788
+ service,
3789
+ smartAccount,
3790
+ txHash,
3791
+ isSwappedOrder,
3792
+ swappedContext?.variant,
3793
+ swappedContext?.expectedOrderUuid
3794
+ ]);
3533
3795
  useEffect6(() => {
3534
3796
  if (directTransfer) return;
3535
3797
  if (state.type !== "processing") {
@@ -3777,21 +4039,37 @@ function ProcessingStep({
3777
4039
  const amountPaid = connectPaidAmount ?? (swappedFiatContext?.paidAmountUsd != null ? `$${swappedFiatContext.paidAmountUsd.toFixed(2)}` : null);
3778
4040
  const depositedAmount = receiveDisplay;
3779
4041
  const onrampFeeUsd = swappedFiatContext?.onrampFeeUsd ?? null;
3780
- const networkFeeUsd = quotedFeeAmount !== void 0 && Number.isFinite(Number(quotedFeeAmount)) ? Number(quotedFeeAmount) : null;
4042
+ const quoteFees = getMarketNetworkFees(quoteFeeBreakdown);
4043
+ const fallbackNetworkFeeUsd = quoteFees === null && quotedFeeAmount !== void 0 && Number.isFinite(Number(quotedFeeAmount)) ? Number(quotedFeeAmount) : null;
4044
+ const marketFeeUsd = quoteFees?.marketUsd ?? null;
4045
+ const networkFeeUsd = quoteFees?.networkUsd ?? fallbackNetworkFeeUsd;
4046
+ const sponsoredFeeTooltip = "This fee is sponsored for this deposit.";
4047
+ const feesTooltip = feeSponsored ? "On-ramp fees are charged by the payment provider. Market and network fees are sponsored for this deposit." : "Fees include on-ramp, market, and network costs for this deposit.";
3781
4048
  const feeRows = [];
3782
4049
  if (onrampFeeUsd != null) {
3783
4050
  feeRows.push({
3784
4051
  label: "On-ramp fee",
3785
- value: `$${onrampFeeUsd.toFixed(2)}`
4052
+ value: formatUsdFee(onrampFeeUsd)
4053
+ });
4054
+ }
4055
+ if (marketFeeUsd != null) {
4056
+ feeRows.push({
4057
+ label: "Market fee",
4058
+ value: formatUsdFee(marketFeeUsd),
4059
+ strike: feeSponsored,
4060
+ tooltip: feeSponsored ? sponsoredFeeTooltip : void 0
3786
4061
  });
3787
4062
  }
3788
4063
  if (networkFeeUsd != null) {
3789
4064
  feeRows.push({
3790
4065
  label: "Network fee",
3791
- value: `$${networkFeeUsd.toFixed(2)}`
4066
+ value: formatUsdFee(networkFeeUsd),
4067
+ strike: feeSponsored,
4068
+ tooltip: feeSponsored ? sponsoredFeeTooltip : void 0
3792
4069
  });
3793
4070
  }
3794
- const feesTotal = feeRows.length > 0 ? `$${((onrampFeeUsd ?? 0) + (networkFeeUsd ?? 0)).toFixed(2)}` : null;
4071
+ const chargeableQuoteFeeUsd = feeSponsored ? 0 : (marketFeeUsd ?? 0) + (networkFeeUsd ?? 0);
4072
+ const feesTotal = feeRows.length > 0 ? formatUsdFee((onrampFeeUsd ?? 0) + chargeableQuoteFeeUsd) : null;
3795
4073
  return /* @__PURE__ */ jsx23(
3796
4074
  SwappedReceipt,
3797
4075
  {
@@ -3802,6 +4080,7 @@ function ProcessingStep({
3802
4080
  depositedIcon: targetTokenIcon,
3803
4081
  feesTotal,
3804
4082
  feeRows,
4083
+ feesTooltip,
3805
4084
  newLabel: `New ${flowNoun}`,
3806
4085
  onNewDeposit,
3807
4086
  onClose