@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/README.md
CHANGED
|
@@ -173,20 +173,7 @@ interface WidgetTheme {
|
|
|
173
173
|
|
|
174
174
|
## Demo
|
|
175
175
|
|
|
176
|
-
A demo
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
git clone https://github.com/wheelx-fi/wheelx-ui.git
|
|
180
|
-
cd wheelx-ui
|
|
181
|
-
git checkout feat/aidenxiao_20260530_widget
|
|
182
|
-
pnpm install
|
|
183
|
-
pnpm --filter @wheelx/widget-demo dev
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
The demo app opens at `http://localhost:3001` and provides:
|
|
187
|
-
- Visual theme configuration with live preview
|
|
188
|
-
- Chain/token configuration
|
|
189
|
-
- Copy-and-paste configuration code generation
|
|
176
|
+
A demo `https://widget.wheelx.fi`
|
|
190
177
|
|
|
191
178
|
## API Endpoint
|
|
192
179
|
|
package/dist/index.js
CHANGED
|
@@ -660,35 +660,8 @@ function ChainsAndTokensLoader({ children, config }) {
|
|
|
660
660
|
if (data.deposit_platforms?.prediction?.tokens) l.push(...data.deposit_platforms.prediction.tokens);
|
|
661
661
|
return l;
|
|
662
662
|
}, [data]);
|
|
663
|
-
const filteredChains =
|
|
664
|
-
|
|
665
|
-
const fromChains = config?.from?.chains;
|
|
666
|
-
const toChains = config?.to?.chains;
|
|
667
|
-
if (!fromChains?.length && !toChains?.length) return allChains;
|
|
668
|
-
const allowedSet = /* @__PURE__ */ new Set();
|
|
669
|
-
fromChains?.forEach((id) => allowedSet.add(id));
|
|
670
|
-
toChains?.forEach((id) => allowedSet.add(id));
|
|
671
|
-
return allChains.filter((c) => allowedSet.has(c.chain_id));
|
|
672
|
-
}, [allChains, config?.from?.chains, config?.to?.chains]);
|
|
673
|
-
const filteredTokens = React5.useMemo(() => {
|
|
674
|
-
if (!allTokens) return null;
|
|
675
|
-
const fromTokenConfig = config?.from?.chainTokens;
|
|
676
|
-
const toTokenConfig = config?.to?.chainTokens;
|
|
677
|
-
if (!fromTokenConfig && !toTokenConfig) return allTokens;
|
|
678
|
-
const allowedSet = /* @__PURE__ */ new Set();
|
|
679
|
-
const addTokens = (tc) => {
|
|
680
|
-
if (!tc) return;
|
|
681
|
-
for (const entries of Object.values(tc)) {
|
|
682
|
-
for (const t of entries) {
|
|
683
|
-
allowedSet.add(`${t.chainId}:${t.address.toLowerCase()}`);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
addTokens(fromTokenConfig);
|
|
688
|
-
addTokens(toTokenConfig);
|
|
689
|
-
if (allowedSet.size === 0) return allTokens;
|
|
690
|
-
return allTokens.filter((t) => allowedSet.has(`${t.chain_id}:${t.address.toLowerCase()}`));
|
|
691
|
-
}, [allTokens, config?.from?.chainTokens, config?.to?.chainTokens]);
|
|
663
|
+
const filteredChains = allChains;
|
|
664
|
+
const filteredTokens = allTokens;
|
|
692
665
|
React5__namespace.default.useEffect(() => {
|
|
693
666
|
if (filteredChains && !initialDataRef.current) {
|
|
694
667
|
setChains(filteredChains);
|
|
@@ -1389,6 +1362,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1389
1362
|
(t) => t.chain_id === config.from?.defaultToken?.chainId && t.address.toLowerCase() === config.from?.defaultToken?.address.toLowerCase()
|
|
1390
1363
|
);
|
|
1391
1364
|
}
|
|
1365
|
+
if (!defaultToken) {
|
|
1366
|
+
const ct = config.from?.chainTokens?.[fromChain.chain_id];
|
|
1367
|
+
if (ct?.length) {
|
|
1368
|
+
defaultToken = tokens.find(
|
|
1369
|
+
(t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1392
1373
|
if (!defaultToken) {
|
|
1393
1374
|
defaultToken = tokens.find(
|
|
1394
1375
|
(t) => t.chain_id === fromChain.chain_id && t.address.toLowerCase() === fromChain.eth_token.toLowerCase()
|
|
@@ -1408,6 +1389,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1408
1389
|
(t) => t.chain_id === config.to?.defaultToken?.chainId && t.address.toLowerCase() === config.to?.defaultToken?.address.toLowerCase()
|
|
1409
1390
|
);
|
|
1410
1391
|
}
|
|
1392
|
+
if (!defaultToken) {
|
|
1393
|
+
const ct = config.to?.chainTokens?.[toChain.chain_id];
|
|
1394
|
+
if (ct?.length) {
|
|
1395
|
+
defaultToken = tokens.find(
|
|
1396
|
+
(t) => t.chain_id === ct[0].chainId && t.address.toLowerCase() === ct[0].address.toLowerCase()
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1411
1400
|
if (!defaultToken) {
|
|
1412
1401
|
defaultToken = tokens.find(
|
|
1413
1402
|
(t) => t.chain_id === toChain.chain_id && t.address.toLowerCase() === toChain.eth_token.toLowerCase()
|
|
@@ -1418,10 +1407,14 @@ var useInitSwapAndBridgeState = (config) => {
|
|
|
1418
1407
|
}
|
|
1419
1408
|
}
|
|
1420
1409
|
}
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1410
|
+
const hasConfigFrom = !!(config?.from?.defaultChainId || config?.from?.chainTokens || config?.from?.defaultToken);
|
|
1411
|
+
const hasConfigTo = !!(config?.to?.defaultChainId || config?.to?.chainTokens || config?.to?.defaultToken);
|
|
1412
|
+
if (!hasConfigFrom && !hasConfigTo) {
|
|
1413
|
+
const cached = tokenSelectionStore.get(address || "default");
|
|
1414
|
+
if (cached?.from && cached?.to) {
|
|
1415
|
+
setFromTokenInfo(cached.from);
|
|
1416
|
+
setToTokenInfo(cached.to);
|
|
1417
|
+
}
|
|
1425
1418
|
}
|
|
1426
1419
|
hasInitialized.current = true;
|
|
1427
1420
|
return () => {
|