@rango-dev/widget-embedded 0.17.1-next.4 → 0.17.1-next.5
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/QueueManager.d.ts +2 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +1 -0
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +1 -1
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +0 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +1 -6
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +1 -2
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +59 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +12 -6
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts +14 -7
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/settings.d.ts +3 -2
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +3 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +4 -3
- package/dist/utils/swap.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/QueueManager.tsx +14 -14
- package/src/Wallets.tsx +30 -5
- package/src/Widget.tsx +11 -25
- package/src/components/AppRouter.tsx +3 -5
- package/src/components/AppRoutes.tsx +6 -39
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -14
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/NoResult/NoResult.tsx +4 -1
- package/src/components/NotificationContent/NotificationContent.tsx +3 -2
- package/src/components/Quote/Quote.tsx +2 -4
- package/src/components/SwapDetails/SwapDetails.tsx +5 -6
- package/src/components/TokenList/TokenList.tsx +6 -7
- package/src/components/UpdateUrl.tsx +20 -14
- package/src/components/WidgetEvents.tsx +7 -4
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +5 -5
- package/src/hooks/useSwapInput.ts +6 -4
- package/src/hooks/useSyncStoresWithConfig.ts +20 -17
- package/src/hooks/useWalletList.ts +3 -5
- package/src/pages/ConfirmSwapPage.tsx +1 -9
- package/src/pages/Home.tsx +7 -7
- package/src/pages/LiquiditySourcePage.tsx +22 -31
- package/src/pages/SelectBlockchainPage.tsx +4 -5
- package/src/pages/SelectSwapItemsPage.tsx +5 -5
- package/src/pages/SettingsPage.tsx +8 -12
- package/src/pages/SwapDetailsPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +4 -11
- package/src/store/AppStore.tsx +35 -0
- package/src/store/app.ts +20 -5
- package/src/store/quote.ts +26 -22
- package/src/store/settings.ts +7 -4
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/wallets.ts +11 -8
- package/src/types/config.ts +5 -5
- package/src/utils/settings.ts +8 -7
- package/src/utils/swap.ts +14 -16
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/src/store/meta.ts +0 -39
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
|
|
3
1
|
import { useEffect, useRef } from 'react';
|
|
4
2
|
import {
|
|
5
3
|
createSearchParams,
|
|
@@ -10,14 +8,12 @@ import {
|
|
|
10
8
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
9
|
import { SearchParams } from '../constants/searchParams';
|
|
12
10
|
import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
|
|
13
|
-
import {
|
|
11
|
+
import { useAppStore } from '../store/AppStore';
|
|
14
12
|
import { useQuoteStore } from '../store/quote';
|
|
15
13
|
import { useUiStore } from '../store/ui';
|
|
16
14
|
import { searchParamsToToken } from '../utils/quote';
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export function UpdateUrl(props: Props) {
|
|
16
|
+
export function UpdateUrl() {
|
|
21
17
|
const firstRender = useRef(true);
|
|
22
18
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
23
19
|
const location = useLocation();
|
|
@@ -33,10 +29,11 @@ export function UpdateUrl(props: Props) {
|
|
|
33
29
|
const setToToken = useQuoteStore.use.setToToken();
|
|
34
30
|
const inputAmount = useQuoteStore.use.inputAmount();
|
|
35
31
|
const setInputAmount = useQuoteStore.use.setInputAmount();
|
|
36
|
-
const
|
|
37
|
-
const
|
|
32
|
+
const fetchMetaStatus = useAppStore().use.fetchStatus();
|
|
33
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
34
|
+
const tokens = useAppStore().use.tokens()();
|
|
38
35
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
39
|
-
useSyncStoresWithConfig(
|
|
36
|
+
useSyncStoresWithConfig();
|
|
40
37
|
|
|
41
38
|
useEffect(() => {
|
|
42
39
|
const params: Record<string, string> = {};
|
|
@@ -60,7 +57,7 @@ export function UpdateUrl(props: Props) {
|
|
|
60
57
|
toChainString = '',
|
|
61
58
|
toTokenString = '',
|
|
62
59
|
fromAmount = '';
|
|
63
|
-
if (
|
|
60
|
+
if (fetchMetaStatus !== 'success') {
|
|
64
61
|
fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
|
|
65
62
|
fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
|
|
66
63
|
toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
|
|
@@ -109,7 +106,7 @@ export function UpdateUrl(props: Props) {
|
|
|
109
106
|
]);
|
|
110
107
|
|
|
111
108
|
useEffect(() => {
|
|
112
|
-
if (
|
|
109
|
+
if (fetchMetaStatus === 'success') {
|
|
113
110
|
const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
|
|
114
111
|
const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
|
|
115
112
|
const toChainString = searchParams.get(SearchParams.TO_CHAIN);
|
|
@@ -134,20 +131,29 @@ export function UpdateUrl(props: Props) {
|
|
|
134
131
|
if (!!fromBlockchain) {
|
|
135
132
|
setFromBlockchain(fromBlockchain);
|
|
136
133
|
if (!!fromToken) {
|
|
137
|
-
setFromToken(
|
|
134
|
+
setFromToken({
|
|
135
|
+
token: fromToken,
|
|
136
|
+
meta: {
|
|
137
|
+
blockchains: blockchains,
|
|
138
|
+
tokens: tokens,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
if (!!toBlockchain) {
|
|
141
144
|
setToBlockchain(toBlockchain);
|
|
142
145
|
if (!!toToken) {
|
|
143
|
-
setToToken(
|
|
146
|
+
setToToken({
|
|
147
|
+
token: toToken,
|
|
148
|
+
meta: { blockchains: blockchains, tokens: tokens },
|
|
149
|
+
});
|
|
144
150
|
}
|
|
145
151
|
}
|
|
146
152
|
if (fromAmount) {
|
|
147
153
|
setInputAmount(fromAmount);
|
|
148
154
|
}
|
|
149
155
|
}
|
|
150
|
-
}, [
|
|
156
|
+
}, [fetchMetaStatus]);
|
|
151
157
|
|
|
152
158
|
return null;
|
|
153
159
|
}
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
|
|
11
|
+
import { useAppStore } from '../store/AppStore';
|
|
11
12
|
import { useNotificationStore } from '../store/notification';
|
|
12
13
|
import { useWalletsStore } from '../store/wallets';
|
|
13
14
|
import { validBlockedStatuses } from '../types/notification';
|
|
14
15
|
|
|
15
16
|
export function WidgetEvents() {
|
|
17
|
+
const tokens = useAppStore().use.tokens()();
|
|
16
18
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
17
19
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
18
20
|
const setNotification = useNotificationStore.use.setNotification();
|
|
@@ -38,12 +40,13 @@ export function WidgetEvents() {
|
|
|
38
40
|
(wallet) => wallet.chain === step?.toBlockchain
|
|
39
41
|
);
|
|
40
42
|
|
|
41
|
-
fromAccount && getWalletsDetails([fromAccount]);
|
|
42
|
-
toAccount && getWalletsDetails([toAccount]);
|
|
43
|
+
fromAccount && getWalletsDetails([fromAccount], tokens);
|
|
44
|
+
toAccount && getWalletsDetails([toAccount], tokens);
|
|
43
45
|
}
|
|
44
46
|
if (
|
|
45
|
-
event.type === StepEventType.TX_EXECUTION_BLOCKED &&
|
|
46
|
-
|
|
47
|
+
(event.type === StepEventType.TX_EXECUTION_BLOCKED &&
|
|
48
|
+
validBlockedStatuses.includes(event.status)) ||
|
|
49
|
+
event.type === StepEventType.FAILED
|
|
47
50
|
) {
|
|
48
51
|
setNotification(event, route);
|
|
49
52
|
} else if (
|
|
@@ -5,7 +5,7 @@ import type { BestRouteResponse } from 'rango-sdk';
|
|
|
5
5
|
import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useAppStore } from '../../store/AppStore';
|
|
9
9
|
import { useQuoteStore } from '../../store/quote';
|
|
10
10
|
import { useSettingsStore } from '../../store/settings';
|
|
11
11
|
import { useWalletsStore } from '../../store/wallets';
|
|
@@ -40,8 +40,8 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
40
40
|
disabledLiquiditySources,
|
|
41
41
|
} = useSettingsStore();
|
|
42
42
|
const { connectedWallets } = useWalletsStore();
|
|
43
|
-
|
|
44
|
-
const
|
|
43
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
44
|
+
const tokens = useAppStore().use.tokens()();
|
|
45
45
|
|
|
46
46
|
const userSlippage = customSlippage || slippage;
|
|
47
47
|
|
|
@@ -105,13 +105,13 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
105
105
|
getWalletsForNewSwap(selectedWallets),
|
|
106
106
|
swapSettings,
|
|
107
107
|
false,
|
|
108
|
-
|
|
108
|
+
{ blockchains, tokens }
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
const confirmSwapWarnings = generateWarnings(initialQuote, currentQuote, {
|
|
112
112
|
fromToken,
|
|
113
113
|
toToken,
|
|
114
|
-
tokens:
|
|
114
|
+
tokens: tokens,
|
|
115
115
|
selectedWallets,
|
|
116
116
|
userSlippage,
|
|
117
117
|
});
|
|
@@ -2,7 +2,7 @@ import type { QuoteError, QuoteWarning } from '../types';
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useAppStore } from '../store/AppStore';
|
|
6
6
|
import { useQuoteStore } from '../store/quote';
|
|
7
7
|
import { useSettingsStore } from '../store/settings';
|
|
8
8
|
import { QuoteErrorType } from '../types';
|
|
@@ -33,6 +33,9 @@ type UseSwapInput = {
|
|
|
33
33
|
*/
|
|
34
34
|
export function useSwapInput(): UseSwapInput {
|
|
35
35
|
const { fetch: fetchQuote, cancelFetch } = useFetchQuote();
|
|
36
|
+
const { liquiditySources, enableNewLiquiditySources } =
|
|
37
|
+
useAppStore().use.config();
|
|
38
|
+
const tokens = useAppStore().use.tokens()();
|
|
36
39
|
const {
|
|
37
40
|
fromToken,
|
|
38
41
|
toToken,
|
|
@@ -41,9 +44,6 @@ export function useSwapInput(): UseSwapInput {
|
|
|
41
44
|
resetQuote,
|
|
42
45
|
setQuote,
|
|
43
46
|
} = useQuoteStore();
|
|
44
|
-
const {
|
|
45
|
-
meta: { tokens },
|
|
46
|
-
} = useMetaStore();
|
|
47
47
|
const {
|
|
48
48
|
slippage,
|
|
49
49
|
customSlippage,
|
|
@@ -79,6 +79,8 @@ export function useSwapInput(): UseSwapInput {
|
|
|
79
79
|
fromToken,
|
|
80
80
|
toToken,
|
|
81
81
|
inputAmount,
|
|
82
|
+
liquiditySources,
|
|
83
|
+
excludeLiquiditySources: enableNewLiquiditySources,
|
|
82
84
|
disabledLiquiditySources,
|
|
83
85
|
slippage: userSlippage,
|
|
84
86
|
affiliateRef,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
1
|
import type { Asset } from 'rango-sdk';
|
|
3
2
|
|
|
4
3
|
import { useEffect, useMemo, useRef } from 'react';
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { useAppStore } from '../store/AppStore';
|
|
7
6
|
import { useQuoteStore } from '../store/quote';
|
|
8
7
|
import { useSettingsStore } from '../store/settings';
|
|
9
8
|
import { tokensAreEqual } from '../utils/wallets';
|
|
10
9
|
|
|
11
|
-
export function useSyncStoresWithConfig(
|
|
10
|
+
export function useSyncStoresWithConfig() {
|
|
12
11
|
const {
|
|
13
12
|
setInputAmount,
|
|
14
13
|
setToToken,
|
|
@@ -21,10 +20,10 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
21
20
|
toBlockchain,
|
|
22
21
|
} = useQuoteStore();
|
|
23
22
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const config = useAppStore().use.config();
|
|
24
|
+
const fetchMetaStatus = useAppStore().use.fetchStatus();
|
|
25
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
26
|
+
const tokens = useAppStore().use.tokens()();
|
|
28
27
|
|
|
29
28
|
const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
|
|
30
29
|
useSettingsStore();
|
|
@@ -55,7 +54,7 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
55
54
|
}, [config?.amount]);
|
|
56
55
|
|
|
57
56
|
useEffect(() => {
|
|
58
|
-
if (
|
|
57
|
+
if (fetchMetaStatus === 'success') {
|
|
59
58
|
const chain = blockchains.find(
|
|
60
59
|
(chain) => chain.name === config?.from?.blockchain
|
|
61
60
|
);
|
|
@@ -67,8 +66,10 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
67
66
|
setFromBlockchain(chain ?? null);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
if (token
|
|
71
|
-
setFromToken(token
|
|
69
|
+
if (token) {
|
|
70
|
+
setFromToken({ token, meta: { blockchains, tokens } });
|
|
71
|
+
} else if (!token && prevConfigFromToken.current) {
|
|
72
|
+
setFromToken({ token: null });
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
prevConfigFromBlockchain.current = config?.from?.blockchain;
|
|
@@ -79,13 +80,13 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
79
80
|
config?.from?.token?.address,
|
|
80
81
|
config?.from?.token?.blockchain,
|
|
81
82
|
config?.from?.blockchain,
|
|
82
|
-
|
|
83
|
+
fetchMetaStatus,
|
|
83
84
|
]);
|
|
84
85
|
|
|
85
86
|
useEffect(() => {
|
|
86
87
|
if (fromToken && fromTokensConfig) {
|
|
87
88
|
if (!fromTokensConfig.some((token) => tokensAreEqual(token, fromToken))) {
|
|
88
|
-
setFromToken(null);
|
|
89
|
+
setFromToken({ token: null });
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -99,7 +100,7 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
99
100
|
useEffect(() => {
|
|
100
101
|
if (toToken && toTokensConfig) {
|
|
101
102
|
if (!toTokensConfig.some((token) => tokensAreEqual(token, toToken))) {
|
|
102
|
-
setToToken(null);
|
|
103
|
+
setToToken({ token: null });
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
|
|
@@ -111,7 +112,7 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
111
112
|
}, [toTokensConfig, toBlockchainsConfig]);
|
|
112
113
|
|
|
113
114
|
useEffect(() => {
|
|
114
|
-
if (
|
|
115
|
+
if (fetchMetaStatus === 'success') {
|
|
115
116
|
const chain = blockchains.find(
|
|
116
117
|
(chain) => chain.name === config?.to?.blockchain
|
|
117
118
|
);
|
|
@@ -123,8 +124,10 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
123
124
|
setToBlockchain(chain ?? null);
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
if (token
|
|
127
|
-
setToToken(token
|
|
127
|
+
if (token) {
|
|
128
|
+
setToToken({ token, meta: { blockchains, tokens } });
|
|
129
|
+
} else if (!token && prevConfigToToken.current) {
|
|
130
|
+
setToToken({ token: null });
|
|
128
131
|
}
|
|
129
132
|
|
|
130
133
|
prevConfigToBlockchain.current = config?.to?.blockchain;
|
|
@@ -135,7 +138,7 @@ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
|
|
|
135
138
|
config?.to?.token?.address,
|
|
136
139
|
config?.to?.token?.blockchain,
|
|
137
140
|
config?.to?.blockchain,
|
|
138
|
-
|
|
141
|
+
fetchMetaStatus,
|
|
139
142
|
]);
|
|
140
143
|
|
|
141
144
|
useEffect(() => {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@rango-dev/wallets-shared';
|
|
11
11
|
import { useEffect, useState } from 'react';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useAppStore } from '../store/AppStore';
|
|
14
14
|
import { useWalletsStore } from '../store/wallets';
|
|
15
15
|
import { configWalletsToWalletName } from '../utils/providers';
|
|
16
16
|
import {
|
|
@@ -37,9 +37,7 @@ export function useWalletList(params: Params) {
|
|
|
37
37
|
const { config, chain, onBeforeConnect, onConnect } = params;
|
|
38
38
|
const { state, disconnect, getWalletInfo, connect } = useWallets();
|
|
39
39
|
const { connectedWallets } = useWalletsStore();
|
|
40
|
-
const
|
|
41
|
-
const multiWallets =
|
|
42
|
-
typeof config?.multiWallets === 'undefined' ? true : config.multiWallets;
|
|
40
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
43
41
|
|
|
44
42
|
/** It can be what has been set by widget config or as a fallback we use all the supported wallets by our library */
|
|
45
43
|
const listAvailableWalletTypes =
|
|
@@ -76,7 +74,7 @@ export function useWalletList(params: Params) {
|
|
|
76
74
|
const atLeastOneWalletIsConnected = !!wallets.find(
|
|
77
75
|
(w) => w.state === WalletState.CONNECTED
|
|
78
76
|
);
|
|
79
|
-
if (!multiWallets && atLeastOneWalletIsConnected) {
|
|
77
|
+
if (!config?.multiWallets && atLeastOneWalletIsConnected) {
|
|
80
78
|
return;
|
|
81
79
|
}
|
|
82
80
|
onBeforeConnect?.(type);
|
|
@@ -3,7 +3,6 @@ import type {
|
|
|
3
3
|
ConfirmSwap,
|
|
4
4
|
ConfirmSwapFetchResult,
|
|
5
5
|
} from '../hooks/useConfirmSwap/useConfirmSwap.types';
|
|
6
|
-
import type { WidgetConfig } from '../types';
|
|
7
6
|
|
|
8
7
|
import { i18n } from '@lingui/core';
|
|
9
8
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -69,13 +68,8 @@ const Buttons = styled('div', {
|
|
|
69
68
|
},
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
config?: WidgetConfig;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export function ConfirmSwapPage(props: PropTypes) {
|
|
71
|
+
export function ConfirmSwapPage() {
|
|
77
72
|
//TODO: move component's logics to a custom hook
|
|
78
|
-
const { config } = props;
|
|
79
73
|
const {
|
|
80
74
|
quote,
|
|
81
75
|
setInputAmount,
|
|
@@ -92,7 +86,6 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
92
86
|
const showWalletsOnInit = !quoteWalletsConfirmed;
|
|
93
87
|
const [showWallets, setShowWallets] = useState(false);
|
|
94
88
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
95
|
-
|
|
96
89
|
const { manager } = useManager();
|
|
97
90
|
const {
|
|
98
91
|
fetch: confirmSwap,
|
|
@@ -296,7 +289,6 @@ export function ConfirmSwapPage(props: PropTypes) {
|
|
|
296
289
|
onCancel={cancelFetch}
|
|
297
290
|
loading={fetchingConfirmationQuote}
|
|
298
291
|
onCheckBalance={onConfirmSwap}
|
|
299
|
-
config={config}
|
|
300
292
|
/>
|
|
301
293
|
)}
|
|
302
294
|
|
package/src/pages/Home.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from '../constants/routing';
|
|
21
21
|
import { QuoteInfo } from '../containers/QuoteInfo';
|
|
22
22
|
import { useSwapInput } from '../hooks/useSwapInput';
|
|
23
|
-
import {
|
|
23
|
+
import { useAppStore } from '../store/AppStore';
|
|
24
24
|
import { useQuoteStore } from '../store/quote';
|
|
25
25
|
import { useUiStore } from '../store/ui';
|
|
26
26
|
import { useWalletsStore } from '../store/wallets';
|
|
@@ -76,7 +76,7 @@ export function Home() {
|
|
|
76
76
|
setQuoteWarningsConfirmed,
|
|
77
77
|
} = useQuoteStore();
|
|
78
78
|
|
|
79
|
-
const
|
|
79
|
+
const fetchMetaStatus = useAppStore().use.fetchStatus();
|
|
80
80
|
|
|
81
81
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
82
82
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
@@ -100,7 +100,7 @@ export function Home() {
|
|
|
100
100
|
outputUsdValue
|
|
101
101
|
);
|
|
102
102
|
const swapButtonState = getSwapButtonState(
|
|
103
|
-
|
|
103
|
+
fetchMetaStatus,
|
|
104
104
|
connectedWallets,
|
|
105
105
|
fetchingQuote,
|
|
106
106
|
quote,
|
|
@@ -227,8 +227,8 @@ export function Home() {
|
|
|
227
227
|
? errorMessages().unknownPriceError.impactTitle
|
|
228
228
|
: undefined,
|
|
229
229
|
}}
|
|
230
|
-
disabled={
|
|
231
|
-
loading={
|
|
230
|
+
disabled={fetchMetaStatus === 'failed'}
|
|
231
|
+
loading={fetchMetaStatus === 'loading'}
|
|
232
232
|
onSelectMaxBalance={() => {
|
|
233
233
|
if (tokenBalance !== '0') {
|
|
234
234
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -273,8 +273,8 @@ export function Home() {
|
|
|
273
273
|
: undefined,
|
|
274
274
|
}}
|
|
275
275
|
onClickToken={() => navigate('to-swap')}
|
|
276
|
-
disabled={
|
|
277
|
-
loading={
|
|
276
|
+
disabled={fetchMetaStatus === 'failed'}
|
|
277
|
+
loading={fetchMetaStatus === 'loading'}
|
|
278
278
|
/>
|
|
279
279
|
</InputsContainer>
|
|
280
280
|
<QuoteInfo
|
|
@@ -25,30 +25,23 @@ import {
|
|
|
25
25
|
} from '../components/SettingsContainer';
|
|
26
26
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
27
27
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
28
|
-
import {
|
|
28
|
+
import { useAppStore } from '../store/AppStore';
|
|
29
29
|
import { useSettingsStore } from '../store/settings';
|
|
30
30
|
import { containsText } from '../utils/numbers';
|
|
31
|
-
import {
|
|
32
|
-
getUniqueSwappersGroups,
|
|
33
|
-
sortLiquiditySourcesByGroupTitle,
|
|
34
|
-
} from '../utils/settings';
|
|
31
|
+
import { getUniqueSwappersGroups } from '../utils/settings';
|
|
35
32
|
|
|
36
33
|
interface PropTypes {
|
|
37
|
-
supportedSwappers?: string[];
|
|
38
34
|
sourceType: 'Exchanges' | 'Bridges';
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
export function LiquiditySourcePage({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}: PropTypes) {
|
|
37
|
+
export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
38
|
+
const fetchStatus = useAppStore().use.fetchStatus();
|
|
39
|
+
const swappers = useAppStore().use.swappers()();
|
|
45
40
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
46
41
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
47
42
|
const { navigateBackFrom } = useNavigateBack();
|
|
48
|
-
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
49
|
-
|
|
50
43
|
const supportedUniqueSwappersGroups: Array<UniqueSwappersGroupType> =
|
|
51
|
-
getUniqueSwappersGroups(
|
|
44
|
+
getUniqueSwappersGroups(swappers);
|
|
52
45
|
|
|
53
46
|
const validTypes: Array<LiquiditySourceType> = [];
|
|
54
47
|
if (sourceType === 'Exchanges') {
|
|
@@ -79,22 +72,20 @@ export function LiquiditySourcePage({
|
|
|
79
72
|
});
|
|
80
73
|
};
|
|
81
74
|
|
|
82
|
-
const list = liquiditySources
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
});
|
|
75
|
+
const list = liquiditySources.map((sourceItem) => {
|
|
76
|
+
const { selected, groupTitle, logo } = sourceItem;
|
|
77
|
+
return {
|
|
78
|
+
start: <Image src={logo} size={22} type="circular" />,
|
|
79
|
+
onClick: () => toggleLiquiditySource(groupTitle),
|
|
80
|
+
end: <Checkbox checked={selected} />,
|
|
81
|
+
title: (
|
|
82
|
+
<Typography variant="title" size="xmedium">
|
|
83
|
+
{i18n.t(groupTitle)}
|
|
84
|
+
</Typography>
|
|
85
|
+
),
|
|
86
|
+
...sourceItem,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
98
89
|
|
|
99
90
|
const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
100
91
|
const value = event.target.value;
|
|
@@ -131,7 +122,7 @@ export function LiquiditySourcePage({
|
|
|
131
122
|
placeholder={i18n.t('Search {sourceType}', { sourceType })}
|
|
132
123
|
onChange={searchHandler}
|
|
133
124
|
/>
|
|
134
|
-
{
|
|
125
|
+
{fetchStatus === 'loading' && <LoadingLiquiditySourceList />}
|
|
135
126
|
|
|
136
127
|
{!filteredList.length && !!searchedFor ? (
|
|
137
128
|
<NotFoundContainer>
|
|
@@ -141,7 +132,7 @@ export function LiquiditySourcePage({
|
|
|
141
132
|
/>
|
|
142
133
|
</NotFoundContainer>
|
|
143
134
|
) : (
|
|
144
|
-
|
|
135
|
+
fetchStatus === 'success' && (
|
|
145
136
|
<LiquiditySourceList>
|
|
146
137
|
{filteredList.map((sourceItem) => {
|
|
147
138
|
return (
|
|
@@ -7,8 +7,7 @@ import { Layout } from '../components/Layout';
|
|
|
7
7
|
import { SearchInput } from '../components/SearchInput';
|
|
8
8
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
9
9
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
10
|
-
import { useAppStore } from '../store/
|
|
11
|
-
import { useMetaStore } from '../store/meta';
|
|
10
|
+
import { useAppStore } from '../store/AppStore';
|
|
12
11
|
import { useQuoteStore } from '../store/quote';
|
|
13
12
|
|
|
14
13
|
interface PropTypes {
|
|
@@ -22,9 +21,9 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
22
21
|
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
23
22
|
const setToBlockchain = useQuoteStore.use.setToBlockchain();
|
|
24
23
|
const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
|
|
25
|
-
const
|
|
24
|
+
const fetchStatus = useAppStore().use.fetchStatus();
|
|
26
25
|
|
|
27
|
-
const blockchains = useAppStore().blockchains({
|
|
26
|
+
const blockchains = useAppStore().use.blockchains()({
|
|
28
27
|
type: type,
|
|
29
28
|
});
|
|
30
29
|
const routeKey = type === 'source' ? 'fromBlockchain' : 'toBlockchain';
|
|
@@ -42,7 +41,7 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
42
41
|
setCategory={setBlockchainCategory}
|
|
43
42
|
category={blockchainCategory}
|
|
44
43
|
blockchains={blockchains}
|
|
45
|
-
isLoading={
|
|
44
|
+
isLoading={fetchStatus === 'loading'}
|
|
46
45
|
/>
|
|
47
46
|
<Divider size={24} />
|
|
48
47
|
<SearchInput
|
|
@@ -11,7 +11,7 @@ import { SearchInput } from '../components/SearchInput';
|
|
|
11
11
|
import { TokenList } from '../components/TokenList/TokenList';
|
|
12
12
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
13
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
14
|
-
import { useAppStore } from '../store/
|
|
14
|
+
import { useAppStore } from '../store/AppStore';
|
|
15
15
|
import { useQuoteStore } from '../store/quote';
|
|
16
16
|
import { useWalletsStore } from '../store/wallets';
|
|
17
17
|
import { getTokensBalanceFromWalletAndSort } from '../utils/wallets';
|
|
@@ -39,10 +39,10 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
39
39
|
const selectedBlockchainName = selectedBlockchain?.name ?? '';
|
|
40
40
|
|
|
41
41
|
// Tokens & Blockchains list
|
|
42
|
-
const blockchains = useAppStore().blockchains({
|
|
42
|
+
const blockchains = useAppStore().use.blockchains()({
|
|
43
43
|
type: type,
|
|
44
44
|
});
|
|
45
|
-
const tokens = useAppStore().tokens({
|
|
45
|
+
const tokens = useAppStore().use.tokens()({
|
|
46
46
|
type,
|
|
47
47
|
blockchain: selectedBlockchainName,
|
|
48
48
|
searchFor: searchedFor,
|
|
@@ -63,9 +63,9 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
63
63
|
|
|
64
64
|
const updateToken = (token: Token) => {
|
|
65
65
|
if (type === 'source') {
|
|
66
|
-
setFromToken(token);
|
|
66
|
+
setFromToken({ token, meta: { blockchains, tokens } });
|
|
67
67
|
} else {
|
|
68
|
-
setToToken(token);
|
|
68
|
+
setToToken({ token, meta: { blockchains, tokens } });
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -19,26 +19,22 @@ import { Slippage } from '../components/Slippage';
|
|
|
19
19
|
import { SlippageTooltipContainer as TooltipContainer } from '../components/Slippage/Slippage.styles';
|
|
20
20
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
21
21
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
22
|
-
import {
|
|
22
|
+
import { useAppStore } from '../store/AppStore';
|
|
23
23
|
import { useSettingsStore } from '../store/settings';
|
|
24
24
|
import { getContainer } from '../utils/common';
|
|
25
25
|
import { getUniqueSwappersGroups } from '../utils/settings';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
supportedSwappers?: string[];
|
|
29
|
-
singleTheme?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
|
|
27
|
+
export function SettingsPage() {
|
|
33
28
|
const navigate = useNavigate();
|
|
29
|
+
const { theme } = useAppStore().use.config();
|
|
30
|
+
const fetchStatus = useAppStore().use.fetchStatus();
|
|
31
|
+
const swappers = useAppStore().use.swappers()();
|
|
34
32
|
const { navigateBackFrom } = useNavigateBack();
|
|
35
33
|
|
|
36
34
|
const infiniteApprove = useSettingsStore.use.infiniteApprove();
|
|
37
35
|
const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
|
|
38
|
-
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
39
36
|
|
|
40
|
-
const supportedUniqueSwappersGroups =
|
|
41
|
-
getUniqueSwappersGroups(supportedSwappers);
|
|
37
|
+
const supportedUniqueSwappersGroups = getUniqueSwappersGroups(swappers);
|
|
42
38
|
|
|
43
39
|
const bridgeSources = supportedUniqueSwappersGroups.filter(
|
|
44
40
|
(uniqueItem) =>
|
|
@@ -58,7 +54,7 @@ export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
|
|
|
58
54
|
).length;
|
|
59
55
|
|
|
60
56
|
const handleEndItem = (totalSelected: number, total: number) => {
|
|
61
|
-
switch (
|
|
57
|
+
switch (fetchStatus) {
|
|
62
58
|
case 'loading':
|
|
63
59
|
return <Skeleton variant="text" size="medium" width={50} />;
|
|
64
60
|
case 'failed':
|
|
@@ -167,7 +163,7 @@ export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
|
|
|
167
163
|
exchangeItem,
|
|
168
164
|
// languageItem
|
|
169
165
|
];
|
|
170
|
-
if (!singleTheme) {
|
|
166
|
+
if (!theme?.singleTheme) {
|
|
171
167
|
settingItems.push(themeItem);
|
|
172
168
|
}
|
|
173
169
|
settingItems.push(infiniteApprovalItem);
|
|
@@ -6,7 +6,7 @@ import { SwapDetails } from '../components/SwapDetails';
|
|
|
6
6
|
import { SwapDetailsPlaceholder } from '../components/SwapDetails/SwapDetails.Placeholder';
|
|
7
7
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
8
8
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
9
|
-
import {
|
|
9
|
+
import { useAppStore } from '../store/AppStore';
|
|
10
10
|
import { useUiStore } from '../store/ui';
|
|
11
11
|
import { getPendingSwaps } from '../utils/queue';
|
|
12
12
|
|
|
@@ -16,9 +16,9 @@ export function SwapDetailsPage() {
|
|
|
16
16
|
const pendingSwaps = getPendingSwaps(manager);
|
|
17
17
|
const requestId = useUiStore.use.selectedSwapRequestId();
|
|
18
18
|
const { navigateBackFrom } = useNavigateBack();
|
|
19
|
-
const {
|
|
19
|
+
const { fetchStatus: fetchMetaStatus } = useAppStore()();
|
|
20
20
|
|
|
21
|
-
const showSkeleton = loading ||
|
|
21
|
+
const showSkeleton = loading || fetchMetaStatus === 'loading';
|
|
22
22
|
|
|
23
23
|
const selectedSwap = pendingSwaps.find(
|
|
24
24
|
({ swap }) => swap.requestId === requestId
|