@rash2x/bridge-widget 0.7.6 → 0.7.8
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-DzUouoJg.cjs → index-Btnz7slS.cjs} +2 -2
- package/dist/{index-DzUouoJg.cjs.map → index-Btnz7slS.cjs.map} +1 -1
- package/dist/{index-CF3yEUFF.js → index-CEcrJo_G.js} +58 -34
- package/dist/index-CEcrJo_G.js.map +1 -0
- package/dist/{index-CDaFAnWU.js → index-DIK7UXln.js} +2 -2
- package/dist/{index-CDaFAnWU.js.map → index-DIK7UXln.js.map} +1 -1
- package/dist/{index-CbuEGPY8.cjs → index-bZ0S5sNd.cjs} +231 -191
- package/dist/index-bZ0S5sNd.cjs.map +1 -0
- package/dist/index.d.ts +29 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/index-CF3yEUFF.js.map +0 -1
- package/dist/index-CbuEGPY8.cjs.map +0 -1
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
|
+
import * as React from "react";
|
|
5
6
|
import { useEffect, useState, useCallback, useMemo, forwardRef, createContext, useContext, useRef, useLayoutEffect } from "react";
|
|
6
7
|
import { initReactI18next, I18nextProvider, useTranslation } from "react-i18next";
|
|
7
8
|
import i18n from "i18next";
|
|
@@ -2402,7 +2403,7 @@ function calculateMinReceived(quote, slippageBps, dstToken) {
|
|
|
2402
2403
|
}
|
|
2403
2404
|
function getQuoteDetails(quote, srcToken, dstToken, tokens, chains, slippageBps, srcChain, dstChain) {
|
|
2404
2405
|
const amounts = getQuoteAmounts(quote, srcToken, dstToken);
|
|
2405
|
-
const fees = computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain);
|
|
2406
|
+
const fees = computeFeeBreakdownUsd(quote, srcToken, dstToken, tokens, chains, srcChain, dstChain);
|
|
2406
2407
|
const minimumReceived = calculateMinReceived(quote, slippageBps, dstToken);
|
|
2407
2408
|
return {
|
|
2408
2409
|
inputAmount: amounts.inputHuman,
|
|
@@ -2422,7 +2423,7 @@ function getRouteDisplayName(route) {
|
|
|
2422
2423
|
if (routeLower.includes("v2")) return "Stargate V2";
|
|
2423
2424
|
return route.split(/[/\-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
2424
2425
|
}
|
|
2425
|
-
function computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstChain) {
|
|
2426
|
+
function computeFeeBreakdownUsd(quote, srcToken, dstToken, tokens, chains, srcChain, dstChain) {
|
|
2426
2427
|
const defaultMsgSymbol = srcChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
2427
2428
|
const defaultBridgeSymbol = srcToken?.symbol?.toUpperCase() ?? "";
|
|
2428
2429
|
const defaultDstGasSymbol = dstChain?.nativeCurrency?.symbol?.toUpperCase() ?? "";
|
|
@@ -2465,7 +2466,7 @@ function computeFeeBreakdownUsd(quote, srcToken, tokens, chains, srcChain, dstCh
|
|
|
2465
2466
|
let bridgeFeeUsd = 0;
|
|
2466
2467
|
const bridgeFeeSymbol = srcToken.symbol?.toUpperCase() ?? "";
|
|
2467
2468
|
const srcHuman = fromLD(quote.srcAmount, srcToken.decimals);
|
|
2468
|
-
const dstHuman = fromLD(quote.dstAmount,
|
|
2469
|
+
const dstHuman = dstToken ? fromLD(quote.dstAmount, dstToken.decimals) : 0;
|
|
2469
2470
|
const diff = srcHuman - dstHuman;
|
|
2470
2471
|
if (diff > 0) {
|
|
2471
2472
|
bridgeFeeAmount = diff;
|
|
@@ -3024,11 +3025,54 @@ const InfoIcon = (props) => {
|
|
|
3024
3025
|
}
|
|
3025
3026
|
);
|
|
3026
3027
|
};
|
|
3028
|
+
const MOBILE_BREAKPOINT = 768;
|
|
3029
|
+
function useIsMobile() {
|
|
3030
|
+
const [isMobile2, setIsMobile] = React.useState(
|
|
3031
|
+
void 0
|
|
3032
|
+
);
|
|
3033
|
+
React.useEffect(() => {
|
|
3034
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
3035
|
+
const onChange = () => {
|
|
3036
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
3037
|
+
};
|
|
3038
|
+
mql.addEventListener("change", onChange);
|
|
3039
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
3040
|
+
return () => mql.removeEventListener("change", onChange);
|
|
3041
|
+
}, []);
|
|
3042
|
+
return !!isMobile2;
|
|
3043
|
+
}
|
|
3027
3044
|
const Tip = (props) => {
|
|
3028
3045
|
const { children, text } = props;
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3046
|
+
const [open, setOpen] = useState(false);
|
|
3047
|
+
const isMobile2 = useIsMobile();
|
|
3048
|
+
const tooltipRef = useRef(null);
|
|
3049
|
+
const handleToggle = () => {
|
|
3050
|
+
setOpen((prev) => !prev);
|
|
3051
|
+
};
|
|
3052
|
+
useEffect(() => {
|
|
3053
|
+
const handleClickOutside = (event) => {
|
|
3054
|
+
if (tooltipRef.current && !tooltipRef.current.contains(event.target)) {
|
|
3055
|
+
setOpen(false);
|
|
3056
|
+
}
|
|
3057
|
+
};
|
|
3058
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
3059
|
+
return () => {
|
|
3060
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
3061
|
+
};
|
|
3062
|
+
}, []);
|
|
3063
|
+
return /* @__PURE__ */ jsxs(Tooltip, { open: isMobile2 ? open : void 0, children: [
|
|
3064
|
+
/* @__PURE__ */ jsx(
|
|
3065
|
+
TooltipTrigger,
|
|
3066
|
+
{
|
|
3067
|
+
onClick: (e2) => {
|
|
3068
|
+
e2.preventDefault();
|
|
3069
|
+
handleToggle();
|
|
3070
|
+
},
|
|
3071
|
+
className: "w-4 h-4 rounded-full bg-muted text-muted-foreground",
|
|
3072
|
+
children
|
|
3073
|
+
}
|
|
3074
|
+
),
|
|
3075
|
+
/* @__PURE__ */ jsx(TooltipContent, { ref: tooltipRef, children: text })
|
|
3032
3076
|
] });
|
|
3033
3077
|
};
|
|
3034
3078
|
const BASE_URL = "https://icons-ckg.pages.dev/stargate-light/tokens";
|
|
@@ -3051,7 +3095,12 @@ function useFeeBreakdown() {
|
|
|
3051
3095
|
selectedAssetSymbol,
|
|
3052
3096
|
fromChain?.chainKey
|
|
3053
3097
|
);
|
|
3054
|
-
|
|
3098
|
+
const dstToken = resolveTokenOnChainFromMatrix$1(
|
|
3099
|
+
assetMatrix,
|
|
3100
|
+
selectedAssetSymbol,
|
|
3101
|
+
toChain?.chainKey
|
|
3102
|
+
);
|
|
3103
|
+
return computeFeeBreakdownUsd(quote, srcToken, dstToken, allTokens ?? tokens, chains, fromChain, toChain);
|
|
3055
3104
|
}, [quote, allTokens, tokens, chains, selectedAssetSymbol, assetMatrix, fromChain, toChain]);
|
|
3056
3105
|
}
|
|
3057
3106
|
function useBridgeExternalData(options) {
|
|
@@ -4109,30 +4158,6 @@ function useSilentValidations(amountString) {
|
|
|
4109
4158
|
status,
|
|
4110
4159
|
error
|
|
4111
4160
|
]);
|
|
4112
|
-
useEffect(() => {
|
|
4113
|
-
if (validationResult.isValidForTransfer) return;
|
|
4114
|
-
console.info("[SilentValidations] invalid", {
|
|
4115
|
-
amountString,
|
|
4116
|
-
hasTooManyDecimals: validationResult.hasTooManyDecimals,
|
|
4117
|
-
hasUnsupportedTokenPair: validationResult.hasUnsupportedTokenPair,
|
|
4118
|
-
hasInsufficientLiquidity: validationResult.hasInsufficientLiquidity,
|
|
4119
|
-
status,
|
|
4120
|
-
hasQuote: Boolean(quote),
|
|
4121
|
-
error,
|
|
4122
|
-
fromChainKey: fromChain?.chainKey,
|
|
4123
|
-
toChainKey: toChain?.chainKey,
|
|
4124
|
-
selectedAssetSymbol
|
|
4125
|
-
});
|
|
4126
|
-
}, [
|
|
4127
|
-
validationResult,
|
|
4128
|
-
amountString,
|
|
4129
|
-
status,
|
|
4130
|
-
quote,
|
|
4131
|
-
error,
|
|
4132
|
-
fromChain?.chainKey,
|
|
4133
|
-
toChain?.chainKey,
|
|
4134
|
-
selectedAssetSymbol
|
|
4135
|
-
]);
|
|
4136
4161
|
return validationResult;
|
|
4137
4162
|
}
|
|
4138
4163
|
function useTelegramRestriction() {
|
|
@@ -4259,7 +4284,6 @@ const MainButton = ({
|
|
|
4259
4284
|
}
|
|
4260
4285
|
};
|
|
4261
4286
|
const disabled = status === "loading" || requiresCustomAddress || !isTelegramRestricted && !missingSrc && !missingDst && (amountNum <= 0 || isBalanceLoading || hasInsufficientBalance || hasAmountTooLarge || !gas.hasEnoughGas || noRoute || !isValidForTransfer);
|
|
4262
|
-
console.log(gas);
|
|
4263
4287
|
return /* @__PURE__ */ jsxs("div", { className: "pt-4 space-y-4", children: [
|
|
4264
4288
|
isTelegramRestricted && /* @__PURE__ */ jsx(
|
|
4265
4289
|
Alert,
|
|
@@ -26106,7 +26130,7 @@ class WalletConnectModal {
|
|
|
26106
26130
|
}
|
|
26107
26131
|
async initUi() {
|
|
26108
26132
|
if (typeof window !== "undefined") {
|
|
26109
|
-
await import("./index-
|
|
26133
|
+
await import("./index-DIK7UXln.js");
|
|
26110
26134
|
const modal = document.createElement("wcm-modal");
|
|
26111
26135
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26112
26136
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -27010,4 +27034,4 @@ export {
|
|
|
27010
27034
|
calculateMinReceived as y,
|
|
27011
27035
|
getQuoteDetails as z
|
|
27012
27036
|
};
|
|
27013
|
-
//# sourceMappingURL=index-
|
|
27037
|
+
//# sourceMappingURL=index-CEcrJo_G.js.map
|