@skip-go/widget 1.2.0 → 1.2.1-alpha.1
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 +47 -12
- package/build/index.es.js +85 -17
- package/build/index.es.js.map +1 -1
- package/build/provider/assets.d.ts +1 -1
- package/build/store/swap-widget.d.ts +51 -0
- package/package.json +2 -3
- package/build/assets/fonts/ABCDiatype-Black.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-BlackItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Bold.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-BoldItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Heavy.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-HeavyItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Light.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-LightItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Medium.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-MediumItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Regular.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-RegularItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Thin.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-ThinItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-Ultra.woff2 +0 -0
- package/build/assets/fonts/ABCDiatype-UltraItalic.woff2 +0 -0
- package/build/assets/fonts/ABCDiatypeMono-Medium.woff2 +0 -0
- package/build/assets/fonts/ABCDiatypeMono-Regular.woff2 +0 -0
- package/build/hooks/use-delete-injected-styles-from-react-hot-toast.d.ts +0 -1
- package/build/hooks/use-force-client-render.d.ts +0 -2
- package/build/hooks/use-inject-style-to-document-head.d.ts +0 -1
- package/build/hooks/use-inject-styles-to-head.d.ts +0 -1
- package/build/styles/importFonts.d.ts +0 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ const SwapPage = () => {
|
|
|
39
39
|
|
|
40
40
|
The `SwapWidget` component accepts the following props:
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
````tsx
|
|
43
43
|
interface SwapWidgetProps {
|
|
44
44
|
colors?: {
|
|
45
45
|
primary?: string; // Custom primary color for the widget. Defaults to `#FF486E`.
|
|
@@ -63,6 +63,33 @@ interface SwapWidgetProps {
|
|
|
63
63
|
chainID: string;
|
|
64
64
|
}[];
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Filter chains and assets in selection
|
|
68
|
+
*
|
|
69
|
+
* Record<chainID, assetDenoms>
|
|
70
|
+
* if assetDenoms is undefined, all assets are allowed
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* {
|
|
74
|
+
* source: {
|
|
75
|
+
* 'noble-1': undefined,
|
|
76
|
+
* },
|
|
77
|
+
* destination: {
|
|
78
|
+
* 'cosmoshub-4': [
|
|
79
|
+
* 'uatom',
|
|
80
|
+
* 'ibc/2181AAB0218EAC24BC9F86BD1364FBBFA3E6E3FCC25E88E3E68C15DC6E752D86',
|
|
81
|
+
* ],
|
|
82
|
+
* 'agoric-3': [
|
|
83
|
+
* 'ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9',
|
|
84
|
+
* ],
|
|
85
|
+
* 'osmosis-1': undefined,
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
filter?: {
|
|
90
|
+
source?: Record<string, string[] | undefined>;
|
|
91
|
+
destination?: Record<string, string[] | undefined>;
|
|
92
|
+
};
|
|
66
93
|
className?: string;
|
|
67
94
|
style?: React.CSSProperties;
|
|
68
95
|
settings?: {
|
|
@@ -88,7 +115,9 @@ interface SwapWidgetProps {
|
|
|
88
115
|
};
|
|
89
116
|
apiURL?: string; // Custom API URL to override Skip API endpoint. Defaults to Skip proxied endpoints. Please reach out to us first if you want to be whitelisted.
|
|
90
117
|
}
|
|
91
|
-
|
|
118
|
+
````
|
|
119
|
+
|
|
120
|
+
# Experimental features (still in development)
|
|
92
121
|
|
|
93
122
|
## Web Component usage
|
|
94
123
|
|
|
@@ -104,29 +133,35 @@ initializeSwapWidget();
|
|
|
104
133
|
|
|
105
134
|
et voilà! you can now use the `swap-widget` web-component as `<swap-widget></swap-widget>`
|
|
106
135
|
|
|
107
|
-
The props for the web component are the same as `SwapWidgetProps` except that
|
|
108
|
-
|
|
136
|
+
The props for the web component are the same as `SwapWidgetProps` except that all props
|
|
137
|
+
are passed to the web-component via attributes in kebab-case as strings or stringified objects ie.
|
|
109
138
|
|
|
110
139
|
```tsx
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
140
|
+
<SwapWidget
|
|
141
|
+
className="test-class"
|
|
142
|
+
onlyTestnet={true}
|
|
143
|
+
colors={{
|
|
144
|
+
primary: '#FF4FFF',
|
|
145
|
+
}}
|
|
146
|
+
defaultRoute={{
|
|
147
|
+
srcChainID: 'osmosis-1',
|
|
148
|
+
srcAssetDenom:
|
|
149
|
+
'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
115
152
|
```
|
|
116
153
|
|
|
117
154
|
becomes
|
|
118
155
|
|
|
119
156
|
```tsx
|
|
120
157
|
<swap-widget
|
|
121
|
-
class-name="
|
|
158
|
+
class-name="test-class"
|
|
159
|
+
onlyTestnet="true"
|
|
122
160
|
colors='{"primary":"#FF4FFF"}'
|
|
123
161
|
default-route={JSON.stringify({
|
|
124
162
|
srcChainID: 'osmosis-1',
|
|
125
163
|
srcAssetDenom:
|
|
126
164
|
'ibc/1480b8fd20ad5fcae81ea87584d269547dd4d436843c1d20f15e00eb64743ef4',
|
|
127
165
|
})}
|
|
128
|
-
toaster-props=""
|
|
129
|
-
endpoint-options=""
|
|
130
|
-
api-url=""
|
|
131
166
|
></swap-widget>
|
|
132
167
|
```
|
package/build/index.es.js
CHANGED
|
@@ -453,6 +453,7 @@ const swapWidgetDefaultValues = {
|
|
|
453
453
|
evmSwaps: true,
|
|
454
454
|
},
|
|
455
455
|
},
|
|
456
|
+
filter: undefined,
|
|
456
457
|
};
|
|
457
458
|
const sessionOptions = {
|
|
458
459
|
name: 'skip-go-widget',
|
|
@@ -475,6 +476,7 @@ const configureSwapWidget = (args) => {
|
|
|
475
476
|
...prev.routeConfig,
|
|
476
477
|
...args.routeConfig,
|
|
477
478
|
},
|
|
479
|
+
filter: args.filter || prev.filter,
|
|
478
480
|
});
|
|
479
481
|
});
|
|
480
482
|
useSettingsStore.setState((prev) => {
|
|
@@ -583,8 +585,11 @@ const AssetsProvider = ({ children }) => {
|
|
|
583
585
|
const { data: assets = {} } = useAssets$1({
|
|
584
586
|
onlyTestnets: useSwapWidgetUIStore.getState().onlyTestnet,
|
|
585
587
|
});
|
|
586
|
-
const assetsByChainID = useCallback((chainID) => {
|
|
588
|
+
const assetsByChainID = useCallback((chainID, filterDenoms) => {
|
|
587
589
|
const chainAssets = chainID ? assets[chainID] || [] : [];
|
|
590
|
+
if (filterDenoms && filterDenoms.length > 0) {
|
|
591
|
+
return chainAssets.filter((asset) => filterDenoms.includes(asset.denom));
|
|
592
|
+
}
|
|
588
593
|
return /* console.log(chainAssets), */ chainAssets;
|
|
589
594
|
}, [assets]);
|
|
590
595
|
const getAsset = useCallback((denom, chainID) => {
|
|
@@ -1871,8 +1876,26 @@ function useSwapWidget() {
|
|
|
1871
1876
|
// #region -- core states
|
|
1872
1877
|
const { routeConfig, defaultRoute } = useSwapWidgetUIStore();
|
|
1873
1878
|
const skipClient = useSkipClient();
|
|
1879
|
+
const filter = useSwapWidgetUIStore((state) => state.filter);
|
|
1880
|
+
const sourceChainIDs = (filter === null || filter === void 0 ? void 0 : filter.source)
|
|
1881
|
+
? Object.keys(filter.source)
|
|
1882
|
+
: undefined;
|
|
1883
|
+
const destinationChainIDs = (filter === null || filter === void 0 ? void 0 : filter.destination)
|
|
1884
|
+
? Object.keys(filter.destination)
|
|
1885
|
+
: undefined;
|
|
1886
|
+
const allChainIDs = useMemo(() => {
|
|
1887
|
+
return [...(sourceChainIDs !== null && sourceChainIDs !== void 0 ? sourceChainIDs : []), ...(destinationChainIDs !== null && destinationChainIDs !== void 0 ? destinationChainIDs : [])];
|
|
1888
|
+
}, [sourceChainIDs, destinationChainIDs]);
|
|
1874
1889
|
const { assetsByChainID, getFeeAsset, isReady: isAssetsReady, getAsset, } = useAssets();
|
|
1875
|
-
const { data: chains } = useChains(
|
|
1890
|
+
const { data: chains } = useChains({
|
|
1891
|
+
select: (chains) => {
|
|
1892
|
+
if (!allChainIDs)
|
|
1893
|
+
return chains;
|
|
1894
|
+
return chains === null || chains === void 0 ? void 0 : chains.filter(({ chainID }) => {
|
|
1895
|
+
return allChainIDs.includes(chainID);
|
|
1896
|
+
});
|
|
1897
|
+
},
|
|
1898
|
+
});
|
|
1876
1899
|
const { getWalletRepo } = useManager();
|
|
1877
1900
|
const { connector, chain: evmChain } = useAccount$1();
|
|
1878
1901
|
const { switchChainAsync: switchNetworkAsync } = useSwitchChain({
|
|
@@ -2042,13 +2065,14 @@ function useSwapWidget() {
|
|
|
2042
2065
|
* - if not, select first available asset
|
|
2043
2066
|
*/
|
|
2044
2067
|
const onSourceChainChange = useCallback(async (chain, injectAsset) => {
|
|
2068
|
+
var _a, _b;
|
|
2045
2069
|
let feeAsset = undefined;
|
|
2046
|
-
if (chain.chainType === 'cosmos') {
|
|
2070
|
+
if (chain.chainType === 'cosmos' && !((_a = filter === null || filter === void 0 ? void 0 : filter.source) === null || _a === void 0 ? void 0 : _a[chain.chainID])) {
|
|
2047
2071
|
feeAsset = await getFeeAsset(chain.chainID);
|
|
2048
2072
|
}
|
|
2049
2073
|
let asset = feeAsset;
|
|
2050
2074
|
if (!asset) {
|
|
2051
|
-
const assets = assetsByChainID(chain.chainID);
|
|
2075
|
+
const assets = assetsByChainID(chain.chainID, (_b = filter === null || filter === void 0 ? void 0 : filter.source) === null || _b === void 0 ? void 0 : _b[chain.chainID]);
|
|
2052
2076
|
if (chain.chainType === 'evm') {
|
|
2053
2077
|
asset = assets.find((x) => {
|
|
2054
2078
|
var _a, _b;
|
|
@@ -2090,15 +2114,17 @@ function useSwapWidget() {
|
|
|
2090
2114
|
* - if not, select first available asset
|
|
2091
2115
|
*/
|
|
2092
2116
|
const onDestinationChainChange = useCallback(async (chain, injectAsset) => {
|
|
2117
|
+
var _a, _b, _c;
|
|
2093
2118
|
const { destinationAsset: currentDstAsset } = useSwapWidgetStore.getState();
|
|
2094
|
-
const assets = assetsByChainID(chain.chainID);
|
|
2119
|
+
const assets = assetsByChainID(chain.chainID, (_a = filter === null || filter === void 0 ? void 0 : filter.destination) === null || _a === void 0 ? void 0 : _a[chain.chainID]);
|
|
2095
2120
|
let feeAsset = undefined;
|
|
2096
|
-
if (chain.chainType === 'cosmos'
|
|
2121
|
+
if (chain.chainType === 'cosmos' &&
|
|
2122
|
+
!((_b = filter === null || filter === void 0 ? void 0 : filter.destination) === null || _b === void 0 ? void 0 : _b[chain.chainID])) {
|
|
2097
2123
|
feeAsset = await getFeeAsset(chain.chainID);
|
|
2098
2124
|
}
|
|
2099
2125
|
let asset = feeAsset;
|
|
2100
2126
|
if (!asset) {
|
|
2101
|
-
const assets = assetsByChainID(chain.chainID);
|
|
2127
|
+
const assets = assetsByChainID(chain.chainID, (_c = filter === null || filter === void 0 ? void 0 : filter.destination) === null || _c === void 0 ? void 0 : _c[chain.chainID]);
|
|
2102
2128
|
if (chain.chainType === 'evm') {
|
|
2103
2129
|
asset = assets.find((x) => {
|
|
2104
2130
|
var _a, _b;
|
|
@@ -2413,6 +2439,7 @@ function useSwapWidget() {
|
|
|
2413
2439
|
wallets,
|
|
2414
2440
|
]);
|
|
2415
2441
|
// #endregion
|
|
2442
|
+
// #region -- Default Route
|
|
2416
2443
|
const shareable = useMemo(() => {
|
|
2417
2444
|
const params = new URLSearchParams();
|
|
2418
2445
|
if (srcChain) {
|
|
@@ -2444,13 +2471,16 @@ function useSwapWidget() {
|
|
|
2444
2471
|
const defaultAmountIn = defaultRoute === null || defaultRoute === void 0 ? void 0 : defaultRoute.amountIn;
|
|
2445
2472
|
const defaultAmountOut = defaultRoute === null || defaultRoute === void 0 ? void 0 : defaultRoute.amountOut;
|
|
2446
2473
|
useEffect(() => {
|
|
2474
|
+
var _a;
|
|
2447
2475
|
if (!chains || !isAssetsReady || srcChain)
|
|
2448
2476
|
return;
|
|
2449
2477
|
if (defaultSourceChain) {
|
|
2450
|
-
const findChain = chains
|
|
2478
|
+
const findChain = chains
|
|
2479
|
+
.filter((c) => sourceChainIDs === null || sourceChainIDs === void 0 ? void 0 : sourceChainIDs.includes(c.chainID))
|
|
2480
|
+
.find((x) => x.chainID.toLowerCase() === defaultSourceChain.toLowerCase());
|
|
2451
2481
|
if (findChain) {
|
|
2452
2482
|
if (defaultSourceAsset) {
|
|
2453
|
-
const assets = assetsByChainID(findChain.chainID);
|
|
2483
|
+
const assets = assetsByChainID(findChain.chainID, (_a = filter === null || filter === void 0 ? void 0 : filter.source) === null || _a === void 0 ? void 0 : _a[findChain.chainID]);
|
|
2454
2484
|
const findAsset = assets.find((x) => x.denom.toLowerCase() === defaultSourceAsset.toLowerCase());
|
|
2455
2485
|
if (findAsset) {
|
|
2456
2486
|
onSourceChainChange(findChain, findAsset);
|
|
@@ -2468,13 +2498,16 @@ function useSwapWidget() {
|
|
|
2468
2498
|
}
|
|
2469
2499
|
}, [srcChain, chains, isAssetsReady, defaultSourceChain, defaultSourceAsset]);
|
|
2470
2500
|
useEffect(() => {
|
|
2501
|
+
var _a;
|
|
2471
2502
|
if (!chains || !isAssetsReady || dstChain)
|
|
2472
2503
|
return;
|
|
2473
2504
|
if (defaultDestinationChain) {
|
|
2474
|
-
const findChain = chains
|
|
2505
|
+
const findChain = chains
|
|
2506
|
+
.filter((c) => destinationChainIDs === null || destinationChainIDs === void 0 ? void 0 : destinationChainIDs.includes(c.chainID))
|
|
2507
|
+
.find((x) => x.chainID.toLowerCase() === defaultDestinationChain.toLowerCase());
|
|
2475
2508
|
if (findChain) {
|
|
2476
2509
|
if (defaultDestinationAsset) {
|
|
2477
|
-
const assets = assetsByChainID(findChain.chainID);
|
|
2510
|
+
const assets = assetsByChainID(findChain.chainID, (_a = filter === null || filter === void 0 ? void 0 : filter.destination) === null || _a === void 0 ? void 0 : _a[findChain.chainID]);
|
|
2478
2511
|
const findAsset = assets.find((x) => x.denom.toLowerCase() === defaultDestinationAsset.toLowerCase());
|
|
2479
2512
|
if (findAsset) {
|
|
2480
2513
|
onDestinationChainChange(findChain, findAsset);
|
|
@@ -2512,6 +2545,7 @@ function useSwapWidget() {
|
|
|
2512
2545
|
});
|
|
2513
2546
|
}
|
|
2514
2547
|
}, [defaultAmountIn, defaultAmountOut]);
|
|
2548
|
+
// #endregion
|
|
2515
2549
|
/////////////////////////////////////////////////////////////////////////////
|
|
2516
2550
|
return {
|
|
2517
2551
|
amountIn,
|
|
@@ -2713,11 +2747,20 @@ const usdFormatter = new Intl.NumberFormat("en-US", {
|
|
|
2713
2747
|
|
|
2714
2748
|
function AssetInput({ amount, amountUSD, diffPercentage = 0, onAmountChange, onAmountMax, asset, onAssetChange, chain, chains, onChainChange, context, isError, isLoading, }) {
|
|
2715
2749
|
const { assetsByChainID, getNativeAssets } = useAssets();
|
|
2750
|
+
const filter = useSwapWidgetUIStore((state) => state.filter);
|
|
2716
2751
|
const assets = useMemo(() => {
|
|
2752
|
+
var _a;
|
|
2753
|
+
if (!chain && filter && (filter === null || filter === void 0 ? void 0 : filter[context])) {
|
|
2754
|
+
return [];
|
|
2755
|
+
}
|
|
2717
2756
|
if (!chain)
|
|
2718
2757
|
return getNativeAssets();
|
|
2719
|
-
|
|
2720
|
-
|
|
2758
|
+
const _assets = assetsByChainID(chain.chainID);
|
|
2759
|
+
if (filter && (filter === null || filter === void 0 ? void 0 : filter[context]) && ((_a = filter[context]) === null || _a === void 0 ? void 0 : _a[chain.chainID])) {
|
|
2760
|
+
return _assets.filter((asset) => { var _a, _b; return (_b = (_a = filter[context]) === null || _a === void 0 ? void 0 : _a[chain.chainID]) === null || _b === void 0 ? void 0 : _b.includes(asset.denom); });
|
|
2761
|
+
}
|
|
2762
|
+
return _assets;
|
|
2763
|
+
}, [assetsByChainID, chain, getNativeAssets, filter]);
|
|
2721
2764
|
const account = useAccount(chain === null || chain === void 0 ? void 0 : chain.chainID);
|
|
2722
2765
|
const isAnyDisclosureOpen = useAnyDisclosureOpen();
|
|
2723
2766
|
const { data: balances, isLoading: isBalancesLoading } = useBalancesByChain({
|
|
@@ -4952,7 +4995,31 @@ const SwapWidgetUI = ({ className, style, }) => {
|
|
|
4952
4995
|
useFixRadixUiWheelEvent();
|
|
4953
4996
|
useEffect(() => void disclosure.rehydrate(), []);
|
|
4954
4997
|
const { openWalletModal } = useWalletModal();
|
|
4955
|
-
const
|
|
4998
|
+
const filter = useSwapWidgetUIStore((state) => state.filter);
|
|
4999
|
+
const sourceChainIDs = (filter === null || filter === void 0 ? void 0 : filter.source)
|
|
5000
|
+
? Object.keys(filter.source)
|
|
5001
|
+
: undefined;
|
|
5002
|
+
const destinationChainIDs = (filter === null || filter === void 0 ? void 0 : filter.destination)
|
|
5003
|
+
? Object.keys(filter.destination)
|
|
5004
|
+
: undefined;
|
|
5005
|
+
const { data: sourceChains } = useChains({
|
|
5006
|
+
select: (chains) => {
|
|
5007
|
+
if (!sourceChainIDs)
|
|
5008
|
+
return chains;
|
|
5009
|
+
return chains === null || chains === void 0 ? void 0 : chains.filter((chain) => {
|
|
5010
|
+
return sourceChainIDs === null || sourceChainIDs === void 0 ? void 0 : sourceChainIDs.includes(chain.chainID);
|
|
5011
|
+
});
|
|
5012
|
+
},
|
|
5013
|
+
});
|
|
5014
|
+
const { data: destinationChains } = useChains({
|
|
5015
|
+
select: (chains) => {
|
|
5016
|
+
if (!destinationChainIDs)
|
|
5017
|
+
return chains;
|
|
5018
|
+
return chains === null || chains === void 0 ? void 0 : chains.filter((chain) => {
|
|
5019
|
+
return destinationChainIDs === null || destinationChainIDs === void 0 ? void 0 : destinationChainIDs.includes(chain.chainID);
|
|
5020
|
+
});
|
|
5021
|
+
},
|
|
5022
|
+
});
|
|
4956
5023
|
const { amountIn, amountOut, bridges, destinationAsset, destinationChain, direction, isAmountError, numberOfTransactions, onAllTransactionComplete, onBridgeChange, onDestinationAmountChange, onDestinationAssetChange, onDestinationChainChange, onInvertDirection, onSourceAmountChange, onSourceAmountMax, onSourceAssetChange, onSourceChainChange, priceImpactThresholdReached, route, routeError, routeLoading, routeWarningMessage, routeWarningTitle, sourceAsset, sourceChain, sourceFeeAmount, sourceFeeAsset, swapPriceImpactPercent, usdDiffPercent, shareable, } = useSwapWidget();
|
|
4957
5024
|
const srcAccount = useAccount(sourceChain === null || sourceChain === void 0 ? void 0 : sourceChain.chainID);
|
|
4958
5025
|
const isWalletConnected = srcAccount === null || srcAccount === void 0 ? void 0 : srcAccount.isWalletConnected;
|
|
@@ -4975,12 +5042,12 @@ const SwapWidgetUI = ({ className, style, }) => {
|
|
|
4975
5042
|
? srcAccount.wallet.walletInfo.logo
|
|
4976
5043
|
: ((_b = srcAccount.wallet.walletInfo.logo) === null || _b === void 0 ? void 0 : _b.major) ||
|
|
4977
5044
|
((_c = srcAccount.wallet.walletInfo.logo) === null || _c === void 0 ? void 0 : _c.minor)
|
|
4978
|
-
: '', className: "animate-slide-left-and-fade" }, srcAccount.address) })) : null] }), jsx("div", { "data-testid": "source", children: jsx(AssetInput, { amount: amountIn, amountUSD: route === null || route === void 0 ? void 0 : route.usdAmountIn, asset: sourceAsset, chain: sourceChain, chains:
|
|
5045
|
+
: '', className: "animate-slide-left-and-fade" }, srcAccount.address) })) : null] }), jsx("div", { "data-testid": "source", children: jsx(AssetInput, { amount: amountIn, amountUSD: route === null || route === void 0 ? void 0 : route.usdAmountIn, asset: sourceAsset, chain: sourceChain, chains: sourceChains !== null && sourceChains !== void 0 ? sourceChains : [], onAmountChange: onSourceAmountChange, onAmountMax: onSourceAmountMax, onAssetChange: onSourceAssetChange, onChainChange: onSourceChainChange, context: "source", isLoading: direction === 'swap-out' && routeLoading, isError: isAmountError }) }), jsxs("div", { className: "relative", children: [jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: jsx("button", { className: cn('pointer-events-auto flex h-8 w-8 items-center justify-center rounded-md bg-neutral-900 text-white', 'transition-transform enabled:hover:rotate-3 enabled:hover:scale-105', 'disabled:cursor-not-allowed disabled:bg-neutral-500 disabled:hover:scale-100', 'data-[swap=true]:pointer-events-none data-[swap=true]:animate-spin-swap'), disabled: !destinationChain, onClick: async () => {
|
|
4979
5046
|
if (!destinationChain || !invertButtonRef.current)
|
|
4980
5047
|
return;
|
|
4981
5048
|
invertButtonRef.current.setAttribute('data-swap', 'true');
|
|
4982
5049
|
await onInvertDirection();
|
|
4983
|
-
}, "data-testid": "swap-button", ref: invertButtonRef, children: jsx(ArrowsUpDownIcon, { className: "h-4 w-4" }) }) }), jsx("p", { className: "text-2xl font-semibold", children: "To" })] }), jsx("div", { "data-testid": "destination", children: jsx(AssetInput, { amount: amountOut, amountUSD: route === null || route === void 0 ? void 0 : route.usdAmountOut, diffPercentage: usdDiffPercent, asset: destinationAsset, chain: destinationChain, chains:
|
|
5050
|
+
}, "data-testid": "swap-button", ref: invertButtonRef, children: jsx(ArrowsUpDownIcon, { className: "h-4 w-4" }) }) }), jsx("p", { className: "text-2xl font-semibold", children: "To" })] }), jsx("div", { "data-testid": "destination", children: jsx(AssetInput, { amount: amountOut, amountUSD: route === null || route === void 0 ? void 0 : route.usdAmountOut, diffPercentage: usdDiffPercent, asset: destinationAsset, chain: destinationChain, chains: destinationChains !== null && destinationChains !== void 0 ? destinationChains : [], onAmountChange: onDestinationAmountChange, onAssetChange: onDestinationAssetChange, onChainChange: onDestinationChainChange, context: "destination", isLoading: direction === 'swap-in' && routeLoading }) }), route && (jsx(SwapDetails, { amountIn: amountIn, amountOut: amountOut, bridges: bridges, destinationAsset: destinationAsset, destinationChain: destinationChain, direction: direction, gasRequired: sourceFeeAmount, onBridgesChange: onBridgeChange, priceImpactPercent: swapPriceImpactPercent !== null && swapPriceImpactPercent !== void 0 ? swapPriceImpactPercent : 0, priceImpactThresholdReached: priceImpactThresholdReached, route: route, sourceAsset: sourceAsset, sourceFeeAsset: sourceFeeAsset, sourceChain: sourceChain })), routeLoading && (jsxs("div", { className: "flex w-full items-center justify-between space-x-2 text-sm font-medium uppercase", children: [jsx("p", { className: "text-neutral-400", children: "Finding best route..." }), jsx(SpinnerIcon, { className: "h-5 w-5 text-neutral-200 animate-spin" })] })), route && !routeLoading && numberOfTransactions > 1 && (jsxs("div", { className: "flex w-full items-center justify-center space-x-2 text-sm font-medium uppercase", children: [jsxs("div", { className: cn('relative rounded-full p-[4px]'), style: {
|
|
4984
5051
|
backgroundColor: useSwapWidgetUIStore.getState().colors.primary,
|
|
4985
5052
|
}, children: [jsx("div", { className: cn('absolute h-6 w-6 animate-ping rounded-full', css `
|
|
4986
5053
|
background-color: ${useSwapWidgetUIStore.getState().colors
|
|
@@ -5076,7 +5143,7 @@ const useInjectFontsToDocumentHead = () => {
|
|
|
5076
5143
|
}, []);
|
|
5077
5144
|
};
|
|
5078
5145
|
|
|
5079
|
-
const SwapWidget = ({ colors, settings, onlyTestnet, defaultRoute, routeConfig, className, style, ...swapWidgetProviderProps }) => {
|
|
5146
|
+
const SwapWidget = ({ colors, settings, onlyTestnet, defaultRoute, routeConfig, className, style, filter, ...swapWidgetProviderProps }) => {
|
|
5080
5147
|
useInjectFontsToDocumentHead();
|
|
5081
5148
|
useEffect(() => {
|
|
5082
5149
|
configureSwapWidget({
|
|
@@ -5085,6 +5152,7 @@ const SwapWidget = ({ colors, settings, onlyTestnet, defaultRoute, routeConfig,
|
|
|
5085
5152
|
settings,
|
|
5086
5153
|
defaultRoute,
|
|
5087
5154
|
routeConfig,
|
|
5155
|
+
filter,
|
|
5088
5156
|
});
|
|
5089
5157
|
}, [colors, onlyTestnet, settings, defaultRoute, routeConfig]);
|
|
5090
5158
|
return (jsx(Scope, { stylesheets: [css_248z, css_248z$1], config: { dsd: 'emulated' }, children: jsx(SwapWidgetProvider, { ...swapWidgetProviderProps, children: jsx(SwapWidgetUI, { className: className, style: style }) }) }));
|