@rango-dev/widget-embedded 0.41.2-next.1 → 0.41.2-next.11
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/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -0
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +3 -0
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +3 -9
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts +4 -0
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +647 -0
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +21 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts +4 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts +323 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts +5 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +1 -0
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -0
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/utils/swap.d.ts +2 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +11 -11
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +13 -11
- package/src/components/ConfirmWalletsModal/WalletList.tsx +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -0
- package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +3 -0
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
- package/src/components/SwapDetails/SwapDetails.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +17 -8
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +3 -8
- package/src/components/WalletStatefulConnect/DerivationPath.tsx +1 -13
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +64 -0
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +58 -3
- package/src/components/WalletStatefulConnect/Namespaces.tsx +97 -50
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +29 -1
- package/src/components/WalletStatefulConnect/SupportedChainsList.styles.ts +25 -0
- package/src/components/WalletStatefulConnect/SupportedChainsList.tsx +58 -0
- package/src/components/WalletStatefulConnect/SupportedChainsList.types.ts +5 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +49 -51
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +2 -0
- package/src/utils/swap.ts +23 -12
- package/src/utils/wallets.ts +8 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.41.2-next.
|
|
3
|
+
"version": "0.41.2-next.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,23 +25,23 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.8.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.44.1-next.
|
|
28
|
+
"@rango-dev/provider-all": "^0.44.1-next.6",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.29.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.44.1-next.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.44.1-next.5",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.29.0",
|
|
32
|
-
"@rango-dev/signer-solana": "^0.38.
|
|
33
|
-
"@rango-dev/ui": "^0.45.1-next.
|
|
34
|
-
"@rango-dev/wallets-core": "^0.42.1-next.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.29.1-next.
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.43.1-next.
|
|
32
|
+
"@rango-dev/signer-solana": "^0.38.1-next.1",
|
|
33
|
+
"@rango-dev/ui": "^0.45.1-next.8",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.42.1-next.5",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.29.1-next.6",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.43.1-next.5",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"dayjs": "^1.11.7",
|
|
40
40
|
"ethers": "^6.13.2",
|
|
41
41
|
"immer": "^9.0.19",
|
|
42
42
|
"mitt": "^3.0.0",
|
|
43
|
-
"rango-sdk": "^0.1.
|
|
44
|
-
"rango-types": "^0.1.
|
|
43
|
+
"rango-sdk": "^0.1.66",
|
|
44
|
+
"rango-types": "^0.1.83",
|
|
45
45
|
"react-i18next": "^12.2.0",
|
|
46
46
|
"react-router-dom": "^6.8.0",
|
|
47
47
|
"values.js": "2.1.1",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
|
@@ -21,7 +21,7 @@ import { useAppStore } from '../../store/AppStore';
|
|
|
21
21
|
import { useQuoteStore } from '../../store/quote';
|
|
22
22
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
23
23
|
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
24
|
-
import {
|
|
24
|
+
import { getQuoteChains } from '../../utils/wallets';
|
|
25
25
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
26
26
|
import { CustomDestination } from '../CustomDestination/CustomDestination';
|
|
27
27
|
|
|
@@ -62,16 +62,16 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
62
62
|
!!customDestination
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
const
|
|
65
|
+
const quoteChains = useMemo(
|
|
66
66
|
() =>
|
|
67
|
-
|
|
67
|
+
getQuoteChains({
|
|
68
68
|
filter: 'all',
|
|
69
69
|
quote: selectedQuote,
|
|
70
70
|
}),
|
|
71
71
|
[selectedQuote]
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
-
const
|
|
74
|
+
const requiredChains = getQuoteChains({
|
|
75
75
|
filter: 'required',
|
|
76
76
|
quote: selectedQuote,
|
|
77
77
|
});
|
|
@@ -82,17 +82,17 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
82
82
|
selectedQuote?.swaps[selectedQuote?.swaps.length - 1].to.blockchain
|
|
83
83
|
);
|
|
84
84
|
const isWalletRequiredFor = (blockchain: string) =>
|
|
85
|
-
|
|
85
|
+
requiredChains.includes(blockchain);
|
|
86
86
|
|
|
87
87
|
const getInitialSelectableWallets = useCallback(
|
|
88
88
|
() =>
|
|
89
89
|
connectedWallets.filter((connectedWallet) => {
|
|
90
90
|
return (
|
|
91
91
|
connectedWallet.selected &&
|
|
92
|
-
|
|
92
|
+
quoteChains.includes(connectedWallet.chain)
|
|
93
93
|
);
|
|
94
94
|
}),
|
|
95
|
-
[connectedWallets,
|
|
95
|
+
[connectedWallets, quoteChains]
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
|
|
@@ -273,13 +273,13 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
273
273
|
return (
|
|
274
274
|
!anyWalletSelected &&
|
|
275
275
|
connectedWallet.selected &&
|
|
276
|
-
|
|
276
|
+
quoteChains.includes(connectedWallet.chain)
|
|
277
277
|
);
|
|
278
278
|
})
|
|
279
279
|
);
|
|
280
280
|
return nextState;
|
|
281
281
|
});
|
|
282
|
-
}, [connectedWallets,
|
|
282
|
+
}, [connectedWallets, quoteChains]);
|
|
283
283
|
|
|
284
284
|
useEffect(() => {
|
|
285
285
|
const nextState: typeof nextSelectedWallets = [];
|
|
@@ -391,6 +391,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
391
391
|
<div className={walletsListStyles()}>
|
|
392
392
|
<WalletList
|
|
393
393
|
chain={showMoreWalletFor}
|
|
394
|
+
quoteChains={quoteChains}
|
|
394
395
|
isSelected={isSelected}
|
|
395
396
|
selectWallet={onChange}
|
|
396
397
|
onShowMore={() => setShowMoreWalletFor(showMoreWalletFor)}
|
|
@@ -410,13 +411,13 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
410
411
|
</>
|
|
411
412
|
)}
|
|
412
413
|
<Wallets>
|
|
413
|
-
{
|
|
414
|
+
{quoteChains.map((requiredWallet, index) => {
|
|
414
415
|
const blockchain = blockchains.find(
|
|
415
416
|
(blockchain) => blockchain.name === requiredWallet
|
|
416
417
|
);
|
|
417
418
|
|
|
418
419
|
const key = `wallet-${index}`;
|
|
419
|
-
const isLastWallet = index ===
|
|
420
|
+
const isLastWallet = index === quoteChains.length - 1;
|
|
420
421
|
const showCustomDestination =
|
|
421
422
|
isLastWallet &&
|
|
422
423
|
lastStepToBlockchain &&
|
|
@@ -444,6 +445,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
444
445
|
<ListContainer>
|
|
445
446
|
<WalletList
|
|
446
447
|
chain={requiredWallet}
|
|
448
|
+
quoteChains={quoteChains}
|
|
447
449
|
isSelected={isSelected}
|
|
448
450
|
selectWallet={onChange}
|
|
449
451
|
limit={NUMBER_OF_WALLETS_TO_DISPLAY}
|
|
@@ -35,7 +35,8 @@ const ACCOUNT_ADDRESS_MAX_CHARACTERS = 7;
|
|
|
35
35
|
const TIME_TO_CLOSE_MODAL = 3_000;
|
|
36
36
|
|
|
37
37
|
export function WalletList(props: PropTypes) {
|
|
38
|
-
const { chain, isSelected, selectWallet, limit, onShowMore } =
|
|
38
|
+
const { chain, quoteChains, isSelected, selectWallet, limit, onShowMore } =
|
|
39
|
+
props;
|
|
39
40
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
40
41
|
|
|
41
42
|
const { blockchains, connectedWallets } = useAppStore();
|
|
@@ -221,6 +222,7 @@ export function WalletList(props: PropTypes) {
|
|
|
221
222
|
})}
|
|
222
223
|
<StatefulConnectModal
|
|
223
224
|
wallet={selectedWalletToConnect}
|
|
225
|
+
options={{ defaultSelectedChains: quoteChains || [chain] }}
|
|
224
226
|
onClose={() => {
|
|
225
227
|
setSelectedWalletToConnect(undefined);
|
|
226
228
|
}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropTypes } from './HistoryGroupedList.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
+
import { getCurrentStep } from '@rango-dev/queue-manager-rango-preset';
|
|
4
5
|
import {
|
|
5
6
|
Divider,
|
|
6
7
|
GroupedVirtualizedList,
|
|
@@ -102,6 +103,7 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
102
103
|
}}
|
|
103
104
|
itemContent={(index, groupIndex) => {
|
|
104
105
|
const swap = swaps[index];
|
|
106
|
+
const currentStep = getCurrentStep(swap);
|
|
105
107
|
if (!swap) {
|
|
106
108
|
return null;
|
|
107
109
|
}
|
|
@@ -114,6 +116,7 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
114
116
|
creationTime={swap.creationTime}
|
|
115
117
|
status={swap.status}
|
|
116
118
|
onClick={onSwapClick}
|
|
119
|
+
currentStep={currentStep}
|
|
117
120
|
tooltipContainer={getContainer()}
|
|
118
121
|
onlyShowTime={groups[groupIndex] === i18n.t('Today')}
|
|
119
122
|
swapTokenData={{
|
|
@@ -28,6 +28,9 @@ interface PropTypes {
|
|
|
28
28
|
onClose: () => void;
|
|
29
29
|
// When connecting wallet is executed **successfully**, this will be called afterwards.
|
|
30
30
|
onConnect?: () => void;
|
|
31
|
+
options?: {
|
|
32
|
+
defaultSelectedChains?: string[];
|
|
33
|
+
};
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export function StatefulConnectModal(props: PropTypes) {
|
|
@@ -122,6 +125,7 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
122
125
|
beforeConnecting();
|
|
123
126
|
handleConnect(props.wallet, {
|
|
124
127
|
disconnectIfConnected: true,
|
|
128
|
+
defaultSelectedChains: props.options?.defaultSelectedChains,
|
|
125
129
|
})
|
|
126
130
|
.then((result) => {
|
|
127
131
|
const resultIsNeedMoreStepsToConnect = [
|
|
@@ -171,7 +171,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
171
171
|
])
|
|
172
172
|
: undefined;
|
|
173
173
|
|
|
174
|
-
const stepMessage = getSwapMessages(swap, currentStep);
|
|
174
|
+
const stepMessage = getSwapMessages(swap, currentStep, getWalletInfo);
|
|
175
175
|
const steps = getSteps({
|
|
176
176
|
swap,
|
|
177
177
|
switchNetwork,
|
|
@@ -465,7 +465,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
465
465
|
onCancel={onCancel}
|
|
466
466
|
onDelete={onDelete}
|
|
467
467
|
message={stepMessage.detailedMessage.content}
|
|
468
|
-
|
|
468
|
+
swap={swap}
|
|
469
469
|
walletButtonDisabled={!isActiveTab}
|
|
470
470
|
/>
|
|
471
471
|
<SwapDetailsCompleteModal
|
|
@@ -2,6 +2,10 @@ import type { WalletStateContentProps } from './SwapDetailsModal.types';
|
|
|
2
2
|
import type { WalletInfoWithExtra } from '../../types';
|
|
3
3
|
|
|
4
4
|
import { warn } from '@rango-dev/logging-core';
|
|
5
|
+
import {
|
|
6
|
+
getCurrentStep,
|
|
7
|
+
getRelatedWalletOrNull,
|
|
8
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
5
9
|
import { MessageBox, Wallet } from '@rango-dev/ui';
|
|
6
10
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
7
11
|
import React, { useState } from 'react';
|
|
@@ -14,17 +18,17 @@ import { StatefulConnectModal } from '../StatefulConnectModal';
|
|
|
14
18
|
import { WalletContainer } from './SwapDetailsModal.styles';
|
|
15
19
|
|
|
16
20
|
export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
title,
|
|
20
|
-
currentStepWallet,
|
|
21
|
-
message,
|
|
22
|
-
showWalletButton,
|
|
23
|
-
walletButtonDisabled,
|
|
24
|
-
} = props;
|
|
21
|
+
const { type, title, swap, message, showWalletButton, walletButtonDisabled } =
|
|
22
|
+
props;
|
|
25
23
|
const [selectedWalletToConnect, setSelectedWalletToConnect] =
|
|
26
24
|
useState<WalletInfoWithExtra>();
|
|
27
25
|
const { getWalletInfo, state } = useWallets();
|
|
26
|
+
|
|
27
|
+
const currentStep = getCurrentStep(swap);
|
|
28
|
+
const currentStepWallet = currentStep
|
|
29
|
+
? getRelatedWalletOrNull(swap, currentStep)
|
|
30
|
+
: null;
|
|
31
|
+
const currentStepFromBlockchain = currentStep?.fromBlockchain;
|
|
28
32
|
const walletType = currentStepWallet?.walletType;
|
|
29
33
|
const walletState = walletType
|
|
30
34
|
? mapStatusToWalletState(state(walletType))
|
|
@@ -73,6 +77,11 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
|
73
77
|
onClose={() => {
|
|
74
78
|
setSelectedWalletToConnect(undefined);
|
|
75
79
|
}}
|
|
80
|
+
options={{
|
|
81
|
+
defaultSelectedChains: currentStepFromBlockchain
|
|
82
|
+
? [currentStepFromBlockchain]
|
|
83
|
+
: undefined,
|
|
84
|
+
}}
|
|
76
85
|
/>
|
|
77
86
|
</>
|
|
78
87
|
);
|
|
@@ -17,7 +17,7 @@ export function SwapDetailsModal(props: ModalPropTypes) {
|
|
|
17
17
|
onClose,
|
|
18
18
|
onDelete,
|
|
19
19
|
onCancel,
|
|
20
|
-
|
|
20
|
+
swap,
|
|
21
21
|
message,
|
|
22
22
|
walletButtonDisabled,
|
|
23
23
|
} = props;
|
|
@@ -38,7 +38,7 @@ export function SwapDetailsModal(props: ModalPropTypes) {
|
|
|
38
38
|
<WalletStateContent
|
|
39
39
|
type={modalNetworkValues[state].type}
|
|
40
40
|
title={modalNetworkValues[state].title}
|
|
41
|
-
|
|
41
|
+
swap={swap}
|
|
42
42
|
message={message}
|
|
43
43
|
walletButtonDisabled={walletButtonDisabled}
|
|
44
44
|
showWalletButton={
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PendingSwapNetworkStatus } from 'rango-types';
|
|
1
|
+
import type { PendingSwap, PendingSwapNetworkStatus } from 'rango-types';
|
|
3
2
|
|
|
4
3
|
export type ModalState =
|
|
5
4
|
| Exclude<PendingSwapNetworkStatus, PendingSwapNetworkStatus.WaitingForQueue>
|
|
6
5
|
| 'delete'
|
|
7
6
|
| 'cancel'
|
|
8
7
|
| null;
|
|
9
|
-
type WalletTypeAndAddress = {
|
|
10
|
-
walletType: WalletType;
|
|
11
|
-
address: string;
|
|
12
|
-
};
|
|
13
8
|
export interface ModalPropTypes {
|
|
14
9
|
onClose: () => void;
|
|
15
10
|
onCancel: () => void;
|
|
16
11
|
onDelete: () => void;
|
|
17
12
|
state: ModalState;
|
|
18
|
-
|
|
13
|
+
swap: PendingSwap;
|
|
19
14
|
message: string;
|
|
20
15
|
walletButtonDisabled: boolean;
|
|
21
16
|
}
|
|
@@ -47,7 +42,7 @@ export interface ModalNetworkValueTypes {
|
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
export interface WalletStateContentProps extends ModalNetworkValueTypes {
|
|
50
|
-
|
|
45
|
+
swap: PendingSwap;
|
|
51
46
|
message: string;
|
|
52
47
|
showWalletButton: boolean;
|
|
53
48
|
walletButtonDisabled: boolean;
|
|
@@ -12,11 +12,6 @@ import {
|
|
|
12
12
|
} from '@rango-dev/ui';
|
|
13
13
|
import React, { useEffect, useState } from 'react';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
LogoContainer,
|
|
17
|
-
Spinner,
|
|
18
|
-
WalletImageContainer,
|
|
19
|
-
} from './ConnectStatus.styles';
|
|
20
15
|
import {
|
|
21
16
|
CUSTOM_DERIVATION_PATH,
|
|
22
17
|
getDerivationPaths,
|
|
@@ -103,14 +98,7 @@ export function DerivationPath(props: PropTypes) {
|
|
|
103
98
|
type,
|
|
104
99
|
},
|
|
105
100
|
})}
|
|
106
|
-
icon={
|
|
107
|
-
<LogoContainer>
|
|
108
|
-
<WalletImageContainer>
|
|
109
|
-
<Image src={image} size={45} />
|
|
110
|
-
</WalletImageContainer>
|
|
111
|
-
<Spinner />
|
|
112
|
-
</LogoContainer>
|
|
113
|
-
}
|
|
101
|
+
icon={<Image src={image} size={45} />}
|
|
114
102
|
/>
|
|
115
103
|
|
|
116
104
|
<InputsContainer>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { NamespaceItemPropTypes } from './Namespaces.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import { Checkbox, Radio, Typography } from '@rango-dev/ui';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { useAppStore } from '../../store/AppStore';
|
|
8
|
+
|
|
9
|
+
import { getBlockchainLogo } from './Namespaces.helpers';
|
|
10
|
+
import {
|
|
11
|
+
NamespaceItemContainer,
|
|
12
|
+
NamespaceItemContent,
|
|
13
|
+
NamespaceLogo,
|
|
14
|
+
NotSupportedNamespaceItemContent,
|
|
15
|
+
} from './Namespaces.styles';
|
|
16
|
+
import { SupportedChainsList } from './SupportedChainsList';
|
|
17
|
+
|
|
18
|
+
export function NamespaceListItem(props: NamespaceItemPropTypes) {
|
|
19
|
+
const { onClick, type, namespace } = props;
|
|
20
|
+
const blockchains = useAppStore().blockchains();
|
|
21
|
+
|
|
22
|
+
if (namespace.unsupported) {
|
|
23
|
+
return (
|
|
24
|
+
<NamespaceItemContainer unsupported>
|
|
25
|
+
<NamespaceLogo
|
|
26
|
+
src={getBlockchainLogo(blockchains, namespace.id)}
|
|
27
|
+
size={40}
|
|
28
|
+
disabled
|
|
29
|
+
/>
|
|
30
|
+
<NotSupportedNamespaceItemContent>
|
|
31
|
+
<Typography variant="label" size="large">
|
|
32
|
+
{namespace.label}
|
|
33
|
+
</Typography>
|
|
34
|
+
<Typography variant="body" size="xsmall">
|
|
35
|
+
{i18n.t('(Currently not supported)')}
|
|
36
|
+
</Typography>
|
|
37
|
+
</NotSupportedNamespaceItemContent>
|
|
38
|
+
</NamespaceItemContainer>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const showSupportedChains = namespace.chains.length > 1;
|
|
43
|
+
return (
|
|
44
|
+
<NamespaceItemContainer onClick={onClick}>
|
|
45
|
+
<NamespaceLogo
|
|
46
|
+
src={getBlockchainLogo(blockchains, namespace.id)}
|
|
47
|
+
size={40}
|
|
48
|
+
/>
|
|
49
|
+
<NamespaceItemContent showSupportedChains={showSupportedChains}>
|
|
50
|
+
<Typography variant="label" size="large">
|
|
51
|
+
{namespace.label}
|
|
52
|
+
</Typography>
|
|
53
|
+
{showSupportedChains && (
|
|
54
|
+
<SupportedChainsList chains={namespace.chains} />
|
|
55
|
+
)}
|
|
56
|
+
</NamespaceItemContent>
|
|
57
|
+
{type === 'radio' ? (
|
|
58
|
+
<Radio value={namespace.value} />
|
|
59
|
+
) : (
|
|
60
|
+
<Checkbox checked={props.value} />
|
|
61
|
+
)}
|
|
62
|
+
</NamespaceItemContainer>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -1,7 +1,62 @@
|
|
|
1
|
-
import { styled } from '@rango-dev/ui';
|
|
1
|
+
import { Image, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const NamespaceList = styled('ul', {
|
|
4
4
|
padding: 0,
|
|
5
|
-
paddingTop: '$
|
|
6
|
-
paddingBottom: '$
|
|
5
|
+
paddingTop: '$10',
|
|
6
|
+
paddingBottom: '$20',
|
|
7
|
+
margin: 0,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const NamespaceItemContainer = styled('li', {
|
|
11
|
+
backgroundColor: '$neutral200',
|
|
12
|
+
padding: '$16',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
gap: '$8',
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
borderRadius: '$sm',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
variants: {
|
|
19
|
+
unsupported: {
|
|
20
|
+
true: {
|
|
21
|
+
cursor: 'not-allowed',
|
|
22
|
+
paddingTop: '$8',
|
|
23
|
+
paddingBottom: '$8',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const NamespaceItemContent = styled('div', {
|
|
30
|
+
flex: '1',
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
height: '$40',
|
|
34
|
+
variants: {
|
|
35
|
+
showSupportedChains: {
|
|
36
|
+
true: {
|
|
37
|
+
justifyContent: 'space-between',
|
|
38
|
+
},
|
|
39
|
+
false: {
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const NotSupportedNamespaceItemContent = styled('div', {
|
|
47
|
+
flex: '1',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
gap: '$4',
|
|
51
|
+
opacity: '0.5',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const NamespaceLogo = styled(Image, {
|
|
55
|
+
variants: {
|
|
56
|
+
disabled: {
|
|
57
|
+
true: {
|
|
58
|
+
opacity: '0.5',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
7
62
|
});
|