@rash2x/bridge-widget 0.6.99 → 0.7.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/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-ZGjXGtUd.js → index-CbOaxQWE.js} +2 -2
- package/dist/{index-ZGjXGtUd.js.map → index-CbOaxQWE.js.map} +1 -1
- package/dist/{index-d47EGpyZ.js → index-D_iIDai5.js} +72 -18
- package/dist/index-D_iIDai5.js.map +1 -0
- package/dist/{index-UMHkIgdO.cjs → index-DwNmWmqq.cjs} +72 -18
- package/dist/index-DwNmWmqq.cjs.map +1 -0
- package/dist/{index-CRWwEw3g.cjs → index-jmefkuWp.cjs} +2 -2
- package/dist/{index-CRWwEw3g.cjs.map → index-jmefkuWp.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-UMHkIgdO.cjs.map +0 -1
- package/dist/index-d47EGpyZ.js.map +0 -1
|
@@ -2211,6 +2211,31 @@ function resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey) {
|
|
|
2211
2211
|
const DEFAULT_SLIPPAGE_BPS = 50;
|
|
2212
2212
|
const lower = (s2) => (s2 ?? "").toLowerCase();
|
|
2213
2213
|
const normSym = (s2) => (s2 ?? "").toUpperCase().replace(/₮/g, "T").replace(/[^A-Z0-9]/g, "");
|
|
2214
|
+
const isPositivePrice = (v2) => typeof v2 === "number" && Number.isFinite(v2) && v2 > 0;
|
|
2215
|
+
const NATIVE_SYMBOL_ALIASES = {
|
|
2216
|
+
ETH: ["WETH"],
|
|
2217
|
+
BNB: ["WBNB"],
|
|
2218
|
+
AVAX: ["WAVAX"],
|
|
2219
|
+
TRX: ["WTRX"],
|
|
2220
|
+
MATIC: ["WMATIC", "POL", "WPOL"],
|
|
2221
|
+
POL: ["MATIC", "WMATIC", "WPOL"]
|
|
2222
|
+
};
|
|
2223
|
+
function nativeSymbolCandidates(symbol) {
|
|
2224
|
+
const out = /* @__PURE__ */ new Set([symbol]);
|
|
2225
|
+
if (symbol.startsWith("W") && symbol.length > 1) {
|
|
2226
|
+
out.add(symbol.slice(1));
|
|
2227
|
+
} else {
|
|
2228
|
+
out.add(`W${symbol}`);
|
|
2229
|
+
}
|
|
2230
|
+
for (const alias of NATIVE_SYMBOL_ALIASES[symbol] ?? []) {
|
|
2231
|
+
out.add(alias);
|
|
2232
|
+
}
|
|
2233
|
+
return out;
|
|
2234
|
+
}
|
|
2235
|
+
function pickBestPricedToken(tokens) {
|
|
2236
|
+
if (!tokens.length) return void 0;
|
|
2237
|
+
return tokens.find((t2) => isPositivePrice(t2.price?.usd)) ?? tokens[0];
|
|
2238
|
+
}
|
|
2214
2239
|
function tonNorm(addr) {
|
|
2215
2240
|
if (!addr) return null;
|
|
2216
2241
|
try {
|
|
@@ -2258,14 +2283,25 @@ function findNativeMeta(tokens, chain2) {
|
|
|
2258
2283
|
if (!sym) {
|
|
2259
2284
|
return { decimals: nativeDecimals, priceUsd: void 0 };
|
|
2260
2285
|
}
|
|
2261
|
-
const
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2286
|
+
const symbols = nativeSymbolCandidates(sym);
|
|
2287
|
+
const sameChainMatches = tokens?.filter(
|
|
2288
|
+
(t2) => t2.chainKey === chain2.chainKey && symbols.has(normSym(t2.symbol))
|
|
2289
|
+
) ?? [];
|
|
2290
|
+
const sameChain = pickBestPricedToken(sameChainMatches);
|
|
2291
|
+
if (sameChain) {
|
|
2292
|
+
return {
|
|
2293
|
+
decimals: sameChain.decimals,
|
|
2294
|
+
priceUsd: isPositivePrice(sameChain.price?.usd) ? sameChain.price?.usd : void 0
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
const anyChainMatches = tokens?.filter((t2) => symbols.has(normSym(t2.symbol))) ?? [];
|
|
2298
|
+
const anyChain = pickBestPricedToken(anyChainMatches);
|
|
2299
|
+
if (anyChain) {
|
|
2300
|
+
return {
|
|
2301
|
+
decimals: anyChain.decimals,
|
|
2302
|
+
priceUsd: isPositivePrice(anyChain.price?.usd) ? anyChain.price?.usd : void 0
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2269
2305
|
return { decimals: nativeDecimals, priceUsd: void 0 };
|
|
2270
2306
|
}
|
|
2271
2307
|
function lookupTokenMeta(tokens, chains, chainKey, tokenAddr) {
|
|
@@ -2280,7 +2316,13 @@ function lookupTokenMeta(tokens, chains, chainKey, tokenAddr) {
|
|
|
2280
2316
|
}
|
|
2281
2317
|
return lower(t2.address) === lower(tokenAddr);
|
|
2282
2318
|
}) ?? void 0;
|
|
2283
|
-
if (hit)
|
|
2319
|
+
if (hit) {
|
|
2320
|
+
const hitPriceUsd = isPositivePrice(hit.price?.usd) ? hit.price?.usd : void 0;
|
|
2321
|
+
if (hitPriceUsd !== void 0 || !isNativeAddrEqual(chain2, tokenAddr)) {
|
|
2322
|
+
return { decimals: hit.decimals, priceUsd: hitPriceUsd };
|
|
2323
|
+
}
|
|
2324
|
+
return findNativeMeta(tokens, chain2);
|
|
2325
|
+
}
|
|
2284
2326
|
if (isNativeAddrEqual(chain2, tokenAddr)) {
|
|
2285
2327
|
return findNativeMeta(tokens, chain2);
|
|
2286
2328
|
}
|
|
@@ -2343,7 +2385,12 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
|
2343
2385
|
let messageFeeUsd = 0;
|
|
2344
2386
|
const messageFees = quote.fees.filter((f4) => f4.type === "message");
|
|
2345
2387
|
for (const f4 of messageFees) {
|
|
2346
|
-
const { decimals, priceUsd } = lookupTokenMeta(
|
|
2388
|
+
const { decimals, priceUsd } = lookupTokenMeta(
|
|
2389
|
+
tokens,
|
|
2390
|
+
chains,
|
|
2391
|
+
f4.chainKey,
|
|
2392
|
+
f4.token
|
|
2393
|
+
);
|
|
2347
2394
|
const human = fromLD(f4.amount || "0", decimals);
|
|
2348
2395
|
messageFeeUsd += human * (priceUsd ?? 0);
|
|
2349
2396
|
}
|
|
@@ -2375,7 +2422,9 @@ async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
|
|
|
2375
2422
|
if (!strategy) continue;
|
|
2376
2423
|
const chain2 = chains.find((c2) => c2.chainKey === chainKey);
|
|
2377
2424
|
if (!chain2) continue;
|
|
2378
|
-
const stepsForChain = quote.steps.filter(
|
|
2425
|
+
const stepsForChain = quote.steps.filter(
|
|
2426
|
+
(step) => step.chainKey === chainKey
|
|
2427
|
+
);
|
|
2379
2428
|
if (!stepsForChain.length) continue;
|
|
2380
2429
|
try {
|
|
2381
2430
|
const networkFeeHuman = await strategy.estimateNetworkFee(stepsForChain);
|
|
@@ -2392,7 +2441,10 @@ async function addNetworkFeesToQuote(quote, chainRegistry, chains) {
|
|
|
2392
2441
|
});
|
|
2393
2442
|
}
|
|
2394
2443
|
} catch (error) {
|
|
2395
|
-
console.warn(
|
|
2444
|
+
console.warn(
|
|
2445
|
+
`Failed to estimate network fee for chain ${chainKey}:`,
|
|
2446
|
+
error
|
|
2447
|
+
);
|
|
2396
2448
|
}
|
|
2397
2449
|
}
|
|
2398
2450
|
return {
|
|
@@ -2866,7 +2918,7 @@ const TokenSymbol = ({
|
|
|
2866
2918
|
};
|
|
2867
2919
|
function useFeeBreakdown() {
|
|
2868
2920
|
const { quote } = useBridgeQuoteStore();
|
|
2869
|
-
const { tokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
2921
|
+
const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
2870
2922
|
const { fromChain, chains } = useChainsStore();
|
|
2871
2923
|
return react.useMemo(() => {
|
|
2872
2924
|
const srcToken = resolveTokenOnChainFromMatrix$1(
|
|
@@ -2874,8 +2926,8 @@ function useFeeBreakdown() {
|
|
|
2874
2926
|
selectedAssetSymbol,
|
|
2875
2927
|
fromChain?.chainKey
|
|
2876
2928
|
);
|
|
2877
|
-
return computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
|
|
2878
|
-
}, [quote, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
|
|
2929
|
+
return computeFeeBreakdownUsd(quote, srcToken, allTokens ?? tokens, chains);
|
|
2930
|
+
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
|
|
2879
2931
|
}
|
|
2880
2932
|
function useBridgeExternalData(options) {
|
|
2881
2933
|
const selectedAssetSymbol = useTokensStore(
|
|
@@ -2883,6 +2935,7 @@ function useBridgeExternalData(options) {
|
|
|
2883
2935
|
);
|
|
2884
2936
|
const assetMatrix = useTokensStore((state2) => state2.assetMatrix);
|
|
2885
2937
|
const tokens = useTokensStore((state2) => state2.tokens);
|
|
2938
|
+
const allTokens = useTokensStore((state2) => state2.allTokens);
|
|
2886
2939
|
const fromChain = useChainsStore((state2) => state2.fromChain);
|
|
2887
2940
|
const toChain = useChainsStore((state2) => state2.toChain);
|
|
2888
2941
|
const chains = useChainsStore((state2) => state2.chains);
|
|
@@ -2897,7 +2950,7 @@ function useBridgeExternalData(options) {
|
|
|
2897
2950
|
dstChain: toChain,
|
|
2898
2951
|
assetMatrix,
|
|
2899
2952
|
chains,
|
|
2900
|
-
tokens,
|
|
2953
|
+
tokens: allTokens ?? tokens,
|
|
2901
2954
|
quote,
|
|
2902
2955
|
slippageBps
|
|
2903
2956
|
}),
|
|
@@ -2908,6 +2961,7 @@ function useBridgeExternalData(options) {
|
|
|
2908
2961
|
toChain,
|
|
2909
2962
|
assetMatrix,
|
|
2910
2963
|
chains,
|
|
2964
|
+
allTokens,
|
|
2911
2965
|
tokens,
|
|
2912
2966
|
quote,
|
|
2913
2967
|
slippageBps
|
|
@@ -25735,7 +25789,7 @@ class WalletConnectModal {
|
|
|
25735
25789
|
}
|
|
25736
25790
|
async initUi() {
|
|
25737
25791
|
if (typeof window !== "undefined") {
|
|
25738
|
-
await Promise.resolve().then(() => require("./index-
|
|
25792
|
+
await Promise.resolve().then(() => require("./index-jmefkuWp.cjs"));
|
|
25739
25793
|
const modal = document.createElement("wcm-modal");
|
|
25740
25794
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25741
25795
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26581,4 +26635,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26581
26635
|
exports.useSwapModel = useSwapModel;
|
|
26582
26636
|
exports.useTokensStore = useTokensStore;
|
|
26583
26637
|
exports.useTransactionStore = useTransactionStore;
|
|
26584
|
-
//# sourceMappingURL=index-
|
|
26638
|
+
//# sourceMappingURL=index-DwNmWmqq.cjs.map
|