@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, amountFieldError, SUPPORTED_CHAIN_IDS, formatUnits, complianceChecks, DIRECT_CHECK_IDS, createEngine, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction,
|
|
2
|
-
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, createElement, useContext,
|
|
1
|
+
import { CHAIN_DISPLAY_NAMES, EXECUTABLE_STABLE_ASSETS, STABLE_ASSETS, SUPPORTED_ASSETS, complianceView, complianceTagOf, symbolKey, normalizeDecimalText, findToken, laneLimitFor, laneLimitSymbol, tokenTicker, exceedsLaneLimit, assetDecimals, parseUnitsDecimal, counterpartTokens, assetClassOf, brokenLaneFor, brokenLaneReason, destinationAvailability, laneLimitHint, tickerOn, laneLimitError, routeNativeValue, formatNative, nativeSymbol, amountFieldError, SUPPORTED_CHAIN_IDS, formatUnits, complianceChecks, DIRECT_CHECK_IDS, createEngine, checkNativeFee, nativeFeeShortLabel, nativeFeeShortMessage, allowanceCovers, validatePlannedTransaction, unattributedComplianceReasons, distinctScreenedWallets, formatJurisdiction, humanizeComplianceReason, DIRECT_SCOPE_NOTE, categoryLabel, SCREENING_BUCKETS, BUNDLED_RPC, foldTicker } from './chunk-A7ADZJXA.js';
|
|
2
|
+
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useId, createElement, useContext, useLayoutEffect, useSyncExternalStore, useReducer } from 'react';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -952,46 +952,79 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
952
952
|
.sg-pct:hover:not(:disabled){color:var(--sg-accent)}
|
|
953
953
|
.sg-pct:disabled{opacity:.55;cursor:not-allowed}
|
|
954
954
|
|
|
955
|
-
/* full-panel
|
|
955
|
+
/* full-panel takeover head (transaction history) */
|
|
956
956
|
.sg-sel-head{display:flex;align-items:center;margin-bottom:14px}
|
|
957
957
|
.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}
|
|
958
958
|
.sg-back:hover{background:var(--sg-surface)}
|
|
959
959
|
.sg-sel-title{flex:1 1 auto;min-width:0;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
|
|
960
960
|
/* Whose transactions these are \u2014 history is per wallet, and the takeover hides the header's pill. */
|
|
961
961
|
.sg-sel-sub{display:block;font-size:11px;font-weight:600;color:var(--sg-text-muted);margin-top:1px}
|
|
962
|
-
/* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
|
|
963
|
-
(9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
|
|
964
|
-
the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
|
|
965
|
-
.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)}
|
|
966
|
-
/* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
|
|
967
|
-
.sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
|
|
968
|
-
.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}
|
|
969
|
-
.sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
|
|
970
|
-
.sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
|
|
971
|
-
.sg-chain-chip[data-selected="true"]{border-color:var(--sg-accent);background:color-mix(in srgb,var(--sg-accent) 10%,var(--sg-surface))}
|
|
972
|
-
.sg-search{position:relative;margin-bottom:10px}
|
|
973
|
-
.sg-search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--sg-text-muted);pointer-events:none}
|
|
974
|
-
.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}
|
|
975
|
-
.sg-search input:focus{border-color:var(--sg-accent)}
|
|
976
962
|
.sg-toklist{display:flex;flex-direction:column;gap:2px;max-height:320px;overflow-y:auto;margin:0 -6px;padding:0 6px;scrollbar-width:thin}
|
|
977
|
-
.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}
|
|
978
|
-
.sg-tokrow:hover{background:var(--sg-surface)}
|
|
979
|
-
.sg-tokrow-main{flex:1 1 auto;min-width:0}
|
|
980
|
-
.sg-tokrow-sym{display:block;font-size:15px;font-weight:700;line-height:1.2}
|
|
981
|
-
.sg-tokrow-name{display:block;font-size:12px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
982
|
-
.sg-tokrow-end{flex:0 0 auto;text-align:right}
|
|
983
|
-
.sg-tokrow-bal{display:block;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}
|
|
984
|
-
.sg-tokrow-chain{display:block;font-size:11px;color:var(--sg-text-muted)}
|
|
985
|
-
/* funding rows the wallet can't cover (zero / insufficient): greyed, non-interactive, reason hint.
|
|
986
|
-
Mirrors RouteList's data-short dim + warn tone; no hover lift. Theme-aware via --sg-* vars. */
|
|
987
|
-
.sg-tokrow--off,.sg-tokrow[disabled]{opacity:.5;cursor:not-allowed}
|
|
988
|
-
.sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
|
|
989
|
-
.sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
|
|
990
|
-
.sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
|
|
991
|
-
/* on a row that stays selectable (a limited lane): a caveat, not a refusal */
|
|
992
|
-
.sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
|
|
993
963
|
.sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
|
|
994
964
|
|
|
965
|
+
/* Token picker, token first then network \u2014 the ZeroDelta dapp's TokenSelectModal (Figma 708:27430,
|
|
966
|
+
2517:52576), drawn in the widget's own theme: the dapp's brand tint is the accent, its green the
|
|
967
|
+
success token. Geometry is the dapp's: 32px plates, 24px row plates, 16px chain marks, 20px gaps. The list keeps
|
|
968
|
+
the previous picker's 320px cap so opening it does not grow the card. */
|
|
969
|
+
.sg-pk{display:flex;flex-direction:column;gap:20px}
|
|
970
|
+
.sg-pk-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
971
|
+
.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)}
|
|
972
|
+
.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}
|
|
973
|
+
.sg-pk-clear{padding:2px}
|
|
974
|
+
.sg-pk-close:hover,.sg-pk-clear:hover{color:var(--sg-text)}
|
|
975
|
+
.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}
|
|
976
|
+
.sg-pk-backlink:hover{color:var(--sg-text)}
|
|
977
|
+
.sg-pk-intro{display:flex;flex-direction:column;gap:4px}
|
|
978
|
+
.sg-pk-lead{margin:0;font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
|
|
979
|
+
.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}
|
|
980
|
+
.sg-pk-search:focus-within{border-color:var(--sg-accent);color:var(--sg-accent)}
|
|
981
|
+
.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}
|
|
982
|
+
.sg-pk-search input::placeholder{color:var(--sg-text-muted)}
|
|
983
|
+
.sg-pk-body{display:flex;flex-direction:column;gap:8px}
|
|
984
|
+
.sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
|
|
985
|
+
.sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
|
|
986
|
+
.sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
|
|
987
|
+
.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}
|
|
988
|
+
.sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
|
|
989
|
+
.sg-pk-row--net{padding:20px 16px}
|
|
990
|
+
.sg-pk-row[data-zero]{background:color-mix(in srgb,var(--sg-text) 4%,transparent)}
|
|
991
|
+
.sg-pk-row[data-zero]:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
|
|
992
|
+
.sg-pk-row[data-selected]{background:color-mix(in srgb,var(--sg-success) 6%,transparent)}
|
|
993
|
+
.sg-pk-row[data-selected]:hover{background:color-mix(in srgb,var(--sg-success) 8%,transparent)}
|
|
994
|
+
.sg-pk-row--off{opacity:.6;cursor:default}
|
|
995
|
+
.sg-pk-row--off:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
|
|
996
|
+
.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}
|
|
997
|
+
.sg-pk-left{display:flex;align-items:center;gap:12px;flex:1 1 auto;min-width:0}
|
|
998
|
+
.sg-pk-text{display:flex;flex-direction:column;align-items:flex-start;gap:2px;flex:1 1 auto;min-width:0;overflow:hidden}
|
|
999
|
+
.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%}
|
|
1000
|
+
.sg-pk-alt{margin-left:8px;font-size:14px;font-weight:400;color:var(--sg-text-muted)}
|
|
1001
|
+
.sg-pk-line{display:flex;align-items:center;gap:4px;min-width:0;max-width:100%}
|
|
1002
|
+
.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}
|
|
1003
|
+
.sg-pk-note{font-size:13px;line-height:1.3;color:var(--sg-text-muted)}
|
|
1004
|
+
.sg-pk-plate,.sg-pk-chainwrap{position:relative;display:grid;place-items:center;flex:0 0 auto;width:32px;height:32px}
|
|
1005
|
+
.sg-pk-plate-in{display:grid;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:16px;background:var(--sg-surface)}
|
|
1006
|
+
.sg-pk-plate-in img{width:32px;height:32px;display:block;object-fit:cover}
|
|
1007
|
+
.sg-pk-plate-fb{font-size:10px;font-weight:700;color:var(--sg-accent)}
|
|
1008
|
+
.sg-pk-plate[data-muted] .sg-pk-plate-in{filter:grayscale(1)}
|
|
1009
|
+
.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)}
|
|
1010
|
+
.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)}
|
|
1011
|
+
.sg-pk-chain img{width:32px;height:32px;display:block;object-fit:cover}
|
|
1012
|
+
.sg-pk-marks{display:flex;align-items:center;gap:4px;flex:0 0 auto}
|
|
1013
|
+
.sg-pk-stack{display:flex;align-items:center;height:18px}
|
|
1014
|
+
.sg-pk-markwrap{display:grid;flex:0 0 auto}
|
|
1015
|
+
.sg-pk-markwrap+.sg-pk-markwrap{margin-left:-2px}
|
|
1016
|
+
.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)}
|
|
1017
|
+
.sg-pk-mark img{width:16px;height:16px;display:block;object-fit:cover}
|
|
1018
|
+
.sg-pk-more{font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
|
|
1019
|
+
.sg-pk-chev{display:grid;place-items:center;flex:0 0 auto;width:16px;height:16px;color:var(--sg-text-muted)}
|
|
1020
|
+
.sg-pk-chev svg{width:16px;height:16px}
|
|
1021
|
+
.sg-pk-chev--sm,.sg-pk-chev--sm svg{width:14px;height:14px}
|
|
1022
|
+
.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}
|
|
1023
|
+
.sg-pk-bal-usd{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
|
|
1024
|
+
.sg-pk-bal-amt{font-size:13px;line-height:1.4;color:var(--sg-text-muted)}
|
|
1025
|
+
.sg-pk-bal-zero{flex:0 0 auto;font-size:16px;font-weight:700;color:var(--sg-t35)}
|
|
1026
|
+
.sg-pk-empty{margin:0;padding:32px 0;text-align:center;font-size:14px;color:var(--sg-text-muted)}
|
|
1027
|
+
|
|
995
1028
|
/* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
|
|
996
1029
|
OWN available width (container query) \u2014 an embedded widget cannot infer the host layout from the
|
|
997
1030
|
viewport. The viewport media query stays as a fallback for engines without container queries. */
|
|
@@ -1938,6 +1971,200 @@ function chainLogoCandidates(chainId, logoUrl) {
|
|
|
1938
1971
|
if (bundled) out.push(bundled);
|
|
1939
1972
|
return out;
|
|
1940
1973
|
}
|
|
1974
|
+
|
|
1975
|
+
// src/react/ui/tokenGroups.ts
|
|
1976
|
+
var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
|
|
1977
|
+
var CHAIN_TVL_ORDER = [
|
|
1978
|
+
1,
|
|
1979
|
+
1151111081099710,
|
|
1980
|
+
8453,
|
|
1981
|
+
56,
|
|
1982
|
+
42161,
|
|
1983
|
+
999,
|
|
1984
|
+
143,
|
|
1985
|
+
4663,
|
|
1986
|
+
137,
|
|
1987
|
+
9745,
|
|
1988
|
+
43114,
|
|
1989
|
+
10,
|
|
1990
|
+
196,
|
|
1991
|
+
57073,
|
|
1992
|
+
14,
|
|
1993
|
+
5e3,
|
|
1994
|
+
2818,
|
|
1995
|
+
30,
|
|
1996
|
+
4217,
|
|
1997
|
+
747474,
|
|
1998
|
+
1672,
|
|
1999
|
+
988,
|
|
2000
|
+
480,
|
|
2001
|
+
81457,
|
|
2002
|
+
1329,
|
|
2003
|
+
80094,
|
|
2004
|
+
130,
|
|
2005
|
+
4326,
|
|
2006
|
+
59144,
|
|
2007
|
+
2222,
|
|
2008
|
+
252,
|
|
2009
|
+
146,
|
|
2010
|
+
324,
|
|
2011
|
+
1776,
|
|
2012
|
+
534352,
|
|
2013
|
+
1030,
|
|
2014
|
+
1868,
|
|
2015
|
+
98866,
|
|
2016
|
+
169,
|
|
2017
|
+
1088,
|
|
2018
|
+
50,
|
|
2019
|
+
34443,
|
|
2020
|
+
1135,
|
|
2021
|
+
88,
|
|
2022
|
+
48900,
|
|
2023
|
+
151,
|
|
2024
|
+
7777777,
|
|
2025
|
+
1923,
|
|
2026
|
+
3343,
|
|
2027
|
+
81224,
|
|
2028
|
+
21e6
|
|
2029
|
+
];
|
|
2030
|
+
var TOKEN_MARKET_CAP_ORDER = ["USDT", "USDC", "USDS", "DAI", "USDE", "USD1", "USDG", "PYUSD", "XAUT", "RLUSD", "USDF", "GHO", "USD0", "USDTB", "AUSD", "WM"];
|
|
2031
|
+
var CHAIN_RANK = new Map(CHAIN_TVL_ORDER.map((chainId, index) => [chainId, index]));
|
|
2032
|
+
var TOKEN_RANK = new Map(TOKEN_MARKET_CAP_ORDER.map((symbol, index) => [symbol, index]));
|
|
2033
|
+
function chainTvlRank(chainId) {
|
|
2034
|
+
return CHAIN_RANK.get(Number(chainId)) ?? CHAIN_TVL_ORDER.length;
|
|
2035
|
+
}
|
|
2036
|
+
function tokenMarketCapRank(symbol) {
|
|
2037
|
+
return TOKEN_RANK.get(String(symbol).toUpperCase()) ?? TOKEN_MARKET_CAP_ORDER.length;
|
|
2038
|
+
}
|
|
2039
|
+
function dominantSymbol(tokens) {
|
|
2040
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2041
|
+
for (const t of tokens) counts.set(t.symbol, (counts.get(t.symbol) ?? 0) + 1);
|
|
2042
|
+
let best = tokens[0].symbol;
|
|
2043
|
+
for (const [symbol, count] of counts) if (count > (counts.get(best) ?? 0)) best = symbol;
|
|
2044
|
+
return best;
|
|
2045
|
+
}
|
|
2046
|
+
function priceOf(prices, symbol) {
|
|
2047
|
+
const p = prices?.[String(symbol).toUpperCase()];
|
|
2048
|
+
return typeof p === "number" && Number.isFinite(p) ? p : void 0;
|
|
2049
|
+
}
|
|
2050
|
+
function buildGroup(key, members, prices) {
|
|
2051
|
+
const tokens = members.map((m) => m.token);
|
|
2052
|
+
let amount = null;
|
|
2053
|
+
let usd = null;
|
|
2054
|
+
for (const m of members) {
|
|
2055
|
+
if (m.balance == null) continue;
|
|
2056
|
+
amount = (amount ?? 0) + m.balance;
|
|
2057
|
+
const price = priceOf(prices, m.token.symbol);
|
|
2058
|
+
if (price !== void 0) usd = (usd ?? 0) + m.balance * price;
|
|
2059
|
+
}
|
|
2060
|
+
const first = members[0].token;
|
|
2061
|
+
return {
|
|
2062
|
+
key,
|
|
2063
|
+
symbol: dominantSymbol(tokens),
|
|
2064
|
+
name: String(first.name || first.symbol),
|
|
2065
|
+
logoUrl: first.logoUrl,
|
|
2066
|
+
deployments: members,
|
|
2067
|
+
unavailable: members.every((m) => m.disabled) ? { reason: members.find((m) => m.reason)?.reason } : null,
|
|
2068
|
+
amount,
|
|
2069
|
+
usd
|
|
2070
|
+
};
|
|
2071
|
+
}
|
|
2072
|
+
function byDeployment(a, b) {
|
|
2073
|
+
return Number(a.disabled) - Number(b.disabled) || (b.balance ?? 0) - (a.balance ?? 0) || chainTvlRank(a.token.chainId) - chainTvlRank(b.token.chainId);
|
|
2074
|
+
}
|
|
2075
|
+
function byPickability(a, b) {
|
|
2076
|
+
const zero = (g) => g.amount === 0 ? 1 : 0;
|
|
2077
|
+
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);
|
|
2078
|
+
}
|
|
2079
|
+
function groupDeployments(deployments, prices) {
|
|
2080
|
+
const order = [];
|
|
2081
|
+
const members = /* @__PURE__ */ new Map();
|
|
2082
|
+
for (const d of [...deployments].sort(byDeployment)) {
|
|
2083
|
+
const key = String(d.token.symbol).toUpperCase();
|
|
2084
|
+
const list = members.get(key);
|
|
2085
|
+
if (list) list.push(d);
|
|
2086
|
+
else {
|
|
2087
|
+
members.set(key, [d]);
|
|
2088
|
+
order.push(key);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
return order.map((key) => buildGroup(key, members.get(key), prices)).sort(byPickability);
|
|
2092
|
+
}
|
|
2093
|
+
var CHAIN_ALIASES = {
|
|
2094
|
+
56: ["bsc", "binance"],
|
|
2095
|
+
137: ["matic"],
|
|
2096
|
+
43114: ["avax"]
|
|
2097
|
+
};
|
|
2098
|
+
function labelForms(label) {
|
|
2099
|
+
const lower = label.trim().toLowerCase();
|
|
2100
|
+
if (!lower) return [];
|
|
2101
|
+
const compact = lower.replace(/[^a-z0-9]/g, "");
|
|
2102
|
+
return compact && compact !== lower ? [lower, compact] : [lower];
|
|
2103
|
+
}
|
|
2104
|
+
function buildChainSearchTerms(chains) {
|
|
2105
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2106
|
+
const ids = /* @__PURE__ */ new Set([...chains.map((c) => Number(c.chainId)), ...Object.keys(CHAIN_LABELS).map(Number)]);
|
|
2107
|
+
for (const id of ids) {
|
|
2108
|
+
const chain = chains.find((c) => Number(c.chainId) === id);
|
|
2109
|
+
const terms = /* @__PURE__ */ new Set();
|
|
2110
|
+
for (const label of [chain?.displayName, chain?.name, typeof chain?.slug === "string" ? chain.slug : void 0, CHAIN_LABELS[id]]) {
|
|
2111
|
+
if (label) for (const form of labelForms(label)) terms.add(form);
|
|
2112
|
+
}
|
|
2113
|
+
for (const alias of CHAIN_ALIASES[id] ?? []) terms.add(alias);
|
|
2114
|
+
byId.set(id, [...terms]);
|
|
2115
|
+
}
|
|
2116
|
+
return byId;
|
|
2117
|
+
}
|
|
2118
|
+
function splitSearchTerms(query) {
|
|
2119
|
+
return query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
2120
|
+
}
|
|
2121
|
+
function looksLikeAddress(term) {
|
|
2122
|
+
return /^(0x)?[0-9a-f]{4,}$/.test(term);
|
|
2123
|
+
}
|
|
2124
|
+
function chainMatches(term, token, chainTerms) {
|
|
2125
|
+
if (term === String(Number(token.chainId))) return true;
|
|
2126
|
+
return chainTerms.some((chainTerm) => chainTerm.includes(term));
|
|
2127
|
+
}
|
|
2128
|
+
function tokenMatches(term, token, asset) {
|
|
2129
|
+
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.
|
|
2130
|
+
foldTicker(tokenTicker(token)).includes(foldTicker(term)) || String(token.name || "").toLowerCase().includes(term) || looksLikeAddress(term) && String(token.address || "").toLowerCase().includes(term);
|
|
2131
|
+
}
|
|
2132
|
+
function matchingDeployments(terms, group, chainTerms) {
|
|
2133
|
+
if (terms.length === 0) return group.deployments;
|
|
2134
|
+
return group.deployments.filter((d) => {
|
|
2135
|
+
const ct = chainTerms.get(Number(d.token.chainId)) ?? [];
|
|
2136
|
+
return terms.every((term) => tokenMatches(term, d.token, group) || chainMatches(term, d.token, ct));
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
function searchGroups(groups, query, chainTerms, prices) {
|
|
2140
|
+
const terms = splitSearchTerms(query);
|
|
2141
|
+
if (terms.length === 0) return groups;
|
|
2142
|
+
const rows = [];
|
|
2143
|
+
for (const g of groups) {
|
|
2144
|
+
const members = matchingDeployments(terms, g, chainTerms);
|
|
2145
|
+
if (members.length === 0) continue;
|
|
2146
|
+
rows.push(members.length === g.deployments.length ? g : buildGroup(g.key, members, prices));
|
|
2147
|
+
}
|
|
2148
|
+
return rows.sort(byPickability);
|
|
2149
|
+
}
|
|
2150
|
+
function groupDecimal2(value) {
|
|
2151
|
+
const match = value.match(/^([+-]?)(\d+)(\.\d+)?$/);
|
|
2152
|
+
if (!match) return value;
|
|
2153
|
+
return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
|
|
2154
|
+
}
|
|
2155
|
+
function humanAmount(n, maxFrac = 6) {
|
|
2156
|
+
if (!Number.isFinite(n)) return String(n);
|
|
2157
|
+
if (n === 0) return "0";
|
|
2158
|
+
const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
|
|
2159
|
+
const fixed = n.toFixed(digits);
|
|
2160
|
+
const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
|
|
2161
|
+
if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
|
|
2162
|
+
return groupDecimal2(out);
|
|
2163
|
+
}
|
|
2164
|
+
function formatBalanceUsd(value) {
|
|
2165
|
+
if (!Number.isFinite(value) || value <= 0) return "$0.00";
|
|
2166
|
+
return value < 0.01 ? "<$0.01" : `$${value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
2167
|
+
}
|
|
1941
2168
|
var CHAIN_SHORT = {
|
|
1942
2169
|
1: "ETH",
|
|
1943
2170
|
10: "OP",
|
|
@@ -2019,103 +2246,280 @@ function FundingTile(props) {
|
|
|
2019
2246
|
/* @__PURE__ */ jsx("span", { className: "sg-tile-main", children: main })
|
|
2020
2247
|
] });
|
|
2021
2248
|
}
|
|
2022
|
-
function
|
|
2249
|
+
function ChainMark(props) {
|
|
2023
2250
|
const [failed, setFailed] = useState([]);
|
|
2024
|
-
const src = chainLogoCandidates(props.
|
|
2025
|
-
|
|
2026
|
-
|
|
2251
|
+
const src = chainLogoCandidates(props.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
|
|
2252
|
+
return /* @__PURE__ */ jsx("span", { className: props.size === "row" ? "sg-pk-chain" : "sg-pk-mark", "aria-hidden": "true", children: src ? /* @__PURE__ */ jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsx("span", { children: chainBadge(props.chainId) }) });
|
|
2253
|
+
}
|
|
2254
|
+
var MARK_LIMIT = 3;
|
|
2255
|
+
function ChainMarks(props) {
|
|
2256
|
+
const ids = props.chainIds;
|
|
2257
|
+
if (!ids.length) return null;
|
|
2258
|
+
const shown = ids.slice(0, MARK_LIMIT);
|
|
2259
|
+
const overflow = ids.length - shown.length;
|
|
2260
|
+
const marks = shown.map((id) => /* @__PURE__ */ jsx("span", { className: "sg-pk-markwrap", children: /* @__PURE__ */ jsx(ChainMark, { chainId: id, chain: props.chainById.get(id), size: "mini" }) }, id));
|
|
2261
|
+
return /* @__PURE__ */ jsxs("span", { className: "sg-pk-marks", children: [
|
|
2262
|
+
props.decorative ? /* @__PURE__ */ jsx("span", { className: "sg-pk-stack", "aria-hidden": "true", children: marks }) : /* @__PURE__ */ jsx("span", { className: "sg-pk-stack", role: "img", "aria-label": `${ids.length} ${ids.length === 1 ? "network" : "networks"}`, children: marks }),
|
|
2263
|
+
overflow > 0 ? /* @__PURE__ */ jsxs("span", { className: "sg-pk-more", "aria-hidden": "true", children: [
|
|
2264
|
+
"+",
|
|
2265
|
+
overflow
|
|
2266
|
+
] }) : null
|
|
2267
|
+
] });
|
|
2268
|
+
}
|
|
2269
|
+
function TokenPlate(props) {
|
|
2270
|
+
const [failed, setFailed] = useState([]);
|
|
2271
|
+
const src = tokenLogoCandidates(props.symbol, props.logoUrl).find((u) => !failed.includes(u));
|
|
2272
|
+
return /* @__PURE__ */ jsxs("span", { className: "sg-pk-plate", "data-muted": props.muted || void 0, children: [
|
|
2273
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-plate-in", children: src ? /* @__PURE__ */ jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsx("span", { className: "sg-pk-plate-fb", children: props.symbol.slice(0, 4) }) }),
|
|
2274
|
+
props.checked ? /* @__PURE__ */ jsx(TickBadge, {}) : null
|
|
2275
|
+
] });
|
|
2276
|
+
}
|
|
2277
|
+
function TickBadge() {
|
|
2278
|
+
return /* @__PURE__ */ jsx("span", { className: "sg-pk-tick", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
|
|
2279
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "11", fill: "currentColor" }),
|
|
2280
|
+
/* @__PURE__ */ jsx("path", { d: "m7 12.5 3.2 3.2L17 9", stroke: "#fff", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
2281
|
+
] }) });
|
|
2282
|
+
}
|
|
2283
|
+
function BalanceColumn(props) {
|
|
2284
|
+
if (props.amount == null) return null;
|
|
2285
|
+
if (props.amount === 0) return /* @__PURE__ */ jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
|
|
2286
|
+
return /* @__PURE__ */ jsxs("span", { className: "sg-pk-bal", children: [
|
|
2287
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
|
|
2288
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
|
|
2289
|
+
humanAmount(props.amount, 6),
|
|
2290
|
+
" ",
|
|
2291
|
+
props.symbol
|
|
2292
|
+
] })
|
|
2293
|
+
] });
|
|
2294
|
+
}
|
|
2295
|
+
var WALLET_STATE_REASONS = /* @__PURE__ */ new Set(["no-balance", "insufficient"]);
|
|
2296
|
+
function isPick(sel, t) {
|
|
2297
|
+
return !!sel && Number(sel.chainId) === Number(t.chainId) && String(sel.symbol).toUpperCase() === String(t.symbol).toUpperCase();
|
|
2298
|
+
}
|
|
2299
|
+
function usdOf(balance, prices, symbol) {
|
|
2300
|
+
const price = priceOf(prices, symbol);
|
|
2301
|
+
return balance == null || price === void 0 ? null : balance * price;
|
|
2302
|
+
}
|
|
2303
|
+
function UnavailableRow(props) {
|
|
2304
|
+
return /* @__PURE__ */ 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__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2305
|
+
props.icon,
|
|
2306
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2307
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: props.label }),
|
|
2308
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-sub", children: props.reason || "Not available right now" })
|
|
2309
|
+
] })
|
|
2310
|
+
] }) });
|
|
2027
2311
|
}
|
|
2028
2312
|
function SearchGlyph() {
|
|
2029
|
-
return /* @__PURE__ */ jsxs("svg", { width: "
|
|
2313
|
+
return /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
|
|
2030
2314
|
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "7" }),
|
|
2031
2315
|
/* @__PURE__ */ jsx("path", { d: "m20 20-3.5-3.5" })
|
|
2032
2316
|
] });
|
|
2033
2317
|
}
|
|
2034
|
-
function
|
|
2035
|
-
return /* @__PURE__ */ jsxs("svg", { width: "
|
|
2318
|
+
function CloseGlyph() {
|
|
2319
|
+
return /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
|
|
2320
|
+
/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
|
|
2321
|
+
/* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
|
|
2322
|
+
] });
|
|
2323
|
+
}
|
|
2324
|
+
function ArrowLeftGlyph() {
|
|
2325
|
+
return /* @__PURE__ */ 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: [
|
|
2036
2326
|
/* @__PURE__ */ jsx("path", { d: "M19 12H5" }),
|
|
2037
2327
|
/* @__PURE__ */ jsx("path", { d: "m12 19-7-7 7-7" })
|
|
2038
2328
|
] });
|
|
2039
2329
|
}
|
|
2040
|
-
var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
|
|
2041
2330
|
function TokenSelect(props) {
|
|
2042
|
-
const
|
|
2331
|
+
const side = props.side ?? "from";
|
|
2043
2332
|
const [query, setQuery] = useState("");
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
const
|
|
2049
|
-
const
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2333
|
+
const [openKey, setOpenKey] = useState(null);
|
|
2334
|
+
const listRef = useRef(null);
|
|
2335
|
+
const savedScroll = useRef(0);
|
|
2336
|
+
const chainById = useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
|
|
2337
|
+
const chainName3 = (chainId) => CHAIN_LABELS[chainId] || chainById.get(chainId)?.displayName || chainById.get(chainId)?.name || `Chain ${chainId}`;
|
|
2338
|
+
const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
|
|
2339
|
+
const [prices, setPrices] = useState({});
|
|
2340
|
+
const symbolKey2 = useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
|
|
2341
|
+
const fetchPrices = props.fetchPrices;
|
|
2342
|
+
useEffect(() => {
|
|
2343
|
+
if (!showBalances || !fetchPrices || !symbolKey2) return;
|
|
2344
|
+
let alive = true;
|
|
2345
|
+
let timer2;
|
|
2346
|
+
const ask = (retriesLeft) => {
|
|
2347
|
+
fetchPrices(symbolKey2.split(",")).then((next) => {
|
|
2348
|
+
if (!alive) return;
|
|
2349
|
+
setPrices(next);
|
|
2350
|
+
if (!Object.keys(next).length && retriesLeft > 0) timer2 = setTimeout(() => ask(retriesLeft - 1), retriesLeft > 1 ? 5e3 : 2e4);
|
|
2351
|
+
}).catch(() => {
|
|
2352
|
+
});
|
|
2062
2353
|
};
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
{
|
|
2075
|
-
chain: c,
|
|
2076
|
-
label: chainBadge(Number(c.chainId)),
|
|
2077
|
-
name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
|
|
2078
|
-
selected: activeFilter === Number(c.chainId),
|
|
2079
|
-
onClick: () => setChainFilter(Number(c.chainId))
|
|
2080
|
-
},
|
|
2081
|
-
c.chainId
|
|
2082
|
-
))
|
|
2083
|
-
] }),
|
|
2084
|
-
/* @__PURE__ */ jsxs("div", { className: "sg-search", children: [
|
|
2085
|
-
/* @__PURE__ */ jsx(SearchGlyph, {}),
|
|
2086
|
-
/* @__PURE__ */ 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" })
|
|
2087
|
-
] }),
|
|
2088
|
-
/* @__PURE__ */ jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
|
|
2089
|
-
const chainId = Number(t.chainId);
|
|
2090
|
-
const key = rowKey(t);
|
|
2091
|
-
const bal = props.balances?.[key];
|
|
2354
|
+
ask(2);
|
|
2355
|
+
return () => {
|
|
2356
|
+
alive = false;
|
|
2357
|
+
if (timer2) clearTimeout(timer2);
|
|
2358
|
+
};
|
|
2359
|
+
}, [showBalances, fetchPrices, symbolKey2]);
|
|
2360
|
+
const groups = useMemo(() => {
|
|
2361
|
+
const deployments = [];
|
|
2362
|
+
for (const token of props.tokens) {
|
|
2363
|
+
const key = rowKey(token);
|
|
2364
|
+
const n = Number(props.balances?.[key]?.formatted);
|
|
2092
2365
|
const st = props.optionStates?.[key];
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2366
|
+
if (st?.disabled && !WALLET_STATE_REASONS.has(String(st.reason))) continue;
|
|
2367
|
+
deployments.push({
|
|
2368
|
+
token,
|
|
2369
|
+
key,
|
|
2370
|
+
balance: showBalances && props.balances?.[key] && Number.isFinite(n) ? n : null,
|
|
2371
|
+
disabled: !!st?.disabled,
|
|
2372
|
+
// The line under a greyed row says why. Callers send either a sentence in `reason` (the
|
|
2373
|
+
// exchange's "cannot be delivered on this chain") or a machine code there with the words in
|
|
2374
|
+
// `hint` (the deposit card's "no-balance" / "No balance on this chain").
|
|
2375
|
+
reason: st?.disabled ? st.reason && /\s/.test(st.reason) ? st.reason : st.hint || st.reason : void 0,
|
|
2376
|
+
hint: st?.disabled ? void 0 : st?.hint
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
return groupDeployments(deployments, prices);
|
|
2380
|
+
}, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
|
|
2381
|
+
const chainTerms = useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
|
|
2382
|
+
const visible = useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
|
|
2383
|
+
const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
|
|
2384
|
+
useEffect(() => {
|
|
2385
|
+
if (openKey && !openGroup) setOpenKey(null);
|
|
2386
|
+
}, [openKey, openGroup]);
|
|
2387
|
+
useLayoutEffect(() => {
|
|
2388
|
+
if (!openKey && listRef.current) listRef.current.scrollTop = savedScroll.current;
|
|
2389
|
+
}, [openKey]);
|
|
2390
|
+
const selected = props.selected;
|
|
2391
|
+
const isSelected = (t) => isPick(selected, t);
|
|
2392
|
+
const pick = (t) => props.onPick({ chainId: Number(t.chainId), symbol: t.symbol });
|
|
2393
|
+
const selectedRow = useMemo(() => {
|
|
2394
|
+
if (!selected) return null;
|
|
2395
|
+
for (const g of groups) for (const d of g.deployments) if (!d.disabled && isPick(selected, d.token)) return d;
|
|
2396
|
+
return null;
|
|
2397
|
+
}, [groups, selected]);
|
|
2398
|
+
const head = /* @__PURE__ */ jsxs("div", { className: "sg-pk-head", children: [
|
|
2399
|
+
openGroup ? /* @__PURE__ */ jsxs("button", { type: "button", className: "sg-pk-backlink", onClick: () => setOpenKey(null), children: [
|
|
2400
|
+
/* @__PURE__ */ jsx(ArrowLeftGlyph, {}),
|
|
2401
|
+
"Tokens"
|
|
2402
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "sg-pk-title", children: props.title }),
|
|
2403
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-pk-close", onClick: props.onBack, "aria-label": "Close", children: /* @__PURE__ */ jsx(CloseGlyph, {}) })
|
|
2404
|
+
] });
|
|
2405
|
+
if (openGroup) {
|
|
2406
|
+
const sym = openGroup.symbol;
|
|
2407
|
+
return /* @__PURE__ */ jsxs("div", { className: "sg-pk", "data-step": "network", children: [
|
|
2408
|
+
head,
|
|
2409
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-pk-intro", children: [
|
|
2410
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-pk-title", children: [
|
|
2411
|
+
side === "from" ? "Pay with" : "Receive",
|
|
2412
|
+
" ",
|
|
2413
|
+
sym
|
|
2414
|
+
] }),
|
|
2415
|
+
/* @__PURE__ */ jsx("p", { className: "sg-pk-lead", children: side === "from" ? "Choose the network to pay from" : `Choose the network to receive ${sym} on` })
|
|
2416
|
+
] }),
|
|
2417
|
+
/* @__PURE__ */ jsx("div", { className: "sg-pk-list", role: "group", "aria-label": "Select network", children: openGroup.deployments.map((d) => {
|
|
2418
|
+
const id = Number(d.token.chainId);
|
|
2419
|
+
const name = chainName3(id);
|
|
2420
|
+
if (d.disabled) {
|
|
2421
|
+
return /* @__PURE__ */ jsx(UnavailableRow, { icon: /* @__PURE__ */ jsx(ChainMark, { chainId: id, chain: chainById.get(id), size: "row" }), label: name, reason: d.reason, testId: "network-row-unavailable" }, d.key);
|
|
2422
|
+
}
|
|
2423
|
+
const sel = isSelected(d.token);
|
|
2424
|
+
const ticker = tokenTicker(d.token);
|
|
2425
|
+
return /* @__PURE__ */ 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: [
|
|
2426
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2427
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-chainwrap", children: [
|
|
2428
|
+
/* @__PURE__ */ jsx(ChainMark, { chainId: id, chain: chainById.get(id), size: "row" }),
|
|
2429
|
+
sel ? /* @__PURE__ */ jsx(TickBadge, {}) : null
|
|
2108
2430
|
] }),
|
|
2109
|
-
/* @__PURE__ */ jsxs("span", { className: "sg-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2431
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2432
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-label", children: [
|
|
2433
|
+
name,
|
|
2434
|
+
ticker !== sym ? /* @__PURE__ */ jsx("span", { className: "sg-pk-alt", children: ticker }) : null
|
|
2435
|
+
] }),
|
|
2436
|
+
d.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
|
|
2113
2437
|
] })
|
|
2114
|
-
]
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
)
|
|
2118
|
-
|
|
2438
|
+
] }),
|
|
2439
|
+
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
|
|
2440
|
+
] }, d.key);
|
|
2441
|
+
}) })
|
|
2442
|
+
] });
|
|
2443
|
+
}
|
|
2444
|
+
return /* @__PURE__ */ jsxs("div", { className: "sg-pk", "data-step": "token", children: [
|
|
2445
|
+
head,
|
|
2446
|
+
/* @__PURE__ */ jsxs("label", { className: "sg-pk-search", children: [
|
|
2447
|
+
/* @__PURE__ */ jsx(SearchGlyph, {}),
|
|
2448
|
+
/* @__PURE__ */ 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" }),
|
|
2449
|
+
query ? /* @__PURE__ */ jsx("button", { type: "button", className: "sg-pk-clear", onClick: () => setQuery(""), "aria-label": "Clear token search", children: /* @__PURE__ */ jsx(CloseGlyph, {}) }) : null
|
|
2450
|
+
] }),
|
|
2451
|
+
/* @__PURE__ */ jsxs("div", { className: "sg-pk-body", children: [
|
|
2452
|
+
selectedRow ? /* @__PURE__ */ jsxs("div", { className: "sg-pk-selected", children: [
|
|
2453
|
+
/* @__PURE__ */ jsx("p", { className: "sg-pk-cap", children: "Selected" }),
|
|
2454
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "sg-pk-row", "data-testid": "selected-row", "data-selected": "true", "aria-pressed": "true", onClick: () => pick(selectedRow.token), children: [
|
|
2455
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2456
|
+
/* @__PURE__ */ jsx(TokenPlate, { symbol: selectedRow.token.symbol, logoUrl: selectedRow.token.logoUrl, checked: true }),
|
|
2457
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2458
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: tokenTicker(selectedRow.token) }),
|
|
2459
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-line", children: [
|
|
2460
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-sub", children: [
|
|
2461
|
+
"On ",
|
|
2462
|
+
chainName3(Number(selectedRow.token.chainId))
|
|
2463
|
+
] }),
|
|
2464
|
+
/* @__PURE__ */ jsx(ChainMarks, { chainIds: [Number(selectedRow.token.chainId)], chainById, decorative: true })
|
|
2465
|
+
] })
|
|
2466
|
+
] })
|
|
2467
|
+
] }),
|
|
2468
|
+
showBalances ? /* @__PURE__ */ jsx(
|
|
2469
|
+
BalanceColumn,
|
|
2470
|
+
{
|
|
2471
|
+
amount: selectedRow.balance,
|
|
2472
|
+
usd: usdOf(selectedRow.balance, prices, selectedRow.token.symbol),
|
|
2473
|
+
symbol: tokenTicker(selectedRow.token)
|
|
2474
|
+
}
|
|
2475
|
+
) : null
|
|
2476
|
+
] })
|
|
2477
|
+
] }) : null,
|
|
2478
|
+
/* @__PURE__ */ jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
|
|
2479
|
+
/* @__PURE__ */ jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) : visible.map((g) => {
|
|
2480
|
+
const members = g.deployments;
|
|
2481
|
+
const multi = members.length > 1;
|
|
2482
|
+
const single = members[0];
|
|
2483
|
+
const label = multi ? g.symbol : tokenTicker(single.token);
|
|
2484
|
+
const blocked = !!g.unavailable;
|
|
2485
|
+
const opensNetworks = multi || blocked;
|
|
2486
|
+
const zero = showBalances && g.amount === 0 || blocked;
|
|
2487
|
+
return /* @__PURE__ */ jsxs(
|
|
2488
|
+
"button",
|
|
2489
|
+
{
|
|
2490
|
+
type: "button",
|
|
2491
|
+
className: "sg-pk-row",
|
|
2492
|
+
"data-testid": "token-row",
|
|
2493
|
+
"data-symbol": g.symbol,
|
|
2494
|
+
"data-networks": members.length,
|
|
2495
|
+
"data-zero": zero || void 0,
|
|
2496
|
+
"data-unavailable": blocked || void 0,
|
|
2497
|
+
onClick: () => {
|
|
2498
|
+
if (opensNetworks) {
|
|
2499
|
+
savedScroll.current = listRef.current?.scrollTop ?? 0;
|
|
2500
|
+
setOpenKey(g.key);
|
|
2501
|
+
} else pick(single.token);
|
|
2502
|
+
},
|
|
2503
|
+
children: [
|
|
2504
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-left", children: [
|
|
2505
|
+
/* @__PURE__ */ jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
|
|
2506
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-text", children: [
|
|
2507
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-label", children: label }),
|
|
2508
|
+
/* @__PURE__ */ jsxs("span", { className: "sg-pk-line", children: [
|
|
2509
|
+
/* @__PURE__ */ jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
|
|
2510
|
+
/* @__PURE__ */ jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById, decorative: !multi }),
|
|
2511
|
+
opensNetworks && showBalances ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2512
|
+
] }),
|
|
2513
|
+
!multi && single.hint ? /* @__PURE__ */ jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
|
|
2514
|
+
] })
|
|
2515
|
+
] }),
|
|
2516
|
+
showBalances ? /* @__PURE__ */ jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label }) : opensNetworks ? /* @__PURE__ */ jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsx(ChevronGlyph, {}) }) : null
|
|
2517
|
+
]
|
|
2518
|
+
},
|
|
2519
|
+
g.key
|
|
2520
|
+
);
|
|
2521
|
+
}) })
|
|
2522
|
+
] })
|
|
2119
2523
|
] });
|
|
2120
2524
|
}
|
|
2121
2525
|
function ChevronRight({ size = 16 }) {
|
|
@@ -2133,7 +2537,7 @@ function ArrowDown({ size = 16 }) {
|
|
|
2133
2537
|
/* @__PURE__ */ jsx("path", { d: "M12.667 8L8 12.667 3.333 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
2134
2538
|
] });
|
|
2135
2539
|
}
|
|
2136
|
-
function
|
|
2540
|
+
function CloseGlyph2() {
|
|
2137
2541
|
return /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
2138
2542
|
}
|
|
2139
2543
|
function ShieldTickGlyph({ size = 16 }) {
|
|
@@ -2173,7 +2577,7 @@ function AmountText({ value, suffix, exact }) {
|
|
|
2173
2577
|
suffix ? ` ${suffix}` : null
|
|
2174
2578
|
] });
|
|
2175
2579
|
}
|
|
2176
|
-
function
|
|
2580
|
+
function usdOf2(amount, price) {
|
|
2177
2581
|
const n = typeof amount === "number" ? amount : Number(amount);
|
|
2178
2582
|
if (!Number.isFinite(n) || n <= 0 || price === void 0 || !Number.isFinite(price) || price <= 0) return null;
|
|
2179
2583
|
const usd = n * price;
|
|
@@ -2303,7 +2707,7 @@ function WidgetShell(props) {
|
|
|
2303
2707
|
] }),
|
|
2304
2708
|
props.onClose ? (
|
|
2305
2709
|
// type="button": a host page may wrap the widget in a <form>.
|
|
2306
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(
|
|
2710
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(CloseGlyph2, {}) })
|
|
2307
2711
|
) : null
|
|
2308
2712
|
] })
|
|
2309
2713
|
] }),
|
|
@@ -2599,7 +3003,7 @@ function useTxHistory(account) {
|
|
|
2599
3003
|
}, [account]);
|
|
2600
3004
|
return entries;
|
|
2601
3005
|
}
|
|
2602
|
-
function
|
|
3006
|
+
function BackGlyph() {
|
|
2603
3007
|
return /* @__PURE__ */ 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: [
|
|
2604
3008
|
/* @__PURE__ */ jsx("path", { d: "M19 12H5" }),
|
|
2605
3009
|
/* @__PURE__ */ jsx("path", { d: "m12 19-7-7 7-7" })
|
|
@@ -2841,7 +3245,7 @@ function TxHistoryPanel(props) {
|
|
|
2841
3245
|
};
|
|
2842
3246
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2843
3247
|
/* @__PURE__ */ jsxs("div", { className: "sg-sel-head", children: [
|
|
2844
|
-
/* @__PURE__ */ jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelected(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx(
|
|
3248
|
+
/* @__PURE__ */ jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelected(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx(BackGlyph, {}) }),
|
|
2845
3249
|
/* @__PURE__ */ jsxs("div", { className: "sg-sel-title", children: [
|
|
2846
3250
|
selected ? "Transaction" : "Transaction history",
|
|
2847
3251
|
account ? /* @__PURE__ */ jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress(account) }) : null
|
|
@@ -3597,6 +4001,9 @@ function PaymentIsland(props) {
|
|
|
3597
4001
|
TokenSelect,
|
|
3598
4002
|
{
|
|
3599
4003
|
title: "Pay with",
|
|
4004
|
+
side: "from",
|
|
4005
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
4006
|
+
fetchPrices: engine.fetchPrices,
|
|
3600
4007
|
chains: fundingChains,
|
|
3601
4008
|
tokens: fundingTokens,
|
|
3602
4009
|
balances: holdings.balances,
|
|
@@ -3612,6 +4019,9 @@ function PaymentIsland(props) {
|
|
|
3612
4019
|
TokenSelect,
|
|
3613
4020
|
{
|
|
3614
4021
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
4022
|
+
side: isFrom ? "from" : "to",
|
|
4023
|
+
selected: isFrom ? exFrom : exTo,
|
|
4024
|
+
fetchPrices: engine.fetchPrices,
|
|
3615
4025
|
chains,
|
|
3616
4026
|
tokens: isFrom ? exFromPicker : exToPicker,
|
|
3617
4027
|
balances: exBalances,
|
|
@@ -4156,6 +4566,9 @@ function PayCard(props) {
|
|
|
4156
4566
|
TokenSelect,
|
|
4157
4567
|
{
|
|
4158
4568
|
title: "Pay with",
|
|
4569
|
+
side: "from",
|
|
4570
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
4571
|
+
fetchPrices: engine.fetchPrices,
|
|
4159
4572
|
chains: fundingChains,
|
|
4160
4573
|
tokens: fundingTokens,
|
|
4161
4574
|
balances: listBalances,
|
|
@@ -4203,7 +4616,7 @@ function PayCard(props) {
|
|
|
4203
4616
|
}
|
|
4204
4617
|
)
|
|
4205
4618
|
] }),
|
|
4206
|
-
/* @__PURE__ */ jsx(PaneFoot, { usd: sel && selectedVisible ?
|
|
4619
|
+
/* @__PURE__ */ jsx(PaneFoot, { usd: sel && selectedVisible ? usdOf2(sel.source.payAmount, prices[selSymbol]) : null, balance: selBal ? shortBalance(selBal.formatted) : null })
|
|
4207
4620
|
] }),
|
|
4208
4621
|
loadingPlan ? /* @__PURE__ */ jsxs("div", { className: "sg-pay-loading", "data-testid": "pay-loading", role: "status", children: [
|
|
4209
4622
|
/* @__PURE__ */ jsx("div", { className: "sg-skel sg-skel--row" }),
|
|
@@ -4715,8 +5128,8 @@ function ExchangeCard(props) {
|
|
|
4715
5128
|
const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
|
|
4716
5129
|
const compliance = selected?.quote.compliance;
|
|
4717
5130
|
const complianceHasQuote = Boolean(selected && flow.status !== "loading");
|
|
4718
|
-
const fromUsd =
|
|
4719
|
-
const toUsd =
|
|
5131
|
+
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
5132
|
+
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
4720
5133
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
4721
5134
|
const flip = () => {
|
|
4722
5135
|
if (!flippable) return;
|
|
@@ -4799,6 +5212,9 @@ function ExchangeCard(props) {
|
|
|
4799
5212
|
TokenSelect,
|
|
4800
5213
|
{
|
|
4801
5214
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
5215
|
+
side: isFrom ? "from" : "to",
|
|
5216
|
+
selected: isFrom ? from : to,
|
|
5217
|
+
fetchPrices: engine.fetchPrices,
|
|
4802
5218
|
chains,
|
|
4803
5219
|
tokens: isFrom ? fromPickerTokens : toPickerVisible,
|
|
4804
5220
|
balances,
|