@glacislabs/stablegenie-zerodelta 4.11.0 → 4.12.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.
- package/dist/{chunk-5WTRI2KO.js → chunk-A7ADZJXA.js} +4 -2
- package/dist/{chunk-TNAW2SWI.js → chunk-MA2VYFG3.js} +537 -121
- package/dist/core/index.cjs +4 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +539 -121
- package/dist/index.js +2 -2
- package/dist/mount.cjs +539 -121
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +73 -40
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1736,7 +1736,7 @@ var CHANNEL_HEADER = "x-zd-channel";
|
|
|
1736
1736
|
var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
|
|
1737
1737
|
var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
|
|
1738
1738
|
var WIDGET_CHANNEL = "widget";
|
|
1739
|
-
var WIDGET_VERSION = "4.
|
|
1739
|
+
var WIDGET_VERSION = "4.12.0" ;
|
|
1740
1740
|
var MAX_CHANNEL_VERSION_LEN = 32;
|
|
1741
1741
|
function sanitizeVersion(raw) {
|
|
1742
1742
|
const v = String(raw).trim();
|
|
@@ -2007,6 +2007,7 @@ function createApiClient(cfg) {
|
|
|
2007
2007
|
const missing = wanted.filter((s) => !nowFresh(priceCache.get(s) ?? null));
|
|
2008
2008
|
if (missing.length) {
|
|
2009
2009
|
let prices = {};
|
|
2010
|
+
let answered = true;
|
|
2010
2011
|
try {
|
|
2011
2012
|
const snapshot = await apiRequest(`/prices?symbols=${encodeURIComponent(missing.join(","))}`, {
|
|
2012
2013
|
timeoutMs: 8e3
|
|
@@ -2014,9 +2015,10 @@ function createApiClient(cfg) {
|
|
|
2014
2015
|
prices = snapshot && typeof snapshot === "object" && !snapshot.stale && snapshot.prices && typeof snapshot.prices === "object" ? snapshot.prices : {};
|
|
2015
2016
|
} catch {
|
|
2016
2017
|
prices = {};
|
|
2018
|
+
answered = false;
|
|
2017
2019
|
}
|
|
2018
2020
|
const at = Date.now();
|
|
2019
|
-
for (const s of missing) {
|
|
2021
|
+
for (const s of answered ? missing : []) {
|
|
2020
2022
|
const n = Number(prices[s]);
|
|
2021
2023
|
priceCache.set(s, { at, value: Number.isFinite(n) && n > 0 ? n : null });
|
|
2022
2024
|
}
|
|
@@ -3756,46 +3758,79 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3756
3758
|
.sg-pct:hover:not(:disabled){color:var(--sg-accent)}
|
|
3757
3759
|
.sg-pct:disabled{opacity:.55;cursor:not-allowed}
|
|
3758
3760
|
|
|
3759
|
-
/* full-panel
|
|
3761
|
+
/* full-panel takeover head (transaction history) */
|
|
3760
3762
|
.sg-sel-head{display:flex;align-items:center;margin-bottom:14px}
|
|
3761
3763
|
.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}
|
|
3762
3764
|
.sg-back:hover{background:var(--sg-surface)}
|
|
3763
3765
|
.sg-sel-title{flex:1 1 auto;min-width:0;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
|
|
3764
3766
|
/* Whose transactions these are \u2014 history is per wallet, and the takeover hides the header's pill. */
|
|
3765
3767
|
.sg-sel-sub{display:block;font-size:11px;font-weight:600;color:var(--sg-text-muted);margin-top:1px}
|
|
3766
|
-
/* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
|
|
3767
|
-
(9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
|
|
3768
|
-
the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
|
|
3769
|
-
.sg-chain-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:12px;max-height:124px;overflow-y:auto;scrollbar-width:thin;padding-bottom:2px;mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent);-webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent)}
|
|
3770
|
-
/* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
|
|
3771
|
-
.sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
|
|
3772
|
-
.sg-chain-chip{height:44px;border-radius:var(--sg-radius-control);border:1px solid var(--sg-border);background:var(--sg-surface);color:var(--sg-text);display:flex;align-items:center;justify-content:center;cursor:pointer;font:inherit;font-size:10px;font-weight:700;letter-spacing:.02em;transition:border-color 120ms ease,background 120ms ease;overflow:hidden}
|
|
3773
|
-
.sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
|
|
3774
|
-
.sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
|
|
3775
|
-
.sg-chain-chip[data-selected="true"]{border-color:var(--sg-accent);background:color-mix(in srgb,var(--sg-accent) 10%,var(--sg-surface))}
|
|
3776
|
-
.sg-search{position:relative;margin-bottom:10px}
|
|
3777
|
-
.sg-search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--sg-text-muted);pointer-events:none}
|
|
3778
|
-
.sg-search input{width:100%;padding:11px 12px 11px 38px;background:var(--sg-surface);color:var(--sg-text);border:1px solid var(--sg-border);border-radius:var(--sg-radius-control);font:inherit;font-size:14px;outline:none;transition:border-color 120ms ease}
|
|
3779
|
-
.sg-search input:focus{border-color:var(--sg-accent)}
|
|
3780
3768
|
.sg-toklist{display:flex;flex-direction:column;gap:2px;max-height:320px;overflow-y:auto;margin:0 -6px;padding:0 6px;scrollbar-width:thin}
|
|
3781
|
-
.sg-tokrow{display:flex;align-items:center;gap:12px;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}
|
|
3782
|
-
.sg-tokrow:hover{background:var(--sg-surface)}
|
|
3783
|
-
.sg-tokrow-main{flex:1 1 auto;min-width:0}
|
|
3784
|
-
.sg-tokrow-sym{display:block;font-size:15px;font-weight:700;line-height:1.2}
|
|
3785
|
-
.sg-tokrow-name{display:block;font-size:12px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
3786
|
-
.sg-tokrow-end{flex:0 0 auto;text-align:right}
|
|
3787
|
-
.sg-tokrow-bal{display:block;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}
|
|
3788
|
-
.sg-tokrow-chain{display:block;font-size:11px;color:var(--sg-text-muted)}
|
|
3789
|
-
/* funding rows the wallet can't cover (zero / insufficient): greyed, non-interactive, reason hint.
|
|
3790
|
-
Mirrors RouteList's data-short dim + warn tone; no hover lift. Theme-aware via --sg-* vars. */
|
|
3791
|
-
.sg-tokrow--off,.sg-tokrow[disabled]{opacity:.5;cursor:not-allowed}
|
|
3792
|
-
.sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
|
|
3793
|
-
.sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
|
|
3794
|
-
.sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
|
|
3795
|
-
/* on a row that stays selectable (a limited lane): a caveat, not a refusal */
|
|
3796
|
-
.sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
|
|
3797
3769
|
.sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
|
|
3798
3770
|
|
|
3771
|
+
/* Token picker, token first then network \u2014 the ZeroDelta dapp's TokenSelectModal (Figma 708:27430,
|
|
3772
|
+
2517:52576), drawn in the widget's own theme: the dapp's brand tint is the accent, its green the
|
|
3773
|
+
success token. Geometry is the dapp's: 32px plates, 24px row plates, 16px chain marks, 20px gaps. The list keeps
|
|
3774
|
+
the previous picker's 320px cap so opening it does not grow the card. */
|
|
3775
|
+
.sg-pk{display:flex;flex-direction:column;gap:20px}
|
|
3776
|
+
.sg-pk-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
3777
|
+
.sg-pk-title{font-family:var(--sg-font-display);font-size:16px;font-weight:600;line-height:1.2;letter-spacing:.32px;color:var(--sg-t90)}
|
|
3778
|
+
.sg-pk-close,.sg-pk-clear{display:grid;place-items:center;flex:0 0 auto;padding:6px;border:none;border-radius:8px;background:transparent;color:var(--sg-text-muted);cursor:pointer}
|
|
3779
|
+
.sg-pk-clear{padding:2px}
|
|
3780
|
+
.sg-pk-close:hover,.sg-pk-clear:hover{color:var(--sg-text)}
|
|
3781
|
+
.sg-pk-backlink{display:flex;align-items:center;gap:10px;padding:0;border:none;border-radius:8px;background:transparent;color:var(--sg-t60);font:inherit;font-size:16px;font-weight:500;line-height:1.2;cursor:pointer}
|
|
3782
|
+
.sg-pk-backlink:hover{color:var(--sg-text)}
|
|
3783
|
+
.sg-pk-intro{display:flex;flex-direction:column;gap:4px}
|
|
3784
|
+
.sg-pk-lead{margin:0;font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
|
|
3785
|
+
.sg-pk-search{display:flex;align-items:center;gap:16px;width:100%;padding:16px;border:1px solid color-mix(in srgb,var(--sg-accent) 12%,transparent);border-radius:16px;background:var(--sg-surface);color:var(--sg-text-muted);cursor:text;transition:border-color 120ms ease}
|
|
3786
|
+
.sg-pk-search:focus-within{border-color:var(--sg-accent);color:var(--sg-accent)}
|
|
3787
|
+
.sg-pk-search input{flex:1 1 auto;min-width:0;padding:0;border:none;background:transparent;color:var(--sg-t90);font:inherit;font-size:15px;line-height:1.2;outline:none}
|
|
3788
|
+
.sg-pk-search input::placeholder{color:var(--sg-text-muted)}
|
|
3789
|
+
.sg-pk-body{display:flex;flex-direction:column;gap:8px}
|
|
3790
|
+
.sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
|
|
3791
|
+
.sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
|
|
3792
|
+
.sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
|
|
3793
|
+
.sg-pk-row{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:16px;border:none;border-radius:24px;background:color-mix(in srgb,var(--sg-accent) 4%,transparent);color:var(--sg-text);font:inherit;text-align:left;cursor:pointer;transition:background 120ms ease}
|
|
3794
|
+
.sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
|
|
3795
|
+
.sg-pk-row--net{padding:20px 16px}
|
|
3796
|
+
.sg-pk-row[data-zero]{background:color-mix(in srgb,var(--sg-text) 4%,transparent)}
|
|
3797
|
+
.sg-pk-row[data-zero]:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
|
|
3798
|
+
.sg-pk-row[data-selected]{background:color-mix(in srgb,var(--sg-success) 6%,transparent)}
|
|
3799
|
+
.sg-pk-row[data-selected]:hover{background:color-mix(in srgb,var(--sg-success) 8%,transparent)}
|
|
3800
|
+
.sg-pk-row--off{opacity:.6;cursor:default}
|
|
3801
|
+
.sg-pk-row--off:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
|
|
3802
|
+
.sg-pk-row:focus-visible,.sg-pk-close:focus-visible,.sg-pk-backlink:focus-visible,.sg-pk-clear:focus-visible{outline:2px solid color-mix(in srgb,var(--sg-accent) 30%,transparent);outline-offset:2px}
|
|
3803
|
+
.sg-pk-left{display:flex;align-items:center;gap:12px;flex:1 1 auto;min-width:0}
|
|
3804
|
+
.sg-pk-text{display:flex;flex-direction:column;align-items:flex-start;gap:2px;flex:1 1 auto;min-width:0;overflow:hidden}
|
|
3805
|
+
.sg-pk-label{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
|
|
3806
|
+
.sg-pk-alt{margin-left:8px;font-size:14px;font-weight:400;color:var(--sg-text-muted)}
|
|
3807
|
+
.sg-pk-line{display:flex;align-items:center;gap:4px;min-width:0;max-width:100%}
|
|
3808
|
+
.sg-pk-sub{flex:0 1 auto;font-size:14px;line-height:1.3;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
3809
|
+
.sg-pk-note{font-size:13px;line-height:1.3;color:var(--sg-text-muted)}
|
|
3810
|
+
.sg-pk-plate,.sg-pk-chainwrap{position:relative;display:grid;place-items:center;flex:0 0 auto;width:32px;height:32px}
|
|
3811
|
+
.sg-pk-plate-in{display:grid;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:16px;background:var(--sg-surface)}
|
|
3812
|
+
.sg-pk-plate-in img{width:32px;height:32px;display:block;object-fit:cover}
|
|
3813
|
+
.sg-pk-plate-fb{font-size:10px;font-weight:700;color:var(--sg-accent)}
|
|
3814
|
+
.sg-pk-plate[data-muted] .sg-pk-plate-in{filter:grayscale(1)}
|
|
3815
|
+
.sg-pk-tick{position:absolute;right:-1px;bottom:-1px;display:grid;place-items:center;width:14px;height:14px;border-radius:999px;background:var(--sg-surface);color:var(--sg-success)}
|
|
3816
|
+
.sg-pk-chain{display:grid;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:999px;background:var(--sg-surface);font-size:9px;font-weight:700;color:var(--sg-text-muted)}
|
|
3817
|
+
.sg-pk-chain img{width:32px;height:32px;display:block;object-fit:cover}
|
|
3818
|
+
.sg-pk-marks{display:flex;align-items:center;gap:4px;flex:0 0 auto}
|
|
3819
|
+
.sg-pk-stack{display:flex;align-items:center;height:18px}
|
|
3820
|
+
.sg-pk-markwrap{display:grid;flex:0 0 auto}
|
|
3821
|
+
.sg-pk-markwrap+.sg-pk-markwrap{margin-left:-2px}
|
|
3822
|
+
.sg-pk-mark{display:grid;place-items:center;width:16px;height:16px;overflow:hidden;border-radius:999px;background:var(--sg-surface);font-size:5px;font-weight:700;color:var(--sg-text-muted)}
|
|
3823
|
+
.sg-pk-mark img{width:16px;height:16px;display:block;object-fit:cover}
|
|
3824
|
+
.sg-pk-more{font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
|
|
3825
|
+
.sg-pk-chev{display:grid;place-items:center;flex:0 0 auto;width:16px;height:16px;color:var(--sg-text-muted)}
|
|
3826
|
+
.sg-pk-chev svg{width:16px;height:16px}
|
|
3827
|
+
.sg-pk-chev--sm,.sg-pk-chev--sm svg{width:14px;height:14px}
|
|
3828
|
+
.sg-pk-bal{display:flex;flex-direction:column;align-items:flex-end;justify-content:center;gap:4px;min-height:36px;flex:0 0 auto;text-align:right}
|
|
3829
|
+
.sg-pk-bal-usd{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
3830
|
+
.sg-pk-bal-amt{font-size:13px;line-height:1.4;color:var(--sg-text-muted)}
|
|
3831
|
+
.sg-pk-bal-zero{flex:0 0 auto;font-size:16px;font-weight:700;color:var(--sg-t35)}
|
|
3832
|
+
.sg-pk-empty{margin:0;padding:32px 0;text-align:center;font-size:14px;color:var(--sg-text-muted)}
|
|
3833
|
+
|
|
3799
3834
|
/* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
|
|
3800
3835
|
OWN available width (container query) \u2014 an embedded widget cannot infer the host layout from the
|
|
3801
3836
|
viewport. The viewport media query stays as a fallback for engines without container queries. */
|
|
@@ -4742,6 +4777,200 @@ function chainLogoCandidates(chainId, logoUrl) {
|
|
|
4742
4777
|
if (bundled) out.push(bundled);
|
|
4743
4778
|
return out;
|
|
4744
4779
|
}
|
|
4780
|
+
|
|
4781
|
+
// src/react/ui/tokenGroups.ts
|
|
4782
|
+
var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
|
|
4783
|
+
var CHAIN_TVL_ORDER = [
|
|
4784
|
+
1,
|
|
4785
|
+
1151111081099710,
|
|
4786
|
+
8453,
|
|
4787
|
+
56,
|
|
4788
|
+
42161,
|
|
4789
|
+
999,
|
|
4790
|
+
143,
|
|
4791
|
+
4663,
|
|
4792
|
+
137,
|
|
4793
|
+
9745,
|
|
4794
|
+
43114,
|
|
4795
|
+
10,
|
|
4796
|
+
196,
|
|
4797
|
+
57073,
|
|
4798
|
+
14,
|
|
4799
|
+
5e3,
|
|
4800
|
+
2818,
|
|
4801
|
+
30,
|
|
4802
|
+
4217,
|
|
4803
|
+
747474,
|
|
4804
|
+
1672,
|
|
4805
|
+
988,
|
|
4806
|
+
480,
|
|
4807
|
+
81457,
|
|
4808
|
+
1329,
|
|
4809
|
+
80094,
|
|
4810
|
+
130,
|
|
4811
|
+
4326,
|
|
4812
|
+
59144,
|
|
4813
|
+
2222,
|
|
4814
|
+
252,
|
|
4815
|
+
146,
|
|
4816
|
+
324,
|
|
4817
|
+
1776,
|
|
4818
|
+
534352,
|
|
4819
|
+
1030,
|
|
4820
|
+
1868,
|
|
4821
|
+
98866,
|
|
4822
|
+
169,
|
|
4823
|
+
1088,
|
|
4824
|
+
50,
|
|
4825
|
+
34443,
|
|
4826
|
+
1135,
|
|
4827
|
+
88,
|
|
4828
|
+
48900,
|
|
4829
|
+
151,
|
|
4830
|
+
7777777,
|
|
4831
|
+
1923,
|
|
4832
|
+
3343,
|
|
4833
|
+
81224,
|
|
4834
|
+
21e6
|
|
4835
|
+
];
|
|
4836
|
+
var TOKEN_MARKET_CAP_ORDER = ["USDT", "USDC", "USDS", "DAI", "USDE", "USD1", "USDG", "PYUSD", "XAUT", "RLUSD", "USDF", "GHO", "USD0", "USDTB", "AUSD", "WM"];
|
|
4837
|
+
var CHAIN_RANK = new Map(CHAIN_TVL_ORDER.map((chainId, index) => [chainId, index]));
|
|
4838
|
+
var TOKEN_RANK = new Map(TOKEN_MARKET_CAP_ORDER.map((symbol, index) => [symbol, index]));
|
|
4839
|
+
function chainTvlRank(chainId) {
|
|
4840
|
+
return CHAIN_RANK.get(Number(chainId)) ?? CHAIN_TVL_ORDER.length;
|
|
4841
|
+
}
|
|
4842
|
+
function tokenMarketCapRank(symbol) {
|
|
4843
|
+
return TOKEN_RANK.get(String(symbol).toUpperCase()) ?? TOKEN_MARKET_CAP_ORDER.length;
|
|
4844
|
+
}
|
|
4845
|
+
function dominantSymbol(tokens) {
|
|
4846
|
+
const counts = /* @__PURE__ */ new Map();
|
|
4847
|
+
for (const t of tokens) counts.set(t.symbol, (counts.get(t.symbol) ?? 0) + 1);
|
|
4848
|
+
let best = tokens[0].symbol;
|
|
4849
|
+
for (const [symbol, count] of counts) if (count > (counts.get(best) ?? 0)) best = symbol;
|
|
4850
|
+
return best;
|
|
4851
|
+
}
|
|
4852
|
+
function priceOf(prices, symbol) {
|
|
4853
|
+
const p = prices?.[String(symbol).toUpperCase()];
|
|
4854
|
+
return typeof p === "number" && Number.isFinite(p) ? p : void 0;
|
|
4855
|
+
}
|
|
4856
|
+
function buildGroup(key, members, prices) {
|
|
4857
|
+
const tokens = members.map((m) => m.token);
|
|
4858
|
+
let amount = null;
|
|
4859
|
+
let usd2 = null;
|
|
4860
|
+
for (const m of members) {
|
|
4861
|
+
if (m.balance == null) continue;
|
|
4862
|
+
amount = (amount ?? 0) + m.balance;
|
|
4863
|
+
const price = priceOf(prices, m.token.symbol);
|
|
4864
|
+
if (price !== void 0) usd2 = (usd2 ?? 0) + m.balance * price;
|
|
4865
|
+
}
|
|
4866
|
+
const first = members[0].token;
|
|
4867
|
+
return {
|
|
4868
|
+
key,
|
|
4869
|
+
symbol: dominantSymbol(tokens),
|
|
4870
|
+
name: String(first.name || first.symbol),
|
|
4871
|
+
logoUrl: first.logoUrl,
|
|
4872
|
+
deployments: members,
|
|
4873
|
+
unavailable: members.every((m) => m.disabled) ? { reason: members.find((m) => m.reason)?.reason } : null,
|
|
4874
|
+
amount,
|
|
4875
|
+
usd: usd2
|
|
4876
|
+
};
|
|
4877
|
+
}
|
|
4878
|
+
function byDeployment(a, b) {
|
|
4879
|
+
return Number(a.disabled) - Number(b.disabled) || (b.balance ?? 0) - (a.balance ?? 0) || chainTvlRank(a.token.chainId) - chainTvlRank(b.token.chainId);
|
|
4880
|
+
}
|
|
4881
|
+
function byPickability(a, b) {
|
|
4882
|
+
const zero = (g) => g.amount === 0 ? 1 : 0;
|
|
4883
|
+
return Number(!!a.unavailable) - Number(!!b.unavailable) || zero(a) - zero(b) || (b.usd ?? b.amount ?? 0) - (a.usd ?? a.amount ?? 0) || tokenMarketCapRank(a.symbol) - tokenMarketCapRank(b.symbol);
|
|
4884
|
+
}
|
|
4885
|
+
function groupDeployments(deployments, prices) {
|
|
4886
|
+
const order = [];
|
|
4887
|
+
const members = /* @__PURE__ */ new Map();
|
|
4888
|
+
for (const d of [...deployments].sort(byDeployment)) {
|
|
4889
|
+
const key = String(d.token.symbol).toUpperCase();
|
|
4890
|
+
const list = members.get(key);
|
|
4891
|
+
if (list) list.push(d);
|
|
4892
|
+
else {
|
|
4893
|
+
members.set(key, [d]);
|
|
4894
|
+
order.push(key);
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
return order.map((key) => buildGroup(key, members.get(key), prices)).sort(byPickability);
|
|
4898
|
+
}
|
|
4899
|
+
var CHAIN_ALIASES = {
|
|
4900
|
+
56: ["bsc", "binance"],
|
|
4901
|
+
137: ["matic"],
|
|
4902
|
+
43114: ["avax"]
|
|
4903
|
+
};
|
|
4904
|
+
function labelForms(label) {
|
|
4905
|
+
const lower2 = label.trim().toLowerCase();
|
|
4906
|
+
if (!lower2) return [];
|
|
4907
|
+
const compact = lower2.replace(/[^a-z0-9]/g, "");
|
|
4908
|
+
return compact && compact !== lower2 ? [lower2, compact] : [lower2];
|
|
4909
|
+
}
|
|
4910
|
+
function buildChainSearchTerms(chains) {
|
|
4911
|
+
const byId = /* @__PURE__ */ new Map();
|
|
4912
|
+
const ids = /* @__PURE__ */ new Set([...chains.map((c) => Number(c.chainId)), ...Object.keys(CHAIN_LABELS).map(Number)]);
|
|
4913
|
+
for (const id of ids) {
|
|
4914
|
+
const chain = chains.find((c) => Number(c.chainId) === id);
|
|
4915
|
+
const terms = /* @__PURE__ */ new Set();
|
|
4916
|
+
for (const label of [chain?.displayName, chain?.name, typeof chain?.slug === "string" ? chain.slug : void 0, CHAIN_LABELS[id]]) {
|
|
4917
|
+
if (label) for (const form of labelForms(label)) terms.add(form);
|
|
4918
|
+
}
|
|
4919
|
+
for (const alias of CHAIN_ALIASES[id] ?? []) terms.add(alias);
|
|
4920
|
+
byId.set(id, [...terms]);
|
|
4921
|
+
}
|
|
4922
|
+
return byId;
|
|
4923
|
+
}
|
|
4924
|
+
function splitSearchTerms(query) {
|
|
4925
|
+
return query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
4926
|
+
}
|
|
4927
|
+
function looksLikeAddress(term) {
|
|
4928
|
+
return /^(0x)?[0-9a-f]{4,}$/.test(term);
|
|
4929
|
+
}
|
|
4930
|
+
function chainMatches(term, token, chainTerms) {
|
|
4931
|
+
if (term === String(Number(token.chainId))) return true;
|
|
4932
|
+
return chainTerms.some((chainTerm) => chainTerm.includes(term));
|
|
4933
|
+
}
|
|
4934
|
+
function tokenMatches(term, token, asset) {
|
|
4935
|
+
return asset.symbol.toLowerCase().includes(term) || asset.name.toLowerCase().includes(term) || String(token.symbol || "").toLowerCase().includes(term) || // `₮` is not on a keyboard: both sides fold it to `T`, so "usdt0" finds USD₮0.
|
|
4936
|
+
foldTicker(tokenTicker(token)).includes(foldTicker(term)) || String(token.name || "").toLowerCase().includes(term) || looksLikeAddress(term) && String(token.address || "").toLowerCase().includes(term);
|
|
4937
|
+
}
|
|
4938
|
+
function matchingDeployments(terms, group, chainTerms) {
|
|
4939
|
+
if (terms.length === 0) return group.deployments;
|
|
4940
|
+
return group.deployments.filter((d) => {
|
|
4941
|
+
const ct = chainTerms.get(Number(d.token.chainId)) ?? [];
|
|
4942
|
+
return terms.every((term) => tokenMatches(term, d.token, group) || chainMatches(term, d.token, ct));
|
|
4943
|
+
});
|
|
4944
|
+
}
|
|
4945
|
+
function searchGroups(groups, query, chainTerms, prices) {
|
|
4946
|
+
const terms = splitSearchTerms(query);
|
|
4947
|
+
if (terms.length === 0) return groups;
|
|
4948
|
+
const rows = [];
|
|
4949
|
+
for (const g of groups) {
|
|
4950
|
+
const members = matchingDeployments(terms, g, chainTerms);
|
|
4951
|
+
if (members.length === 0) continue;
|
|
4952
|
+
rows.push(members.length === g.deployments.length ? g : buildGroup(g.key, members, prices));
|
|
4953
|
+
}
|
|
4954
|
+
return rows.sort(byPickability);
|
|
4955
|
+
}
|
|
4956
|
+
function groupDecimal2(value) {
|
|
4957
|
+
const match = value.match(/^([+-]?)(\d+)(\.\d+)?$/);
|
|
4958
|
+
if (!match) return value;
|
|
4959
|
+
return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
|
|
4960
|
+
}
|
|
4961
|
+
function humanAmount(n, maxFrac = 6) {
|
|
4962
|
+
if (!Number.isFinite(n)) return String(n);
|
|
4963
|
+
if (n === 0) return "0";
|
|
4964
|
+
const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
|
|
4965
|
+
const fixed = n.toFixed(digits);
|
|
4966
|
+
const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
4967
|
+
if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
|
|
4968
|
+
return groupDecimal2(out);
|
|
4969
|
+
}
|
|
4970
|
+
function formatBalanceUsd(value) {
|
|
4971
|
+
if (!Number.isFinite(value) || value <= 0) return "$0.00";
|
|
4972
|
+
return value < 0.01 ? "<$0.01" : `$${value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
4973
|
+
}
|
|
4745
4974
|
var CHAIN_SHORT = {
|
|
4746
4975
|
1: "ETH",
|
|
4747
4976
|
10: "OP",
|
|
@@ -4823,103 +5052,280 @@ function FundingTile(props) {
|
|
|
4823
5052
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: main })
|
|
4824
5053
|
] });
|
|
4825
5054
|
}
|
|
4826
|
-
function
|
|
5055
|
+
function ChainMark(props) {
|
|
4827
5056
|
const [failed, setFailed] = react.useState([]);
|
|
4828
|
-
const src = chainLogoCandidates(props.
|
|
4829
|
-
|
|
4830
|
-
|
|
5057
|
+
const src = chainLogoCandidates(props.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
|
|
5058
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: props.size === "row" ? "sg-pk-chain" : "sg-pk-mark", "aria-hidden": "true", children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: chainBadge(props.chainId) }) });
|
|
5059
|
+
}
|
|
5060
|
+
var MARK_LIMIT = 3;
|
|
5061
|
+
function ChainMarks(props) {
|
|
5062
|
+
const ids = props.chainIds;
|
|
5063
|
+
if (!ids.length) return null;
|
|
5064
|
+
const shown = ids.slice(0, MARK_LIMIT);
|
|
5065
|
+
const overflow = ids.length - shown.length;
|
|
5066
|
+
const marks = shown.map((id) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-markwrap", children: /* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: props.chainById.get(id), size: "mini" }) }, id));
|
|
5067
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-marks", children: [
|
|
5068
|
+
props.decorative ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-stack", "aria-hidden": "true", children: marks }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-stack", role: "img", "aria-label": `${ids.length} ${ids.length === 1 ? "network" : "networks"}`, children: marks }),
|
|
5069
|
+
overflow > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-more", "aria-hidden": "true", children: [
|
|
5070
|
+
"+",
|
|
5071
|
+
overflow
|
|
5072
|
+
] }) : null
|
|
5073
|
+
] });
|
|
5074
|
+
}
|
|
5075
|
+
function TokenPlate(props) {
|
|
5076
|
+
const [failed, setFailed] = react.useState([]);
|
|
5077
|
+
const src = tokenLogoCandidates(props.symbol, props.logoUrl).find((u) => !failed.includes(u));
|
|
5078
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-plate", "data-muted": props.muted || void 0, children: [
|
|
5079
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-plate-in", children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-plate-fb", children: props.symbol.slice(0, 4) }) }),
|
|
5080
|
+
props.checked ? /* @__PURE__ */ jsxRuntime.jsx(TickBadge, {}) : null
|
|
5081
|
+
] });
|
|
5082
|
+
}
|
|
5083
|
+
function TickBadge() {
|
|
5084
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-tick", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
5085
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "11", fill: "currentColor" }),
|
|
5086
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m7 12.5 3.2 3.2L17 9", stroke: "#fff", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
5087
|
+
] }) });
|
|
5088
|
+
}
|
|
5089
|
+
function BalanceColumn(props) {
|
|
5090
|
+
if (props.amount == null) return null;
|
|
5091
|
+
if (props.amount === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
|
|
5092
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
|
|
5093
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
5094
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
|
|
5095
|
+
humanAmount(props.amount, 6),
|
|
5096
|
+
" ",
|
|
5097
|
+
props.symbol
|
|
5098
|
+
] })
|
|
5099
|
+
] });
|
|
5100
|
+
}
|
|
5101
|
+
var WALLET_STATE_REASONS = /* @__PURE__ */ new Set(["no-balance", "insufficient"]);
|
|
5102
|
+
function isPick(sel, t) {
|
|
5103
|
+
return !!sel && Number(sel.chainId) === Number(t.chainId) && String(sel.symbol).toUpperCase() === String(t.symbol).toUpperCase();
|
|
5104
|
+
}
|
|
5105
|
+
function usdOf(balance, prices, symbol) {
|
|
5106
|
+
const price = priceOf(prices, symbol);
|
|
5107
|
+
return balance == null || price === void 0 ? null : balance * price;
|
|
5108
|
+
}
|
|
5109
|
+
function UnavailableRow(props) {
|
|
5110
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-row sg-pk-row--off", "data-testid": props.testId, "data-label": props.label, title: props.label, "aria-disabled": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
5111
|
+
props.icon,
|
|
5112
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
5113
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: props.label }),
|
|
5114
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: props.reason || "Not available right now" })
|
|
5115
|
+
] })
|
|
5116
|
+
] }) });
|
|
4831
5117
|
}
|
|
4832
5118
|
function SearchGlyph() {
|
|
4833
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
5119
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
|
|
4834
5120
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "7" }),
|
|
4835
5121
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m20 20-3.5-3.5" })
|
|
4836
5122
|
] });
|
|
4837
5123
|
}
|
|
4838
|
-
function
|
|
4839
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
5124
|
+
function CloseGlyph() {
|
|
5125
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
|
|
5126
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18" }),
|
|
5127
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12" })
|
|
5128
|
+
] });
|
|
5129
|
+
}
|
|
5130
|
+
function ArrowLeftGlyph() {
|
|
5131
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
4840
5132
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
|
|
4841
5133
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
|
|
4842
5134
|
] });
|
|
4843
5135
|
}
|
|
4844
|
-
var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
|
|
4845
5136
|
function TokenSelect(props) {
|
|
4846
|
-
const
|
|
5137
|
+
const side = props.side ?? "from";
|
|
4847
5138
|
const [query, setQuery] = react.useState("");
|
|
4848
|
-
const
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
const
|
|
4853
|
-
const
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
5139
|
+
const [openKey, setOpenKey] = react.useState(null);
|
|
5140
|
+
const listRef = react.useRef(null);
|
|
5141
|
+
const savedScroll = react.useRef(0);
|
|
5142
|
+
const chainById2 = react.useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
|
|
5143
|
+
const chainName3 = (chainId) => CHAIN_LABELS[chainId] || chainById2.get(chainId)?.displayName || chainById2.get(chainId)?.name || `Chain ${chainId}`;
|
|
5144
|
+
const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
|
|
5145
|
+
const [prices, setPrices] = react.useState({});
|
|
5146
|
+
const symbolKey2 = react.useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
|
|
5147
|
+
const fetchPrices = props.fetchPrices;
|
|
5148
|
+
react.useEffect(() => {
|
|
5149
|
+
if (!showBalances || !fetchPrices || !symbolKey2) return;
|
|
5150
|
+
let alive = true;
|
|
5151
|
+
let timer2;
|
|
5152
|
+
const ask = (retriesLeft) => {
|
|
5153
|
+
fetchPrices(symbolKey2.split(",")).then((next) => {
|
|
5154
|
+
if (!alive) return;
|
|
5155
|
+
setPrices(next);
|
|
5156
|
+
if (!Object.keys(next).length && retriesLeft > 0) timer2 = setTimeout(() => ask(retriesLeft - 1), retriesLeft > 1 ? 5e3 : 2e4);
|
|
5157
|
+
}).catch(() => {
|
|
5158
|
+
});
|
|
4866
5159
|
};
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
{
|
|
4879
|
-
chain: c,
|
|
4880
|
-
label: chainBadge(Number(c.chainId)),
|
|
4881
|
-
name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
|
|
4882
|
-
selected: activeFilter === Number(c.chainId),
|
|
4883
|
-
onClick: () => setChainFilter(Number(c.chainId))
|
|
4884
|
-
},
|
|
4885
|
-
c.chainId
|
|
4886
|
-
))
|
|
4887
|
-
] }),
|
|
4888
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-search", children: [
|
|
4889
|
-
/* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
|
|
4890
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: true, placeholder: "Search by token, network or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token, network or address" })
|
|
4891
|
-
] }),
|
|
4892
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
|
|
4893
|
-
const chainId = Number(t.chainId);
|
|
4894
|
-
const key = rowKey(t);
|
|
4895
|
-
const bal = props.balances?.[key];
|
|
5160
|
+
ask(2);
|
|
5161
|
+
return () => {
|
|
5162
|
+
alive = false;
|
|
5163
|
+
if (timer2) clearTimeout(timer2);
|
|
5164
|
+
};
|
|
5165
|
+
}, [showBalances, fetchPrices, symbolKey2]);
|
|
5166
|
+
const groups = react.useMemo(() => {
|
|
5167
|
+
const deployments = [];
|
|
5168
|
+
for (const token of props.tokens) {
|
|
5169
|
+
const key = rowKey(token);
|
|
5170
|
+
const n = Number(props.balances?.[key]?.formatted);
|
|
4896
5171
|
const st = props.optionStates?.[key];
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
5172
|
+
if (st?.disabled && !WALLET_STATE_REASONS.has(String(st.reason))) continue;
|
|
5173
|
+
deployments.push({
|
|
5174
|
+
token,
|
|
5175
|
+
key,
|
|
5176
|
+
balance: showBalances && props.balances?.[key] && Number.isFinite(n) ? n : null,
|
|
5177
|
+
disabled: !!st?.disabled,
|
|
5178
|
+
// The line under a greyed row says why. Callers send either a sentence in `reason` (the
|
|
5179
|
+
// exchange's "cannot be delivered on this chain") or a machine code there with the words in
|
|
5180
|
+
// `hint` (the deposit card's "no-balance" / "No balance on this chain").
|
|
5181
|
+
reason: st?.disabled ? st.reason && /\s/.test(st.reason) ? st.reason : st.hint || st.reason : void 0,
|
|
5182
|
+
hint: st?.disabled ? void 0 : st?.hint
|
|
5183
|
+
});
|
|
5184
|
+
}
|
|
5185
|
+
return groupDeployments(deployments, prices);
|
|
5186
|
+
}, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
|
|
5187
|
+
const chainTerms = react.useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
|
|
5188
|
+
const visible = react.useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
|
|
5189
|
+
const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
|
|
5190
|
+
react.useEffect(() => {
|
|
5191
|
+
if (openKey && !openGroup) setOpenKey(null);
|
|
5192
|
+
}, [openKey, openGroup]);
|
|
5193
|
+
react.useLayoutEffect(() => {
|
|
5194
|
+
if (!openKey && listRef.current) listRef.current.scrollTop = savedScroll.current;
|
|
5195
|
+
}, [openKey]);
|
|
5196
|
+
const selected = props.selected;
|
|
5197
|
+
const isSelected = (t) => isPick(selected, t);
|
|
5198
|
+
const pick = (t) => props.onPick({ chainId: Number(t.chainId), symbol: t.symbol });
|
|
5199
|
+
const selectedRow = react.useMemo(() => {
|
|
5200
|
+
if (!selected) return null;
|
|
5201
|
+
for (const g of groups) for (const d of g.deployments) if (!d.disabled && isPick(selected, d.token)) return d;
|
|
5202
|
+
return null;
|
|
5203
|
+
}, [groups, selected]);
|
|
5204
|
+
const head = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-head", children: [
|
|
5205
|
+
openGroup ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-backlink", onClick: () => setOpenKey(null), children: [
|
|
5206
|
+
/* @__PURE__ */ jsxRuntime.jsx(ArrowLeftGlyph, {}),
|
|
5207
|
+
"Tokens"
|
|
5208
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-title", children: props.title }),
|
|
5209
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-pk-close", onClick: props.onBack, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, {}) })
|
|
5210
|
+
] });
|
|
5211
|
+
if (openGroup) {
|
|
5212
|
+
const sym = openGroup.symbol;
|
|
5213
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk", "data-step": "network", children: [
|
|
5214
|
+
head,
|
|
5215
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-intro", children: [
|
|
5216
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-title", children: [
|
|
5217
|
+
side === "from" ? "Pay with" : "Receive",
|
|
5218
|
+
" ",
|
|
5219
|
+
sym
|
|
5220
|
+
] }),
|
|
5221
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-lead", children: side === "from" ? "Choose the network to pay from" : `Choose the network to receive ${sym} on` })
|
|
5222
|
+
] }),
|
|
5223
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", role: "group", "aria-label": "Select network", children: openGroup.deployments.map((d) => {
|
|
5224
|
+
const id = Number(d.token.chainId);
|
|
5225
|
+
const name = chainName3(id);
|
|
5226
|
+
if (d.disabled) {
|
|
5227
|
+
return /* @__PURE__ */ jsxRuntime.jsx(UnavailableRow, { icon: /* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: chainById2.get(id), size: "row" }), label: name, reason: d.reason, testId: "network-row-unavailable" }, d.key);
|
|
5228
|
+
}
|
|
5229
|
+
const sel = isSelected(d.token);
|
|
5230
|
+
const ticker = tokenTicker(d.token);
|
|
5231
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-row sg-pk-row--net", "data-testid": "network-row", "data-selected": sel || void 0, "aria-pressed": sel, title: name, onClick: () => pick(d.token), children: [
|
|
5232
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
5233
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-chainwrap", children: [
|
|
5234
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: chainById2.get(id), size: "row" }),
|
|
5235
|
+
sel ? /* @__PURE__ */ jsxRuntime.jsx(TickBadge, {}) : null
|
|
4912
5236
|
] }),
|
|
4913
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
5237
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
5238
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-label", children: [
|
|
5239
|
+
name,
|
|
5240
|
+
ticker !== sym ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-alt", children: ticker }) : null
|
|
5241
|
+
] }),
|
|
5242
|
+
d.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
|
|
4917
5243
|
] })
|
|
4918
|
-
]
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
)
|
|
4922
|
-
|
|
5244
|
+
] }),
|
|
5245
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
|
|
5246
|
+
] }, d.key);
|
|
5247
|
+
}) })
|
|
5248
|
+
] });
|
|
5249
|
+
}
|
|
5250
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk", "data-step": "token", children: [
|
|
5251
|
+
head,
|
|
5252
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "sg-pk-search", children: [
|
|
5253
|
+
/* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
|
|
5254
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: true, placeholder: "Search by token or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token or address" }),
|
|
5255
|
+
query ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-pk-clear", onClick: () => setQuery(""), "aria-label": "Clear token search", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, {}) }) : null
|
|
5256
|
+
] }),
|
|
5257
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-body", children: [
|
|
5258
|
+
selectedRow ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-selected", children: [
|
|
5259
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: "Selected" }),
|
|
5260
|
+
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-row", "data-testid": "selected-row", "data-selected": "true", "aria-pressed": "true", onClick: () => pick(selectedRow.token), children: [
|
|
5261
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
5262
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: selectedRow.token.symbol, logoUrl: selectedRow.token.logoUrl, checked: true }),
|
|
5263
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
5264
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: tokenTicker(selectedRow.token) }),
|
|
5265
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
5266
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-sub", children: [
|
|
5267
|
+
"On ",
|
|
5268
|
+
chainName3(Number(selectedRow.token.chainId))
|
|
5269
|
+
] }),
|
|
5270
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: [Number(selectedRow.token.chainId)], chainById: chainById2, decorative: true })
|
|
5271
|
+
] })
|
|
5272
|
+
] })
|
|
5273
|
+
] }),
|
|
5274
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5275
|
+
BalanceColumn,
|
|
5276
|
+
{
|
|
5277
|
+
amount: selectedRow.balance,
|
|
5278
|
+
usd: usdOf(selectedRow.balance, prices, selectedRow.token.symbol),
|
|
5279
|
+
symbol: tokenTicker(selectedRow.token)
|
|
5280
|
+
}
|
|
5281
|
+
) : null
|
|
5282
|
+
] })
|
|
5283
|
+
] }) : null,
|
|
5284
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
|
|
5285
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) : visible.map((g) => {
|
|
5286
|
+
const members = g.deployments;
|
|
5287
|
+
const multi = members.length > 1;
|
|
5288
|
+
const single = members[0];
|
|
5289
|
+
const label = multi ? g.symbol : tokenTicker(single.token);
|
|
5290
|
+
const blocked = !!g.unavailable;
|
|
5291
|
+
const opensNetworks = multi || blocked;
|
|
5292
|
+
const zero = showBalances && g.amount === 0 || blocked;
|
|
5293
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5294
|
+
"button",
|
|
5295
|
+
{
|
|
5296
|
+
type: "button",
|
|
5297
|
+
className: "sg-pk-row",
|
|
5298
|
+
"data-testid": "token-row",
|
|
5299
|
+
"data-symbol": g.symbol,
|
|
5300
|
+
"data-networks": members.length,
|
|
5301
|
+
"data-zero": zero || void 0,
|
|
5302
|
+
"data-unavailable": blocked || void 0,
|
|
5303
|
+
onClick: () => {
|
|
5304
|
+
if (opensNetworks) {
|
|
5305
|
+
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
5306
|
+
setOpenKey(g.key);
|
|
5307
|
+
} else pick(single.token);
|
|
5308
|
+
},
|
|
5309
|
+
children: [
|
|
5310
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
|
|
5311
|
+
/* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
5312
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
|
|
5313
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label }),
|
|
5314
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
|
|
5315
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
5316
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi }),
|
|
5317
|
+
opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
5318
|
+
] }),
|
|
5319
|
+
!multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
5320
|
+
] })
|
|
5321
|
+
] }),
|
|
5322
|
+
showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label }) : opensNetworks ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
|
|
5323
|
+
]
|
|
5324
|
+
},
|
|
5325
|
+
g.key
|
|
5326
|
+
);
|
|
5327
|
+
}) })
|
|
5328
|
+
] })
|
|
4923
5329
|
] });
|
|
4924
5330
|
}
|
|
4925
5331
|
function ChevronRight({ size = 16 }) {
|
|
@@ -4937,7 +5343,7 @@ function ArrowDown({ size = 16 }) {
|
|
|
4937
5343
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.667 8L8 12.667 3.333 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
4938
5344
|
] });
|
|
4939
5345
|
}
|
|
4940
|
-
function
|
|
5346
|
+
function CloseGlyph2() {
|
|
4941
5347
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
4942
5348
|
}
|
|
4943
5349
|
function ShieldTickGlyph({ size = 16 }) {
|
|
@@ -4977,7 +5383,7 @@ function AmountText({ value, suffix, exact }) {
|
|
|
4977
5383
|
suffix ? ` ${suffix}` : null
|
|
4978
5384
|
] });
|
|
4979
5385
|
}
|
|
4980
|
-
function
|
|
5386
|
+
function usdOf2(amount, price) {
|
|
4981
5387
|
const n = typeof amount === "number" ? amount : Number(amount);
|
|
4982
5388
|
if (!Number.isFinite(n) || n <= 0 || price === void 0 || !Number.isFinite(price) || price <= 0) return null;
|
|
4983
5389
|
const usd2 = n * price;
|
|
@@ -5107,7 +5513,7 @@ function WidgetShell(props) {
|
|
|
5107
5513
|
] }),
|
|
5108
5514
|
props.onClose ? (
|
|
5109
5515
|
// type="button": a host page may wrap the widget in a <form>.
|
|
5110
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5516
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph2, {}) })
|
|
5111
5517
|
) : null
|
|
5112
5518
|
] })
|
|
5113
5519
|
] }),
|
|
@@ -5403,7 +5809,7 @@ function useTxHistory(account) {
|
|
|
5403
5809
|
}, [account]);
|
|
5404
5810
|
return entries;
|
|
5405
5811
|
}
|
|
5406
|
-
function
|
|
5812
|
+
function BackGlyph() {
|
|
5407
5813
|
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
5408
5814
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
|
|
5409
5815
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
|
|
@@ -5645,7 +6051,7 @@ function TxHistoryPanel(props) {
|
|
|
5645
6051
|
};
|
|
5646
6052
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
5647
6053
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
|
|
5648
|
-
/* @__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(
|
|
6054
|
+
/* @__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(BackGlyph, {}) }),
|
|
5649
6055
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
|
|
5650
6056
|
selected ? "Transaction" : "Transaction history",
|
|
5651
6057
|
account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress2(account) }) : null
|
|
@@ -6401,6 +6807,9 @@ function PaymentIsland(props) {
|
|
|
6401
6807
|
TokenSelect,
|
|
6402
6808
|
{
|
|
6403
6809
|
title: "Pay with",
|
|
6810
|
+
side: "from",
|
|
6811
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
6812
|
+
fetchPrices: engine.fetchPrices,
|
|
6404
6813
|
chains: fundingChains,
|
|
6405
6814
|
tokens: fundingTokens,
|
|
6406
6815
|
balances: holdings.balances,
|
|
@@ -6416,6 +6825,9 @@ function PaymentIsland(props) {
|
|
|
6416
6825
|
TokenSelect,
|
|
6417
6826
|
{
|
|
6418
6827
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
6828
|
+
side: isFrom ? "from" : "to",
|
|
6829
|
+
selected: isFrom ? exFrom : exTo,
|
|
6830
|
+
fetchPrices: engine.fetchPrices,
|
|
6419
6831
|
chains,
|
|
6420
6832
|
tokens: isFrom ? exFromPicker : exToPicker,
|
|
6421
6833
|
balances: exBalances,
|
|
@@ -6960,6 +7372,9 @@ function PayCard(props) {
|
|
|
6960
7372
|
TokenSelect,
|
|
6961
7373
|
{
|
|
6962
7374
|
title: "Pay with",
|
|
7375
|
+
side: "from",
|
|
7376
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
7377
|
+
fetchPrices: engine.fetchPrices,
|
|
6963
7378
|
chains: fundingChains,
|
|
6964
7379
|
tokens: fundingTokens,
|
|
6965
7380
|
balances: listBalances,
|
|
@@ -7007,7 +7422,7 @@ function PayCard(props) {
|
|
|
7007
7422
|
}
|
|
7008
7423
|
)
|
|
7009
7424
|
] }),
|
|
7010
|
-
/* @__PURE__ */ jsxRuntime.jsx(PaneFoot, { usd: sel && selectedVisible ?
|
|
7425
|
+
/* @__PURE__ */ jsxRuntime.jsx(PaneFoot, { usd: sel && selectedVisible ? usdOf2(sel.source.payAmount, prices[selSymbol]) : null, balance: selBal ? shortBalance(selBal.formatted) : null })
|
|
7011
7426
|
] }),
|
|
7012
7427
|
loadingPlan ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pay-loading", "data-testid": "pay-loading", role: "status", children: [
|
|
7013
7428
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel sg-skel--row" }),
|
|
@@ -7519,8 +7934,8 @@ function ExchangeCard(props) {
|
|
|
7519
7934
|
const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
|
|
7520
7935
|
const compliance = selected?.quote.compliance;
|
|
7521
7936
|
const complianceHasQuote = Boolean(selected && flow.status !== "loading");
|
|
7522
|
-
const fromUsd =
|
|
7523
|
-
const toUsd =
|
|
7937
|
+
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
7938
|
+
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
7524
7939
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
7525
7940
|
const flip = () => {
|
|
7526
7941
|
if (!flippable) return;
|
|
@@ -7603,6 +8018,9 @@ function ExchangeCard(props) {
|
|
|
7603
8018
|
TokenSelect,
|
|
7604
8019
|
{
|
|
7605
8020
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
8021
|
+
side: isFrom ? "from" : "to",
|
|
8022
|
+
selected: isFrom ? from : to,
|
|
8023
|
+
fetchPrices: engine.fetchPrices,
|
|
7606
8024
|
chains,
|
|
7607
8025
|
tokens: isFrom ? fromPickerTokens : toPickerVisible,
|
|
7608
8026
|
balances,
|