@rango-dev/widget-embedded 0.17.1-next.3 → 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 +4 -2
- 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
package/src/Wallets.tsx
CHANGED
|
@@ -6,10 +6,10 @@ import type { PropsWithChildren } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
8
8
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
9
|
-
import React, { createContext, useRef } from 'react';
|
|
9
|
+
import React, { createContext, useEffect, useRef } from 'react';
|
|
10
10
|
|
|
11
11
|
import { useWalletProviders } from './hooks/useWalletProviders';
|
|
12
|
-
import {
|
|
12
|
+
import { AppStoreProvider, useAppStore } from './store/AppStore';
|
|
13
13
|
import { useWalletsStore } from './store/wallets';
|
|
14
14
|
import {
|
|
15
15
|
prepareAccountsForWalletStore,
|
|
@@ -27,19 +27,28 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
function Main(
|
|
31
31
|
props: PropsWithChildren<{
|
|
32
32
|
providers: WidgetConfig['wallets'];
|
|
33
33
|
options?: ProvidersOptions;
|
|
34
34
|
onUpdateState?: EventHandler;
|
|
35
|
+
config: WidgetConfig;
|
|
35
36
|
}>
|
|
36
37
|
) {
|
|
37
|
-
const
|
|
38
|
+
const updateConfig = useAppStore().use.updateConfig();
|
|
39
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
40
|
+
const tokens = useAppStore().use.tokens()();
|
|
38
41
|
const { providers } = useWalletProviders(props.providers, props?.options);
|
|
39
42
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
40
43
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
41
44
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
42
45
|
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (props.config) {
|
|
48
|
+
updateConfig(props.config);
|
|
49
|
+
}
|
|
50
|
+
}, [props.config]);
|
|
51
|
+
|
|
43
52
|
const evmBasedChainNames = blockchains
|
|
44
53
|
.filter(isEvmBlockchain)
|
|
45
54
|
.map((chain) => chain.name);
|
|
@@ -61,7 +70,7 @@ export function WidgetWallets(
|
|
|
61
70
|
evmBasedChainNames,
|
|
62
71
|
supportedChainNames
|
|
63
72
|
);
|
|
64
|
-
connectWallet(data);
|
|
73
|
+
connectWallet(data, tokens);
|
|
65
74
|
} else {
|
|
66
75
|
disconnectWallet(type);
|
|
67
76
|
}
|
|
@@ -112,3 +121,19 @@ export function WidgetWallets(
|
|
|
112
121
|
</WidgetContext.Provider>
|
|
113
122
|
);
|
|
114
123
|
}
|
|
124
|
+
|
|
125
|
+
export function WidgetWallets(
|
|
126
|
+
props: PropsWithChildren<{
|
|
127
|
+
providers: WidgetConfig['wallets'];
|
|
128
|
+
options?: ProvidersOptions;
|
|
129
|
+
onUpdateState?: EventHandler;
|
|
130
|
+
config: WidgetConfig;
|
|
131
|
+
}>
|
|
132
|
+
) {
|
|
133
|
+
const { config, ...otherProps } = props;
|
|
134
|
+
return (
|
|
135
|
+
<AppStoreProvider config={config}>
|
|
136
|
+
<Main {...otherProps} config={config} />
|
|
137
|
+
</AppStoreProvider>
|
|
138
|
+
);
|
|
139
|
+
}
|
package/src/Widget.tsx
CHANGED
|
@@ -12,10 +12,10 @@ import { globalFont } from './globalStyles';
|
|
|
12
12
|
import { useLanguage } from './hooks/useLanguage';
|
|
13
13
|
import { useTheme } from './hooks/useTheme';
|
|
14
14
|
import QueueManager from './QueueManager';
|
|
15
|
-
import { useAppStore } from './store/
|
|
16
|
-
import { useMetaStore } from './store/meta';
|
|
15
|
+
import { useAppStore } from './store/AppStore';
|
|
17
16
|
import { useNotificationStore } from './store/notification';
|
|
18
17
|
import { useSettingsStore } from './store/settings';
|
|
18
|
+
import { DEFAULT_CONFIG } from './store/slices/config';
|
|
19
19
|
import { initConfig } from './utils/configs';
|
|
20
20
|
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
21
21
|
|
|
@@ -40,18 +40,16 @@ export type WidgetProps = {
|
|
|
40
40
|
config?: WidgetConfig;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export function Main(
|
|
44
|
-
const { config } = props;
|
|
43
|
+
export function Main() {
|
|
45
44
|
globalFont();
|
|
46
45
|
|
|
46
|
+
const { fetch: fetchMeta, config } = useAppStore()();
|
|
47
47
|
const { activeTheme } = useTheme(config?.theme || {});
|
|
48
48
|
const { activeLanguage, changeLanguage } = useLanguage();
|
|
49
|
-
|
|
50
49
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
51
50
|
useState<string>('');
|
|
52
51
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
53
52
|
const widgetContext = useContext(WidgetContext);
|
|
54
|
-
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
55
53
|
|
|
56
54
|
useMemo(() => {
|
|
57
55
|
if (config?.apiKey) {
|
|
@@ -60,33 +58,29 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
|
60
58
|
});
|
|
61
59
|
}
|
|
62
60
|
}, [config]);
|
|
63
|
-
|
|
64
61
|
useEffect(() => {
|
|
65
|
-
void fetchMeta();
|
|
62
|
+
void fetchMeta().catch();
|
|
66
63
|
void useSettingsStore.persist.rehydrate();
|
|
67
64
|
void useNotificationStore.persist.rehydrate();
|
|
68
65
|
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
69
66
|
}, []);
|
|
70
|
-
|
|
71
67
|
useEffect(() => {
|
|
72
68
|
if (config?.language) {
|
|
73
69
|
changeLanguage(config.language);
|
|
74
70
|
}
|
|
75
71
|
}, [config?.language]);
|
|
76
|
-
|
|
77
72
|
return (
|
|
78
73
|
<I18nManager language={activeLanguage}>
|
|
79
74
|
<MainContainer id="swap-container" className={activeTheme()}>
|
|
80
75
|
<QueueManager>
|
|
81
76
|
<WidgetEvents />
|
|
82
77
|
<AppRouter
|
|
83
|
-
config={config}
|
|
84
78
|
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
85
79
|
disconnectedWallet={disconnectedWallet}
|
|
86
80
|
clearDisconnectedWallet={() => {
|
|
87
81
|
setDisconnectedWallet(undefined);
|
|
88
82
|
}}>
|
|
89
|
-
<AppRoutes
|
|
83
|
+
<AppRoutes />
|
|
90
84
|
</AppRouter>
|
|
91
85
|
</QueueManager>
|
|
92
86
|
</MainContainer>
|
|
@@ -95,25 +89,17 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
98
|
-
const { updateConfig, config } = useAppStore();
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (props.config) {
|
|
101
|
-
updateConfig(props.config);
|
|
102
|
-
}
|
|
103
|
-
}, [props.config]);
|
|
104
|
-
|
|
105
92
|
if (!props.config?.externalWallets) {
|
|
106
93
|
return (
|
|
107
94
|
<WidgetWallets
|
|
108
|
-
|
|
95
|
+
config={props.config ?? DEFAULT_CONFIG}
|
|
96
|
+
providers={props.config?.wallets}
|
|
109
97
|
options={{
|
|
110
|
-
walletConnectProjectId:
|
|
111
|
-
config?.walletConnectProjectId ||
|
|
112
|
-
props.config?.walletConnectProjectId,
|
|
98
|
+
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
113
99
|
}}>
|
|
114
|
-
<Main
|
|
100
|
+
<Main />
|
|
115
101
|
</WidgetWallets>
|
|
116
102
|
);
|
|
117
103
|
}
|
|
118
|
-
return <Main
|
|
104
|
+
return <Main />;
|
|
119
105
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
1
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
2
|
import type { PropsWithChildren } from 'react';
|
|
4
3
|
|
|
@@ -11,7 +10,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
|
|
|
11
10
|
|
|
12
11
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
12
|
import { Home } from '../pages/Home';
|
|
14
|
-
import {
|
|
13
|
+
import { useAppStore } from '../store/AppStore';
|
|
15
14
|
|
|
16
15
|
import { UpdateUrl } from './UpdateUrl';
|
|
17
16
|
|
|
@@ -44,11 +43,10 @@ export function AppRouter({
|
|
|
44
43
|
lastConnectedWallet: string;
|
|
45
44
|
disconnectedWallet: WalletType | undefined;
|
|
46
45
|
clearDisconnectedWallet: () => void;
|
|
47
|
-
config: WidgetConfig | undefined;
|
|
48
46
|
}) {
|
|
49
47
|
const isRouterInContext = useInRouterContext();
|
|
50
48
|
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
51
|
-
const
|
|
49
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
52
50
|
const { canSwitchNetworkTo } = useWallets();
|
|
53
51
|
|
|
54
52
|
const evmChains = blockchains.filter(isEvmBlockchain);
|
|
@@ -64,7 +62,7 @@ export function AppRouter({
|
|
|
64
62
|
return (
|
|
65
63
|
<>
|
|
66
64
|
<Router>{children}</Router>
|
|
67
|
-
{isRouterInContext && <UpdateUrl
|
|
65
|
+
{isRouterInContext && <UpdateUrl />}
|
|
68
66
|
</>
|
|
69
67
|
);
|
|
70
68
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
|
-
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { useRoutes } from 'react-router-dom';
|
|
5
3
|
|
|
@@ -18,13 +16,7 @@ import { WalletsPage } from '../pages/WalletsPage';
|
|
|
18
16
|
|
|
19
17
|
const getAbsolutePath = (path: string) => path.replace('/', '');
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
config?: WidgetConfig;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function AppRoutes(props: PropTypes) {
|
|
26
|
-
const { config } = props;
|
|
27
|
-
|
|
19
|
+
export function AppRoutes() {
|
|
28
20
|
return useRoutes([
|
|
29
21
|
{
|
|
30
22
|
path: navigationRoutes.home,
|
|
@@ -48,12 +40,7 @@ export function AppRoutes(props: PropTypes) {
|
|
|
48
40
|
},
|
|
49
41
|
{
|
|
50
42
|
path: navigationRoutes.settings,
|
|
51
|
-
element:
|
|
52
|
-
<SettingsPage
|
|
53
|
-
singleTheme={config?.theme?.singleTheme}
|
|
54
|
-
supportedSwappers={config?.liquiditySources}
|
|
55
|
-
/>
|
|
56
|
-
),
|
|
43
|
+
element: <SettingsPage />,
|
|
57
44
|
},
|
|
58
45
|
{
|
|
59
46
|
path: navigationRoutes.themes,
|
|
@@ -65,21 +52,11 @@ export function AppRoutes(props: PropTypes) {
|
|
|
65
52
|
},
|
|
66
53
|
{
|
|
67
54
|
path: navigationRoutes.exchanges,
|
|
68
|
-
element:
|
|
69
|
-
<LiquiditySourcePage
|
|
70
|
-
sourceType="Exchanges"
|
|
71
|
-
supportedSwappers={config?.liquiditySources}
|
|
72
|
-
/>
|
|
73
|
-
),
|
|
55
|
+
element: <LiquiditySourcePage sourceType="Exchanges" />,
|
|
74
56
|
},
|
|
75
57
|
{
|
|
76
58
|
path: navigationRoutes.bridges,
|
|
77
|
-
element:
|
|
78
|
-
<LiquiditySourcePage
|
|
79
|
-
sourceType="Bridges"
|
|
80
|
-
supportedSwappers={config?.liquiditySources}
|
|
81
|
-
/>
|
|
82
|
-
),
|
|
59
|
+
element: <LiquiditySourcePage sourceType="Bridges" />,
|
|
83
60
|
},
|
|
84
61
|
{ path: navigationRoutes.swaps, element: <HistoryPage /> },
|
|
85
62
|
{
|
|
@@ -88,21 +65,11 @@ export function AppRoutes(props: PropTypes) {
|
|
|
88
65
|
},
|
|
89
66
|
{
|
|
90
67
|
path: navigationRoutes.wallets,
|
|
91
|
-
element:
|
|
92
|
-
<WalletsPage
|
|
93
|
-
supportedWallets={config?.wallets}
|
|
94
|
-
multiWallets={
|
|
95
|
-
typeof config?.multiWallets === 'undefined'
|
|
96
|
-
? true
|
|
97
|
-
: config.multiWallets
|
|
98
|
-
}
|
|
99
|
-
config={config}
|
|
100
|
-
/>
|
|
101
|
-
),
|
|
68
|
+
element: <WalletsPage />,
|
|
102
69
|
},
|
|
103
70
|
{
|
|
104
71
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
105
|
-
element: <ConfirmSwapPage
|
|
72
|
+
element: <ConfirmSwapPage />,
|
|
106
73
|
},
|
|
107
74
|
]);
|
|
108
75
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
12
|
import React, { useEffect, useState } from 'react';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { useAppStore } from '../../store/AppStore';
|
|
15
15
|
|
|
16
16
|
import { filterBlockchains } from './BlockchainList.helpers';
|
|
17
17
|
import { Container, List } from './BlockchainList.styles';
|
|
@@ -20,7 +20,7 @@ import { LoadingBlockchainList } from './LoadingBlockchainList';
|
|
|
20
20
|
export function BlockchainList(props: PropTypes) {
|
|
21
21
|
const { list, searchedFor, onChange, blockchainCategory } = props;
|
|
22
22
|
const [blockchains, setBlockchains] = useState<BlockchainMeta[]>(list);
|
|
23
|
-
const
|
|
23
|
+
const { fetchStatus } = useAppStore()();
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
setBlockchains([
|
|
@@ -66,8 +66,8 @@ export function BlockchainList(props: PropTypes) {
|
|
|
66
66
|
{i18n.t('Select Blockchain')}
|
|
67
67
|
</Typography>
|
|
68
68
|
<Divider size={4} />
|
|
69
|
-
{
|
|
70
|
-
{
|
|
69
|
+
{fetchStatus === 'loading' && <LoadingBlockchainList />}
|
|
70
|
+
{fetchStatus === 'success' && renderList()}
|
|
71
71
|
</Container>
|
|
72
72
|
);
|
|
73
73
|
}
|
|
@@ -13,7 +13,7 @@ import React from 'react';
|
|
|
13
13
|
|
|
14
14
|
import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
|
|
15
15
|
import { usePrepareBlockchainList } from '../../hooks/usePrepareBlockchainList';
|
|
16
|
-
import {
|
|
16
|
+
import { useAppStore } from '../../store/AppStore';
|
|
17
17
|
import { useQuoteStore } from '../../store/quote';
|
|
18
18
|
|
|
19
19
|
import { Container } from './BlockchainsSection.styles';
|
|
@@ -27,7 +27,7 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
27
27
|
selected: blockchain?.name,
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const { fetchStatus } = useAppStore()();
|
|
31
31
|
const resetToBlockchain = useQuoteStore.use.resetToBlockchain();
|
|
32
32
|
const resetFromBlockchain = useQuoteStore.use.resetFromBlockchain();
|
|
33
33
|
const hasMoreItemsInList = blockchainsList.more.length > 0;
|
|
@@ -45,11 +45,11 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
45
45
|
</Typography>
|
|
46
46
|
<Divider size={12} />
|
|
47
47
|
<Container>
|
|
48
|
-
{
|
|
48
|
+
{fetchStatus === 'loading' &&
|
|
49
49
|
Array.from(Array(NUMBER_OF_LOADING), (e) => (
|
|
50
50
|
<Skeleton key={e} variant="rounded" height={50} />
|
|
51
51
|
))}
|
|
52
|
-
{
|
|
52
|
+
{fetchStatus === 'success' && (
|
|
53
53
|
<>
|
|
54
54
|
<BlockchainsChip
|
|
55
55
|
selected={!blockchain}
|
|
@@ -21,7 +21,7 @@ import { useNavigate } from 'react-router-dom';
|
|
|
21
21
|
import { getQuoteErrorMessage } from '../../constants/errors';
|
|
22
22
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
23
23
|
import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
|
|
24
|
-
import {
|
|
24
|
+
import { useAppStore } from '../../store/AppStore';
|
|
25
25
|
import { useQuoteStore } from '../../store/quote';
|
|
26
26
|
import { useWalletsStore } from '../../store/wallets';
|
|
27
27
|
import { confirmSwapDisabled } from '../../utils/swap';
|
|
@@ -50,8 +50,9 @@ const NUMBER_OF_WALLETS_TO_DISPLAY = 2;
|
|
|
50
50
|
|
|
51
51
|
export function ConfirmWalletsModal(props: PropTypes) {
|
|
52
52
|
//TODO: move component's logics to a custom hook
|
|
53
|
-
const { open, onClose, onCancel, onCheckBalance,
|
|
54
|
-
const
|
|
53
|
+
const { open, onClose, onCancel, onCheckBalance, loading } = props;
|
|
54
|
+
const config = useAppStore().use.config();
|
|
55
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
55
56
|
const {
|
|
56
57
|
quote,
|
|
57
58
|
setSelectedWallets: selectQuoteWallets,
|
|
@@ -75,10 +76,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
75
76
|
const customDestinationRef = useRef<HTMLDivElement | null>(null);
|
|
76
77
|
|
|
77
78
|
const requiredWallets = getRequiredWallets(quote);
|
|
78
|
-
const customDestinationEnabled =
|
|
79
|
-
typeof config?.customDestination === 'undefined'
|
|
80
|
-
? true
|
|
81
|
-
: config.customDestination;
|
|
82
79
|
|
|
83
80
|
const lastStepToBlockchain = blockchains.find(
|
|
84
81
|
(blockchain) =>
|
|
@@ -320,9 +317,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
320
317
|
chain={showMoreWalletFor}
|
|
321
318
|
isSelected={isSelected}
|
|
322
319
|
selectWallet={onChange}
|
|
323
|
-
multiWallets={config?.multiWallets ?? true}
|
|
324
|
-
supportedWallets={config?.wallets ?? []}
|
|
325
|
-
config={config}
|
|
326
320
|
onShowMore={setShowMoreWalletFor.bind(null, showMoreWalletFor)}
|
|
327
321
|
/>
|
|
328
322
|
</div>
|
|
@@ -380,9 +374,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
380
374
|
chain={requiredWallet}
|
|
381
375
|
isSelected={isSelected}
|
|
382
376
|
selectWallet={onChange}
|
|
383
|
-
multiWallets={config?.multiWallets ?? true}
|
|
384
|
-
supportedWallets={config?.wallets ?? []}
|
|
385
|
-
config={config}
|
|
386
377
|
limit={NUMBER_OF_WALLETS_TO_DISPLAY}
|
|
387
378
|
onShowMore={() =>
|
|
388
379
|
setShowMoreWalletFor(blockchain?.name ?? '')
|
|
@@ -390,7 +381,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
390
381
|
/>
|
|
391
382
|
</ListContainer>
|
|
392
383
|
{!isLastWallet && <Divider size={32} />}
|
|
393
|
-
{isLastWallet &&
|
|
384
|
+
{isLastWallet && config?.customDestination && (
|
|
394
385
|
<CustomDestination>
|
|
395
386
|
<CollapsibleRoot
|
|
396
387
|
ref={customDestinationRef}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../..';
|
|
2
1
|
import type { ConfirmSwap } from '../../hooks/useConfirmSwap/useConfirmSwap.types';
|
|
3
2
|
|
|
4
3
|
export type PropTypes = {
|
|
@@ -6,6 +5,5 @@ export type PropTypes = {
|
|
|
6
5
|
onClose: () => void;
|
|
7
6
|
onCancel: () => void;
|
|
8
7
|
onCheckBalance: ConfirmSwap['fetch'];
|
|
9
|
-
config?: WidgetConfig;
|
|
10
8
|
loading: boolean;
|
|
11
9
|
};
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
TIME_TO_CLOSE_MODAL,
|
|
24
24
|
TIME_TO_IGNORE_MODAL,
|
|
25
25
|
} from '../../pages/WalletsPage';
|
|
26
|
-
import {
|
|
26
|
+
import { useAppStore } from '../../store/AppStore';
|
|
27
27
|
import { useWalletsStore } from '../../store/wallets';
|
|
28
28
|
import { getBlockchainDisplayNameFor } from '../../utils/meta';
|
|
29
29
|
import {
|
|
@@ -41,10 +41,11 @@ import {
|
|
|
41
41
|
} from './WalletList.styles';
|
|
42
42
|
|
|
43
43
|
export function WalletList(props: PropTypes) {
|
|
44
|
-
const {
|
|
44
|
+
const { chain, isSelected, selectWallet, limit, onShowMore } = props;
|
|
45
|
+
const { config } = useAppStore()();
|
|
45
46
|
|
|
46
47
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
47
|
-
const { blockchains } =
|
|
48
|
+
const { blockchains } = useAppStore()();
|
|
48
49
|
const [openWalletStateModal, setOpenWalletStateModal] =
|
|
49
50
|
useState<WalletType>('');
|
|
50
51
|
const [experimentalChainWallet, setExperimentalChainWallet] =
|
|
@@ -137,7 +138,7 @@ export function WalletList(props: PropTypes) {
|
|
|
137
138
|
});
|
|
138
139
|
const conciseAddress = address ? getConciseAddress(address) : '';
|
|
139
140
|
|
|
140
|
-
const experimentalChain = isExperimentalChain(blockchains, chain);
|
|
141
|
+
const experimentalChain = isExperimentalChain(blockchains(), chain);
|
|
141
142
|
|
|
142
143
|
const experimentalChainNotAdded = !connectedWallets.find(
|
|
143
144
|
(connectedWallet) =>
|
|
@@ -180,7 +181,7 @@ export function WalletList(props: PropTypes) {
|
|
|
180
181
|
experimentalChainWallet?.chain
|
|
181
182
|
? getBlockchainDisplayNameFor(
|
|
182
183
|
experimentalChainWallet.chain,
|
|
183
|
-
blockchains
|
|
184
|
+
blockchains()
|
|
184
185
|
)
|
|
185
186
|
: undefined;
|
|
186
187
|
return (
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type { Wallet
|
|
1
|
+
import type { Wallet } from '../../types';
|
|
2
2
|
|
|
3
3
|
export type PropTypes = {
|
|
4
4
|
chain: string;
|
|
5
|
-
supportedWallets: WidgetConfig['wallets'];
|
|
6
5
|
isSelected: (walletType: string, chain: string) => boolean;
|
|
7
6
|
selectWallet: (wallet: Wallet) => void;
|
|
8
|
-
multiWallets: boolean;
|
|
9
|
-
config?: WidgetConfig;
|
|
10
7
|
limit?: number;
|
|
11
8
|
onShowMore: () => void;
|
|
12
9
|
};
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import React from 'react';
|
|
12
12
|
|
|
13
13
|
import { errorMessages } from '../../constants/errors';
|
|
14
|
+
import { useAppStore } from '../../store/AppStore';
|
|
14
15
|
import { useSettingsStore } from '../../store/settings';
|
|
15
16
|
|
|
16
17
|
import { makeInfo } from './NoResult.helpers';
|
|
@@ -23,10 +24,12 @@ export function NoResult(props: PropTypes) {
|
|
|
23
24
|
const toggleAllLiquiditySources =
|
|
24
25
|
useSettingsStore.use.toggleAllLiquiditySources();
|
|
25
26
|
|
|
27
|
+
const swappers = useAppStore().use.swappers()();
|
|
28
|
+
|
|
26
29
|
const info = makeInfo(
|
|
27
30
|
error,
|
|
28
31
|
disabledLiquiditySources,
|
|
29
|
-
toggleAllLiquiditySources,
|
|
32
|
+
() => toggleAllLiquiditySources(swappers, true),
|
|
30
33
|
fetch
|
|
31
34
|
);
|
|
32
35
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useAppStore } from '../../store/AppStore';
|
|
14
14
|
import { useNotificationStore } from '../../store/notification';
|
|
15
15
|
import { useUiStore } from '../../store/ui';
|
|
16
16
|
|
|
@@ -26,7 +26,8 @@ export function NotificationContent() {
|
|
|
26
26
|
const { getUnreadNotifications } = useNotificationStore();
|
|
27
27
|
|
|
28
28
|
const notifications: Notification[] = getUnreadNotifications();
|
|
29
|
-
const
|
|
29
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
30
|
+
const tokens = useAppStore().use.tokens()();
|
|
30
31
|
const sortedNotification = notifications
|
|
31
32
|
.sort((a, b) => b.creationTime - a.creationTime)
|
|
32
33
|
.slice(0, MAX_NOTIFICATIONS_DISPLAYED);
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
FooterAlert,
|
|
31
31
|
FooterStepAlarm,
|
|
32
32
|
} from '../../containers/QuoteInfo/QuoteInfo.styles';
|
|
33
|
-
import {
|
|
33
|
+
import { useAppStore } from '../../store/AppStore';
|
|
34
34
|
import { QuoteErrorType, QuoteWarningType } from '../../types';
|
|
35
35
|
import {
|
|
36
36
|
numberToString,
|
|
@@ -53,9 +53,6 @@ import {
|
|
|
53
53
|
import { QuoteSummary } from './QuoteSummary';
|
|
54
54
|
|
|
55
55
|
export function Quote(props: QuoteProps) {
|
|
56
|
-
const {
|
|
57
|
-
meta: { tokens },
|
|
58
|
-
} = useMetaStore();
|
|
59
56
|
const {
|
|
60
57
|
quote,
|
|
61
58
|
input,
|
|
@@ -65,6 +62,7 @@ export function Quote(props: QuoteProps) {
|
|
|
65
62
|
type,
|
|
66
63
|
recommended = true,
|
|
67
64
|
} = props;
|
|
65
|
+
const tokens = useAppStore().use.tokens()();
|
|
68
66
|
|
|
69
67
|
const [expanded, setExpanded] = useState(props.expanded);
|
|
70
68
|
const quoteRef = useRef<HTMLButtonElement | null>(null);
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
USD_VALUE_MIN_DECIMALS,
|
|
35
35
|
} from '../../constants/routing';
|
|
36
36
|
import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
37
|
-
import {
|
|
37
|
+
import { useAppStore } from '../../store/AppStore';
|
|
38
38
|
import { useNotificationStore } from '../../store/notification';
|
|
39
39
|
import { useQuoteStore } from '../../store/quote';
|
|
40
40
|
import {
|
|
@@ -64,6 +64,8 @@ import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
|
|
|
64
64
|
export function SwapDetails(props: SwapDetailsProps) {
|
|
65
65
|
const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
|
|
66
66
|
const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
|
|
67
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
68
|
+
const tokens = useAppStore().use.tokens()();
|
|
67
69
|
const retry = useQuoteStore.use.retry();
|
|
68
70
|
const navigate = useNavigate();
|
|
69
71
|
const { navigateBackFrom } = useNavigateBack();
|
|
@@ -73,9 +75,6 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
73
75
|
const [showCompletedModal, setShowCompletedModal] = useState<
|
|
74
76
|
'success' | 'failed' | null
|
|
75
77
|
>(null);
|
|
76
|
-
const {
|
|
77
|
-
meta: { tokens, blockchains },
|
|
78
|
-
} = useMetaStore();
|
|
79
78
|
|
|
80
79
|
const onCancel = () => {
|
|
81
80
|
onCancelProps();
|
|
@@ -150,7 +149,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
150
149
|
showNetworkModal: currentStepNetworkStatus,
|
|
151
150
|
setNetworkModal: setModalState,
|
|
152
151
|
message: stepMessage,
|
|
153
|
-
blockchains,
|
|
152
|
+
blockchains: blockchains,
|
|
154
153
|
});
|
|
155
154
|
const numberOfSteps = steps.length;
|
|
156
155
|
const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
|
|
@@ -264,7 +263,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
264
263
|
type="primary"
|
|
265
264
|
size="large"
|
|
266
265
|
onClick={() => {
|
|
267
|
-
retry(swap);
|
|
266
|
+
retry(swap, { blockchains: blockchains, tokens: tokens });
|
|
268
267
|
setTimeout(() => {
|
|
269
268
|
navigate(navigationRoutes.home);
|
|
270
269
|
}, 0);
|
|
@@ -21,8 +21,7 @@ import {
|
|
|
21
21
|
} from '@rango-dev/ui';
|
|
22
22
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
23
23
|
|
|
24
|
-
import { useAppStore } from '../../store/
|
|
25
|
-
import { useMetaStore } from '../../store/meta';
|
|
24
|
+
import { useAppStore } from '../../store/AppStore';
|
|
26
25
|
import { useWalletsStore } from '../../store/wallets';
|
|
27
26
|
import { generateRangeColors } from '../../utils/colors';
|
|
28
27
|
|
|
@@ -87,11 +86,11 @@ export function TokenList(props: PropTypes) {
|
|
|
87
86
|
const { list, searchedFor = '', onChange, selectedBlockchain } = props;
|
|
88
87
|
|
|
89
88
|
const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
|
|
90
|
-
const
|
|
89
|
+
const fetchStatus = useAppStore().use.fetchStatus();
|
|
90
|
+
const blockchains = useAppStore().use.blockchains()();
|
|
91
91
|
const [hasNextPage, setHasNextPage] = useState<boolean>(true);
|
|
92
92
|
const loadingWallet = useWalletsStore.use.loading();
|
|
93
|
-
const {
|
|
94
|
-
const { isTokenPinned } = useAppStore();
|
|
93
|
+
const { isTokenPinned } = useAppStore()();
|
|
95
94
|
|
|
96
95
|
// eslint-disable-next-line react/display-name
|
|
97
96
|
const innerElementType: React.FC<CommonProps> = forwardRef((render, ref) => {
|
|
@@ -268,8 +267,8 @@ export function TokenList(props: PropTypes) {
|
|
|
268
267
|
{i18n.t('Select Token')}
|
|
269
268
|
</Typography>
|
|
270
269
|
<Divider size={4} />
|
|
271
|
-
{
|
|
272
|
-
{
|
|
270
|
+
{fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
|
|
271
|
+
{fetchStatus === 'success' && <List>{renderList()}</List>}
|
|
273
272
|
</Container>
|
|
274
273
|
);
|
|
275
274
|
}
|