@rango-dev/widget-embedded 0.27.4-next.2 → 0.27.4-next.4
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/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +6 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts +163 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts +10 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/index.d.ts +2 -0
- package/dist/components/WalletNamespacesModal/index.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts +4 -4
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Routes.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +6 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +3 -3
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/ConfirmWalletsModal/WalletList.tsx +68 -23
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +40 -4
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.styles.ts +7 -0
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +142 -0
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.types.tsx +10 -0
- package/src/components/WalletNamespacesModal/index.ts +1 -0
- package/src/hooks/useSwapInput.ts +11 -5
- package/src/hooks/useSyncStoresWithConfig.ts +3 -0
- package/src/hooks/useWalletList.ts +11 -3
- package/src/pages/ConfirmSwapPage.tsx +3 -4
- package/src/pages/Routes.tsx +5 -2
- package/src/pages/WalletsPage.tsx +38 -2
- package/src/types/wallets.ts +7 -1
- package/src/utils/wallets.ts +8 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
1
|
+
import type { Namespace, WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
import { styled, Typography, Wallet, WalletState } from '@rango-dev/ui';
|
|
@@ -6,11 +6,19 @@ import React, { useState } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Layout, PageContainer } from '../components/Layout';
|
|
8
8
|
import { WalletModal } from '../components/WalletModal';
|
|
9
|
+
import { WalletNamespacesModal } from '../components/WalletNamespacesModal';
|
|
9
10
|
import { useWalletList } from '../hooks/useWalletList';
|
|
10
11
|
import { useAppStore } from '../store/AppStore';
|
|
11
12
|
import { useUiStore } from '../store/ui';
|
|
12
13
|
import { getContainer } from '../utils/common';
|
|
13
14
|
|
|
15
|
+
interface NamespacesModalState {
|
|
16
|
+
providerType: string;
|
|
17
|
+
providerImage: string;
|
|
18
|
+
availableNamespaces?: Namespace[];
|
|
19
|
+
singleNamespace?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
const ListContainer = styled('div', {
|
|
15
23
|
display: 'flex',
|
|
16
24
|
justifyContent: 'center',
|
|
@@ -30,6 +38,8 @@ export const TIME_TO_IGNORE_MODAL = 300;
|
|
|
30
38
|
export function WalletsPage() {
|
|
31
39
|
const { fetchStatus: fetchMetaStatus } = useAppStore();
|
|
32
40
|
const [openModal, setOpenModal] = useState(false);
|
|
41
|
+
const [namespacesModalState, setNamespacesModalState] =
|
|
42
|
+
useState<NamespacesModalState | null>(null);
|
|
33
43
|
const [selectedWalletType, setSelectedWalletType] = useState<WalletType>('');
|
|
34
44
|
let modalTimerId: ReturnType<typeof setTimeout> | null = null;
|
|
35
45
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
@@ -82,7 +92,19 @@ export function WalletsPage() {
|
|
|
82
92
|
{...wallet}
|
|
83
93
|
container={getContainer()}
|
|
84
94
|
onClick={(type) => {
|
|
85
|
-
|
|
95
|
+
if (
|
|
96
|
+
!!wallet.namespaces &&
|
|
97
|
+
wallet.state === WalletState.DISCONNECTED
|
|
98
|
+
) {
|
|
99
|
+
setNamespacesModalState({
|
|
100
|
+
providerType: type,
|
|
101
|
+
providerImage: wallet.image,
|
|
102
|
+
availableNamespaces: wallet.namespaces,
|
|
103
|
+
singleNamespace: wallet.singleNamespace,
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
void handleClick(type);
|
|
107
|
+
}
|
|
86
108
|
}}
|
|
87
109
|
isLoading={fetchMetaStatus === 'loading'}
|
|
88
110
|
disabled={!isActiveTab}
|
|
@@ -96,6 +118,20 @@ export function WalletsPage() {
|
|
|
96
118
|
state={selectedWalletState}
|
|
97
119
|
error={error}
|
|
98
120
|
/>
|
|
121
|
+
<WalletNamespacesModal
|
|
122
|
+
open={!!namespacesModalState}
|
|
123
|
+
onClose={() => setNamespacesModalState(null)}
|
|
124
|
+
onConfirm={(namespaces) => {
|
|
125
|
+
void handleClick(
|
|
126
|
+
namespacesModalState?.providerType as string,
|
|
127
|
+
namespaces
|
|
128
|
+
);
|
|
129
|
+
setNamespacesModalState(null);
|
|
130
|
+
}}
|
|
131
|
+
image={namespacesModalState?.providerImage}
|
|
132
|
+
namespaces={namespacesModalState?.availableNamespaces}
|
|
133
|
+
singleNamespace={namespacesModalState?.singleNamespace}
|
|
134
|
+
/>
|
|
99
135
|
</ListContainer>
|
|
100
136
|
</Container>
|
|
101
137
|
</Layout>
|
package/src/types/wallets.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WalletInfo } from '@rango-dev/ui';
|
|
2
|
+
import type { Namespace, WalletType } from '@rango-dev/wallets-shared';
|
|
2
3
|
|
|
3
4
|
export interface Wallet {
|
|
4
5
|
chain: string;
|
|
@@ -22,3 +23,8 @@ export type TokenHash = `${Blockchain}-${TokenSymbol}-${Address}`;
|
|
|
22
23
|
export type TokensBalance = {
|
|
23
24
|
[key: TokenHash]: Balance;
|
|
24
25
|
};
|
|
26
|
+
|
|
27
|
+
export type WalletInfoWithNamespaces = WalletInfo & {
|
|
28
|
+
namespaces?: Namespace[];
|
|
29
|
+
singleNamespace?: boolean;
|
|
30
|
+
};
|
package/src/utils/wallets.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
TokenHash,
|
|
6
6
|
TokensBalance,
|
|
7
7
|
Wallet,
|
|
8
|
+
WalletInfoWithNamespaces,
|
|
8
9
|
} from '../types';
|
|
9
10
|
import type { WalletInfo as ModalWalletInfo } from '@rango-dev/ui';
|
|
10
11
|
import type {
|
|
@@ -58,7 +59,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
58
59
|
getWalletInfo: (type: WalletType) => WalletInfo,
|
|
59
60
|
list: WalletType[],
|
|
60
61
|
chain?: string
|
|
61
|
-
):
|
|
62
|
+
): WalletInfoWithNamespaces[] {
|
|
62
63
|
return list
|
|
63
64
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
64
65
|
.filter((wallet) => {
|
|
@@ -82,6 +83,8 @@ export function mapWalletTypesToWalletInfo(
|
|
|
82
83
|
img: image,
|
|
83
84
|
installLink,
|
|
84
85
|
showOnMobile,
|
|
86
|
+
namespaces,
|
|
87
|
+
singleNamespace,
|
|
85
88
|
} = getWalletInfo(type);
|
|
86
89
|
const state = mapStatusToWalletState(getState(type));
|
|
87
90
|
return {
|
|
@@ -91,6 +94,8 @@ export function mapWalletTypesToWalletInfo(
|
|
|
91
94
|
state,
|
|
92
95
|
type,
|
|
93
96
|
showOnMobile,
|
|
97
|
+
namespaces,
|
|
98
|
+
singleNamespace,
|
|
94
99
|
};
|
|
95
100
|
});
|
|
96
101
|
}
|
|
@@ -433,8 +438,8 @@ export function areTokensEqual(
|
|
|
433
438
|
}
|
|
434
439
|
|
|
435
440
|
export function sortWalletsBasedOnConnectionState(
|
|
436
|
-
wallets:
|
|
437
|
-
):
|
|
441
|
+
wallets: WalletInfoWithNamespaces[]
|
|
442
|
+
): WalletInfoWithNamespaces[] {
|
|
438
443
|
return wallets.sort(
|
|
439
444
|
(a, b) =>
|
|
440
445
|
Number(b.state === WalletStatus.CONNECTED) -
|