@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
|
@@ -1073,6 +1073,49 @@ const useTokensStore = create((set2) => ({
|
|
|
1073
1073
|
});
|
|
1074
1074
|
}
|
|
1075
1075
|
}));
|
|
1076
|
+
const ALLOWED_TO_CHAINS = /* @__PURE__ */ new Set([
|
|
1077
|
+
"ethereum",
|
|
1078
|
+
"manta",
|
|
1079
|
+
"opbnb",
|
|
1080
|
+
"polygon",
|
|
1081
|
+
"conflux",
|
|
1082
|
+
"ton",
|
|
1083
|
+
"tron",
|
|
1084
|
+
"megaeth",
|
|
1085
|
+
"mantle",
|
|
1086
|
+
"base",
|
|
1087
|
+
"plasma",
|
|
1088
|
+
"monad",
|
|
1089
|
+
"celo",
|
|
1090
|
+
"linea",
|
|
1091
|
+
"blast",
|
|
1092
|
+
"scroll",
|
|
1093
|
+
"cronosevm",
|
|
1094
|
+
"optimism",
|
|
1095
|
+
"gnosis",
|
|
1096
|
+
"sonic",
|
|
1097
|
+
"fantom",
|
|
1098
|
+
"zksync",
|
|
1099
|
+
"metis",
|
|
1100
|
+
"zkevm",
|
|
1101
|
+
"moonbeam",
|
|
1102
|
+
"moonriver",
|
|
1103
|
+
"kava",
|
|
1104
|
+
"klaytn",
|
|
1105
|
+
"avalanche",
|
|
1106
|
+
"arbitrum",
|
|
1107
|
+
"bsc",
|
|
1108
|
+
"aurora"
|
|
1109
|
+
]);
|
|
1110
|
+
const ALLOWED_FROM_CHAINS = new Set(
|
|
1111
|
+
[...ALLOWED_TO_CHAINS].filter((k2) => k2 !== "tron")
|
|
1112
|
+
);
|
|
1113
|
+
function isAllowedFromChain(chainKey) {
|
|
1114
|
+
return ALLOWED_FROM_CHAINS.has(chainKey);
|
|
1115
|
+
}
|
|
1116
|
+
function isAllowedToChain(chainKey) {
|
|
1117
|
+
return ALLOWED_TO_CHAINS.has(chainKey);
|
|
1118
|
+
}
|
|
1076
1119
|
async function getChains() {
|
|
1077
1120
|
const res = await fetch("https://stargate.finance/api/v1/chains", {
|
|
1078
1121
|
credentials: "same-origin"
|
|
@@ -1081,7 +1124,8 @@ async function getChains() {
|
|
|
1081
1124
|
throw new Error(`Failed to load chains: ${res.status}`);
|
|
1082
1125
|
}
|
|
1083
1126
|
const data = await res.json();
|
|
1084
|
-
|
|
1127
|
+
const all = Array.isArray(data) ? data : data.chains ?? [];
|
|
1128
|
+
return all.filter((c2) => ALLOWED_TO_CHAINS.has(c2.chainKey));
|
|
1085
1129
|
}
|
|
1086
1130
|
async function getTokens() {
|
|
1087
1131
|
const res = await fetch("https://stargate.finance/api/v1/tokens", {
|
|
@@ -1224,17 +1268,18 @@ const ChainSelectModal = ({
|
|
|
1224
1268
|
);
|
|
1225
1269
|
const groupedChains = useMemo(() => {
|
|
1226
1270
|
const q3 = query.trim().toLowerCase();
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
|
|
1271
|
+
const isAllowed = isSource ? isAllowedFromChain : isAllowedToChain;
|
|
1272
|
+
const filtered = (items ?? []).filter((c2) => isAllowed(c2.chainKey)).filter(
|
|
1273
|
+
(c2) => !q3 || c2.name.toLowerCase().includes(q3) || c2.chainKey.toLowerCase().includes(q3)
|
|
1274
|
+
);
|
|
1230
1275
|
const groups = {
|
|
1231
1276
|
available: [],
|
|
1232
1277
|
willChangeSrc: [],
|
|
1233
1278
|
willChangeTokenAndSrc: []
|
|
1234
1279
|
};
|
|
1235
1280
|
for (const chain2 of filtered) {
|
|
1236
|
-
const
|
|
1237
|
-
if (
|
|
1281
|
+
const isAllowed2 = allowedItems?.some((c2) => c2.chainKey === chain2.chainKey) || false;
|
|
1282
|
+
if (isAllowed2) {
|
|
1238
1283
|
groups.available.push(chain2);
|
|
1239
1284
|
} else {
|
|
1240
1285
|
const compatibleSrc = findCompatibleSrcChain(chain2);
|
|
@@ -1257,7 +1302,8 @@ const ChainSelectModal = ({
|
|
|
1257
1302
|
query,
|
|
1258
1303
|
allowedItems,
|
|
1259
1304
|
findCompatibleSrcChain,
|
|
1260
|
-
findCompatibleTokenAndSrcChain
|
|
1305
|
+
findCompatibleTokenAndSrcChain,
|
|
1306
|
+
isSource
|
|
1261
1307
|
]);
|
|
1262
1308
|
const PRIORITY_CHAINS = useMemo(
|
|
1263
1309
|
() => ["ethereum", "arbitrum", "bsc", "polygon", "optimism", "base"],
|
|
@@ -2356,9 +2402,9 @@ function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
|
2356
2402
|
const minAmountLD = dstAmountLD * BigInt(1e4 - slippageBps) / BigInt(1e4);
|
|
2357
2403
|
return fromLD(minAmountLD.toString(), dstToken.decimals);
|
|
2358
2404
|
}
|
|
2359
|
-
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps) {
|
|
2405
|
+
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps, srcChain, dstChain) {
|
|
2360
2406
|
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2361
|
-
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains);
|
|
2407
|
+
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain);
|
|
2362
2408
|
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2363
2409
|
return {
|
|
2364
2410
|
inputAmount: amounts.inputHuman,
|
|
@@ -2378,16 +2424,19 @@ function getRouteDisplayName(route) {
|
|
|
2378
2424
|
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2379
2425
|
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2380
2426
|
}
|
|
2381
|
-
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
2427
|
+
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain) {
|
|
2428
|
+
const defaultMsgSymbol = srcChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
2429
|
+
const defaultBridgeSymbol = srcToken?.symbol?.toUpperCase() ?? "";
|
|
2430
|
+
const defaultDstGasSymbol = dstChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
2382
2431
|
const empty = {
|
|
2383
2432
|
messageFeeAmount: 0,
|
|
2384
|
-
messageFeeSymbol:
|
|
2433
|
+
messageFeeSymbol: defaultMsgSymbol,
|
|
2385
2434
|
messageFeeUsd: 0,
|
|
2386
2435
|
bridgeFeeAmount: 0,
|
|
2387
|
-
bridgeFeeSymbol:
|
|
2436
|
+
bridgeFeeSymbol: defaultBridgeSymbol,
|
|
2388
2437
|
bridgeFeeUsd: 0,
|
|
2389
2438
|
dstGasAmount: 0,
|
|
2390
|
-
dstGasSymbol:
|
|
2439
|
+
dstGasSymbol: defaultDstGasSymbol,
|
|
2391
2440
|
dstGasUsd: 0,
|
|
2392
2441
|
totalFeeUsd: 0
|
|
2393
2442
|
};
|
|
@@ -2429,16 +2478,16 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains) {
|
|
|
2429
2478
|
let dstGasUsd = 0;
|
|
2430
2479
|
const dstNativeAmountLD = quote.dstNativeAmount;
|
|
2431
2480
|
if (dstNativeAmountLD && BigInt(dstNativeAmountLD || "0") > 0n) {
|
|
2432
|
-
const
|
|
2433
|
-
if (
|
|
2481
|
+
const dstChain2 = chains?.find((c2) => c2.chainKey === quote.dstChainKey);
|
|
2482
|
+
if (dstChain2) {
|
|
2434
2483
|
const { decimals, priceUsd } = lookupTokenMeta(
|
|
2435
2484
|
tokens,
|
|
2436
2485
|
chains,
|
|
2437
|
-
|
|
2438
|
-
|
|
2486
|
+
dstChain2.chainKey,
|
|
2487
|
+
dstChain2.nativeCurrency.address
|
|
2439
2488
|
);
|
|
2440
2489
|
dstGasAmount = fromLD(dstNativeAmountLD, decimals);
|
|
2441
|
-
dstGasSymbol =
|
|
2490
|
+
dstGasSymbol = dstChain2.nativeCurrency.symbol?.toUpperCase() ?? "";
|
|
2442
2491
|
dstGasUsd = dstGasAmount * (priceUsd ?? 0);
|
|
2443
2492
|
}
|
|
2444
2493
|
}
|
|
@@ -2696,7 +2745,7 @@ const useChainDerivations = () => {
|
|
|
2696
2745
|
return [];
|
|
2697
2746
|
const byChain = assetMatrix[selectedAssetSymbol.toUpperCase()];
|
|
2698
2747
|
const keys2 = new Set(Object.keys(byChain ?? {}));
|
|
2699
|
-
const result = chains.filter((c2) => keys2.has(c2.chainKey));
|
|
2748
|
+
const result = chains.filter((c2) => keys2.has(c2.chainKey) && isAllowedFromChain(c2.chainKey));
|
|
2700
2749
|
return result;
|
|
2701
2750
|
}, [selectedAssetSymbol, assetMatrix, chains]);
|
|
2702
2751
|
useEffect(() => {
|
|
@@ -2760,7 +2809,7 @@ const useChainDerivations = () => {
|
|
|
2760
2809
|
return !!symbolMatch;
|
|
2761
2810
|
});
|
|
2762
2811
|
const keys2 = new Set(filteredDest.map((t2) => t2.chainKey));
|
|
2763
|
-
let list = chains.filter((c2) => keys2.has(c2.chainKey));
|
|
2812
|
+
let list = chains.filter((c2) => keys2.has(c2.chainKey) && isAllowedToChain(c2.chainKey));
|
|
2764
2813
|
if (fromChain?.chainKey) {
|
|
2765
2814
|
list = list.filter((c2) => c2.chainKey !== fromChain.chainKey);
|
|
2766
2815
|
}
|
|
@@ -2994,15 +3043,15 @@ const TokenSymbol = ({
|
|
|
2994
3043
|
function useFeeBreakdown() {
|
|
2995
3044
|
const { quote } = useBridgeQuoteStore();
|
|
2996
3045
|
const { tokens, allTokens, selectedAssetSymbol, assetMatrix } = useTokensStore();
|
|
2997
|
-
const { fromChain, chains } = useChainsStore();
|
|
3046
|
+
const { fromChain, toChain, chains } = useChainsStore();
|
|
2998
3047
|
return useMemo(() => {
|
|
2999
3048
|
const srcToken = resolveTokenOnChainFromMatrix$1(
|
|
3000
3049
|
assetMatrix,
|
|
3001
3050
|
selectedAssetSymbol,
|
|
3002
3051
|
fromChain?.chainKey
|
|
3003
3052
|
);
|
|
3004
|
-
return computeFeeBreakdownUsd(quote, srcToken, allTokens ?? tokens, chains);
|
|
3005
|
-
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain]);
|
|
3053
|
+
return computeFeeBreakdownUsd(quote, srcToken, allTokens ?? tokens, chains, fromChain, toChain);
|
|
3054
|
+
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain, toChain]);
|
|
3006
3055
|
}
|
|
3007
3056
|
function useBridgeExternalData(options) {
|
|
3008
3057
|
const selectedAssetSymbol = useTokensStore(
|
|
@@ -3089,7 +3138,9 @@ function buildBridgeExternalData({
|
|
|
3089
3138
|
destinationToken,
|
|
3090
3139
|
tokens,
|
|
3091
3140
|
chains,
|
|
3092
|
-
slippageBps
|
|
3141
|
+
slippageBps,
|
|
3142
|
+
fromChain,
|
|
3143
|
+
toChain
|
|
3093
3144
|
);
|
|
3094
3145
|
const etaText = quoteDetails.etaSeconds != null ? `≈ ${Math.max(1, Math.round(quoteDetails.etaSeconds / 60))}m` : "—";
|
|
3095
3146
|
const currentSlippageText = !quote ? "—" : formatPercentage(slippageBps);
|
|
@@ -26046,7 +26097,7 @@ class WalletConnectModal {
|
|
|
26046
26097
|
}
|
|
26047
26098
|
async initUi() {
|
|
26048
26099
|
if (typeof window !== "undefined") {
|
|
26049
|
-
await import("./index-
|
|
26100
|
+
await import("./index-HUIu1V_6.js");
|
|
26050
26101
|
const modal = document.createElement("wcm-modal");
|
|
26051
26102
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26052
26103
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26885,7 +26936,7 @@ const EvaaBridgeContent = ({
|
|
|
26885
26936
|
};
|
|
26886
26937
|
const EvaaBridge = EvaaBridgeWithProviders;
|
|
26887
26938
|
export {
|
|
26888
|
-
|
|
26939
|
+
getDestTokens as $,
|
|
26889
26940
|
getRouteDisplayName as A,
|
|
26890
26941
|
computeFeeBreakdownUsd as B,
|
|
26891
26942
|
ConfigCtrl as C,
|
|
@@ -26909,17 +26960,19 @@ export {
|
|
|
26909
26960
|
findNativeMeta as U,
|
|
26910
26961
|
lookupTokenMeta as V,
|
|
26911
26962
|
normalizeTickerSymbol$1 as W,
|
|
26912
|
-
|
|
26913
|
-
|
|
26914
|
-
|
|
26915
|
-
|
|
26963
|
+
isAllowedFromChain as X,
|
|
26964
|
+
isAllowedToChain as Y,
|
|
26965
|
+
getChains as Z,
|
|
26966
|
+
getTokens as _,
|
|
26916
26967
|
ThemeCtrl as a,
|
|
26917
|
-
|
|
26918
|
-
|
|
26919
|
-
|
|
26920
|
-
|
|
26921
|
-
|
|
26922
|
-
|
|
26968
|
+
getQuotesByPriority as a0,
|
|
26969
|
+
isNativeAddress as a1,
|
|
26970
|
+
getEvmBalances as a2,
|
|
26971
|
+
getTonBalances as a3,
|
|
26972
|
+
getTronBalances as a4,
|
|
26973
|
+
getDeliveryStatus as a5,
|
|
26974
|
+
pollUntilDelivered as a6,
|
|
26975
|
+
reportBridgeTransaction as a7,
|
|
26923
26976
|
ExplorerCtrl as b,
|
|
26924
26977
|
CoreUtil as c,
|
|
26925
26978
|
EvaaBridge as d,
|
|
@@ -26946,4 +26999,4 @@ export {
|
|
|
26946
26999
|
calculateMinReceived as y,
|
|
26947
27000
|
getQuoteDetails as z
|
|
26948
27001
|
};
|
|
26949
|
-
//# sourceMappingURL=index-
|
|
27002
|
+
//# sourceMappingURL=index-CeW-ueEx.js.map
|