@wheelx-widget/widget 0.1.6 → 0.1.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/README.md +1 -14
- package/dist/index.js +26 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -636,35 +636,8 @@ function ChainsAndTokensLoader({ children, config }) {
|
|
|
636
636
|
if (data.deposit_platforms?.prediction?.tokens) l.push(...data.deposit_platforms.prediction.tokens);
|
|
637
637
|
return l;
|
|
638
638
|
}, [data]);
|
|
639
|
-
const filteredChains =
|
|
640
|
-
|
|
641
|
-
const fromChains = config?.from?.chains;
|
|
642
|
-
const toChains = config?.to?.chains;
|
|
643
|
-
if (!fromChains?.length && !toChains?.length) return allChains;
|
|
644
|
-
const allowedSet = /* @__PURE__ */ new Set();
|
|
645
|
-
fromChains?.forEach((id) => allowedSet.add(id));
|
|
646
|
-
toChains?.forEach((id) => allowedSet.add(id));
|
|
647
|
-
return allChains.filter((c) => allowedSet.has(c.chain_id));
|
|
648
|
-
}, [allChains, config?.from?.chains, config?.to?.chains]);
|
|
649
|
-
const filteredTokens = useMemo(() => {
|
|
650
|
-
if (!allTokens) return null;
|
|
651
|
-
const fromTokenConfig = config?.from?.chainTokens;
|
|
652
|
-
const toTokenConfig = config?.to?.chainTokens;
|
|
653
|
-
if (!fromTokenConfig && !toTokenConfig) return allTokens;
|
|
654
|
-
const allowedSet = /* @__PURE__ */ new Set();
|
|
655
|
-
const addTokens = (tc) => {
|
|
656
|
-
if (!tc) return;
|
|
657
|
-
for (const entries of Object.values(tc)) {
|
|
658
|
-
for (const t of entries) {
|
|
659
|
-
allowedSet.add(`${t.chainId}:${t.address.toLowerCase()}`);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
addTokens(fromTokenConfig);
|
|
664
|
-
addTokens(toTokenConfig);
|
|
665
|
-
if (allowedSet.size === 0) return allTokens;
|
|
666
|
-
return allTokens.filter((t) => allowedSet.has(`${t.chain_id}:${t.address.toLowerCase()}`));
|
|
667
|
-
}, [allTokens, config?.from?.chainTokens, config?.to?.chainTokens]);
|
|
639
|
+
const filteredChains = allChains;
|
|
640
|
+
const filteredTokens = allTokens;
|
|
668
641
|
React5__default.useEffect(() => {
|
|
669
642
|
if (filteredChains && !initialDataRef.current) {
|
|
670
643
|
setChains(filteredChains);
|
|
@@ -1365,6 +1338,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1365
1338
|
(t) => t.chain_id === config.from?.defaultToken?.chainId && t.address.toLowerCase() === config.from?.defaultToken?.address.toLowerCase()
|
|
1366
1339
|
);
|
|
1367
1340
|
}
|
|
1341
|
+
if (!defaultToken) {
|
|
1342
|
+
const ct = config.from?.chainTokens?.[fromChain.chain_id];
|
|
1343
|
+
if (ct?.length) {
|
|
1344
|
+
defaultToken = tokens.find(
|
|
1345
|
+
(t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1368
1349
|
if (!defaultToken) {
|
|
1369
1350
|
defaultToken = tokens.find(
|
|
1370
1351
|
(t) => t.chain_id === fromChain.chain_id && t.address.toLowerCase() === fromChain.eth_token.toLowerCase()
|
|
@@ -1384,6 +1365,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1384
1365
|
(t) => t.chain_id === config.to?.defaultToken?.chainId && t.address.toLowerCase() === config.to?.defaultToken?.address.toLowerCase()
|
|
1385
1366
|
);
|
|
1386
1367
|
}
|
|
1368
|
+
if (!defaultToken) {
|
|
1369
|
+
const ct = config.to?.chainTokens?.[toChain.chain_id];
|
|
1370
|
+
if (ct?.length) {
|
|
1371
|
+
defaultToken = tokens.find(
|
|
1372
|
+
(t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
|
|
1373
|
+
);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1387
1376
|
if (!defaultToken) {
|
|
1388
1377
|
defaultToken = tokens.find(
|
|
1389
1378
|
(t) => t.chain_id === toChain.chain_id && t.address.toLowerCase() === toChain.eth_token.toLowerCase()
|
|
@@ -1394,10 +1383,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1394
1383
|
}
|
|
1395
1384
|
}
|
|
1396
1385
|
}
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1386
|
+
const hasConfigFrom = !!(config?.from?.defaultChainId || config?.from?.chainTokens || config?.from?.defaultToken);
|
|
1387
|
+
const hasConfigTo = !!(config?.to?.defaultChainId || config?.to?.chainTokens || config?.to?.defaultToken);
|
|
1388
|
+
if (!hasConfigFrom && !hasConfigTo) {
|
|
1389
|
+
const cached = tokenSelectionStore.get(address || "default");
|
|
1390
|
+
if (cached?.from && cached?.to) {
|
|
1391
|
+
setFromTokenInfo(cached.from);
|
|
1392
|
+
setToTokenInfo(cached.to);
|
|
1393
|
+
}
|
|
1401
1394
|
}
|
|
1402
1395
|
hasInitialized.current = true;
|
|
1403
1396
|
return () => {
|