@glacislabs/stablegenie-zerodelta 4.0.0 → 4.1.1

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.
package/dist/index.cjs CHANGED
@@ -547,10 +547,10 @@ function brokenLaneFor(token, source, brokenLanes) {
547
547
  }
548
548
  function destinationAvailability(token, ctx, source) {
549
549
  if (brokenLaneFor(token, source ?? void 0, ctx.brokenLanes)) return "unreachable";
550
- if (ctx.execution.has(Number(token.chainId))) return "available";
551
- if (token.isChainedDestination === true) return "available";
552
- if (!isKnownUnbridgeable(token.bridge) && ctx.destination.has(tokenKey(token.chainId, token.address)) && directLaneOK(token, source ?? void 0, ctx.lanes)) {
553
- return "available";
550
+ if (directLaneOK(token, source ?? void 0, ctx.lanes)) {
551
+ if (ctx.execution.has(Number(token.chainId))) return "available";
552
+ if (token.isChainedDestination === true) return "available";
553
+ if (!isKnownUnbridgeable(token.bridge) && ctx.destination.has(tokenKey(token.chainId, token.address))) return "available";
554
554
  }
555
555
  return ctx.hubSymbols.has(symbolKey(token.symbol)) ? "hub-only" : "unreachable";
556
556
  }
@@ -600,7 +600,7 @@ function buildCatalogue(input) {
600
600
  );
601
601
  const byId = new Map(enabledChains.map((c) => [Number(c.chainId), c]));
602
602
  for (const id of chainIds) if (!byId.has(id)) byId.set(id, { chainId: id, isEnabled: true });
603
- return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready };
603
+ return { ...ctx, product, tokens: catalogue, sources, chainIds, chains: [...byId.values()], ready, vaultIcons: input.vaultIcons ?? /* @__PURE__ */ new Map() };
604
604
  }
605
605
 
606
606
  // src/core/options.ts
@@ -725,10 +725,10 @@ function nativeFeeShortLabel(check, symbol) {
725
725
  if (!check.short) return null;
726
726
  return `Need ${formatNative(check.required)} ${symbol} for the bridge fee`;
727
727
  }
728
- function nativeFeeShortMessage(check, symbol, chainName2) {
728
+ function nativeFeeShortMessage(check, symbol, chainName3) {
729
729
  const need = formatNative(check.required);
730
730
  const have = formatNative(check.balance ?? 0n);
731
- const where = chainName2 ? ` on ${chainName2}` : "";
731
+ const where = chainName3 ? ` on ${chainName3}` : "";
732
732
  return `This route bridges via LayerZero, which charges a ${need} ${symbol} network fee paid as part of the transaction. Your wallet holds ${have} ${symbol}${where}. Add ${symbol}${where} and try again \u2014 gas is owed on top of this fee.`;
733
733
  }
734
734
 
@@ -738,7 +738,8 @@ function suppressedLanes(health) {
738
738
  if (health?.mode !== "enforce" || !Array.isArray(health.lanes)) return EMPTY;
739
739
  const out = /* @__PURE__ */ new Map();
740
740
  for (const lane of health.lanes) {
741
- if (lane?.status !== "broken") continue;
741
+ const firewalled = lane?.status === "unknown" && lane?.kind === "firewalled";
742
+ if (lane?.status !== "broken" && !firewalled) continue;
742
743
  const key = typeof lane.laneKey === "string" ? lane.laneKey.toLowerCase() : "";
743
744
  if (!key) continue;
744
745
  out.set(key, {
@@ -755,6 +756,8 @@ function brokenLaneReason(lane) {
755
756
  switch (lane.kind) {
756
757
  case "bridge-throttled":
757
758
  return "The issuer's bridge for this pair is closed right now.";
759
+ case "firewalled":
760
+ return "This pair is temporarily unavailable.";
758
761
  case "vault-closed":
759
762
  return "This vault is not accepting deposits right now.";
760
763
  default:
@@ -762,6 +765,34 @@ function brokenLaneReason(lane) {
762
765
  }
763
766
  }
764
767
 
768
+ // src/core/rwa-icons.ts
769
+ var GATEWAY_ICON_PREFIX = "/api/v1/rwa/icons/";
770
+ var ICON_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.(?:png|jpg|jpeg|webp|gif)$/;
771
+ function resolveVaultIcon(apiBase, iconPath) {
772
+ if (typeof iconPath !== "string" || !iconPath.startsWith(GATEWAY_ICON_PREFIX)) return void 0;
773
+ const file = iconPath.slice(GATEWAY_ICON_PREFIX.length);
774
+ if (!ICON_FILE.test(file)) return void 0;
775
+ return `${apiBase.replace(/\/$/, "")}/rwa/icons/${file}`;
776
+ }
777
+ function vaultIconsBySymbol(apiBase, vaults) {
778
+ const out = /* @__PURE__ */ new Map();
779
+ for (const vault of vaults) {
780
+ const key = symbolKey(vault?.symbol);
781
+ if (!key || out.has(key)) continue;
782
+ const url = resolveVaultIcon(apiBase, vault?.iconMiniUrl) ?? resolveVaultIcon(apiBase, vault?.iconUrl);
783
+ if (url) out.set(key, url);
784
+ }
785
+ return out;
786
+ }
787
+ function withVaultArtwork(tokens, icons) {
788
+ if (!icons.size) return tokens;
789
+ return tokens.map((token) => {
790
+ if (token.logoUrl) return token;
791
+ const url = icons.get(symbolKey(token.symbol));
792
+ return url ? { ...token, logoUrl: url } : token;
793
+ });
794
+ }
795
+
765
796
  // src/core/compliance.ts
766
797
  var COMPLIANCE_DENY_LABEL = "Compliance check failed";
767
798
  function complianceView(compliance, hasQuote = true) {
@@ -1330,7 +1361,63 @@ function routeLabelFor(option, destinationToken, result) {
1330
1361
  const bridge = result.quote.bridge ? ` via ${result.quote.bridge}` : "";
1331
1362
  return `Swap ${option.symbol} to ${destinationToken.symbol} and settle on ZeroDelta${bridge}.`;
1332
1363
  }
1333
- async function buildRoute({ option, destination, destinationToken, chains, payer, fetchQuote, solve = solveExactOut, amountInRaw, compliance }) {
1364
+ function tokenAt(tokens, chainId, address) {
1365
+ const wanted = normalizeAddress(address);
1366
+ if (!wanted || !tokens?.length) return void 0;
1367
+ return tokens.find((t) => Number(t.chainId) === Number(chainId) && normalizeAddress(t.address) === wanted);
1368
+ }
1369
+ function legAmount(raw, decimals) {
1370
+ if (decimals === void 0) return "";
1371
+ try {
1372
+ return formatUnits(raw || "0", decimals);
1373
+ } catch {
1374
+ return "";
1375
+ }
1376
+ }
1377
+ function buildLegs(orders, ctx) {
1378
+ const legs = [];
1379
+ let fromChainId = ctx.option.chainId;
1380
+ let fromAsset = ctx.option.symbol;
1381
+ let fromDecimals = ctx.option.decimals;
1382
+ for (let index = 0; index < orders.length; index += 1) {
1383
+ const order = orders[index];
1384
+ const isLast = index === orders.length - 1;
1385
+ const toChainId = Number(order.destinationChainId);
1386
+ const askToken = isLast ? ctx.destinationToken : tokenAt(ctx.tokens, toChainId, order.askToken);
1387
+ const toAsset = isLast ? ctx.destinationToken.symbol : askToken?.symbol ?? "";
1388
+ const toDecimals = askToken ? assetDecimals(askToken) : void 0;
1389
+ const executionChainId = Number(order.executionChainId);
1390
+ legs.push({
1391
+ index: index + 1,
1392
+ fromAsset,
1393
+ fromChainId,
1394
+ fromChainName: chainNameOf(fromChainId, ctx.chains),
1395
+ fromAmount: legAmount(order.bidTokenAmount, fromDecimals),
1396
+ toAsset,
1397
+ toChainId,
1398
+ toChainName: chainNameOf(toChainId, ctx.chains),
1399
+ toAmount: legAmount(order.askTokenAmount, toDecimals),
1400
+ executionChainId,
1401
+ executionChainName: chainNameOf(executionChainId, ctx.chains)
1402
+ });
1403
+ fromChainId = toChainId;
1404
+ fromAsset = toAsset;
1405
+ fromDecimals = toDecimals;
1406
+ }
1407
+ return legs;
1408
+ }
1409
+ async function buildRoute({
1410
+ option,
1411
+ destination,
1412
+ destinationToken,
1413
+ chains,
1414
+ tokens,
1415
+ payer,
1416
+ fetchQuote,
1417
+ solve = solveExactOut,
1418
+ amountInRaw,
1419
+ compliance
1420
+ }) {
1334
1421
  const result = await solve({ option, destination, destinationToken, payer, fetchQuote, amountInRaw });
1335
1422
  const quote = result.quote;
1336
1423
  const destDecimals = assetDecimals(destinationToken);
@@ -1360,6 +1447,23 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
1360
1447
  },
1361
1448
  routeLabel: routeLabelFor(option, destinationToken, result),
1362
1449
  deltaLabel: routeDeltaLabel(result, quote),
1450
+ // A direct transfer submits no order at all, but it is still ONE hop and history renders the
1451
+ // same shape for it — an empty `legs` would leave "one order or two?" unanswerable for it alone.
1452
+ legs: [
1453
+ {
1454
+ index: 1,
1455
+ fromAsset: option.symbol,
1456
+ fromChainId: option.chainId,
1457
+ fromChainName: option.chainName,
1458
+ fromAmount: sourceAmount,
1459
+ toAsset: destinationToken.symbol,
1460
+ toChainId: Number(destination.chainId),
1461
+ toChainName: chainNameOf(Number(destination.chainId), chains),
1462
+ toAmount: receiveAmount,
1463
+ executionChainId: option.chainId,
1464
+ executionChainName: option.chainName
1465
+ }
1466
+ ],
1363
1467
  transactions: [
1364
1468
  {
1365
1469
  id: "transfer",
@@ -1433,6 +1537,7 @@ async function buildRoute({ option, destination, destinationToken, chains, payer
1433
1537
  },
1434
1538
  routeLabel: routeLabelFor(option, destinationToken, result),
1435
1539
  deltaLabel: routeDeltaLabel(result, quote),
1540
+ legs: buildLegs(orders, { option, destinationToken, chains, tokens }),
1436
1541
  transactions: [
1437
1542
  {
1438
1543
  id: "approve",
@@ -1540,7 +1645,8 @@ function createApiClient(cfg) {
1540
1645
  chains: null,
1541
1646
  tokens: null,
1542
1647
  routes: null,
1543
- health: null
1648
+ health: null,
1649
+ vaults: null
1544
1650
  };
1545
1651
  const screenCache = /* @__PURE__ */ new Map();
1546
1652
  const screenInflight = /* @__PURE__ */ new Map();
@@ -1624,6 +1730,19 @@ function createApiClient(cfg) {
1624
1730
  cache.health = { at: Date.now(), value };
1625
1731
  return value;
1626
1732
  }
1733
+ async function fetchRwaVaults() {
1734
+ if (nowFresh(cache.vaults)) return cache.vaults.value;
1735
+ let value = [];
1736
+ try {
1737
+ const payload = await apiRequest("/rwa/vaults?status=active,coming_soon", { timeoutMs: 8e3 });
1738
+ const rows = Array.isArray(payload) ? payload : payload?.vaults;
1739
+ value = Array.isArray(rows) ? rows.filter((v) => !!v && typeof v === "object") : [];
1740
+ } catch {
1741
+ value = [];
1742
+ }
1743
+ cache.vaults = { at: Date.now(), value };
1744
+ return value;
1745
+ }
1627
1746
  async function fetchQuote(body, retries = 1) {
1628
1747
  let lastError;
1629
1748
  for (let attempt = 0; attempt <= retries; attempt += 1) {
@@ -1663,7 +1782,7 @@ function createApiClient(cfg) {
1663
1782
  screenInflight.set(key, request);
1664
1783
  return request;
1665
1784
  }
1666
- return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchQuote, screenWallet, apiBase };
1785
+ return { apiRequest, fetchChains, fetchTokens, fetchRoutes, fetchRouteHealth, fetchRwaVaults, fetchQuote, screenWallet, apiBase };
1667
1786
  }
1668
1787
 
1669
1788
  // src/core/plan.ts
@@ -1780,7 +1899,16 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
1780
1899
  }
1781
1900
  const routeErrors = [];
1782
1901
  const routePromises = candidates.map(
1783
- (option) => buildRoute({ option, destination, destinationToken, chains, payer, fetchQuote: api.fetchQuote, compliance: option.direct ? directCompliance ?? void 0 : void 0 }).catch((error) => {
1902
+ (option) => buildRoute({
1903
+ option,
1904
+ destination,
1905
+ destinationToken,
1906
+ chains,
1907
+ tokens,
1908
+ payer,
1909
+ fetchQuote: api.fetchQuote,
1910
+ compliance: option.direct ? directCompliance ?? void 0 : void 0
1911
+ }).catch((error) => {
1784
1912
  routeErrors.push(error);
1785
1913
  return null;
1786
1914
  })
@@ -1893,7 +2021,7 @@ async function buildSwapPlan(api, swap, payer, wallet = {}) {
1893
2021
  direct: false
1894
2022
  };
1895
2023
  const destination = { address: receiver, chainId: v.toChainId, asset: destToken.symbol };
1896
- const route = await buildRoute({ option, destination, destinationToken: destToken, chains, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
2024
+ const route = await buildRoute({ option, destination, destinationToken: destToken, chains, tokens, payer: account, fetchQuote: api.fetchQuote, solve: solveExactIn, amountInRaw });
1897
2025
  if (route.state === "SHORT") throw new Error("ZeroDelta could not price this swap right now.");
1898
2026
  route.recommended = true;
1899
2027
  return {
@@ -2248,6 +2376,24 @@ function resolveConfig(config = {}) {
2248
2376
  }
2249
2377
 
2250
2378
  // src/core/index.ts
2379
+ function sanitizeLegs(legs) {
2380
+ if (!Array.isArray(legs) || !legs.length) return void 0;
2381
+ const text = (v, max) => String(v ?? "").slice(0, max);
2382
+ const chain = (v) => Number(v) || 0;
2383
+ return legs.slice(0, 8).map((leg, i) => ({
2384
+ index: Number(leg?.index) || i + 1,
2385
+ fromAsset: text(leg?.fromAsset, 12),
2386
+ fromChainId: chain(leg?.fromChainId),
2387
+ fromChainName: text(leg?.fromChainName, 40),
2388
+ fromAmount: text(leg?.fromAmount, 40),
2389
+ toAsset: text(leg?.toAsset, 12),
2390
+ toChainId: chain(leg?.toChainId),
2391
+ toChainName: text(leg?.toChainName, 40),
2392
+ toAmount: text(leg?.toAmount, 40),
2393
+ executionChainId: chain(leg?.executionChainId),
2394
+ executionChainName: text(leg?.executionChainName, 40)
2395
+ }));
2396
+ }
2251
2397
  function sanitizeTxEntry(entry) {
2252
2398
  return {
2253
2399
  kind: entry.kind === "swap" ? "swap" : "payment",
@@ -2263,7 +2409,8 @@ function sanitizeTxEntry(entry) {
2263
2409
  recipient: isAddress(entry.recipient) ? normalizeAddress(entry.recipient) : "",
2264
2410
  settlement: entry.settlement === "direct" ? "direct" : "escrow",
2265
2411
  status: entry.status && ["confirmed", "unconfirmed", "error"].includes(entry.status) ? entry.status : "submitted",
2266
- at: (/* @__PURE__ */ new Date()).toISOString()
2412
+ at: (/* @__PURE__ */ new Date()).toISOString(),
2413
+ legs: sanitizeLegs(entry.legs)
2267
2414
  };
2268
2415
  }
2269
2416
  function createEngine(config = {}) {
@@ -2280,12 +2427,15 @@ function createEngine(config = {}) {
2280
2427
  fetchRouteHealth: api.fetchRouteHealth,
2281
2428
  fetchQuote: api.fetchQuote,
2282
2429
  fetchCatalogue: async (allowedAssets, product) => {
2283
- const [chains, tokens, routes, health] = await Promise.all([
2430
+ const [chains, registryTokens, routes, health, vaults] = await Promise.all([
2284
2431
  api.fetchChains().catch(() => []),
2285
2432
  api.fetchTokens().catch(() => []),
2286
2433
  api.fetchRoutes().catch(() => []),
2287
- api.fetchRouteHealth()
2434
+ api.fetchRouteHealth(),
2435
+ api.fetchRwaVaults()
2288
2436
  ]);
2437
+ const vaultIcons = vaultIconsBySymbol(api.apiBase, vaults);
2438
+ const tokens = withVaultArtwork(registryTokens, vaultIcons);
2289
2439
  const allowed = allowedAssets?.length ? new Set([...allowedAssets].map(symbolKey).filter((a) => SUPPORTED_ASSETS.has(a))) : void 0;
2290
2440
  return buildCatalogue({
2291
2441
  chains,
@@ -2294,7 +2444,8 @@ function createEngine(config = {}) {
2294
2444
  product,
2295
2445
  ...allowed ? { allowedAssets: allowed } : {},
2296
2446
  supportedChainIds: SUPPORTED_CHAIN_IDS,
2297
- brokenLanes: suppressedLanes(health)
2447
+ brokenLanes: suppressedLanes(health),
2448
+ vaultIcons
2298
2449
  });
2299
2450
  },
2300
2451
  fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
@@ -2758,7 +2909,10 @@ function useFlow(args) {
2758
2909
  account,
2759
2910
  recipient,
2760
2911
  settlement: route.state === "DIRECT" ? "direct" : "escrow",
2761
- status: v.status === "confirmed" ? "confirmed" : v.status === "mismatch" || v.status === "reverted" ? "error" : "unconfirmed"
2912
+ status: v.status === "confirmed" ? "confirmed" : v.status === "mismatch" || v.status === "reverted" ? "error" : "unconfirmed",
2913
+ // One signature can be several orders. Record them, or the history of a chained RWA trade
2914
+ // reads as a single hop that skipped a chain it demonstrably went through.
2915
+ legs: route.legs
2762
2916
  });
2763
2917
  setLastTxEntry(entry.hash ? entry : null);
2764
2918
  appendTxHistory(account, entry);
@@ -2979,6 +3133,12 @@ var WIDGET_CSS = `
2979
3133
  @keyframes sg-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}
2980
3134
 
2981
3135
  .sg-foot{margin-top:14px;display:flex;align-items:center;justify-content:center;gap:6px;font-size:11px;color:var(--sg-text-muted);text-align:center}
3136
+ /* display:inline-block is load-bearing, not tidiness. A host running a CSS reset \u2014 Tailwind
3137
+ preflight, which most integrators use and which this repo's own playground applies \u2014 sets
3138
+ svg{display:block}, and the padlock then takes a line of its own above the sentence. Every other
3139
+ glyph in the widget sits in a flex or absolute box where that is harmless; this is the one that
3140
+ lives in normal text flow. (WIDGET_CSS is a template literal: no backticks in these comments.) */
3141
+ .sg-foot svg{display:inline-block;vertical-align:-1px;margin-right:5px}
2982
3142
 
2983
3143
  /* fixed-height variant \u2014 head/foot pinned, body scrolls */
2984
3144
  .sg-widget[data-sg-fixed="true"]{display:flex;flex-direction:column}
@@ -2998,6 +3158,7 @@ var WIDGET_CSS = `
2998
3158
  .sg-tile:disabled{cursor:default}
2999
3159
  .sg-tile-label{font-size:12px;color:var(--sg-text-muted)}
3000
3160
  .sg-tile-main{display:flex;align-items:center;gap:10px;min-width:0}
3161
+ .sg-tile-text{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
3001
3162
  .sg-tile-sym{font-size:16px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
3002
3163
  .sg-tile-chain{font-size:11px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
3003
3164
  .sg-tile-empty{color:var(--sg-text-muted);font-size:15px;font-weight:600}
@@ -3032,7 +3193,9 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
3032
3193
  .sg-sel-head{display:flex;align-items:center;margin-bottom:14px}
3033
3194
  .sg-back{width:32px;height:32px;flex:0 0 auto;border:none;border-radius:999px;background:transparent;color:var(--sg-text);cursor:pointer;font:inherit;display:flex;align-items:center;justify-content:center;transition:background 120ms ease}
3034
3195
  .sg-back:hover{background:var(--sg-surface)}
3035
- .sg-sel-title{flex:1 1 auto;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
3196
+ .sg-sel-title{flex:1 1 auto;min-width:0;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
3197
+ /* Whose transactions these are \u2014 history is per wallet, and the takeover hides the header's pill. */
3198
+ .sg-sel-sub{display:block;font-size:11px;font-weight:600;color:var(--sg-text-muted);margin-top:1px}
3036
3199
  /* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
3037
3200
  (9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
3038
3201
  the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
@@ -3091,6 +3254,53 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
3091
3254
  .sg-hist{width:32px;height:32px;flex:0 0 auto;border:1px solid var(--sg-border);border-radius:999px;background:transparent;color:var(--sg-text-muted);cursor:pointer;font:inherit;display:flex;align-items:center;justify-content:center;transition:color 120ms ease,border-color 120ms ease}
3092
3255
  .sg-hist:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
3093
3256
 
3257
+ /* transaction history row. NOT the picker's flex row: at 390px that layout wrapped the pair onto two
3258
+ lines and then ellipsised the whole meta line down to "\u2026". A 3-column grid instead, where the meta
3259
+ spans the badge column so it always has the full card width to wrap into. */
3260
+ .sg-txrow{display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:11px;row-gap:3px;align-items:center;width:100%;padding:10px 8px;border:none;border-radius:var(--sg-radius-control);background:transparent;color:var(--sg-text);cursor:pointer;font:inherit;text-align:left;transition:background 120ms ease}
3261
+ .sg-txrow:hover{background:var(--sg-surface)}
3262
+ /* Both ends of the trade, side by side \u2014 the RWA gets a mark of its own. NOT overlapped: each disc
3263
+ carries a chain badge at its bottom-right, and an overlap parks that badge on top of its neighbour. */
3264
+ .sg-txrow-glyphs{grid-column:1;grid-row:1 / span 2;display:flex;align-items:center;gap:9px}
3265
+ /* Each side is its own nowrap span, so a narrow card breaks the line AT THE ARROW, never mid-symbol. */
3266
+ .sg-txrow-pair{grid-column:2;grid-row:1;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 6px;font-size:14px;font-weight:700;line-height:1.35;min-width:0}
3267
+ .sg-txrow-side{white-space:nowrap;display:inline-flex;align-items:center;gap:5px}
3268
+ .sg-txrow-arrow{display:inline-flex;color:var(--sg-text-muted)}
3269
+ /* Meta and status share line 2. The badge sat beside the pair until it squeezed the pair onto two
3270
+ lines at 390px; down here the pair gets the card's full width and the badge still reads at a glance. */
3271
+ /* flex-start, not center: on a phone the meta wraps to two lines, and a centred badge then floats
3272
+ between them. Pinned to the first line it reads as the row's status rather than as a third line. */
3273
+ .sg-txrow-meta{grid-column:2;grid-row:2;display:flex;align-items:flex-start;gap:8px;font-size:11.5px;color:var(--sg-text-muted);line-height:1.4}
3274
+ .sg-txrow-when{flex:1 1 auto;min-width:0;display:flex;flex-wrap:wrap;column-gap:8px}
3275
+ /* The kind+chain+orders unit WRAPS; only the timestamp is unbreakable. Holding both as nowrap made
3276
+ the express card (the narrowest surface) overflow its text straight under the status pill. */
3277
+ .sg-txrow-time{white-space:nowrap}
3278
+ .sg-txrow-what{display:flex;flex-wrap:wrap;column-gap:5px;min-width:0}
3279
+ .sg-txrow-what>span{white-space:nowrap}
3280
+ /* The separator is the literal character, never a CSS unicode escape. WIDGET_CSS is a JS template
3281
+ literal, so a backslash-zero-zero escape in here is a legacy octal sequence and esbuild refuses to
3282
+ build the package at all \u2014 including inside a comment like this one. */
3283
+ .sg-txrow-what>span:not(:last-child)::after{content:"\xB7";margin-left:5px}
3284
+ .sg-txrow-end{flex:0 0 auto;margin-left:auto}
3285
+
3286
+ /* transaction detail: the route, one row per ORDER. A chained (RWA) trade is ONE signature and TWO
3287
+ orders; the numbered rail is what makes the middle hop visible instead of merely implied. */
3288
+ /* The pair's artwork above the anchor amount, same marks the pickers draw. */
3289
+ .sg-panel > .sg-txrow-glyphs{margin-bottom:10px}
3290
+ .sg-legs{margin-top:14px}
3291
+ .sg-legs-head{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:13px;margin-bottom:6px}
3292
+ .sg-leg-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}
3293
+ .sg-leg{display:flex;align-items:flex-start;gap:10px;padding:8px 0;border-bottom:1px solid var(--sg-border)}
3294
+ .sg-leg:last-child{border-bottom:none}
3295
+ /* The step number doubles as the rail: a pseudo-element joins consecutive orders, so two legs read as
3296
+ one continuous path rather than as two unrelated rows. */
3297
+ .sg-leg-n{position:relative;flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-top:1px;border-radius:999px;background:color-mix(in srgb,var(--sg-accent) 14%,transparent);color:var(--sg-accent);font-size:10px;font-weight:700;font-variant-numeric:tabular-nums}
3298
+ .sg-leg:not(:last-child) .sg-leg-n::after{content:"";position:absolute;top:19px;left:50%;width:1px;height:calc(100% + 6px);background:var(--sg-border)}
3299
+ .sg-leg-body{min-width:0;flex:1 1 auto}
3300
+ .sg-leg-line{display:flex;align-items:center;gap:7px;flex-wrap:wrap;font-size:13px;font-weight:600}
3301
+ .sg-leg-arrow{display:inline-flex;color:var(--sg-text-muted)}
3302
+ .sg-leg-sub{margin-top:2px;font-size:11.5px;color:var(--sg-text-muted);line-height:1.45}
3303
+
3094
3304
  /* transaction detail: copyable hash row (no external links \u2014 everything stays in-widget) */
3095
3305
  .sg-txd-hash{display:flex;align-items:center;gap:8px;margin-top:12px;font-size:13px}
3096
3306
  .sg-txd-hash .sg-mono{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@@ -3480,10 +3690,10 @@ function WidgetShell(props) {
3480
3690
  ] })
3481
3691
  ] }),
3482
3692
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-body", children: props.children }),
3483
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-foot", children: [
3693
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-foot", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3484
3694
  /* @__PURE__ */ jsxRuntime.jsx(LockGlyph, {}),
3485
3695
  " Your wallet signs every transaction \xB7 Powered by ZeroDelta"
3486
- ] })
3696
+ ] }) })
3487
3697
  ] });
3488
3698
  }
3489
3699
  function shortAddress2(a) {
@@ -3979,9 +4189,15 @@ var BUNDLED_TOKEN_LOGO = {
3979
4189
  function isHttpsUrl(u) {
3980
4190
  return typeof u === "string" && /^https:\/\//i.test(u);
3981
4191
  }
4192
+ function isSameOriginPath2(u) {
4193
+ return typeof u === "string" && u.startsWith("/") && !u.startsWith("//") && !u.startsWith("/\\");
4194
+ }
4195
+ function isDisplayableImageSrc(u) {
4196
+ return isHttpsUrl(u) || isSameOriginPath2(u);
4197
+ }
3982
4198
  function tokenLogoCandidates(symbol, logoUrl) {
3983
4199
  const out = [];
3984
- if (isHttpsUrl(logoUrl)) out.push(logoUrl);
4200
+ if (isDisplayableImageSrc(logoUrl)) out.push(logoUrl);
3985
4201
  const bundled = BUNDLED_TOKEN_LOGO[symbolKey(symbol)];
3986
4202
  if (bundled && !out.includes(bundled)) out.push(bundled);
3987
4203
  return out;
@@ -4028,7 +4244,7 @@ function TokenTile(props) {
4028
4244
  const shown = props.token?.symbol ?? props.pick?.symbol ?? "";
4029
4245
  const glyph = props.pick ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4030
4246
  /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: props.pick.symbol, logoUrl: props.token?.logoUrl, chainId: props.pick.chainId }),
4031
- /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { minWidth: 0 }, children: [
4247
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tile-text", children: [
4032
4248
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: shown }),
4033
4249
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: CHAIN_LABELS[props.pick.chainId] || `Chain ${props.pick.chainId}` })
4034
4250
  ] })
@@ -4216,6 +4432,59 @@ function HistoryButton(props) {
4216
4432
  function chainLabel(entry) {
4217
4433
  return entry.chainId != null && CHAIN_LABELS[entry.chainId] || entry.chainName || (entry.chainId != null ? `Chain ${entry.chainId}` : "Unknown chain");
4218
4434
  }
4435
+ function chainName(chainId, fallback) {
4436
+ return CHAIN_LABELS[chainId] || fallback || (chainId ? `Chain ${chainId}` : "Unknown chain");
4437
+ }
4438
+ function legsOf(entry) {
4439
+ if (entry.legs?.length) return entry.legs;
4440
+ const leg = {
4441
+ index: 1,
4442
+ fromAsset: entry.fromAsset,
4443
+ fromChainId: entry.chainId ?? 0,
4444
+ fromChainName: entry.chainName,
4445
+ fromAmount: entry.payAmount,
4446
+ toAsset: entry.toAsset,
4447
+ toChainId: 0,
4448
+ toChainName: "",
4449
+ toAmount: entry.receiveAmount,
4450
+ executionChainId: 0,
4451
+ executionChainName: ""
4452
+ };
4453
+ return [leg];
4454
+ }
4455
+ function ordersLabel(count) {
4456
+ return count === 1 ? "1 order" : `${count} orders`;
4457
+ }
4458
+ function LegArrowGlyph() {
4459
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
4460
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }),
4461
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m13 6 6 6-6 6" })
4462
+ ] });
4463
+ }
4464
+ function TxLegs(props) {
4465
+ const multi = props.legs.length > 1;
4466
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-legs", "data-multi": multi || void 0, children: [
4467
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-legs-head", children: [
4468
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Route" }),
4469
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", children: ordersLabel(props.legs.length) })
4470
+ ] }),
4471
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "sg-leg-list", children: props.legs.map((leg) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-leg", children: [
4472
+ multi ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-leg-n", "aria-hidden": "true", children: leg.index }) : null,
4473
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-leg-body", children: [
4474
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-leg-line", children: [
4475
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-mono", children: `${leg.fromAmount ? `${leg.fromAmount} ` : ""}${leg.fromAsset || "\u2014"}` }),
4476
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-leg-arrow", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(LegArrowGlyph, {}) }),
4477
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-mono", children: `${leg.toAmount ? `${leg.toAmount} ` : ""}${leg.toAsset || "\u2014"}` })
4478
+ ] }),
4479
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-leg-sub", children: [
4480
+ chainName(leg.fromChainId, leg.fromChainName),
4481
+ leg.toChainId ? ` \u2192 ${chainName(leg.toChainId, leg.toChainName)}` : "",
4482
+ leg.executionChainId && leg.executionChainId !== leg.fromChainId ? ` \xB7 filled on ${chainName(leg.executionChainId, leg.executionChainName)}` : ""
4483
+ ] })
4484
+ ] })
4485
+ ] }, `${leg.index}:${leg.fromChainId}:${leg.toChainId}`)) })
4486
+ ] });
4487
+ }
4219
4488
  function statusBadge(status) {
4220
4489
  if (status === "confirmed")
4221
4490
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "ok", children: "Confirmed" });
@@ -4225,40 +4494,73 @@ function statusBadge(status) {
4225
4494
  }
4226
4495
  function whenLabel(at) {
4227
4496
  const d = new Date(at);
4228
- return Number.isNaN(d.getTime()) ? "" : d.toLocaleString();
4497
+ if (Number.isNaN(d.getTime())) return "";
4498
+ const sameYear = d.getFullYear() === (/* @__PURE__ */ new Date()).getFullYear();
4499
+ try {
4500
+ return d.toLocaleString(void 0, { day: "numeric", month: "short", year: sameYear ? void 0 : "numeric", hour: "2-digit", minute: "2-digit" });
4501
+ } catch {
4502
+ return d.toLocaleString();
4503
+ }
4504
+ }
4505
+ function endpoints(entry) {
4506
+ const legs = entry.legs;
4507
+ return {
4508
+ fromChainId: entry.chainId ?? legs?.[0]?.fromChainId ?? void 0,
4509
+ toChainId: legs?.length ? legs[legs.length - 1].toChainId || void 0 : void 0
4510
+ };
4511
+ }
4512
+ function TxPairGlyphs(props) {
4513
+ const e = props.entry;
4514
+ const { fromChainId, toChainId } = endpoints(e);
4515
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-glyphs", children: [
4516
+ /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: e.fromAsset || "?", logoUrl: logoFor(props.art, e.fromAsset, fromChainId ?? null), chainId: fromChainId, size: "sm" }),
4517
+ /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: e.toAsset || "?", logoUrl: logoFor(props.art, e.toAsset, toChainId ?? null), chainId: toChainId, size: "sm" })
4518
+ ] });
4229
4519
  }
4230
- function logoFor(tokens, symbol, chainId) {
4231
- if (!tokens?.length) return void 0;
4520
+ function TxPair(props) {
4521
+ const e = props.entry;
4522
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-pair", children: [
4523
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-side sg-mono", children: `${e.payAmount} ${e.fromAsset}` }),
4524
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-side sg-mono", children: [
4525
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-arrow", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(LegArrowGlyph, {}) }),
4526
+ `${e.receiveAmount} ${e.toAsset}`
4527
+ ] })
4528
+ ] });
4529
+ }
4530
+ function logoFor(art, symbol, chainId) {
4232
4531
  const key = symbolKey(symbol);
4233
4532
  if (!key) return void 0;
4234
- const sameChain = chainId == null ? void 0 : tokens.find((t) => Number(t.chainId) === chainId && symbolKey(t.symbol) === key);
4235
- return (sameChain ?? tokens.find((t) => symbolKey(t.symbol) === key))?.logoUrl;
4533
+ const tokens = art.tokens;
4534
+ if (tokens?.length) {
4535
+ const sameChain = chainId == null ? void 0 : tokens.find((t) => Number(t.chainId) === chainId && symbolKey(t.symbol) === key);
4536
+ const found = (sameChain ?? tokens.find((t) => symbolKey(t.symbol) === key))?.logoUrl;
4537
+ if (found) return found;
4538
+ }
4539
+ return art.vaultIcons?.get(key);
4236
4540
  }
4237
4541
  function TxHistoryList(props) {
4238
4542
  if (!props.entries.length) {
4239
4543
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "No transactions yet \u2014 activity from this wallet will appear here." });
4240
4544
  }
4241
- return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "sg-toklist", "aria-label": "Transaction history", children: props.entries.map((e) => /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-tokrow", onClick: () => props.onPick(e), children: [
4242
- /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: e.fromAsset || e.toAsset || "?", logoUrl: logoFor(props.tokens, e.fromAsset, e.chainId), chainId: e.chainId ?? void 0 }),
4243
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-main", children: [
4244
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-sym sg-mono", children: [
4245
- e.payAmount,
4246
- " ",
4247
- e.fromAsset,
4248
- " \u2192 ",
4249
- e.receiveAmount,
4250
- " ",
4251
- e.toAsset
4252
- ] }),
4253
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-name", children: [
4254
- e.kind === "payment" ? "Payment" : "Swap",
4255
- " \xB7 ",
4256
- chainLabel(e),
4257
- whenLabel(e.at) ? ` \xB7 ${whenLabel(e.at)}` : ""
4545
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "sg-toklist", "aria-label": "Transaction history", children: props.entries.map((e) => (
4546
+ // A GRID, not the picker's flex row: the meta line spans the badge column too, so at 390px it
4547
+ // has the full card width to wrap into instead of being ellipsised away to "…".
4548
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-txrow", onClick: () => props.onPick(e), children: [
4549
+ /* @__PURE__ */ jsxRuntime.jsx(TxPairGlyphs, { entry: e, art: props }),
4550
+ /* @__PURE__ */ jsxRuntime.jsx(TxPair, { entry: e }),
4551
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-meta", children: [
4552
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-when", children: [
4553
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-txrow-what", children: [
4554
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: e.kind === "payment" ? "Payment" : "Swap" }),
4555
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: chainLabel(e) }),
4556
+ (e.legs?.length ?? 1) > 1 ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: ordersLabel(e.legs.length) }) : null
4557
+ ] }),
4558
+ whenLabel(e.at) ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-time", children: whenLabel(e.at) }) : null
4559
+ ] }),
4560
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-txrow-end", children: statusBadge(e.status) })
4258
4561
  ] })
4259
- ] }),
4260
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-end", children: statusBadge(e.status) })
4261
- ] }, `${e.hash}:${e.at}`)) });
4562
+ ] }, `${e.hash}:${e.at}`)
4563
+ )) });
4262
4564
  }
4263
4565
  function TxDetail(props) {
4264
4566
  const e = props.entry;
@@ -4281,6 +4583,7 @@ function TxDetail(props) {
4281
4583
  }
4282
4584
  };
4283
4585
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", children: [
4586
+ /* @__PURE__ */ jsxRuntime.jsx(TxPairGlyphs, { entry: e, art: props }),
4284
4587
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
4285
4588
  e.receiveAmount,
4286
4589
  " ",
@@ -4290,6 +4593,7 @@ function TxDetail(props) {
4290
4593
  e.kind === "payment" ? "Payment" : "Swap",
4291
4594
  whenLabel(e.at) ? ` \xB7 ${whenLabel(e.at)}` : ""
4292
4595
  ] }),
4596
+ /* @__PURE__ */ jsxRuntime.jsx(TxLegs, { legs: legsOf(e) }),
4293
4597
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta", children: [
4294
4598
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
4295
4599
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Status" }),
@@ -4304,7 +4608,7 @@ function TxDetail(props) {
4304
4608
  ] })
4305
4609
  ] }),
4306
4610
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
4307
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Chain" }),
4611
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-meta-label", children: "Signed on" }),
4308
4612
  /* @__PURE__ */ jsxRuntime.jsx("b", { children: chainLabel(e) })
4309
4613
  ] }),
4310
4614
  e.recipient ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-meta-row", children: [
@@ -4323,14 +4627,17 @@ function TxDetail(props) {
4323
4627
  ] })
4324
4628
  ] });
4325
4629
  }
4326
- function displayableHistory(entries) {
4327
- return entries.filter((e) => e.txKind !== "approve");
4630
+ function displayableHistory(entries, account) {
4631
+ const owner = typeof account === "string" ? account.toLowerCase() : "";
4632
+ return entries.filter((e) => e.txKind !== "approve" && (!e.account || !owner || e.account.toLowerCase() === owner));
4328
4633
  }
4329
4634
  function TxHistoryPanel(props) {
4330
- const entries = displayableHistory(useTxHistory(props.account));
4331
- const [selected, setSelected] = react.useState(props.initialEntry ?? null);
4635
+ const account = props.account;
4636
+ const entries = displayableHistory(useTxHistory(account), account);
4637
+ const deepLink = props.initialEntry && displayableHistory([props.initialEntry], account).length ? props.initialEntry : null;
4638
+ const [selected, setSelected] = react.useState(deepLink);
4332
4639
  const backRef = react.useRef(null);
4333
- react.useEffect(() => setSelected(props.initialEntry ?? null), [props.initialEntry]);
4640
+ react.useEffect(() => setSelected(deepLink), [deepLink]);
4334
4641
  const pick = (entry) => {
4335
4642
  setSelected(entry);
4336
4643
  requestAnimationFrame(() => backRef.current?.focus());
@@ -4338,9 +4645,12 @@ function TxHistoryPanel(props) {
4338
4645
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4339
4646
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
4340
4647
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelected(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph2, {}) }),
4341
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-title", children: selected ? "Transaction" : "Transaction history" })
4648
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
4649
+ selected ? "Transaction" : "Transaction history",
4650
+ account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress2(account) }) : null
4651
+ ] })
4342
4652
  ] }),
4343
- selected ? /* @__PURE__ */ jsxRuntime.jsx(TxDetail, { entry: selected }) : /* @__PURE__ */ jsxRuntime.jsx(TxHistoryList, { entries, tokens: props.tokens, onPick: pick })
4653
+ selected ? /* @__PURE__ */ jsxRuntime.jsx(TxDetail, { entry: selected, tokens: props.tokens, vaultIcons: props.vaultIcons }) : /* @__PURE__ */ jsxRuntime.jsx(TxHistoryList, { entries, tokens: props.tokens, vaultIcons: props.vaultIcons, onPick: pick })
4344
4654
  ] });
4345
4655
  }
4346
4656
  var IDENTITY_KEY_PREFIX = "sg:link:v1:";
@@ -4403,7 +4713,7 @@ function forgetIdentity(account) {
4403
4713
  }
4404
4714
  }
4405
4715
  var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
4406
- var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
4716
+ var chainName2 = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
4407
4717
  var STABLES = EXECUTABLE_STABLE_ASSETS;
4408
4718
  function BankGlyph() {
4409
4719
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4919,6 +5229,7 @@ function PaymentIsland(props) {
4919
5229
  const [expanded, setExpanded] = react.useState(() => Boolean(props.defaultExpanded) || rampMode);
4920
5230
  const [view, setView] = react.useState("main");
4921
5231
  const [hist, setHist] = react.useState(null);
5232
+ const histBtnRef = react.useRef(null);
4922
5233
  const pillRef = react.useRef(null);
4923
5234
  const methodRowRef = react.useRef(null);
4924
5235
  const exFromTileRef = react.useRef(null);
@@ -4926,6 +5237,7 @@ function PaymentIsland(props) {
4926
5237
  const regionRef = react.useRef(null);
4927
5238
  const panelId = react.useId();
4928
5239
  react.useEffect(() => setView("main"), [wallet.account, payParamsKey]);
5240
+ react.useEffect(() => setHist(null), [wallet.account]);
4929
5241
  const firstRender = react.useRef(true);
4930
5242
  react.useEffect(() => {
4931
5243
  if (firstRender.current) {
@@ -4949,7 +5261,7 @@ function PaymentIsland(props) {
4949
5261
  };
4950
5262
  const closeHistory = () => {
4951
5263
  setHist(null);
4952
- requestAnimationFrame(() => (methodRowRef.current ?? regionRef.current)?.focus());
5264
+ requestAnimationFrame(() => (histBtnRef.current ?? methodRowRef.current ?? regionRef.current)?.focus());
4953
5265
  };
4954
5266
  const pickFunding = (pick) => {
4955
5267
  const r = visibleRoutes.find((x) => x.source.chainId === pick.chainId && symbolKey(x.source.asset) === symbolKey(pick.symbol));
@@ -5011,7 +5323,11 @@ function PaymentIsland(props) {
5011
5323
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-link-word", children: "ZeroDelta" }),
5012
5324
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-badge", "data-tone": "accent", children: "Link" })
5013
5325
  ] });
5014
- const walletSlot = menuItems.length ? /* @__PURE__ */ jsxRuntime.jsx(LinkMenu, { items: menuItems }) : void 0;
5326
+ const linkMenu = menuItems.length ? /* @__PURE__ */ jsxRuntime.jsx(LinkMenu, { items: menuItems }) : null;
5327
+ const walletSlot = wallet.account || linkMenu ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-head-tools", children: [
5328
+ wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }) : null,
5329
+ linkMenu
5330
+ ] }) : void 0;
5015
5331
  const activeStep = flow.steps.find((s) => s.state === "active");
5016
5332
  const liveMsg = flow.status === "loading" ? isPay ? "Finding the best way to pay." : "Finding the best route." : flow.status === "submitting" ? `${activeStep?.label ?? (isPay ? "Processing your payment" : `Processing your ${verb.present.toLowerCase()}`)} \u2014 in progress.` : flow.status === "success" || flow.status === "pending" ? flow.verdict?.status === "confirmed" ? isPay ? "Payment confirmed on-chain \u2014 the merchant has been settled." : `${verb.past} \u2014 confirmed on-chain.` : isPay ? "Payment sent \u2014 confirmation is still pending." : "Submitted \u2014 confirmation is still pending." : "";
5017
5333
  const loading = flow.status === "loading";
@@ -5045,7 +5361,7 @@ function PaymentIsland(props) {
5045
5361
  ] });
5046
5362
  let body;
5047
5363
  if (hist && wallet.account) {
5048
- body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory });
5364
+ body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
5049
5365
  } else if (isPay && view === "select" && wallet.account) {
5050
5366
  body = /* @__PURE__ */ jsxRuntime.jsx(
5051
5367
  TokenSelect,
@@ -5224,7 +5540,7 @@ function PaymentIsland(props) {
5224
5540
  ] }),
5225
5541
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor-sub", children: [
5226
5542
  "on ",
5227
- chainName(sel.source.chainId),
5543
+ chainName2(sel.source.chainId),
5228
5544
  selBal ? ` \xB7 balance ${selBal.formatted}` : ""
5229
5545
  ] })
5230
5546
  ] }) : null,
@@ -5237,7 +5553,7 @@ function PaymentIsland(props) {
5237
5553
  ] }),
5238
5554
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor-sub", children: [
5239
5555
  "on ",
5240
- chainName(sel.source.chainId)
5556
+ chainName2(sel.source.chainId)
5241
5557
  ] })
5242
5558
  ] }) : null,
5243
5559
  sel && !loading && !quoteError ? /* @__PURE__ */ jsxRuntime.jsx(CompliancePanel, { compliance: sel.quote.compliance, direct: sel.state === "DIRECT" }) : null,
@@ -5509,7 +5825,7 @@ function StableGeniePay(props) {
5509
5825
  ] })
5510
5826
  ] }) : void 0;
5511
5827
  if (props.variant === "pill") return /* @__PURE__ */ jsxRuntime.jsx(PaymentIsland, { kind: "pay", ...props });
5512
- return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
5828
+ return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
5513
5829
  TokenSelect,
5514
5830
  {
5515
5831
  title: "Pay with",
@@ -5682,7 +5998,7 @@ function StableGenieSwap(props) {
5682
5998
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-brand", children: "ZeroDelta" })
5683
5999
  ] }) : void 0;
5684
6000
  if (hist && wallet.account) {
5685
- return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
6001
+ return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) });
5686
6002
  }
5687
6003
  if (flow.status === "success" || flow.status === "pending") {
5688
6004
  return /* @__PURE__ */ jsxRuntime.jsxs(WidgetShell, { title: config.title || "Swap", theme: config.theme, walletSlot, children: [
@@ -5932,7 +6248,7 @@ function StableGenieExchange(props) {
5932
6248
  if (props.variant === "pill") return /* @__PURE__ */ jsxRuntime.jsx(PaymentIsland, { kind: "exchange", ...props });
5933
6249
  let body;
5934
6250
  if (hist && connected) {
5935
- body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens, initialEntry: hist.entry ?? null, onBack: closeHistory });
6251
+ body = /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory });
5936
6252
  } else if (view === "from" || view === "to") {
5937
6253
  const isFrom = view === "from";
5938
6254
  body = /* @__PURE__ */ jsxRuntime.jsx(