@glacislabs/stablegenie-zerodelta 4.10.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-BOEY6DG5.js → chunk-A7ADZJXA.js} +25 -4
- package/dist/{chunk-AWTQU6CW.js → chunk-MA2VYFG3.js} +630 -147
- package/dist/core/index.cjs +25 -3
- package/dist/core/index.d.cts +19 -3
- package/dist/core/index.d.ts +19 -3
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +652 -148
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/{mount-Bw7W3Bfk.d.ts → mount-hxb3zioQ.d.ts} +1 -1
- package/dist/{mount-wJ7WrkOC.d.cts → mount-xruGixNZ.d.cts} +1 -1
- package/dist/mount.cjs +652 -148
- package/dist/mount.d.cts +2 -2
- package/dist/mount.d.ts +2 -2
- package/dist/mount.js +2 -2
- package/dist/standalone.global.js +78 -40
- package/dist/{verify-QEs-XHri.d.cts → verify-D8tr1yY1.d.cts} +6 -0
- package/dist/{verify-QEs-XHri.d.ts → verify-D8tr1yY1.d.ts} +6 -0
- 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
|
}
|
|
@@ -2199,9 +2201,11 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
2199
2201
|
perChainBest.push(option);
|
|
2200
2202
|
}
|
|
2201
2203
|
}
|
|
2202
|
-
|
|
2204
|
+
const ranked = [...heldOptions, ...perChainBest, ...leftovers];
|
|
2205
|
+
for (const option of ranked.slice(0, MAX_QUOTE_CANDIDATES)) {
|
|
2203
2206
|
candidates.push(option);
|
|
2204
2207
|
}
|
|
2208
|
+
const unquotedOptions = ranked.slice(MAX_QUOTE_CANDIDATES);
|
|
2205
2209
|
const routeErrors = [];
|
|
2206
2210
|
const routePromises = candidates.map(
|
|
2207
2211
|
(option) => buildRoute({
|
|
@@ -2243,6 +2247,7 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
2243
2247
|
expiresAt: new Date(Date.now() + 2 * 60 * 1e3).toISOString(),
|
|
2244
2248
|
apiBase: api.apiBase,
|
|
2245
2249
|
routes: routesBuilt,
|
|
2250
|
+
unquotedOptions,
|
|
2246
2251
|
fundingBalances: walletBalances,
|
|
2247
2252
|
fundingAccount: payer.toLowerCase(),
|
|
2248
2253
|
destination: {
|
|
@@ -2256,6 +2261,21 @@ async function fetchPaymentPlan(api, request, payer, wallet = {}, readBalances)
|
|
|
2256
2261
|
}
|
|
2257
2262
|
};
|
|
2258
2263
|
}
|
|
2264
|
+
async function quotePayOption(api, request, payer, picked, wallet = {}) {
|
|
2265
|
+
validateDestination(request);
|
|
2266
|
+
assertAddress(payer, "Payer wallet");
|
|
2267
|
+
const [chains, tokens, routes, health] = await Promise.all([api.fetchChains(), api.fetchTokens(), api.fetchRoutes(), api.fetchRouteHealth()]);
|
|
2268
|
+
const catalogue = buildCatalogue({ chains, tokens, routes, product: "stable", supportedChainIds: SUPPORTED_CHAIN_IDS, brokenLanes: suppressedLanes(health) });
|
|
2269
|
+
const destination = { ...request, chainId: Number(request.chainId), asset: symbolKey(request.asset) };
|
|
2270
|
+
const destinationToken = findToken(tokens, destination.chainId, destination.asset);
|
|
2271
|
+
if (!destinationToken) throw new Error(`${destination.asset} is not enabled on ${chainNameOf(destination.chainId, chains)}.`);
|
|
2272
|
+
const allowedFunding = wallet.fundingAssets?.length ? new Set(wallet.fundingAssets.map(symbolKey)) : null;
|
|
2273
|
+
const option = buildPayOptions({ invoiceAsset: destination.asset, invoiceChainId: destination.chainId, tokens, routes, chains, walletChainId: wallet.chainId, catalogue }).find(
|
|
2274
|
+
(o) => !o.direct && Number(o.chainId) === Number(picked.chainId) && o.address.toLowerCase() === String(picked.address).toLowerCase() && (!allowedFunding || allowedFunding.has(o.symbolKey))
|
|
2275
|
+
);
|
|
2276
|
+
if (!option) throw new Error("That funding option is not available for this payment right now.");
|
|
2277
|
+
return buildRoute({ option, destination, destinationToken, chains, tokens, payer, fetchQuote: api.fetchQuote });
|
|
2278
|
+
}
|
|
2259
2279
|
|
|
2260
2280
|
// src/core/swap.ts
|
|
2261
2281
|
function validateSwap(swap = {}) {
|
|
@@ -2777,6 +2797,7 @@ function createEngine(config = {}) {
|
|
|
2777
2797
|
});
|
|
2778
2798
|
},
|
|
2779
2799
|
fetchPaymentPlan: (request, payer, wallet) => fetchPaymentPlan(api, request, payer, wallet, verifier.readBalances),
|
|
2800
|
+
quotePayOption: (request, payer, option, wallet) => quotePayOption(api, request, payer, option, wallet),
|
|
2780
2801
|
quoteSwapPreview: (swap, owner) => quoteSwapPreview(api, swap, owner),
|
|
2781
2802
|
buildSwapPlan: (swap, payer, wallet) => buildSwapPlan(api, swap, payer, wallet),
|
|
2782
2803
|
payerNonceBaseline: verifier.payerNonceBaseline,
|
|
@@ -3168,6 +3189,10 @@ function useFlow(args) {
|
|
|
3168
3189
|
const routes = plan?.routes ?? [];
|
|
3169
3190
|
const selected = react.useMemo(() => routes.find((r) => r.id === selectedId) ?? routes.find((r) => r.recommended) ?? routes[0] ?? null, [routes, selectedId]);
|
|
3170
3191
|
const reload = react.useCallback(() => setNonce((n) => n + 1), []);
|
|
3192
|
+
const addRoute = react.useCallback((route) => {
|
|
3193
|
+
setPlan((p) => p ? { ...p, routes: [...p.routes.filter((r) => r.id !== route.id), route] } : p);
|
|
3194
|
+
setSelectedId(route.id);
|
|
3195
|
+
}, []);
|
|
3171
3196
|
react.useEffect(() => {
|
|
3172
3197
|
if (busyRef.current) return;
|
|
3173
3198
|
setFieldError(null);
|
|
@@ -3390,7 +3415,8 @@ function useFlow(args) {
|
|
|
3390
3415
|
quotePaused,
|
|
3391
3416
|
quoteStale,
|
|
3392
3417
|
submit,
|
|
3393
|
-
reload
|
|
3418
|
+
reload,
|
|
3419
|
+
addRoute
|
|
3394
3420
|
};
|
|
3395
3421
|
}
|
|
3396
3422
|
function balanceKey(chainId, tokenAddress) {
|
|
@@ -3652,6 +3678,11 @@ var WIDGET_CSS = `
|
|
|
3652
3678
|
/* skeleton loading */
|
|
3653
3679
|
.sg-skel{height:64px;border-radius:var(--sg-radius-control);background:linear-gradient(90deg,var(--sg-surface) 25%,color-mix(in srgb,var(--sg-border) 50%,var(--sg-surface)) 37%,var(--sg-surface) 63%);background-size:400% 100%;animation:sg-shimmer 1.2s ease-in-out infinite;margin-bottom:8px}
|
|
3654
3680
|
|
|
3681
|
+
.sg-skel--amt{display:inline-block;width:112px;height:30px;margin:0;vertical-align:middle;border-radius:10px}
|
|
3682
|
+
.sg-skel--row{height:48px}
|
|
3683
|
+
.sg-pay-loading{display:flex;flex-direction:column}
|
|
3684
|
+
.sg-pay-loading-line{display:flex;align-items:center;gap:8px;font-size:13px;line-height:16px;padding:2px 2px 0}
|
|
3685
|
+
|
|
3655
3686
|
/* spinner */
|
|
3656
3687
|
.sg-spinner{display:inline-block;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:999px;animation:sg-spin 0.7s linear infinite;vertical-align:-2px}
|
|
3657
3688
|
@keyframes sg-spin{to{transform:rotate(360deg)}}
|
|
@@ -3727,46 +3758,79 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
|
|
|
3727
3758
|
.sg-pct:hover:not(:disabled){color:var(--sg-accent)}
|
|
3728
3759
|
.sg-pct:disabled{opacity:.55;cursor:not-allowed}
|
|
3729
3760
|
|
|
3730
|
-
/* full-panel
|
|
3761
|
+
/* full-panel takeover head (transaction history) */
|
|
3731
3762
|
.sg-sel-head{display:flex;align-items:center;margin-bottom:14px}
|
|
3732
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}
|
|
3733
3764
|
.sg-back:hover{background:var(--sg-surface)}
|
|
3734
3765
|
.sg-sel-title{flex:1 1 auto;min-width:0;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
|
|
3735
3766
|
/* Whose transactions these are \u2014 history is per wallet, and the takeover hides the header's pill. */
|
|
3736
3767
|
.sg-sel-sub{display:block;font-size:11px;font-weight:600;color:var(--sg-text-muted);margin-top:1px}
|
|
3737
|
-
/* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
|
|
3738
|
-
(9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
|
|
3739
|
-
the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
|
|
3740
|
-
.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)}
|
|
3741
|
-
/* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
|
|
3742
|
-
.sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
|
|
3743
|
-
.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}
|
|
3744
|
-
.sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
|
|
3745
|
-
.sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
|
|
3746
|
-
.sg-chain-chip[data-selected="true"]{border-color:var(--sg-accent);background:color-mix(in srgb,var(--sg-accent) 10%,var(--sg-surface))}
|
|
3747
|
-
.sg-search{position:relative;margin-bottom:10px}
|
|
3748
|
-
.sg-search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--sg-text-muted);pointer-events:none}
|
|
3749
|
-
.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}
|
|
3750
|
-
.sg-search input:focus{border-color:var(--sg-accent)}
|
|
3751
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}
|
|
3752
|
-
.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}
|
|
3753
|
-
.sg-tokrow:hover{background:var(--sg-surface)}
|
|
3754
|
-
.sg-tokrow-main{flex:1 1 auto;min-width:0}
|
|
3755
|
-
.sg-tokrow-sym{display:block;font-size:15px;font-weight:700;line-height:1.2}
|
|
3756
|
-
.sg-tokrow-name{display:block;font-size:12px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
3757
|
-
.sg-tokrow-end{flex:0 0 auto;text-align:right}
|
|
3758
|
-
.sg-tokrow-bal{display:block;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}
|
|
3759
|
-
.sg-tokrow-chain{display:block;font-size:11px;color:var(--sg-text-muted)}
|
|
3760
|
-
/* funding rows the wallet can't cover (zero / insufficient): greyed, non-interactive, reason hint.
|
|
3761
|
-
Mirrors RouteList's data-short dim + warn tone; no hover lift. Theme-aware via --sg-* vars. */
|
|
3762
|
-
.sg-tokrow--off,.sg-tokrow[disabled]{opacity:.5;cursor:not-allowed}
|
|
3763
|
-
.sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
|
|
3764
|
-
.sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
|
|
3765
|
-
.sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
|
|
3766
|
-
/* on a row that stays selectable (a limited lane): a caveat, not a refusal */
|
|
3767
|
-
.sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
|
|
3768
3769
|
.sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
|
|
3769
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
|
+
|
|
3770
3834
|
/* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
|
|
3771
3835
|
OWN available width (container query) \u2014 an embedded widget cannot infer the host layout from the
|
|
3772
3836
|
viewport. The viewport media query stays as a fallback for engines without container queries. */
|
|
@@ -4713,6 +4777,200 @@ function chainLogoCandidates(chainId, logoUrl) {
|
|
|
4713
4777
|
if (bundled) out.push(bundled);
|
|
4714
4778
|
return out;
|
|
4715
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
|
+
}
|
|
4716
4974
|
var CHAIN_SHORT = {
|
|
4717
4975
|
1: "ETH",
|
|
4718
4976
|
10: "OP",
|
|
@@ -4794,103 +5052,280 @@ function FundingTile(props) {
|
|
|
4794
5052
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: main })
|
|
4795
5053
|
] });
|
|
4796
5054
|
}
|
|
4797
|
-
function
|
|
5055
|
+
function ChainMark(props) {
|
|
5056
|
+
const [failed, setFailed] = react.useState([]);
|
|
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) {
|
|
4798
5076
|
const [failed, setFailed] = react.useState([]);
|
|
4799
|
-
const src =
|
|
4800
|
-
|
|
4801
|
-
|
|
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
|
+
] }) });
|
|
4802
5117
|
}
|
|
4803
5118
|
function SearchGlyph() {
|
|
4804
|
-
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: [
|
|
4805
5120
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "7" }),
|
|
4806
5121
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m20 20-3.5-3.5" })
|
|
4807
5122
|
] });
|
|
4808
5123
|
}
|
|
4809
|
-
function
|
|
4810
|
-
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: [
|
|
4811
5132
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
|
|
4812
5133
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
|
|
4813
5134
|
] });
|
|
4814
5135
|
}
|
|
4815
|
-
var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
|
|
4816
5136
|
function TokenSelect(props) {
|
|
4817
|
-
const
|
|
5137
|
+
const side = props.side ?? "from";
|
|
4818
5138
|
const [query, setQuery] = react.useState("");
|
|
4819
|
-
const
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
const
|
|
4824
|
-
const
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
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
|
+
});
|
|
4837
5159
|
};
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
{
|
|
4850
|
-
chain: c,
|
|
4851
|
-
label: chainBadge(Number(c.chainId)),
|
|
4852
|
-
name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
|
|
4853
|
-
selected: activeFilter === Number(c.chainId),
|
|
4854
|
-
onClick: () => setChainFilter(Number(c.chainId))
|
|
4855
|
-
},
|
|
4856
|
-
c.chainId
|
|
4857
|
-
))
|
|
4858
|
-
] }),
|
|
4859
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-search", children: [
|
|
4860
|
-
/* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
|
|
4861
|
-
/* @__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" })
|
|
4862
|
-
] }),
|
|
4863
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
|
|
4864
|
-
const chainId = Number(t.chainId);
|
|
4865
|
-
const key = rowKey(t);
|
|
4866
|
-
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);
|
|
4867
5171
|
const st = props.optionStates?.[key];
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
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
|
|
4883
5236
|
] }),
|
|
4884
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
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
|
|
4888
5243
|
] })
|
|
4889
|
-
]
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
)
|
|
4893
|
-
|
|
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
|
+
] })
|
|
4894
5329
|
] });
|
|
4895
5330
|
}
|
|
4896
5331
|
function ChevronRight({ size = 16 }) {
|
|
@@ -4908,7 +5343,7 @@ function ArrowDown({ size = 16 }) {
|
|
|
4908
5343
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.667 8L8 12.667 3.333 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
4909
5344
|
] });
|
|
4910
5345
|
}
|
|
4911
|
-
function
|
|
5346
|
+
function CloseGlyph2() {
|
|
4912
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" }) });
|
|
4913
5348
|
}
|
|
4914
5349
|
function ShieldTickGlyph({ size = 16 }) {
|
|
@@ -4948,7 +5383,7 @@ function AmountText({ value, suffix, exact }) {
|
|
|
4948
5383
|
suffix ? ` ${suffix}` : null
|
|
4949
5384
|
] });
|
|
4950
5385
|
}
|
|
4951
|
-
function
|
|
5386
|
+
function usdOf2(amount, price) {
|
|
4952
5387
|
const n = typeof amount === "number" ? amount : Number(amount);
|
|
4953
5388
|
if (!Number.isFinite(n) || n <= 0 || price === void 0 || !Number.isFinite(price) || price <= 0) return null;
|
|
4954
5389
|
const usd2 = n * price;
|
|
@@ -5078,7 +5513,7 @@ function WidgetShell(props) {
|
|
|
5078
5513
|
] }),
|
|
5079
5514
|
props.onClose ? (
|
|
5080
5515
|
// type="button": a host page may wrap the widget in a <form>.
|
|
5081
|
-
/* @__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, {}) })
|
|
5082
5517
|
) : null
|
|
5083
5518
|
] })
|
|
5084
5519
|
] }),
|
|
@@ -5374,7 +5809,7 @@ function useTxHistory(account) {
|
|
|
5374
5809
|
}, [account]);
|
|
5375
5810
|
return entries;
|
|
5376
5811
|
}
|
|
5377
|
-
function
|
|
5812
|
+
function BackGlyph() {
|
|
5378
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: [
|
|
5379
5814
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
|
|
5380
5815
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
|
|
@@ -5616,7 +6051,7 @@ function TxHistoryPanel(props) {
|
|
|
5616
6051
|
};
|
|
5617
6052
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
5618
6053
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
|
|
5619
|
-
/* @__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, {}) }),
|
|
5620
6055
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
|
|
5621
6056
|
selected ? "Transaction" : "Transaction history",
|
|
5622
6057
|
account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress2(account) }) : null
|
|
@@ -6372,6 +6807,9 @@ function PaymentIsland(props) {
|
|
|
6372
6807
|
TokenSelect,
|
|
6373
6808
|
{
|
|
6374
6809
|
title: "Pay with",
|
|
6810
|
+
side: "from",
|
|
6811
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
6812
|
+
fetchPrices: engine.fetchPrices,
|
|
6375
6813
|
chains: fundingChains,
|
|
6376
6814
|
tokens: fundingTokens,
|
|
6377
6815
|
balances: holdings.balances,
|
|
@@ -6387,6 +6825,9 @@ function PaymentIsland(props) {
|
|
|
6387
6825
|
TokenSelect,
|
|
6388
6826
|
{
|
|
6389
6827
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
6828
|
+
side: isFrom ? "from" : "to",
|
|
6829
|
+
selected: isFrom ? exFrom : exTo,
|
|
6830
|
+
fetchPrices: engine.fetchPrices,
|
|
6390
6831
|
chains,
|
|
6391
6832
|
tokens: isFrom ? exFromPicker : exToPicker,
|
|
6392
6833
|
balances: exBalances,
|
|
@@ -6736,6 +7177,21 @@ function PayCard(props) {
|
|
|
6736
7177
|
);
|
|
6737
7178
|
const heldIds = react.useMemo(() => new Set(held.map((a) => a.route.id)), [held]);
|
|
6738
7179
|
const scannedEmpty = !holdings.loading && Object.keys(holdings.balances).length > 0 && held.length === 0;
|
|
7180
|
+
const [failedOptions, setFailedOptions] = react.useState(/* @__PURE__ */ new Set());
|
|
7181
|
+
const [pricing, setPricing] = react.useState(null);
|
|
7182
|
+
const [pickError, setPickError] = react.useState(null);
|
|
7183
|
+
react.useEffect(() => {
|
|
7184
|
+
setFailedOptions(/* @__PURE__ */ new Set());
|
|
7185
|
+
setPricing(null);
|
|
7186
|
+
setPickError(null);
|
|
7187
|
+
}, [wallet.account, paramsKey]);
|
|
7188
|
+
const unquoted = react.useMemo(
|
|
7189
|
+
() => (paymentPlan?.unquotedOptions ?? []).filter(
|
|
7190
|
+
(o) => (!fundingSet || fundingSet.has(o.symbolKey)) && (STABLES2.has(o.symbolKey)) && !failedOptions.has(balanceKey(o.chainId, o.address))
|
|
7191
|
+
),
|
|
7192
|
+
[paymentPlan, fundingSet, method, failedOptions]
|
|
7193
|
+
);
|
|
7194
|
+
const listBalances = react.useMemo(() => ({ ...prefetchedBalances ?? {}, ...holdings.balances }), [prefetchedBalances, holdings.balances]);
|
|
6739
7195
|
const optionStates = react.useMemo(() => {
|
|
6740
7196
|
const map = {};
|
|
6741
7197
|
for (const a of annotated) {
|
|
@@ -6758,8 +7214,19 @@ function PayCard(props) {
|
|
|
6758
7214
|
map[key] = { disabled: false };
|
|
6759
7215
|
}
|
|
6760
7216
|
}
|
|
7217
|
+
for (const o of unquoted) {
|
|
7218
|
+
const key = balanceKey(o.chainId, o.address);
|
|
7219
|
+
if (map[key]) continue;
|
|
7220
|
+
let zero = false;
|
|
7221
|
+
try {
|
|
7222
|
+
zero = BigInt(listBalances[key]?.raw ?? "x") === 0n;
|
|
7223
|
+
} catch {
|
|
7224
|
+
zero = false;
|
|
7225
|
+
}
|
|
7226
|
+
map[key] = zero ? { disabled: true, reason: "no-balance", hint: "No balance on this chain" } : { disabled: false };
|
|
7227
|
+
}
|
|
6761
7228
|
return map;
|
|
6762
|
-
}, [annotated, holdings.loading]);
|
|
7229
|
+
}, [annotated, holdings.loading, unquoted, listBalances]);
|
|
6763
7230
|
const [catalogue, setCatalogue] = react.useState(null);
|
|
6764
7231
|
const chains = react.useMemo(() => {
|
|
6765
7232
|
const order = new Map(SUPPORTED_CHAINS.map((id, i) => [id, i]));
|
|
@@ -6779,24 +7246,27 @@ function PayCard(props) {
|
|
|
6779
7246
|
const fundingTokens = react.useMemo(() => {
|
|
6780
7247
|
const seen = /* @__PURE__ */ new Set();
|
|
6781
7248
|
const list = [];
|
|
6782
|
-
|
|
6783
|
-
const key = balanceKey(
|
|
6784
|
-
if (seen.has(key))
|
|
7249
|
+
const push = (chainId, address, fallback) => {
|
|
7250
|
+
const key = balanceKey(chainId, address);
|
|
7251
|
+
if (seen.has(key)) return;
|
|
6785
7252
|
seen.add(key);
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
);
|
|
7253
|
+
list.push(registryTokens.find((t) => Number(t.chainId) === chainId && addrEq2(t.address, address)) ?? fallback);
|
|
7254
|
+
};
|
|
7255
|
+
for (const r of visibleRoutes) {
|
|
7256
|
+
push(r.source.chainId, r.source.tokenAddress, {
|
|
7257
|
+
symbol: r.source.asset,
|
|
7258
|
+
displaySymbol: r.source.ticker,
|
|
7259
|
+
name: r.source.asset,
|
|
7260
|
+
chainId: r.source.chainId,
|
|
7261
|
+
address: r.source.tokenAddress ?? "",
|
|
7262
|
+
decimals: r.source.decimals ?? 18
|
|
7263
|
+
});
|
|
7264
|
+
}
|
|
7265
|
+
for (const o of unquoted) {
|
|
7266
|
+
push(o.chainId, o.address, { symbol: o.symbol, displaySymbol: o.ticker, name: o.name, chainId: o.chainId, address: o.address, decimals: o.decimals, logoUrl: o.logoUrl });
|
|
6797
7267
|
}
|
|
6798
7268
|
return list;
|
|
6799
|
-
}, [visibleRoutes, registryTokens]);
|
|
7269
|
+
}, [visibleRoutes, unquoted, registryTokens]);
|
|
6800
7270
|
const fundingChains = react.useMemo(() => {
|
|
6801
7271
|
const ids = new Set(fundingTokens.map((t) => Number(t.chainId)));
|
|
6802
7272
|
return chains.filter((c) => ids.has(Number(c.chainId)));
|
|
@@ -6840,9 +7310,23 @@ function PayCard(props) {
|
|
|
6840
7310
|
react.useEffect(() => setHist(null), [wallet.account]);
|
|
6841
7311
|
const lastTxOwned = Boolean(flow.lastTxEntry?.hash && wallet.account && flow.lastTxEntry.account === wallet.account.toLowerCase());
|
|
6842
7312
|
const pickFunding = (pick) => {
|
|
7313
|
+
setPickError(null);
|
|
6843
7314
|
const r = visibleRoutes.find((x) => x.source.chainId === pick.chainId && symbolKey(x.source.asset) === symbolKey(pick.symbol));
|
|
6844
|
-
if (r)
|
|
7315
|
+
if (r) {
|
|
7316
|
+
selectRoute(r.id);
|
|
7317
|
+
closeSelector();
|
|
7318
|
+
return;
|
|
7319
|
+
}
|
|
7320
|
+
const option = unquoted.find((o) => o.chainId === pick.chainId && o.symbolKey === symbolKey(pick.symbol));
|
|
6845
7321
|
closeSelector();
|
|
7322
|
+
if (!option || !wallet.account) return;
|
|
7323
|
+
const key = balanceKey(option.chainId, option.address);
|
|
7324
|
+
setPricing(key);
|
|
7325
|
+
userPicked.current = true;
|
|
7326
|
+
engine.quotePayOption({ address: props.recipient, chainId: props.toChainId, asset: props.toAsset, amount: props.amount }, wallet.account, { chainId: option.chainId, address: option.address }, { chainId: wallet.chainId ?? void 0, fundingAssets: planFundingAssets }).then((route) => flow.addRoute(route)).catch(() => {
|
|
7327
|
+
setFailedOptions((prev) => /* @__PURE__ */ new Set([...prev, key]));
|
|
7328
|
+
setPickError(`${option.ticker || option.symbol} on ${option.chainName} cannot settle this payment right now. Pick another way to pay.`);
|
|
7329
|
+
}).finally(() => setPricing((cur) => cur === key ? null : cur));
|
|
6846
7330
|
};
|
|
6847
7331
|
const parked = !isLiveMethod(method);
|
|
6848
7332
|
const submitting = flow.status === "submitting";
|
|
@@ -6869,7 +7353,7 @@ function PayCard(props) {
|
|
|
6869
7353
|
setSheet(false);
|
|
6870
7354
|
requestAnimationFrame(() => complianceBtnRef.current?.focus());
|
|
6871
7355
|
};
|
|
6872
|
-
const payLabel = parked ? "Coming soon" : submitting ? "Paying\u2026" : flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${groupDecimal(atLeastCents(sel.source.payAmount))} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
7356
|
+
const payLabel = parked ? "Coming soon" : wallet.account && (flow.status === "loading" || pricing !== null) ? "Finding the best way to pay\u2026" : submitting ? "Paying\u2026" : flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall ? flow.nativeShortfall : sel && selectedVisible ? `Pay ${groupDecimal(atLeastCents(sel.source.payAmount))} ${sel.source.ticker || sel.source.asset}` : "Pay";
|
|
6873
7357
|
const walletSlot = wallet.account ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-head-tools", children: [
|
|
6874
7358
|
/* @__PURE__ */ jsxRuntime.jsx(HistoryButton, { btnRef: histBtnRef, disabled: submitting, onClick: () => setHist({}) }),
|
|
6875
7359
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-wallet", "data-connected": "true", children: [
|
|
@@ -6883,14 +7367,17 @@ function PayCard(props) {
|
|
|
6883
7367
|
{ label: "Network fee", value: nativeWei > 0n ? `~${formatNative(nativeWei)} ${nativeSymbol(sel.source.chainId)}` : "Gas only" },
|
|
6884
7368
|
...durationLabel(sel.quote.estimatedDuration) ? [{ label: "Estimated time", value: durationLabel(sel.quote.estimatedDuration) }] : []
|
|
6885
7369
|
] : [];
|
|
6886
|
-
const loadingPlan = flow.status === "loading" || holdings.loading && !sel;
|
|
7370
|
+
const loadingPlan = flow.status === "loading" || holdings.loading && !sel || pricing !== null;
|
|
6887
7371
|
return /* @__PURE__ */ jsxRuntime.jsx(WidgetShell, { title: config.title || "Complete payment", theme: config.theme, heightPx: props.heightPx, walletSlot, onClose: props.onClose, children: hist && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(TxHistoryPanel, { account: wallet.account, tokens: registryTokens, vaultIcons: catalogue?.vaultIcons, initialEntry: hist.entry ?? null, onBack: closeHistory }) : view === "select" && wallet.account ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6888
7372
|
TokenSelect,
|
|
6889
7373
|
{
|
|
6890
7374
|
title: "Pay with",
|
|
7375
|
+
side: "from",
|
|
7376
|
+
selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
|
|
7377
|
+
fetchPrices: engine.fetchPrices,
|
|
6891
7378
|
chains: fundingChains,
|
|
6892
7379
|
tokens: fundingTokens,
|
|
6893
|
-
balances:
|
|
7380
|
+
balances: listBalances,
|
|
6894
7381
|
optionStates,
|
|
6895
7382
|
onBack: closeSelector,
|
|
6896
7383
|
onPick: pickFunding
|
|
@@ -6921,7 +7408,7 @@ function PayCard(props) {
|
|
|
6921
7408
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "pay", children: [
|
|
6922
7409
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pane-label", children: "You pay" }),
|
|
6923
7410
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-mid", children: [
|
|
6924
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-
|
|
7411
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-out", "aria-live": "polite", children: loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-skel sg-skel--amt", "data-testid": "pay-loading-amount", "aria-hidden": "true" }) : sel && selectedVisible ? /* @__PURE__ */ jsxRuntime.jsx(AmountText, { value: groupDecimal(atLeastCents(sel.source.payAmount)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-amt-empty", children: "\u2014" }) }),
|
|
6925
7412
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6926
7413
|
TokenButton,
|
|
6927
7414
|
{
|
|
@@ -6935,12 +7422,22 @@ function PayCard(props) {
|
|
|
6935
7422
|
}
|
|
6936
7423
|
)
|
|
6937
7424
|
] }),
|
|
6938
|
-
/* @__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 })
|
|
6939
7426
|
] }),
|
|
7427
|
+
loadingPlan ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pay-loading", "data-testid": "pay-loading", role: "status", children: [
|
|
7428
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel sg-skel--row" }),
|
|
7429
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel sg-skel--row" }),
|
|
7430
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-muted sg-pay-loading-line", children: [
|
|
7431
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-spinner", "aria-hidden": "true" }),
|
|
7432
|
+
" ",
|
|
7433
|
+
pricing ? "Pricing this option\u2026" : "Checking your balances and finding the best way to pay\u2026"
|
|
7434
|
+
] })
|
|
7435
|
+
] }) : null,
|
|
7436
|
+
pickError ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: pickError }) : null,
|
|
6940
7437
|
flow.status === "error" && flow.error ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { tone: "error", children: flow.error }) : null,
|
|
6941
7438
|
scannedEmpty ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-note", children: "None of your balances can cover this yet \u2014 pick a different asset to fund with." }) : null,
|
|
6942
7439
|
flow.status === "ready" && !visibleRoutes.length ? /* @__PURE__ */ jsxRuntime.jsx(StatusPanel, { children: "No funding route matches the accepted assets for this payment." }) : null,
|
|
6943
|
-
sel &&
|
|
7440
|
+
sel && !loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6944
7441
|
DetailButton,
|
|
6945
7442
|
{
|
|
6946
7443
|
btnRef: complianceBtnRef,
|
|
@@ -6952,7 +7449,7 @@ function PayCard(props) {
|
|
|
6952
7449
|
onClick: () => setSheet(true)
|
|
6953
7450
|
}
|
|
6954
7451
|
) : null,
|
|
6955
|
-
sel && selectedVisible &&
|
|
7452
|
+
sel && selectedVisible && !loadingPlan ? /* @__PURE__ */ jsxRuntime.jsx(RateBox, { rowsOnly: true, rate: null, fromSymbol: "", toTicker: "", rows: feeRows }) : null
|
|
6956
7453
|
] }),
|
|
6957
7454
|
submitting ? /* @__PURE__ */ jsxRuntime.jsx(StepList, { steps: flow.steps }) : null,
|
|
6958
7455
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cta-wrap", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6960,7 +7457,7 @@ function PayCard(props) {
|
|
|
6960
7457
|
{
|
|
6961
7458
|
onClick: parked || !selectedVisible ? void 0 : flow.submit,
|
|
6962
7459
|
busy: submitting,
|
|
6963
|
-
disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall ||
|
|
7460
|
+
disabled: parked || !selectedVisible || flow.insufficient || !!flow.nativeShortfall || loadingPlan,
|
|
6964
7461
|
children: payLabel
|
|
6965
7462
|
}
|
|
6966
7463
|
) })
|
|
@@ -7298,6 +7795,10 @@ function ExchangeCard(props) {
|
|
|
7298
7795
|
}
|
|
7299
7796
|
return states;
|
|
7300
7797
|
}, [catalogue, fromToken]);
|
|
7798
|
+
const toPickerVisible = react.useMemo(
|
|
7799
|
+
() => destinationStates ? toPickerTokens.filter((t) => !destinationStates[`${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`]?.disabled) : toPickerTokens,
|
|
7800
|
+
[toPickerTokens, destinationStates]
|
|
7801
|
+
);
|
|
7301
7802
|
const normalizedAmount = normalizeDecimalText(amount);
|
|
7302
7803
|
const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
|
|
7303
7804
|
const rampMode = mode !== "exchange";
|
|
@@ -7433,8 +7934,8 @@ function ExchangeCard(props) {
|
|
|
7433
7934
|
const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
|
|
7434
7935
|
const compliance = selected?.quote.compliance;
|
|
7435
7936
|
const complianceHasQuote = Boolean(selected && flow.status !== "loading");
|
|
7436
|
-
const fromUsd =
|
|
7437
|
-
const toUsd =
|
|
7937
|
+
const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
|
|
7938
|
+
const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
|
|
7438
7939
|
const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
|
|
7439
7940
|
const flip = () => {
|
|
7440
7941
|
if (!flippable) return;
|
|
@@ -7517,8 +8018,11 @@ function ExchangeCard(props) {
|
|
|
7517
8018
|
TokenSelect,
|
|
7518
8019
|
{
|
|
7519
8020
|
title: isFrom ? "Exchange from" : "Exchange to",
|
|
8021
|
+
side: isFrom ? "from" : "to",
|
|
8022
|
+
selected: isFrom ? from : to,
|
|
8023
|
+
fetchPrices: engine.fetchPrices,
|
|
7520
8024
|
chains,
|
|
7521
|
-
tokens: isFrom ? fromPickerTokens :
|
|
8025
|
+
tokens: isFrom ? fromPickerTokens : toPickerVisible,
|
|
7522
8026
|
balances,
|
|
7523
8027
|
optionStates: isFrom ? void 0 : destinationStates,
|
|
7524
8028
|
loading: !catalogue?.ready,
|