@rash2x/bridge-widget 0.7.4 → 0.7.5
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 +3 -1
- package/dist/evaa-bridge.cjs.map +1 -1
- package/dist/evaa-bridge.mjs +14 -12
- package/dist/{index-B9T9OLH8.cjs → index-CQTSauOr.cjs} +2 -2
- package/dist/{index-B9T9OLH8.cjs.map → index-CQTSauOr.cjs.map} +1 -1
- package/dist/{index-DGMnvCZU.js → index-CeW-ueEx.js} +90 -37
- package/dist/index-CeW-ueEx.js.map +1 -0
- package/dist/{index-Cvo_dMKt.cjs → index-DXcV5o9h.cjs} +79 -26
- package/dist/index-DXcV5o9h.cjs.map +1 -0
- package/dist/{index-Giyq4_RJ.js → index-HUIu1V_6.js} +2 -2
- package/dist/{index-Giyq4_RJ.js.map → index-HUIu1V_6.js.map} +1 -1
- package/dist/index.d.ts +6 -2
- package/package.json +1 -1
- package/dist/index-Cvo_dMKt.cjs.map +0 -1
- package/dist/index-DGMnvCZU.js.map +0 -1
|
@@ -1074,6 +1074,49 @@ const useTokensStore = zustand.create((set2) => ({
|
|
|
1074
1074
|
});
|
|
1075
1075
|
}
|
|
1076
1076
|
}));
|
|
1077
|
+
const ALLOWED_TO_CHAINS = /* @__PURE__ */ new Set([
|
|
1078
|
+
"ethereum",
|
|
1079
|
+
"manta",
|
|
1080
|
+
"opbnb",
|
|
1081
|
+
"polygon",
|
|
1082
|
+
"conflux",
|
|
1083
|
+
"ton",
|
|
1084
|
+
"tron",
|
|
1085
|
+
"megaeth",
|
|
1086
|
+
"mantle",
|
|
1087
|
+
"base",
|
|
1088
|
+
"plasma",
|
|
1089
|
+
"monad",
|
|
1090
|
+
"celo",
|
|
1091
|
+
"linea",
|
|
1092
|
+
"blast",
|
|
1093
|
+
"scroll",
|
|
1094
|
+
"cronosevm",
|
|
1095
|
+
"optimism",
|
|
1096
|
+
"gnosis",
|
|
1097
|
+
"sonic",
|
|
1098
|
+
"fantom",
|
|
1099
|
+
"zksync",
|
|
1100
|
+
"metis",
|
|
1101
|
+
"zkevm",
|
|
1102
|
+
"moonbeam",
|
|
1103
|
+
"moonriver",
|
|
1104
|
+
"kava",
|
|
1105
|
+
"klaytn",
|
|
1106
|
+
"avalanche",
|
|
1107
|
+
"arbitrum",
|
|
1108
|
+
"bsc",
|
|
1109
|
+
"aurora"
|
|
1110
|
+
]);
|
|
1111
|
+
const ALLOWED_FROM_CHAINS = new Set(
|
|
1112
|
+
[...ALLOWED_TO_CHAINS].filter((k2) => k2 !== "tron")
|
|
1113
|
+
);
|
|
1114
|
+
function isAllowedFromChain(chainKey) {
|
|
1115
|
+
return ALLOWED_FROM_CHAINS.has(chainKey);
|
|
1116
|
+
}
|
|
1117
|
+
function isAllowedToChain(chainKey) {
|
|
1118
|
+
return ALLOWED_TO_CHAINS.has(chainKey);
|
|
1119
|
+
}
|
|
1077
1120
|
async function getChains() {
|
|
1078
1121
|
const res = await fetch("https://stargate.finance/api/v1/chains", {
|
|
1079
1122
|
credentials: "same-origin"
|
|
@@ -1082,7 +1125,8 @@ async function getChains() {
|
|
|
1082
1125
|
throw new Error(`Failed to load chains: ${res.status}`);
|
|
1083
1126
|
}
|
|
1084
1127
|
const data = await res.json();
|
|
1085
|
-
|
|
1128
|
+
const all = Array.isArray(data) ? data : data.chains ?? [];
|
|
1129
|
+
return all.filter((c2) => ALLOWED_TO_CHAINS.has(c2.chainKey));
|
|
1086
1130
|
}
|
|
1087
1131
|
async function getTokens() {
|
|
1088
1132
|
const res = await fetch("https://stargate.finance/api/v1/tokens", {
|
|
@@ -1225,17 +1269,18 @@ const ChainSelectModal = ({
|
|
|
1225
1269
|
);
|
|
1226
1270
|
const groupedChains = react.useMemo(() => {
|
|
1227
1271
|
const q3 = query.trim().toLowerCase();
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1272
|
+
const isAllowed = isSource ? isAllowedFromChain : isAllowedToChain;
|
|
1273
|
+
const filtered = (items ?? []).filter((c2) => isAllowed(c2.chainKey)).filter(
|
|
1274
|
+
(c2) => !q3 || c2.name.toLowerCase().includes(q3) || c2.chainKey.toLowerCase().includes(q3)
|
|
1275
|
+
);
|
|
1231
1276
|
const groups = {
|
|
1232
1277
|
available: [],
|
|
1233
1278
|
willChangeSrc: [],
|
|
1234
1279
|
willChangeTokenAndSrc: []
|
|
1235
1280
|
};
|
|
1236
1281
|
for (const chain2 of filtered) {
|
|
1237
|
-
const
|
|
1238
|
-
if (
|
|
1282
|
+
const isAllowed2 = allowedItems?.some((c2) => c2.chainKey === chain2.chainKey) || false;
|
|
1283
|
+
if (isAllowed2) {
|
|
1239
1284
|
groups.available.push(chain2);
|
|
1240
1285
|
} else {
|
|
1241
1286
|
const compatibleSrc = findCompatibleSrcChain(chain2);
|
|
@@ -1258,7 +1303,8 @@ const ChainSelectModal = ({
|
|
|
1258
1303
|
query,
|
|
1259
1304
|
allowedItems,
|
|
1260
1305
|
findCompatibleSrcChain,
|
|
1261
|
-
findCompatibleTokenAndSrcChain
|
|
1306
|
+
findCompatibleTokenAndSrcChain,
|
|
1307
|
+
isSource
|
|
1262
1308
|
]);
|
|
1263
1309
|
const PRIORITY_CHAINS = react.useMemo(
|
|
1264
1310
|
() => ["ethereum", "arbitrum", "bsc", "polygon", "optimism", "base"],
|
|
@@ -2357,9 +2403,9 @@ function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
|
2357
2403
|
const minAmountLD = dstAmountLD * BigInt(1e4 - slippageBps) / BigInt(1e4);
|
|
2358
2404
|
return fromLD(minAmountLD.toString(), dstToken.decimals);
|
|
2359
2405
|
}
|
|
2360
|
-
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
2406
|
+
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps, srcChain, dstChain) {
|
|
2361
2407
|
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2362
|
-
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
|
|
2408
|
+
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain);
|
|
2363
2409
|
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2364
2410
|
return {
|
|
2365
2411
|
inputAmount: amounts.inputHuman,
|
|
@@ -2379,16 +2425,19 @@ function getRouteDisplayName(route) {
|
|
|
2379
2425
|
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2380
2426
|
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2381
2427
|
}
|
|
2382
|
-
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
2428
|
+
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain) {
|
|
2429
|
+
const defaultMsgSymbol = srcChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
2430
|
+
const defaultBridgeSymbol = srcToken?.symbol?.toUpperCase() ?? "";
|
|
2431
|
+
const defaultDstGasSymbol = dstChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
2383
2432
|
const empty = {
|
|
2384
2433
|
messageFeeAmount: 0,
|
|
2385
|
-
messageFeeSymbol:
|
|
2434
|
+
messageFeeSymbol: defaultMsgSymbol,
|
|
2386
2435
|
messageFeeUsd: 0,
|
|
2387
2436
|
bridgeFeeAmount: 0,
|
|
2388
|
-
bridgeFeeSymbol:
|
|
2437
|
+
bridgeFeeSymbol: defaultBridgeSymbol,
|
|
2389
2438
|
bridgeFeeUsd: 0,
|
|
2390
2439
|
dstGasAmount: 0,
|
|
2391
|
-
dstGasSymbol:
|
|
2440
|
+
dstGasSymbol: defaultDstGasSymbol,
|
|
2392
2441
|
dstGasUsd: 0,
|
|
2393
2442
|
totalFeeUsd: 0
|
|
2394
2443
|
};
|
|
@@ -2430,16 +2479,16 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
|
2430
2479
|
let dstGasUsd = 0;
|
|
2431
2480
|
const dstNativeAmountLD = quote.dstNativeAmount;
|
|
2432
2481
|
if (dstNativeAmountLD && BigInt(dstNativeAmountLD || "0") > 0n) {
|
|
2433
|
-
const
|
|
2434
|
-
if (
|
|
2482
|
+
const dstChain2 = chains?.find((c2) => c2.chainKey === quote.dstChainKey);
|
|
2483
|
+
if (dstChain2) {
|
|
2435
2484
|
const { decimals, priceUsd } = lookupTokenMeta(
|
|
2436
2485
|
tokens,
|
|
2437
2486
|
chains,
|
|
2438
|
-
|
|
2439
|
-
|
|
2487
|
+
dstChain2.chainKey,
|
|
2488
|
+
dstChain2.nativeCurrency.address
|
|
2440
2489
|
);
|
|
2441
2490
|
dstGasAmount = fromLD(dstNativeAmountLD, decimals);
|
|
2442
|
-
dstGasSymbol =
|
|
2491
|
+
dstGasSymbol = dstChain2.nativeCurrency.symbol?.toUpperCase() ?? "";
|
|
2443
2492
|
dstGasUsd = dstGasAmount * (priceUsd ?? 0);
|
|
2444
2493
|
}
|
|
2445
2494
|
}
|
|
@@ -2697,7 +2746,7 @@ const useChainDerivations = () => {
|
|
|
2697
2746
|
return [];
|
|
2698
2747
|
const byChain = assetMatrix[selectedAssetSymbol.toUpperCase()];
|
|
2699
2748
|
const keys2 = new Set(Object.keys(byChain ?? {}));
|
|
2700
|
-
const result = chains.filter((c2) => keys2.has(c2.chainKey));
|
|
2749
|
+
const result = chains.filter((c2) => keys2.has(c2.chainKey) && isAllowedFromChain(c2.chainKey));
|
|
2701
2750
|
return result;
|
|
2702
2751
|
}, [selectedAssetSymbol, assetMatrix, chains]);
|
|
2703
2752
|
react.useEffect(() => {
|
|
@@ -2761,7 +2810,7 @@ const useChainDerivations = () => {
|
|
|
2761
2810
|
return !!symbolMatch;
|
|
2762
2811
|
});
|
|
2763
2812
|
const keys2 = new Set(filteredDest.map((t2) => t2.chainKey));
|
|
2764
|
-
let list = chains.filter((c2) => keys2.has(c2.chainKey));
|
|
2813
|
+
let list = chains.filter((c2) => keys2.has(c2.chainKey) && isAllowedToChain(c2.chainKey));
|
|
2765
2814
|
if (fromChain?.chainKey) {
|
|
2766
2815
|
list = list.filter((c2) => c2.chainKey !== fromChain.chainKey);
|
|
2767
2816
|
}
|
|
@@ -2995,15 +3044,15 @@ const TokenSymbol = ({
|
|
|
2995
3044
|
function useFeeBreakdown() {
|
|
2996
3045
|
const { quote } = useBridgeQuoteStore();
|
|
2997
3046
|
const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
2998
|
-
const { fromChain, chains } = useChainsStore();
|
|
3047
|
+
const { fromChain, toChain, chains } = useChainsStore();
|
|
2999
3048
|
return react.useMemo(() => {
|
|
3000
3049
|
const srcToken = resolveTokenOnChainFromMatrix$1(
|
|
3001
3050
|
assetMatrix,
|
|
3002
3051
|
selectedAssetSymbol,
|
|
3003
3052
|
fromChain?.chainKey
|
|
3004
3053
|
);
|
|
3005
|
-
return computeFeeBreakdownUsd(quote, srcToken, allTokens ?? tokens, chains);
|
|
3006
|
-
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
|
|
3054
|
+
return computeFeeBreakdownUsd(quote, srcToken, allTokens ?? tokens, chains, fromChain, toChain);
|
|
3055
|
+
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain, toChain]);
|
|
3007
3056
|
}
|
|
3008
3057
|
function useBridgeExternalData(options) {
|
|
3009
3058
|
const selectedAssetSymbol = useTokensStore(
|
|
@@ -3090,7 +3139,9 @@ function buildBridgeExternalData({
|
|
|
3090
3139
|
destinationToken,
|
|
3091
3140
|
tokens,
|
|
3092
3141
|
chains,
|
|
3093
|
-
slippageBps
|
|
3142
|
+
slippageBps,
|
|
3143
|
+
fromChain,
|
|
3144
|
+
toChain
|
|
3094
3145
|
);
|
|
3095
3146
|
const etaText = quoteDetails.etaSeconds != null ? `≈ ${Math.max(1, Math.round(quoteDetails.etaSeconds / 60))}m` : "—";
|
|
3096
3147
|
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
@@ -26047,7 +26098,7 @@ class WalletConnectModal {
|
|
|
26047
26098
|
}
|
|
26048
26099
|
async initUi() {
|
|
26049
26100
|
if (typeof window !== "undefined") {
|
|
26050
|
-
await Promise.resolve().then(() => require("./index-
|
|
26101
|
+
await Promise.resolve().then(() => require("./index-CQTSauOr.cjs"));
|
|
26051
26102
|
const modal = document.createElement("wcm-modal");
|
|
26052
26103
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26053
26104
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26923,6 +26974,8 @@ exports.getRouteDisplayName = getRouteDisplayName;
|
|
|
26923
26974
|
exports.getTokens = getTokens;
|
|
26924
26975
|
exports.getTonBalances = getTonBalances;
|
|
26925
26976
|
exports.getTronBalances = getTronBalances;
|
|
26977
|
+
exports.isAllowedFromChain = isAllowedFromChain;
|
|
26978
|
+
exports.isAllowedToChain = isAllowedToChain;
|
|
26926
26979
|
exports.isNativeAddrEqual = isNativeAddrEqual;
|
|
26927
26980
|
exports.isNativeAddress = isNativeAddress;
|
|
26928
26981
|
exports.isZeroAddr = isZeroAddr;
|
|
@@ -26945,4 +26998,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26945
26998
|
exports.useSwapModel = useSwapModel;
|
|
26946
26999
|
exports.useTokensStore = useTokensStore;
|
|
26947
27000
|
exports.useTransactionStore = useTransactionStore;
|
|
26948
|
-
//# sourceMappingURL=index-
|
|
27001
|
+
//# sourceMappingURL=index-DXcV5o9h.cjs.map
|