@skip-go/widget 2.1.3-alpha.0 → 2.2.0
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 -0
- package/build/hooks/use-swap-widget.d.ts +1 -1
- package/build/index.es.js +12 -8
- package/build/index.es.js.map +1 -1
- package/build/ui/Widget.d.ts +2 -1
- package/package.json +3 -3
- package/build/preinstall.cjs +0 -16
- package/build/ui/WalletModal/PraxWalletIndex.d.ts +0 -4
- package/build/utils/prax.d.ts +0 -75
package/README.md
CHANGED
|
@@ -133,6 +133,7 @@ interface SwapWidgetProps {
|
|
|
133
133
|
brandColor: string; // color used for confirmation buttons
|
|
134
134
|
highlightColor: string; // color used when hovering over buttons, and in select chain/asset dropdown
|
|
135
135
|
};
|
|
136
|
+
persistSwapWidgetState?: boolean; // whether or not swap widget state should persist after refresh. Defaults to true
|
|
136
137
|
}
|
|
137
138
|
````
|
|
138
139
|
|
|
@@ -10,7 +10,7 @@ export interface DefaultRouteConfig {
|
|
|
10
10
|
destChainID?: string;
|
|
11
11
|
destAssetDenom?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function useSwapWidget(): {
|
|
13
|
+
export declare function useSwapWidget(persistSwapWidgetState?: boolean): {
|
|
14
14
|
amountIn: string;
|
|
15
15
|
amountOut: string;
|
|
16
16
|
bridges: BridgeType[];
|
package/build/index.es.js
CHANGED
|
@@ -81,7 +81,7 @@ const wallets = [
|
|
|
81
81
|
const CosmosProvider = ({ children }) => {
|
|
82
82
|
const chains = getChains();
|
|
83
83
|
const assets = getAssetLists();
|
|
84
|
-
return (jsx(ChainProvider, { chains: chains, wallets: wallets, throwErrors: false, assetLists: assets, sessionOptions: {
|
|
84
|
+
return (jsx(ChainProvider, { chains: chains, wallets: wallets, throwErrors: false, assetLists: assets, disableIframe: false, sessionOptions: {
|
|
85
85
|
duration: 1000 * 60 * 60 * 24, // 1 day
|
|
86
86
|
}, children: children }, 'skip-widget-chain-provider'));
|
|
87
87
|
};
|
|
@@ -1962,12 +1962,16 @@ function parseAmountWei(amount, decimals = 6) {
|
|
|
1962
1962
|
}
|
|
1963
1963
|
|
|
1964
1964
|
const PRICE_IMPACT_THRESHOLD = 0.1;
|
|
1965
|
-
function useSwapWidget() {
|
|
1965
|
+
function useSwapWidget(persistSwapWidgetState = true) {
|
|
1966
1966
|
/**
|
|
1967
1967
|
* intentional manual hydration to prevent ssr mismatch
|
|
1968
1968
|
* @see {useSwapWidgetStore}
|
|
1969
1969
|
*/
|
|
1970
|
-
useEffect(() =>
|
|
1970
|
+
useEffect(() => {
|
|
1971
|
+
if (persistSwapWidgetState) {
|
|
1972
|
+
useSwapWidgetStore.persist.rehydrate();
|
|
1973
|
+
}
|
|
1974
|
+
}, []);
|
|
1971
1975
|
/////////////////////////////////////////////////////////////////////////////
|
|
1972
1976
|
// #region -- core states
|
|
1973
1977
|
const { routeConfig, defaultRoute } = useSwapWidgetUIStore();
|
|
@@ -3991,7 +3995,7 @@ const SetAddressDialog = ({ open, onOpen, chain, index, signRequired, isDestinat
|
|
|
3991
3995
|
return '0x...';
|
|
3992
3996
|
}
|
|
3993
3997
|
if (chainType === 'svm') {
|
|
3994
|
-
return 'Enter
|
|
3998
|
+
return 'Enter solana address...';
|
|
3995
3999
|
}
|
|
3996
4000
|
return 'Enter address...';
|
|
3997
4001
|
}, [chainType, bech32Prefix]);
|
|
@@ -5016,7 +5020,7 @@ function TransactionDialog({ isLoading, route, isAmountError, shouldShowPriceImp
|
|
|
5016
5020
|
return (jsxs(Fragment$1, { children: [jsxs("div", { children: [jsx(StyledBrandDiv, { as: "button", className: cn('w-full rounded-md py-4 font-semibold text-white outline-none transition-[opacity,transform]', 'disabled:cursor-not-allowed disabled:opacity-75', 'enabled:hover:rotate-1 enabled:hover:scale-102'), disabled: !route || (typeof isLoading === 'boolean' && isLoading), onClick: () => confirmControl.open(), children: "Preview Route" }), isOpen && route && (jsx(PreviewRoute, { route: route, disclosure: confirmDisclosure, isAmountError: isAmountError }))] }), jsx(PriceImpactWarning, { onGoBack: confirmControl.close, message: routeWarningMessage, title: routeWarningTitle })] }));
|
|
5017
5021
|
}
|
|
5018
5022
|
|
|
5019
|
-
const SwapWidgetUI = ({ className, style, toasterProps, }) => {
|
|
5023
|
+
const SwapWidgetUI = ({ className, style, toasterProps, persistSwapWidgetState, }) => {
|
|
5020
5024
|
var _a, _b, _c;
|
|
5021
5025
|
const theme = useTheme();
|
|
5022
5026
|
useEffect(() => void disclosure.rehydrate(), []);
|
|
@@ -5046,7 +5050,7 @@ const SwapWidgetUI = ({ className, style, toasterProps, }) => {
|
|
|
5046
5050
|
});
|
|
5047
5051
|
},
|
|
5048
5052
|
});
|
|
5049
|
-
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();
|
|
5053
|
+
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(persistSwapWidgetState);
|
|
5050
5054
|
const srcAccount = useAccount(sourceChain === null || sourceChain === void 0 ? void 0 : sourceChain.chainID);
|
|
5051
5055
|
const isWalletConnected = srcAccount === null || srcAccount === void 0 ? void 0 : srcAccount.isWalletConnected;
|
|
5052
5056
|
function promptDestAsset() {
|
|
@@ -5233,7 +5237,7 @@ const SwapWidgetWithoutProviders = ({ settings, onlyTestnet, defaultRoute, route
|
|
|
5233
5237
|
}, [defaultTheme, theme]);
|
|
5234
5238
|
return (jsx(WithStyledShadowDom, { children: jsx(ThemeProvider, { theme: mergedThemes, children: jsx(SwapWidgetUI, { ...swapWidgetUIProps }) }) }));
|
|
5235
5239
|
};
|
|
5236
|
-
const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, className, style, filter, toasterProps, ...swapWidgetProviderProps }) => {
|
|
5240
|
+
const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, className, style, filter, toasterProps, persistSwapWidgetState, ...swapWidgetProviderProps }) => {
|
|
5237
5241
|
useEffect(() => {
|
|
5238
5242
|
configureSwapWidget({
|
|
5239
5243
|
onlyTestnet,
|
|
@@ -5249,7 +5253,7 @@ const SwapWidget = ({ settings, onlyTestnet, defaultRoute, routeConfig, theme, c
|
|
|
5249
5253
|
...theme,
|
|
5250
5254
|
};
|
|
5251
5255
|
}, [defaultTheme, theme]);
|
|
5252
|
-
return (jsx(WithStyledShadowDom, { children: jsx(ThemeProvider, { theme: mergedThemes, children: jsx(SwapWidgetProvider, { ...swapWidgetProviderProps, children: jsx(SwapWidgetUI, { className: className, style: style, toasterProps: toasterProps }) }) }) }));
|
|
5256
|
+
return (jsx(WithStyledShadowDom, { children: jsx(ThemeProvider, { theme: mergedThemes, children: jsx(SwapWidgetProvider, { ...swapWidgetProviderProps, children: jsx(SwapWidgetUI, { className: className, style: style, toasterProps: toasterProps, persistSwapWidgetState: persistSwapWidgetState }) }) }) }));
|
|
5253
5257
|
};
|
|
5254
5258
|
|
|
5255
5259
|
function isJsonString(str) {
|