@glacislabs/stablegenie-zerodelta 2.0.0 → 3.0.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/mount.cjs CHANGED
@@ -2057,6 +2057,10 @@ var WIDGET_CSS = `
2057
2057
  .sg-tile-sym{font-size:16px;font-weight:700;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2058
2058
  .sg-tile-chain{font-size:11px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2059
2059
  .sg-tile-empty{color:var(--sg-text-muted);font-size:15px;font-weight:600}
2060
+ .sg-funding-glyphs{display:flex;align-items:center;flex:0 0 auto;padding-right:2px}
2061
+ .sg-funding-glyphs .sg-tok{box-shadow:0 0 0 2px var(--sg-surface);border-radius:999px}
2062
+ .sg-funding-glyphs .sg-tok+.sg-tok{margin-left:-8px}
2063
+ .sg-funding-copy{display:flex;flex-direction:column;min-width:0}
2060
2064
  .sg-ft-arrow{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:30px;height:30px;border-radius:999px;background:var(--sg-bg);border:1px solid var(--sg-border);display:flex;align-items:center;justify-content:center;color:var(--sg-text-muted);z-index:1;pointer-events:none}
2061
2065
 
2062
2066
  /* token identity: logo circle + tiny chain badge, with a letters fallback */
@@ -2244,9 +2248,7 @@ var WIDGET_CSS = `
2244
2248
  .sg-soonpanel-title{font-size:14px;font-weight:700;margin-bottom:6px}
2245
2249
  .sg-soonpanel-sub{font-size:12px;color:var(--sg-text-muted);line-height:1.45}
2246
2250
 
2247
- /* compact merchant-receives anchor + click-to-expand "Details" disclosure (merchant-configured;
2248
- the payer never edits it). Reveal mirrors the island's grid-rows morph; reduced-motion covered by
2249
- the .sg-island guard below (it disables transitions on .sg-island *). */
2251
+ /* payout slot \u2014 bank settlement only (the stablecoin destination anchor is never rendered) */
2250
2252
  .sg-merch-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
2251
2253
  .sg-merch-lead{min-width:0}
2252
2254
  /* bank payout destination (settlement="bank") \u2014 sits in the same anchor slot as the stablecoin
@@ -2256,19 +2258,6 @@ var WIDGET_CSS = `
2256
2258
  .sg-bank-text{display:flex;flex-direction:column;min-width:0}
2257
2259
  .sg-bank-name{font-size:16px;font-weight:700;color:var(--sg-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2258
2260
  .sg-bank-cur{font-size:12px;color:var(--sg-text-muted)}
2259
- .sg-details-toggle{flex:0 0 auto;display:inline-flex;align-items:center;gap:4px;padding:5px 10px;border:1px solid var(--sg-border);border-radius:var(--sg-radius-cta);background:transparent;color:var(--sg-text-muted);font:inherit;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap;transition:color var(--sg-motion-fast) var(--sg-ease-out-soft),border-color var(--sg-motion-fast) var(--sg-ease-out-soft)}
2260
- .sg-details-toggle:hover{color:var(--sg-accent);border-color:var(--sg-accent)}
2261
- .sg-details-chev{display:inline-flex;font-size:11px;line-height:1;transition:transform var(--sg-motion-fast) var(--sg-ease-out-soft)}
2262
- .sg-details-toggle[data-open="true"] .sg-details-chev{transform:rotate(180deg)}
2263
- .sg-details-reveal{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--sg-motion-base) var(--sg-ease-out-soft)}
2264
- .sg-details-reveal[data-open="true"]{grid-template-rows:1fr}
2265
- .sg-details-reveal-inner{min-height:0;overflow:hidden}
2266
- .sg-details-body{margin-top:12px;padding-top:12px;border-top:1px solid var(--sg-border)}
2267
- .sg-details-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:4px 0;font-size:12px}
2268
- .sg-details-k{flex:0 0 auto;color:var(--sg-text-muted)}
2269
- .sg-details-v{min-width:0;text-align:right;color:var(--sg-text)}
2270
- .sg-details-addr{word-break:break-all;font-size:11px}
2271
- .sg-details-note{margin-top:8px;font-size:11px;color:var(--sg-text-muted);line-height:1.45}
2272
2261
 
2273
2262
  /* express-card compaction for the 5-tab method selector (already overflow-x:auto for narrow cells) */
2274
2263
  .sg-widget[data-sg-express] .sg-tabs{margin:12px 0 8px}
@@ -2298,7 +2287,7 @@ var WIDGET_CSS = `
2298
2287
  broken) and shows the static accent dot instead; the label + live region carry the state. */
2299
2288
  @media (prefers-reduced-motion:reduce){
2300
2289
  .sg-island,.sg-island *{transition:none!important;animation:none!important}
2301
- .sg-island-reveal,.sg-details-reveal{transition:none!important}
2290
+ .sg-island-reveal{transition:none!important}
2302
2291
  .sg-island .sg-spinner{display:none!important}
2303
2292
  .sg-island .sg-rm-dot{display:inline-block}
2304
2293
  }
@@ -2546,14 +2535,22 @@ function StepList(props) {
2546
2535
  }
2547
2536
  var SHOW_ROADMAP_METHODS = true;
2548
2537
  var METHODS = [
2549
- { id: "recommended", label: "Recommended", live: true },
2550
2538
  { id: "stablecoin", label: "Stablecoin", live: true },
2551
- { id: "anyasset", label: "Any asset", live: true },
2552
2539
  { id: "card", label: "Card", live: false },
2553
- { id: "bank", label: "Bank", live: false }
2540
+ { id: "bank", label: "Bank account", live: false }
2554
2541
  ];
2555
2542
  function isLiveMethod(m) {
2556
- return m === "recommended" || m === "stablecoin" || m === "anyasset";
2543
+ return m === "stablecoin";
2544
+ }
2545
+ function balanceRank(raw, decimals) {
2546
+ if (raw == null) return 0n;
2547
+ try {
2548
+ const d = Number.isFinite(Number(decimals)) ? Math.max(0, Math.trunc(Number(decimals))) : 18;
2549
+ const v = BigInt(raw);
2550
+ return d <= 18 ? v * 10n ** BigInt(18 - d) : v / 10n ** BigInt(d - 18);
2551
+ } catch {
2552
+ return 0n;
2553
+ }
2557
2554
  }
2558
2555
  function MethodTabs(props) {
2559
2556
  const showRoadmap = props.showRoadmap ?? SHOW_ROADMAP_METHODS;
@@ -2700,6 +2697,31 @@ function TokenTile(props) {
2700
2697
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: glyph })
2701
2698
  ] });
2702
2699
  }
2700
+ function FundingTile(props) {
2701
+ const symbols = props.assets.map((asset) => asset.symbol);
2702
+ const summary = props.loading ? "Checking wallet assets\u2026" : symbols.length ? symbols.join(", ") : "No payable balance";
2703
+ const detail = props.loading ? "Finding what you can pay with" : symbols.length ? `${symbols.length} wallet asset${symbols.length === 1 ? "" : "s"} available` : "Open to review funding options";
2704
+ const ariaLabel = `${props.label}: ${props.loading ? "checking wallet assets" : symbols.length ? symbols.join(", ") : "no payable balance"}`;
2705
+ const glyphs = props.loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "\u2026" }) }) : symbols.length ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-funding-glyphs", "aria-hidden": "true", children: props.assets.slice(0, 3).map((asset) => /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: asset.symbol, logoUrl: asset.logoUrl, size: "sm" }, asset.symbol)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tok-fb", children: "?" }) });
2706
+ const main = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2707
+ glyphs,
2708
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-funding-copy", children: [
2709
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-sym", children: summary }),
2710
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chain", children: detail })
2711
+ ] })
2712
+ ] });
2713
+ if (props.row) {
2714
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile sg-tile--row", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
2715
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-label", children: props.label }),
2716
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-rowmain", children: main }),
2717
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-chev", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) })
2718
+ ] });
2719
+ }
2720
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", ref: props.btnRef, className: "sg-tile", disabled: props.disabled, onClick: props.onClick, "aria-label": ariaLabel, children: [
2721
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-label", children: props.label }),
2722
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: main })
2723
+ ] });
2724
+ }
2703
2725
  function ChainChip(props) {
2704
2726
  const [broken, setBroken] = react.useState(false);
2705
2727
  const logo = props.chain?.logoUrl;
@@ -3028,55 +3050,6 @@ function forgetIdentity(account) {
3028
3050
  var addrEq = (a, b) => String(a || "").toLowerCase() === String(b || "").toLowerCase();
3029
3051
  var chainName = (id) => id != null ? CHAIN_LABELS[id] || `Chain ${id}` : "";
3030
3052
  var STABLES = /* @__PURE__ */ new Set(["USDC", "USDT", "USDE"]);
3031
- function MerchantReceives(props) {
3032
- const [open, setOpen] = react.useState(false);
3033
- const bodyId = react.useId();
3034
- const hasDetails = Boolean(props.recipient);
3035
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel sg-merch", children: [
3036
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-merch-head", children: [
3037
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-merch-lead", children: [
3038
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "Merchant receives exactly" }),
3039
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
3040
- props.amount,
3041
- " ",
3042
- props.asset
3043
- ] })
3044
- ] }),
3045
- hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs(
3046
- "button",
3047
- {
3048
- type: "button",
3049
- className: "sg-details-toggle",
3050
- "data-open": open,
3051
- "aria-expanded": open,
3052
- "aria-controls": bodyId,
3053
- onClick: () => setOpen((o) => !o),
3054
- children: [
3055
- "Details",
3056
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-details-chev", "aria-hidden": "true", children: "\u2304" })
3057
- ]
3058
- }
3059
- ) : null
3060
- ] }),
3061
- hasDetails ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-details-reveal", "data-open": open, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-details-reveal-inner", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-details-body", id: bodyId, children: [
3062
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-details-row", children: [
3063
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-details-k", children: "Network" }),
3064
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-details-v", children: chainName(props.chainId) })
3065
- ] }),
3066
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-details-row", children: [
3067
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-details-k", children: "Recipient" }),
3068
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-details-v sg-mono sg-details-addr", children: props.recipient })
3069
- ] }),
3070
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-details-note", children: [
3071
- "Settled like a card \u2014 the merchant always receives exactly ",
3072
- props.amount,
3073
- " ",
3074
- props.asset,
3075
- ". You pay a little more to cover the network cost."
3076
- ] })
3077
- ] }) }) }) : null
3078
- ] });
3079
- }
3080
3053
  function BankGlyph() {
3081
3054
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3 10h18M5 10v8M10 10v8M14 10v8M19 10v8M3 19h18M12 3 3 8h18Z" }) });
3082
3055
  }
@@ -3279,7 +3252,7 @@ function PaymentIsland(props) {
3279
3252
  onSuccess: config.onSuccess,
3280
3253
  onError: config.onError
3281
3254
  });
3282
- const [method, setMethod] = react.useState("recommended");
3255
+ const [method, setMethod] = react.useState("stablecoin");
3283
3256
  const parked = isPay && !isLiveMethod(method);
3284
3257
  const fundingSet = react.useMemo(
3285
3258
  () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
@@ -3305,7 +3278,13 @@ function PaymentIsland(props) {
3305
3278
  }),
3306
3279
  [visibleRoutes, holdings.balances]
3307
3280
  );
3308
- const held = react.useMemo(() => annotated.filter((a) => a.affordable === true), [annotated]);
3281
+ const held = react.useMemo(
3282
+ () => annotated.filter((a) => a.affordable === true).sort((a, b) => {
3283
+ const d = balanceRank(b.balance?.raw, b.route.source.decimals) - balanceRank(a.balance?.raw, a.route.source.decimals);
3284
+ return d > 0n ? 1 : d < 0n ? -1 : 0;
3285
+ }),
3286
+ [annotated]
3287
+ );
3309
3288
  const heldIds = react.useMemo(() => new Set(held.map((a) => a.route.id)), [held]);
3310
3289
  const optionStates = react.useMemo(() => {
3311
3290
  const map = {};
@@ -3386,6 +3365,18 @@ function PaymentIsland(props) {
3386
3365
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
3387
3366
  return chains.filter((c) => ids.has(Number(c.chainId)));
3388
3367
  }, [chains, fundingTokens]);
3368
+ const payableAssets = react.useMemo(() => {
3369
+ const seen = /* @__PURE__ */ new Set();
3370
+ const list = [];
3371
+ for (const { route } of held) {
3372
+ const symbol = symbolKey(route.source.asset);
3373
+ if (seen.has(symbol)) continue;
3374
+ seen.add(symbol);
3375
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq(t.address, route.source.tokenAddress));
3376
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
3377
+ }
3378
+ return list;
3379
+ }, [held, registryTokens]);
3389
3380
  const userPicked = react.useRef(false);
3390
3381
  const selectRoute = react.useCallback(
3391
3382
  (id) => {
@@ -3488,15 +3479,11 @@ function PaymentIsland(props) {
3488
3479
  const submitting = flow.status === "submitting";
3489
3480
  const sel = flow.selected;
3490
3481
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
3491
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
3492
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq(t.address, sel.source.tokenAddress)) ?? null : null;
3493
3482
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
3494
3483
  const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
3495
3484
  const mismatch = flow.status === "error" && flow.verdict?.status === "mismatch";
3496
3485
  const destAsset = isPay ? props.toAsset : exToAsset;
3497
- const destChainId = isPay ? props.toChainId : exToChainId;
3498
- const anchorLabel = isPay ? "Merchant receives exactly" : "You receive (estimated)";
3499
- const anchorAmount = isPay ? props.amount : sel?.receive.amount ?? (flow.status === "loading" ? "\u2026" : "\u2014");
3486
+ const anchorAmount = sel?.receive.amount ?? (flow.status === "loading" ? "\u2026" : "\u2014");
3500
3487
  const successAmount = isPay ? props.amount : sel?.receive.amount;
3501
3488
  const money = props.moneyDisplay ?? (isPay ? props.amount ? `${props.amount} ${props.toAsset}` : "" : exAmount ? `${exAmount} ${exFromAsset ?? ""}`.trim() : "");
3502
3489
  const verb = isPay ? { present: "Pay", gerund: "Paying", past: "Paid" } : kind === "swap" ? { present: "Swap", gerund: "Swapping", past: "Swapped" } : { present: "Exchange", gerund: "Exchanging", past: "Exchanged" };
@@ -3618,7 +3605,7 @@ function PaymentIsland(props) {
3618
3605
  } else if (!wallet.account) {
3619
3606
  body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3620
3607
  /* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: null, email: identity?.email }),
3621
- isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(MerchantReceives, { amount: props.amount, asset: destAsset, chainId: destChainId, recipient: props.recipient }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3608
+ isPay ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3622
3609
  exchangeControls,
3623
3610
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
3624
3611
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
@@ -3689,10 +3676,10 @@ function PaymentIsland(props) {
3689
3676
  const walletError = flow.status === "error" && flow.steps.length > 0;
3690
3677
  body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3691
3678
  /* @__PURE__ */ jsxRuntime.jsx(IdentityLine, { account: wallet.account, email: identity?.email }),
3692
- isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(MerchantReceives, { amount: props.amount, asset: destAsset, chainId: destChainId, recipient: props.recipient }) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3679
+ isPay ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3693
3680
  exchangeControls,
3694
3681
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
3695
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: anchorLabel }),
3682
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You receive (estimated)" }),
3696
3683
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
3697
3684
  anchorAmount,
3698
3685
  " ",
@@ -3715,7 +3702,18 @@ function PaymentIsland(props) {
3715
3702
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { disabled: true, children: method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" }) })
3716
3703
  ] })
3717
3704
  ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3718
- isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { row: true, label: "Pay with", pick: selPick, token: selToken, disabled: submitting || !visibleRoutes.length, btnRef: methodRowRef, onClick: () => setView("select") }) }) : null,
3705
+ isPay ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3706
+ FundingTile,
3707
+ {
3708
+ row: true,
3709
+ label: "Pay with",
3710
+ assets: payableAssets,
3711
+ loading: flow.status === "loading" || holdings.loading,
3712
+ disabled: submitting || !visibleRoutes.length,
3713
+ btnRef: methodRowRef,
3714
+ onClick: () => setView("select")
3715
+ }
3716
+ ) }) : null,
3719
3717
  loading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
3720
3718
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
3721
3719
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
@@ -3799,7 +3797,7 @@ function StableGeniePay(props) {
3799
3797
  onSuccess: config.onSuccess,
3800
3798
  onError: config.onError
3801
3799
  });
3802
- const [method, setMethod] = react.useState("recommended");
3800
+ const [method, setMethod] = react.useState("stablecoin");
3803
3801
  const fundingSet = react.useMemo(
3804
3802
  () => props.fundingAssets?.length ? new Set(props.fundingAssets.map((a) => a.toUpperCase())) : null,
3805
3803
  [props.fundingAssets]
@@ -3824,7 +3822,13 @@ function StableGeniePay(props) {
3824
3822
  }),
3825
3823
  [visibleRoutes, holdings.balances]
3826
3824
  );
3827
- const held = react.useMemo(() => annotated.filter((a) => a.affordable === true), [annotated]);
3825
+ const held = react.useMemo(
3826
+ () => annotated.filter((a) => a.affordable === true).sort((a, b) => {
3827
+ const d = balanceRank(b.balance?.raw, b.route.source.decimals) - balanceRank(a.balance?.raw, a.route.source.decimals);
3828
+ return d > 0n ? 1 : d < 0n ? -1 : 0;
3829
+ }),
3830
+ [annotated]
3831
+ );
3828
3832
  const heldIds = react.useMemo(() => new Set(held.map((a) => a.route.id)), [held]);
3829
3833
  const scannedEmpty = !holdings.loading && Object.keys(holdings.balances).length > 0 && held.length === 0;
3830
3834
  const optionStates = react.useMemo(() => {
@@ -3884,6 +3888,18 @@ function StableGeniePay(props) {
3884
3888
  const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
3885
3889
  return chains.filter((c) => ids.has(Number(c.chainId)));
3886
3890
  }, [chains, fundingTokens]);
3891
+ const payableAssets = react.useMemo(() => {
3892
+ const seen = /* @__PURE__ */ new Set();
3893
+ const list = [];
3894
+ for (const { route } of held) {
3895
+ const symbol = symbolKey(route.source.asset);
3896
+ if (seen.has(symbol)) continue;
3897
+ seen.add(symbol);
3898
+ const token = registryTokens.find((t) => Number(t.chainId) === route.source.chainId && addrEq2(t.address, route.source.tokenAddress));
3899
+ list.push({ symbol: route.source.asset, logoUrl: token?.logoUrl });
3900
+ }
3901
+ return list;
3902
+ }, [held, registryTokens]);
3887
3903
  const userPicked = react.useRef(false);
3888
3904
  const selectRoute = react.useCallback(
3889
3905
  (id) => {
@@ -3927,15 +3943,15 @@ function StableGeniePay(props) {
3927
3943
  if (r) selectRoute(r.id);
3928
3944
  closeSelector();
3929
3945
  };
3930
- const chainName2 = CHAIN_LABELS[props.toChainId] || `Chain ${props.toChainId}`;
3931
3946
  const parked = !isLiveMethod(method);
3932
3947
  const submitting = flow.status === "submitting";
3933
3948
  const sel = flow.selected;
3934
3949
  const selectedVisible = Boolean(sel && visibleRoutes.some((r) => r.id === sel.id));
3935
- const selPick = sel && selectedVisible ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null;
3936
- const selToken = sel ? registryTokens.find((t) => Number(t.chainId) === sel.source.chainId && addrEq2(t.address, sel.source.tokenAddress)) ?? null : null;
3937
3950
  const selBal = sel ? holdings.balances[balanceKey(sel.source.chainId, sel.source.tokenAddress)] : void 0;
3938
- const why = parked ? "" : sel && selectedVisible ? sel.state === "DIRECT" ? `Direct ${sel.source.asset} transfer on ${CHAIN_LABELS[sel.source.chainId] || sel.source.chainName} \xB7 lowest cost` : `Routed through ZeroDelta \u2014 the merchant still receives exactly ${props.amount} ${props.toAsset}` : method === "stablecoin" ? "Pay with USDC, USDT, or USDE from your wallet." : method === "anyasset" ? "Pay with any supported asset \u2014 we route it to exactly what the merchant needs." : "Best route \xB7 picked for you";
3951
+ const why = parked ? "" : sel && selectedVisible ? sel.state === "DIRECT" ? `Direct ${sel.source.asset} transfer on ${CHAIN_LABELS[sel.source.chainId] || sel.source.chainName} \xB7 lowest cost` : (
3952
+ // Deliberately does NOT restate the destination amount — that is merchant config, not a payer fact.
3953
+ `Routed through ZeroDelta \xB7 the extra covers the network cost`
3954
+ ) : "Pay with USDC, USDT, or USDE from your wallet.";
3939
3955
  const comingSoon = method === "card" ? "Card payments are coming soon. Today StableGenie pays from your connected wallet." : "Bank transfers are coming soon.";
3940
3956
  const payLabel = parked ? method === "card" ? "Card \u2014 coming soon" : "Bank \u2014 coming soon" : submitting ? "Paying\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${sel.source.payAmount} ${sel.source.asset}` : "Pay";
3941
3957
  const walletSlot = wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-head-tools", children: [
@@ -3946,82 +3962,66 @@ function StableGeniePay(props) {
3946
3962
  ] })
3947
3963
  ] }) : void 0;
3948
3964
  if (props.variant === "pill") return /* @__PURE__ */ jsxRuntime.jsx(PaymentIsland, { kind: "pay", ...props });
3949
- 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(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: closeSelector, onPick: pickFunding }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3950
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", children: [
3951
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "Merchant receives exactly" }),
3952
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
3965
+ 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(TokenSelect, { title: "Pay with", chains: fundingChains, tokens: fundingTokens, balances: holdings.balances, optionStates, onBack: closeSelector, onPick: pickFunding }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: !wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
3966
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
3967
+ wallet.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
3968
+ ] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3969
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
3970
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": flow.verdict?.status !== "confirmed", children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph3, {}) }),
3971
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
3953
3972
  props.amount,
3954
3973
  " ",
3955
3974
  props.toAsset
3956
3975
  ] }),
3957
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor-sub", children: [
3958
- "on ",
3959
- chainName2,
3976
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
3977
+ flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
3960
3978
  " \xB7 ",
3961
3979
  shortAddress(props.recipient)
3962
3980
  ] })
3963
3981
  ] }),
3964
- !wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cta-wrap", children: [
3965
- /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: wallet.connect, busy: wallet.connecting, children: "Connect wallet" }),
3966
- wallet.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: wallet.error }) : null
3967
- ] }) : flow.status === "success" || flow.status === "pending" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3968
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success", children: [
3969
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-success-check", "data-pending": flow.verdict?.status !== "confirmed", children: /* @__PURE__ */ jsxRuntime.jsx(CheckGlyph3, {}) }),
3970
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-amt sg-mono", children: [
3971
- props.amount,
3982
+ lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
3983
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3984
+ /* @__PURE__ */ jsxRuntime.jsx(MethodTabs, { value: method, onChange: setMethod }),
3985
+ parked ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3986
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3987
+ FundingTile,
3988
+ {
3989
+ label: "Pay with",
3990
+ assets: payableAssets,
3991
+ loading: flow.status === "loading" || holdings.loading,
3992
+ disabled: submitting || !visibleRoutes.length,
3993
+ btnRef: payTileRef,
3994
+ onClick: () => setView("select")
3995
+ }
3996
+ ) }),
3997
+ flow.status === "loading" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-route", style: { marginTop: 12 }, children: [
3998
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
3999
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
4000
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-spinner" }),
4001
+ " Finding the best way to pay\u2026"
4002
+ ] })
4003
+ ] }) : null,
4004
+ flow.status === "error" && flow.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
4005
+ sel && selectedVisible && flow.status !== "loading" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
4006
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You pay" }),
4007
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
4008
+ sel.source.payAmount,
3972
4009
  " ",
3973
- props.toAsset
4010
+ sel.source.asset
3974
4011
  ] }),
3975
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-success-sub", children: [
3976
- flow.verdict?.status === "confirmed" ? "Confirmed on-chain" : "Submitted \u2014 awaiting confirmation",
3977
- " \xB7 ",
3978
- shortAddress(props.recipient)
4012
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor-sub", children: [
4013
+ "on ",
4014
+ CHAIN_LABELS[sel.source.chainId] || sel.source.chainName,
4015
+ selBal ? ` \xB7 balance ${selBal.formatted}` : ""
3979
4016
  ] })
3980
- ] }),
3981
- lastTxOwned ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setHist({ entry: flow.lastTxEntry }), children: "View transaction" }) }) : null
3982
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3983
- /* @__PURE__ */ jsxRuntime.jsx(MethodTabs, { value: method, onChange: setMethod }),
3984
- parked ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: comingSoon }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3985
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntime.jsx(
3986
- TokenTile,
3987
- {
3988
- label: "Pay with",
3989
- pick: selPick,
3990
- token: selToken,
3991
- disabled: submitting || !visibleRoutes.length,
3992
- btnRef: payTileRef,
3993
- onClick: () => setView("select")
3994
- }
3995
- ) }),
3996
- flow.status === "loading" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-route", style: { marginTop: 12 }, children: [
3997
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel" }),
3998
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-muted", style: { fontSize: 13 }, children: [
3999
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-spinner" }),
4000
- " Finding the best way to pay\u2026"
4001
- ] })
4002
- ] }) : null,
4003
- flow.status === "error" && flow.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
4004
- sel && selectedVisible && flow.status !== "loading" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-panel", style: { marginTop: 12 }, children: [
4005
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-label", children: "You pay" }),
4006
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor sg-mono", children: [
4007
- sel.source.payAmount,
4008
- " ",
4009
- sel.source.asset
4010
- ] }),
4011
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-anchor-sub", children: [
4012
- "on ",
4013
- CHAIN_LABELS[sel.source.chainId] || sel.source.chainName,
4014
- selBal ? ` \xB7 balance ${selBal.formatted}` : ""
4015
- ] })
4016
- ] }) : null,
4017
- why ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-why", style: { marginTop: 10 }, children: why }) : null,
4018
- scannedEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-note", children: "None of your balances can cover this yet \u2014 pick a different asset to fund with." }) : null,
4019
- flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
4020
- ] }),
4021
- submitting ? /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps: flow.steps }) : null,
4022
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: parked || !selectedVisible ? void 0 : flow.submit, busy: submitting, disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading", children: payLabel }) })
4023
- ] })
4024
- ] }) });
4017
+ ] }) : null,
4018
+ why ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-why", style: { marginTop: 10 }, children: why }) : null,
4019
+ scannedEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-note", children: "None of your balances can cover this yet \u2014 pick a different asset to fund with." }) : null,
4020
+ flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null
4021
+ ] }),
4022
+ submitting ? /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps: flow.steps }) : null,
4023
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: parked || !selectedVisible ? void 0 : flow.submit, busy: submitting, disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || flow.status === "loading", children: payLabel }) })
4024
+ ] }) }) });
4025
4025
  }
4026
4026
  var chainOptions = SUPPORTED_CHAINS.map((c) => ({ value: c, label: CHAIN_LABELS[c] || `Chain ${c}` }));
4027
4027
  var assetOptions = SUPPORTED_ASSETS2.map((a) => ({ value: a, label: a }));
package/dist/mount.js CHANGED
@@ -1,2 +1,2 @@
1
- export { mount } from './chunk-DSQ7MRF7.js';
1
+ export { mount } from './chunk-DH7QYQG4.js';
2
2
  import './chunk-VL5MWEY2.js';