@rash2x/bridge-widget 0.6.76 → 0.6.77
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-UP2rtmG0.cjs → index-Bwsox4tK.cjs} +2 -2
- package/dist/{index-UP2rtmG0.cjs.map → index-Bwsox4tK.cjs.map} +1 -1
- package/dist/{index-yABy9lq6.js → index-Cf0s9o1V.js} +49 -46
- package/dist/index-Cf0s9o1V.js.map +1 -0
- package/dist/{index-D7rILjYR.cjs → index-CmGINAdQ.cjs} +49 -46
- package/dist/index-CmGINAdQ.cjs.map +1 -0
- package/dist/{index-DGTEYGjh.js → index-aQ85eLjl.js} +2 -2
- package/dist/{index-DGTEYGjh.js.map → index-aQ85eLjl.js.map} +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/index-D7rILjYR.cjs.map +0 -1
- package/dist/index-yABy9lq6.js.map +0 -1
|
@@ -300,6 +300,7 @@ const useChainsStore = zustand.create()(
|
|
|
300
300
|
allowedFromChains: void 0,
|
|
301
301
|
allowedToChains: void 0,
|
|
302
302
|
isLoadingToChains: false,
|
|
303
|
+
isUrlInitialized: false,
|
|
303
304
|
setChains: async (data) => {
|
|
304
305
|
const prev = get2().chains;
|
|
305
306
|
const same = (() => {
|
|
@@ -353,6 +354,7 @@ const useChainsStore = zustand.create()(
|
|
|
353
354
|
set2({ allowedToChains: data });
|
|
354
355
|
},
|
|
355
356
|
setIsLoadingToChains: (v2) => set2({ isLoadingToChains: v2 }),
|
|
357
|
+
setIsUrlInitialized: (v2) => set2({ isUrlInitialized: v2 }),
|
|
356
358
|
swapChains: () => set2((state2) => ({
|
|
357
359
|
fromChain: state2.toChain,
|
|
358
360
|
toChain: state2.fromChain
|
|
@@ -1323,34 +1325,6 @@ async function getDestTokens(srcChainKey, srcTokenAddr) {
|
|
|
1323
1325
|
});
|
|
1324
1326
|
return unique.map(normalizeTokenSymbol);
|
|
1325
1327
|
}
|
|
1326
|
-
function parseBridgeUrlParams(source) {
|
|
1327
|
-
if (source && typeof source === "object") {
|
|
1328
|
-
return source;
|
|
1329
|
-
}
|
|
1330
|
-
const queryString = typeof source === "string" ? source : typeof window !== "undefined" ? window.location.search : "";
|
|
1331
|
-
const searchParams = new URLSearchParams(queryString);
|
|
1332
|
-
return {
|
|
1333
|
-
srcToken: searchParams.get("srcToken") || void 0,
|
|
1334
|
-
srcChain: searchParams.get("srcChain") || void 0,
|
|
1335
|
-
dstChain: searchParams.get("dstChain") || void 0,
|
|
1336
|
-
amount: searchParams.get("amount") || void 0
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
function buildQueryString(params) {
|
|
1340
|
-
const searchParams = new URLSearchParams();
|
|
1341
|
-
if (params.srcToken) searchParams.set("srcToken", params.srcToken);
|
|
1342
|
-
if (params.srcChain) searchParams.set("srcChain", params.srcChain);
|
|
1343
|
-
if (params.dstChain) searchParams.set("dstChain", params.dstChain);
|
|
1344
|
-
if (params.amount) searchParams.set("amount", params.amount);
|
|
1345
|
-
const queryString = searchParams.toString();
|
|
1346
|
-
return queryString ? `?${queryString}` : "";
|
|
1347
|
-
}
|
|
1348
|
-
function updateBridgeUrlNative(params) {
|
|
1349
|
-
if (typeof window === "undefined" || !window.history) return;
|
|
1350
|
-
const queryString = buildQueryString(params);
|
|
1351
|
-
const newUrl = `${window.location.pathname}${queryString}${window.location.hash}`;
|
|
1352
|
-
window.history.replaceState(null, "", newUrl);
|
|
1353
|
-
}
|
|
1354
1328
|
function resolveTokenOnChainFromMatrix$1(assetMatrix, assetSymbol, chainKey) {
|
|
1355
1329
|
if (!assetMatrix || !assetSymbol || !chainKey) return void 0;
|
|
1356
1330
|
const byChain = assetMatrix[assetSymbol.toUpperCase()];
|
|
@@ -1369,7 +1343,8 @@ const useChainDerivations = () => {
|
|
|
1369
1343
|
allowedToChains,
|
|
1370
1344
|
setAllowedToChains,
|
|
1371
1345
|
isLoadingToChains,
|
|
1372
|
-
setIsLoadingToChains
|
|
1346
|
+
setIsLoadingToChains,
|
|
1347
|
+
isUrlInitialized
|
|
1373
1348
|
} = useChainsStore();
|
|
1374
1349
|
const supportedFrom = react.useMemo(() => {
|
|
1375
1350
|
if (typeof selectedAssetSymbol !== "string" || !assetMatrix || !chains?.length)
|
|
@@ -1380,10 +1355,8 @@ const useChainDerivations = () => {
|
|
|
1380
1355
|
return result;
|
|
1381
1356
|
}, [selectedAssetSymbol, assetMatrix, chains]);
|
|
1382
1357
|
react.useEffect(() => {
|
|
1383
|
-
const urlParams = parseBridgeUrlParams();
|
|
1384
|
-
const hasUrlParams = !!urlParams.srcToken || !!urlParams.srcChain || !!urlParams.dstChain;
|
|
1385
1358
|
setAllowedFromChains(supportedFrom);
|
|
1386
|
-
if (
|
|
1359
|
+
if (!isUrlInitialized) {
|
|
1387
1360
|
return;
|
|
1388
1361
|
}
|
|
1389
1362
|
if (!supportedFrom.length) {
|
|
@@ -1409,7 +1382,8 @@ const useChainDerivations = () => {
|
|
|
1409
1382
|
setAllowedFromChains,
|
|
1410
1383
|
setFromChain,
|
|
1411
1384
|
setToChain,
|
|
1412
|
-
setAllowedToChains
|
|
1385
|
+
setAllowedToChains,
|
|
1386
|
+
isUrlInitialized
|
|
1413
1387
|
]);
|
|
1414
1388
|
react.useEffect(() => {
|
|
1415
1389
|
let ignore = false;
|
|
@@ -1451,8 +1425,10 @@ const useChainDerivations = () => {
|
|
|
1451
1425
|
list = list.filter((c2) => c2.chainKey !== fromChain.chainKey);
|
|
1452
1426
|
}
|
|
1453
1427
|
setAllowedToChains(list);
|
|
1454
|
-
if (
|
|
1455
|
-
|
|
1428
|
+
if (isUrlInitialized) {
|
|
1429
|
+
if (!toChain || !list.some((c2) => c2.chainKey === toChain.chainKey)) {
|
|
1430
|
+
setToChain(list[0]);
|
|
1431
|
+
}
|
|
1456
1432
|
}
|
|
1457
1433
|
} catch (e2) {
|
|
1458
1434
|
if (!ignore) {
|
|
@@ -1476,7 +1452,8 @@ const useChainDerivations = () => {
|
|
|
1476
1452
|
toChain,
|
|
1477
1453
|
setAllowedToChains,
|
|
1478
1454
|
setToChain,
|
|
1479
|
-
setIsLoadingToChains
|
|
1455
|
+
setIsLoadingToChains,
|
|
1456
|
+
isUrlInitialized
|
|
1480
1457
|
]);
|
|
1481
1458
|
return {
|
|
1482
1459
|
allowedFromChains,
|
|
@@ -25757,7 +25734,7 @@ class WalletConnectModal {
|
|
|
25757
25734
|
}
|
|
25758
25735
|
async initUi() {
|
|
25759
25736
|
if (typeof window !== "undefined") {
|
|
25760
|
-
await Promise.resolve().then(() => require("./index-
|
|
25737
|
+
await Promise.resolve().then(() => require("./index-Bwsox4tK.cjs"));
|
|
25761
25738
|
const modal = document.createElement("wcm-modal");
|
|
25762
25739
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
25763
25740
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -26013,13 +25990,41 @@ function useTronWalletConnect(projectId) {
|
|
|
26013
25990
|
signTransaction
|
|
26014
25991
|
};
|
|
26015
25992
|
}
|
|
25993
|
+
function parseBridgeUrlParams(source) {
|
|
25994
|
+
if (source && typeof source === "object") {
|
|
25995
|
+
return source;
|
|
25996
|
+
}
|
|
25997
|
+
const queryString = typeof source === "string" ? source : typeof window !== "undefined" ? window.location.search : "";
|
|
25998
|
+
const searchParams = new URLSearchParams(queryString);
|
|
25999
|
+
return {
|
|
26000
|
+
srcToken: searchParams.get("srcToken") || void 0,
|
|
26001
|
+
srcChain: searchParams.get("srcChain") || void 0,
|
|
26002
|
+
dstChain: searchParams.get("dstChain") || void 0,
|
|
26003
|
+
amount: searchParams.get("amount") || void 0
|
|
26004
|
+
};
|
|
26005
|
+
}
|
|
26006
|
+
function buildQueryString(params) {
|
|
26007
|
+
const searchParams = new URLSearchParams();
|
|
26008
|
+
if (params.srcToken) searchParams.set("srcToken", params.srcToken);
|
|
26009
|
+
if (params.srcChain) searchParams.set("srcChain", params.srcChain);
|
|
26010
|
+
if (params.dstChain) searchParams.set("dstChain", params.dstChain);
|
|
26011
|
+
if (params.amount) searchParams.set("amount", params.amount);
|
|
26012
|
+
const queryString = searchParams.toString();
|
|
26013
|
+
return queryString ? `?${queryString}` : "";
|
|
26014
|
+
}
|
|
26015
|
+
function updateBridgeUrlNative(params) {
|
|
26016
|
+
if (typeof window === "undefined" || !window.history) return;
|
|
26017
|
+
const queryString = buildQueryString(params);
|
|
26018
|
+
const newUrl = `${window.location.pathname}${queryString}${window.location.hash}`;
|
|
26019
|
+
window.history.replaceState(null, "", newUrl);
|
|
26020
|
+
}
|
|
26016
26021
|
function useUrlSync(options) {
|
|
26017
26022
|
const {
|
|
26018
26023
|
enabled = true,
|
|
26019
26024
|
urlParams: externalUrlParams,
|
|
26020
26025
|
onUrlParamsChange
|
|
26021
26026
|
} = options || {};
|
|
26022
|
-
const { chains, setFromChain, setToChain } = useChainsStore();
|
|
26027
|
+
const { chains, setFromChain, setToChain, setIsUrlInitialized } = useChainsStore();
|
|
26023
26028
|
const { tokens, assetMatrix, setSelectedAssetSymbol } = useTokensStore();
|
|
26024
26029
|
const { setInputAmount } = useBridgeQuoteStore();
|
|
26025
26030
|
const internalData = useBridgeExternalData();
|
|
@@ -26100,12 +26105,7 @@ function useUrlSync(options) {
|
|
|
26100
26105
|
isSyncingRef.current = false;
|
|
26101
26106
|
}, 0);
|
|
26102
26107
|
},
|
|
26103
|
-
[
|
|
26104
|
-
enabled,
|
|
26105
|
-
hasInitialized,
|
|
26106
|
-
currentUrlParams,
|
|
26107
|
-
onUrlParamsChange
|
|
26108
|
-
]
|
|
26108
|
+
[enabled, hasInitialized, currentUrlParams, onUrlParamsChange]
|
|
26109
26109
|
);
|
|
26110
26110
|
const handleAmountBlur = react.useCallback(() => {
|
|
26111
26111
|
if (!enabled || !hasInitialized) return;
|
|
@@ -26117,6 +26117,7 @@ function useUrlSync(options) {
|
|
|
26117
26117
|
}
|
|
26118
26118
|
const urlParams = externalUrlParams ? parseBridgeUrlParams(externalUrlParams) : parseBridgeUrlParams();
|
|
26119
26119
|
if (!urlParams.srcToken && !urlParams.srcChain && !urlParams.dstChain && !urlParams.amount) {
|
|
26120
|
+
setIsUrlInitialized(true);
|
|
26120
26121
|
setHasInitialized(true);
|
|
26121
26122
|
return;
|
|
26122
26123
|
}
|
|
@@ -26140,6 +26141,7 @@ function useUrlSync(options) {
|
|
|
26140
26141
|
dstChain: validated.dstChain?.chainKey,
|
|
26141
26142
|
amount: validated.amount
|
|
26142
26143
|
};
|
|
26144
|
+
setIsUrlInitialized(true);
|
|
26143
26145
|
setHasInitialized(true);
|
|
26144
26146
|
}, 0);
|
|
26145
26147
|
return () => clearTimeout(timeoutId);
|
|
@@ -26152,7 +26154,8 @@ function useUrlSync(options) {
|
|
|
26152
26154
|
setSelectedAssetSymbol,
|
|
26153
26155
|
setFromChain,
|
|
26154
26156
|
setToChain,
|
|
26155
|
-
setInputAmount
|
|
26157
|
+
setInputAmount,
|
|
26158
|
+
setIsUrlInitialized
|
|
26156
26159
|
]);
|
|
26157
26160
|
react.useEffect(() => {
|
|
26158
26161
|
if (!enabled || !hasInitialized) return;
|
|
@@ -26524,4 +26527,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
26524
26527
|
exports.useSwapModel = useSwapModel;
|
|
26525
26528
|
exports.useTokensStore = useTokensStore;
|
|
26526
26529
|
exports.useTransactionStore = useTransactionStore;
|
|
26527
|
-
//# sourceMappingURL=index-
|
|
26530
|
+
//# sourceMappingURL=index-CmGINAdQ.cjs.map
|