@rango-dev/widget-embedded 0.42.4-next.1 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +5 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.types.d.ts +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +3 -5
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +0 -440
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +0 -162
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/helpers.d.ts +0 -3
- package/dist/components/StatefulConnectModal/helpers.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/index.d.ts +1 -1
- package/dist/components/StatefulConnectModal/index.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +3 -805
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +8 -11
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
- package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.types.d.ts +3 -5
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts +3 -3
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -3
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -11
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts +2 -2
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.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/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +0 -2
- package/dist/store/AppStore.d.ts.map +1 -1
- package/dist/store/app.d.ts +0 -2
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts +0 -2
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +0 -3
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/types/quote.d.ts +0 -1
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +0 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +8 -8
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +47 -4
- package/src/components/ConfirmWalletsModal/WalletList.tsx +19 -35
- package/src/components/NoResult/NoResult.tsx +1 -4
- package/src/components/NoResult/NoResult.types.ts +0 -1
- package/src/components/Quote/Quote.tsx +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +4 -29
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +1 -10
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +7 -38
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -2
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +21 -20
- package/src/components/Slippage/Slippage.styles.ts +0 -23
- package/src/components/Slippage/Slippage.tsx +22 -28
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -19
- package/src/components/StatefulConnectModal/helpers.ts +0 -6
- package/src/components/StatefulConnectModal/index.ts +1 -1
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +33 -14
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +6 -44
- package/src/components/WalletStatefulConnect/Namespaces.tsx +7 -12
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +11 -13
- package/src/components/WalletStatefulConnect/index.ts +0 -1
- package/src/constants/errors.ts +7 -6
- package/src/containers/Inputs/Inputs.tsx +0 -2
- package/src/containers/Wallets/Wallets.tsx +5 -6
- package/src/containers/Wallets/Wallets.types.ts +3 -5
- package/src/containers/Wallets/useUpdates.ts +32 -40
- package/src/hooks/useBootstrap/useBootstrap.ts +10 -33
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -11
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +4 -33
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -13
- package/src/hooks/useSwapInput.ts +1 -1
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +0 -2
- package/src/hooks/useWalletList.ts +3 -3
- package/src/index.ts +1 -8
- package/src/pages/ConfirmSwapPage.tsx +1 -6
- package/src/pages/Home.tsx +12 -61
- package/src/pages/LiquiditySourcePage.tsx +3 -5
- package/src/pages/WalletsPage.tsx +1 -17
- package/src/store/app.ts +0 -1
- package/src/store/quote.ts +4 -23
- package/src/store/slices/settings.ts +0 -11
- package/src/types/quote.ts +1 -4
- package/src/utils/colors.ts +10 -3
- package/src/utils/numbers.ts +0 -11
- package/src/utils/settings.ts +4 -11
- package/src/utils/wallets.ts +14 -59
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts +0 -4
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts +0 -8
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts +0 -4
- package/dist/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts +0 -5
- package/dist/components/SwapMetrics/SwapMetrics.constants.d.ts.map +0 -1
- package/dist/components/SwapMetrics/SwapMetrics.d.ts +0 -4
- package/dist/components/SwapMetrics/SwapMetrics.d.ts.map +0 -1
- package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts +0 -11
- package/dist/components/SwapMetrics/SwapMetrics.helpers.d.ts.map +0 -1
- package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +0 -482
- package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +0 -1
- package/dist/components/SwapMetrics/SwapMetrics.types.d.ts +0 -27
- package/dist/components/SwapMetrics/SwapMetrics.types.d.ts.map +0 -1
- package/dist/components/SwapMetrics/index.d.ts +0 -2
- package/dist/components/SwapMetrics/index.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts.map +0 -1
- package/dist/utils/sanitizers.d.ts +0 -27
- package/dist/utils/sanitizers.d.ts.map +0 -1
- package/dist/utils/sanitizers.test.d.ts +0 -2
- package/dist/utils/sanitizers.test.d.ts.map +0 -1
- package/dist/utils/validation.d.ts +0 -26
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.test.d.ts +0 -2
- package/dist/utils/validation.test.d.ts.map +0 -1
- package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.helpers.ts +0 -33
- package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.tsx +0 -48
- package/src/components/SlippageWarningsAndErrors/SlippageWarningsAndErrors.types.ts +0 -3
- package/src/components/SwapMetrics/SwapMetrics.constants.ts +0 -4
- package/src/components/SwapMetrics/SwapMetrics.helpers.ts +0 -76
- package/src/components/SwapMetrics/SwapMetrics.styles.ts +0 -32
- package/src/components/SwapMetrics/SwapMetrics.tsx +0 -134
- package/src/components/SwapMetrics/SwapMetrics.types.ts +0 -26
- package/src/components/SwapMetrics/index.ts +0 -1
- package/src/components/WalletStatefulConnect/Detached.tsx +0 -53
- package/src/components/WalletStatefulConnect/Detached.types.ts +0 -8
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +0 -177
- package/src/components/WalletStatefulConnect/NamespaceUnsupportedItem.tsx +0 -42
- package/src/utils/sanitizers.test.ts +0 -122
- package/src/utils/sanitizers.ts +0 -41
- package/src/utils/validation.test.ts +0 -121
- package/src/utils/validation.ts +0 -45
|
@@ -17,14 +17,8 @@ import {
|
|
|
17
17
|
DerivationPath,
|
|
18
18
|
Namespaces,
|
|
19
19
|
} from '../WalletStatefulConnect';
|
|
20
|
-
import { Detached } from '../WalletStatefulConnect/Detached';
|
|
21
20
|
|
|
22
|
-
import {
|
|
23
|
-
isOnDerivationPath,
|
|
24
|
-
isOnDetached,
|
|
25
|
-
isOnNamespace,
|
|
26
|
-
isOnStatus,
|
|
27
|
-
} from './helpers';
|
|
21
|
+
import { isOnDerivationPath, isOnNamespace, isOnStatus } from './helpers';
|
|
28
22
|
|
|
29
23
|
const KEEP_SUCCESS_MODAL_FOR = 3_000;
|
|
30
24
|
const DELAY_SHOWING_MODAL_FOR = 300;
|
|
@@ -62,10 +56,6 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
62
56
|
.catch(catchErrorOnHandle);
|
|
63
57
|
};
|
|
64
58
|
|
|
65
|
-
const handleDetachedConfirm = () => {
|
|
66
|
-
handleClosingModal();
|
|
67
|
-
};
|
|
68
|
-
|
|
69
59
|
const handleDerivationPathConfirm = (derivationPath: string) => {
|
|
70
60
|
if (!derivationPath) {
|
|
71
61
|
throw new Error(
|
|
@@ -140,7 +130,6 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
140
130
|
.then((result) => {
|
|
141
131
|
const resultIsNeedMoreStepsToConnect = [
|
|
142
132
|
ResultStatus.Namespace,
|
|
143
|
-
ResultStatus.Detached,
|
|
144
133
|
ResultStatus.DerivationPath,
|
|
145
134
|
].includes(result.status);
|
|
146
135
|
|
|
@@ -189,13 +178,6 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
189
178
|
value={getState().derivationPath}
|
|
190
179
|
/>
|
|
191
180
|
)}
|
|
192
|
-
{isOnDetached(getState) && (
|
|
193
|
-
<Detached
|
|
194
|
-
onConfirm={handleDetachedConfirm}
|
|
195
|
-
value={getState().namespace}
|
|
196
|
-
selectedNamespaces={getState().selectedNamespaces}
|
|
197
|
-
/>
|
|
198
|
-
)}
|
|
199
181
|
</WatermarkedModal>
|
|
200
182
|
);
|
|
201
183
|
}
|
|
@@ -21,9 +21,3 @@ export function isOnDerivationPath(
|
|
|
21
21
|
} {
|
|
22
22
|
return getState().status === 'derivationPath';
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
export function isOnDetached(
|
|
26
|
-
getState: () => State
|
|
27
|
-
): getState is () => State & { namespace: NonNullable<State['namespace']> } {
|
|
28
|
-
return getState().status === 'detached';
|
|
29
|
-
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { StatefulConnectModal } from './StatefulConnectModal';
|
|
2
|
-
export { isOnNamespace, isOnDerivationPath
|
|
2
|
+
export { isOnNamespace, isOnDerivationPath } from './helpers';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NamespaceItemPropTypes } from './Namespaces.types';
|
|
2
2
|
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
3
4
|
import { Checkbox, Radio, Typography } from '@rango-dev/ui';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
|
|
@@ -9,8 +10,8 @@ import { getBlockchainLogo } from './Namespaces.helpers';
|
|
|
9
10
|
import {
|
|
10
11
|
NamespaceItemContainer,
|
|
11
12
|
NamespaceItemContent,
|
|
12
|
-
NamespaceItemInnerContent,
|
|
13
13
|
NamespaceLogo,
|
|
14
|
+
NotSupportedNamespaceItemContent,
|
|
14
15
|
} from './Namespaces.styles';
|
|
15
16
|
import { SupportedChainsList } from './SupportedChainsList';
|
|
16
17
|
|
|
@@ -18,28 +19,46 @@ export function NamespaceListItem(props: NamespaceItemPropTypes) {
|
|
|
18
19
|
const { onClick, type, namespace } = props;
|
|
19
20
|
const blockchains = useAppStore().blockchains();
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<NamespaceItemContent>
|
|
22
|
+
if (namespace.unsupported) {
|
|
23
|
+
return (
|
|
24
|
+
<NamespaceItemContainer unsupported>
|
|
25
25
|
<NamespaceLogo
|
|
26
26
|
src={getBlockchainLogo(blockchains, namespace.id)}
|
|
27
27
|
size={40}
|
|
28
|
+
disabled
|
|
28
29
|
/>
|
|
29
|
-
<
|
|
30
|
+
<NotSupportedNamespaceItemContent>
|
|
30
31
|
<Typography variant="label" size="large">
|
|
31
32
|
{namespace.label}
|
|
32
33
|
</Typography>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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} />
|
|
41
55
|
)}
|
|
42
56
|
</NamespaceItemContent>
|
|
57
|
+
{type === 'radio' ? (
|
|
58
|
+
<Radio value={namespace.value} />
|
|
59
|
+
) : (
|
|
60
|
+
<Checkbox checked={props.value} />
|
|
61
|
+
)}
|
|
43
62
|
</NamespaceItemContainer>
|
|
44
63
|
);
|
|
45
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button,
|
|
1
|
+
import { Button, Image, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const NamespaceList = styled('ul', {
|
|
4
4
|
padding: 0,
|
|
@@ -10,21 +10,12 @@ export const NamespaceList = styled('ul', {
|
|
|
10
10
|
export const NamespaceItemContainer = styled('li', {
|
|
11
11
|
backgroundColor: '$neutral200',
|
|
12
12
|
padding: '$16',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
gap: '$8',
|
|
15
|
+
cursor: 'pointer',
|
|
13
16
|
borderRadius: '$sm',
|
|
17
|
+
alignItems: 'center',
|
|
14
18
|
variants: {
|
|
15
|
-
clickable: {
|
|
16
|
-
true: {
|
|
17
|
-
cursor: 'pointer',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
hasError: {
|
|
21
|
-
true: {
|
|
22
|
-
background: '$error100 ',
|
|
23
|
-
[`.${darkTheme} &`]: {
|
|
24
|
-
backgroundColor: '$error700',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
19
|
unsupported: {
|
|
29
20
|
true: {
|
|
30
21
|
cursor: 'not-allowed',
|
|
@@ -36,16 +27,9 @@ export const NamespaceItemContainer = styled('li', {
|
|
|
36
27
|
});
|
|
37
28
|
|
|
38
29
|
export const NamespaceItemContent = styled('div', {
|
|
39
|
-
display: 'flex',
|
|
40
|
-
gap: '$8',
|
|
41
|
-
alignItems: 'center',
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export const NamespaceItemInnerContent = styled('div', {
|
|
45
30
|
flex: '1',
|
|
46
31
|
display: 'flex',
|
|
47
32
|
flexDirection: 'column',
|
|
48
|
-
justifyContent: 'space-between',
|
|
49
33
|
height: '$40',
|
|
50
34
|
variants: {
|
|
51
35
|
showSupportedChains: {
|
|
@@ -59,7 +43,7 @@ export const NamespaceItemInnerContent = styled('div', {
|
|
|
59
43
|
},
|
|
60
44
|
});
|
|
61
45
|
|
|
62
|
-
export const
|
|
46
|
+
export const NotSupportedNamespaceItemContent = styled('div', {
|
|
63
47
|
flex: '1',
|
|
64
48
|
display: 'flex',
|
|
65
49
|
alignItems: 'center',
|
|
@@ -80,25 +64,3 @@ export const NamespaceLogo = styled(Image, {
|
|
|
80
64
|
export const StyledButton = styled(Button, {
|
|
81
65
|
minHeight: '$40',
|
|
82
66
|
});
|
|
83
|
-
|
|
84
|
-
export const NamespaceAccountAddress = styled(Typography, {
|
|
85
|
-
maxWidth: '100px',
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
export const NamespaceItemError = styled('div', {
|
|
89
|
-
paddingLeft: '48px',
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
export const NamespaceItemErrorDropdownToggle = styled('div', {
|
|
93
|
-
display: 'flex',
|
|
94
|
-
gap: '2px',
|
|
95
|
-
cursor: 'pointer',
|
|
96
|
-
alignItems: 'center',
|
|
97
|
-
width: 'fit-content',
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export const NamespaceDetachedItemInfo = styled('div', {
|
|
101
|
-
display: 'flex',
|
|
102
|
-
gap: '6px',
|
|
103
|
-
alignItems: 'center',
|
|
104
|
-
});
|
|
@@ -14,7 +14,6 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
14
14
|
|
|
15
15
|
import { NamespaceListItem } from './NamespaceListItem';
|
|
16
16
|
import { NamespaceList, StyledButton } from './Namespaces.styles';
|
|
17
|
-
import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
|
|
18
17
|
|
|
19
18
|
export function Namespaces(props: PropTypes) {
|
|
20
19
|
const { targetWallet } = props.value;
|
|
@@ -98,7 +97,7 @@ export function Namespaces(props: PropTypes) {
|
|
|
98
97
|
wallet: targetWallet.title,
|
|
99
98
|
})}
|
|
100
99
|
description={i18n.t(
|
|
101
|
-
|
|
100
|
+
"This wallet supports multiple chains. Choose which chains you'd like to connect to."
|
|
102
101
|
)}
|
|
103
102
|
icon={<Image src={providerImage} size={45} />}
|
|
104
103
|
/>
|
|
@@ -135,16 +134,12 @@ export function Namespaces(props: PropTypes) {
|
|
|
135
134
|
{targetWallet.needsNamespace?.data.map(
|
|
136
135
|
(namespace, index, array) => (
|
|
137
136
|
<React.Fragment key={namespace.id}>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
type={singleNamespace ? 'radio' : 'checkbox'}
|
|
145
|
-
onClick={() => onSelect(namespace.value)}
|
|
146
|
-
/>
|
|
147
|
-
)}
|
|
137
|
+
<NamespaceListItem
|
|
138
|
+
value={selectedNamespaces.includes(namespace.value)}
|
|
139
|
+
namespace={namespace}
|
|
140
|
+
type={singleNamespace ? 'radio' : 'checkbox'}
|
|
141
|
+
onClick={() => onSelect(namespace.value)}
|
|
142
|
+
/>
|
|
148
143
|
{index !== array.length - 1 && <Divider size={10} />}
|
|
149
144
|
</React.Fragment>
|
|
150
145
|
)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
Chain,
|
|
4
|
+
Namespace,
|
|
5
|
+
} from '@rango-dev/wallets-core/namespaces/common';
|
|
4
6
|
|
|
5
7
|
export interface PropTypes {
|
|
6
8
|
onConfirm: (namespaces: Namespace[]) => void;
|
|
@@ -10,7 +12,13 @@ export interface PropTypes {
|
|
|
10
12
|
interface NamespaceItemSharedPropTypes {
|
|
11
13
|
onClick: () => void;
|
|
12
14
|
type: 'radio' | 'checkbox';
|
|
13
|
-
namespace:
|
|
15
|
+
namespace: {
|
|
16
|
+
label: string;
|
|
17
|
+
id: string;
|
|
18
|
+
value: Namespace;
|
|
19
|
+
chains: Chain[];
|
|
20
|
+
unsupported?: boolean;
|
|
21
|
+
};
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
interface RadioNamespaceItemPropTypes extends NamespaceItemSharedPropTypes {
|
|
@@ -25,13 +33,3 @@ interface CheckboxNamespaceItemPropTypes extends NamespaceItemSharedPropTypes {
|
|
|
25
33
|
export type NamespaceItemPropTypes =
|
|
26
34
|
| RadioNamespaceItemPropTypes
|
|
27
35
|
| CheckboxNamespaceItemPropTypes;
|
|
28
|
-
|
|
29
|
-
export type NamespaceDetachedItemPropTypes = {
|
|
30
|
-
walletType: string;
|
|
31
|
-
initialConnect?: boolean;
|
|
32
|
-
namespace: LegacyNamespaceMeta;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type NamespaceUnsupportedItemPropTypes = {
|
|
36
|
-
namespace: LegacyNamespaceMeta;
|
|
37
|
-
};
|
package/src/constants/errors.ts
CHANGED
|
@@ -52,11 +52,12 @@ export const errorMessages = () => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export function getQuoteErrorMessage(error: QuoteError) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
switch (error.type) {
|
|
56
|
+
case QuoteErrorType.NO_RESULT:
|
|
57
|
+
return error.diagnosisMessage ?? errorMessages().noResultError.title;
|
|
58
|
+
case QuoteErrorType.REQUEST_FAILED:
|
|
59
|
+
return errorMessages().genericServerError;
|
|
60
|
+
default:
|
|
61
|
+
return '';
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
return '';
|
|
62
63
|
}
|
|
@@ -34,7 +34,6 @@ export function Inputs(props: PropTypes) {
|
|
|
34
34
|
toToken,
|
|
35
35
|
toBlockchain,
|
|
36
36
|
setInputAmount,
|
|
37
|
-
sanitizeInputAmount,
|
|
38
37
|
inputAmount,
|
|
39
38
|
inputUsdValue,
|
|
40
39
|
outputAmount,
|
|
@@ -80,7 +79,6 @@ export function Inputs(props: PropTypes) {
|
|
|
80
79
|
label={i18n.t('From')}
|
|
81
80
|
mode="From"
|
|
82
81
|
onInputChange={setInputAmount}
|
|
83
|
-
onInputBlur={sanitizeInputAmount}
|
|
84
82
|
balance={fromTokenFormattedBalance}
|
|
85
83
|
chain={{
|
|
86
84
|
displayName: fromBlockchain?.displayName || '',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
OnWalletDisconnectHandler,
|
|
2
|
+
OnWalletConnectionChange,
|
|
4
3
|
PropTypes,
|
|
5
4
|
WidgetContextInterface,
|
|
6
5
|
} from './Wallets.types';
|
|
@@ -46,8 +45,8 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
46
45
|
?.walletConnectListedDesktopWalletLink,
|
|
47
46
|
};
|
|
48
47
|
const { providers } = useWalletProviders(config.wallets, walletOptions);
|
|
49
|
-
const onConnectWalletHandler = useRef<
|
|
50
|
-
const onDisconnectWalletHandler = useRef<
|
|
48
|
+
const onConnectWalletHandler = useRef<OnWalletConnectionChange>();
|
|
49
|
+
const onDisconnectWalletHandler = useRef<OnWalletConnectionChange>();
|
|
51
50
|
const { handler: handleEvent } = useUpdates({
|
|
52
51
|
onConnectWalletHandler,
|
|
53
52
|
onDisconnectWalletHandler,
|
|
@@ -72,10 +71,10 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
72
71
|
|
|
73
72
|
const handlers = useMemo(
|
|
74
73
|
() => ({
|
|
75
|
-
onConnectWallet: (handler:
|
|
74
|
+
onConnectWallet: (handler: OnWalletConnectionChange) => {
|
|
76
75
|
onConnectWalletHandler.current = handler;
|
|
77
76
|
},
|
|
78
|
-
onDisconnectWallet: (handler:
|
|
77
|
+
onDisconnectWallet: (handler: OnWalletConnectionChange) => {
|
|
79
78
|
onDisconnectWalletHandler.current = handler;
|
|
80
79
|
},
|
|
81
80
|
}),
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import type { WidgetConfig } from '../../types';
|
|
2
|
-
import type { LastConnectedWallet } from '@rango-dev/queue-manager-rango-preset';
|
|
3
2
|
import type {
|
|
4
3
|
LegacyEventHandler as EventHandler,
|
|
5
4
|
LegacyEvents,
|
|
6
5
|
} from '@rango-dev/wallets-core/legacy';
|
|
7
6
|
|
|
8
|
-
export type
|
|
9
|
-
export type OnWalletDisconnectHandler = (walletType: string) => void;
|
|
7
|
+
export type OnWalletConnectionChange = (key: string) => void;
|
|
10
8
|
export interface WidgetContextInterface {
|
|
11
9
|
/**
|
|
12
10
|
* A wallet connection handler, utilized within the wallet provider,
|
|
13
11
|
* is linked to the useBootstrap hook for synchronizing the state of the last connected wallet.
|
|
14
12
|
* It's important not to override this handler in other locations.
|
|
15
13
|
*/
|
|
16
|
-
onConnectWallet(handler:
|
|
14
|
+
onConnectWallet(handler: OnWalletConnectionChange): void;
|
|
17
15
|
/**
|
|
18
16
|
* A wallet disconnection handler, utilized within the wallet provider,
|
|
19
17
|
* is linked to the useBootstrap hook for synchronizing the state of the last disconnected wallet.
|
|
20
18
|
* It's important not to override this handler in other locations.
|
|
21
19
|
*/
|
|
22
|
-
onDisconnectWallet(handler:
|
|
20
|
+
onDisconnectWallet(handler: OnWalletConnectionChange): void;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
type EventHandlerParams = Parameters<EventHandler>;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
OnWalletConnectHandler,
|
|
3
|
-
OnWalletDisconnectHandler,
|
|
4
|
-
} from './Wallets.types';
|
|
5
|
-
import type { LastConnectedWallet } from '@rango-dev/queue-manager-rango-preset';
|
|
1
|
+
import type { OnWalletConnectionChange } from './Wallets.types';
|
|
6
2
|
import type {
|
|
7
3
|
LegacyEventHandler as EventHandler,
|
|
8
4
|
LegacyEventHandler,
|
|
@@ -24,10 +20,10 @@ import {
|
|
|
24
20
|
|
|
25
21
|
interface UseUpdatesParams {
|
|
26
22
|
onConnectWalletHandler: React.MutableRefObject<
|
|
27
|
-
|
|
23
|
+
OnWalletConnectionChange | undefined
|
|
28
24
|
>;
|
|
29
25
|
onDisconnectWalletHandler: React.MutableRefObject<
|
|
30
|
-
|
|
26
|
+
OnWalletConnectionChange | undefined
|
|
31
27
|
>;
|
|
32
28
|
}
|
|
33
29
|
interface UseUpdates {
|
|
@@ -55,18 +51,7 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
55
51
|
supportedChainNames: Network[] | null;
|
|
56
52
|
}
|
|
57
53
|
) => {
|
|
58
|
-
const [type, , value,
|
|
59
|
-
|
|
60
|
-
const walletFromEvent: LastConnectedWallet = {
|
|
61
|
-
walletType: type,
|
|
62
|
-
network: state.network ?? undefined,
|
|
63
|
-
accounts: value,
|
|
64
|
-
};
|
|
65
|
-
if (!!onConnectWalletHandler.current) {
|
|
66
|
-
onConnectWalletHandler.current(walletFromEvent);
|
|
67
|
-
} else {
|
|
68
|
-
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
69
|
-
}
|
|
54
|
+
const [type, , value, , info] = event;
|
|
70
55
|
|
|
71
56
|
const data = prepareAccountsForWalletStore(
|
|
72
57
|
type,
|
|
@@ -100,6 +85,16 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
100
85
|
}
|
|
101
86
|
}
|
|
102
87
|
|
|
88
|
+
if (event === Events.CONNECTED) {
|
|
89
|
+
const key = `${type}-${state.network}-${value}`;
|
|
90
|
+
|
|
91
|
+
if (!!onConnectWalletHandler.current) {
|
|
92
|
+
onConnectWalletHandler.current(key);
|
|
93
|
+
} else {
|
|
94
|
+
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
103
98
|
if (event === Events.PROVIDER_DISCONNECTED) {
|
|
104
99
|
disconnectWallet(type);
|
|
105
100
|
if (!!onDisconnectWalletHandler.current) {
|
|
@@ -196,36 +191,33 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
196
191
|
}
|
|
197
192
|
}
|
|
198
193
|
}
|
|
194
|
+
|
|
195
|
+
/*
|
|
196
|
+
* TODO: not sure why we used `Events.Acccounts` for detecting if a provider gets connected or not, if we can use `CONNCECTED` for the legacy
|
|
197
|
+
* we can only rely Events.Connected and remove the legacy conidition
|
|
198
|
+
*/
|
|
199
|
+
if (event === Events.ACCOUNTS && state.connected) {
|
|
200
|
+
const key = `${type}-${state.network}-${value}`;
|
|
201
|
+
|
|
202
|
+
if (!!onConnectWalletHandler.current) {
|
|
203
|
+
onConnectWalletHandler.current(key);
|
|
204
|
+
} else {
|
|
205
|
+
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
199
208
|
};
|
|
200
209
|
|
|
201
210
|
const handleUpdatesForBoth: EventHandler = (
|
|
202
211
|
type,
|
|
203
212
|
event,
|
|
204
|
-
|
|
213
|
+
_value,
|
|
205
214
|
state,
|
|
206
215
|
_info
|
|
207
216
|
) => {
|
|
208
|
-
if (event === Events.
|
|
209
|
-
const
|
|
210
|
-
walletType: type,
|
|
211
|
-
network: state.network ?? undefined,
|
|
212
|
-
accounts: state.accounts ?? undefined,
|
|
213
|
-
};
|
|
214
|
-
if (!!onConnectWalletHandler.current) {
|
|
215
|
-
onConnectWalletHandler.current(walletFromEvent);
|
|
216
|
-
} else {
|
|
217
|
-
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (event === Events.NETWORK && value) {
|
|
222
|
-
const walletFromEvent: LastConnectedWallet = {
|
|
223
|
-
walletType: type,
|
|
224
|
-
network: value,
|
|
225
|
-
accounts: state.accounts ?? undefined,
|
|
226
|
-
};
|
|
217
|
+
if (event === Events.NETWORK && state.network) {
|
|
218
|
+
const key = `${type}-${state.network}`;
|
|
227
219
|
if (!!onConnectWalletHandler.current) {
|
|
228
|
-
onConnectWalletHandler.current(
|
|
220
|
+
onConnectWalletHandler.current(key);
|
|
229
221
|
} else {
|
|
230
222
|
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
231
223
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WalletType } from '../..';
|
|
2
|
-
import type { LastConnectedWallet } from '@rango-dev/queue-manager-rango-preset';
|
|
3
2
|
|
|
4
3
|
import { useQueueManager } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
+
import { splitWalletNetwork } from '@rango-dev/wallets-shared';
|
|
5
5
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
6
6
|
import { useContext, useEffect, useState } from 'react';
|
|
7
7
|
|
|
@@ -24,8 +24,8 @@ export function useBootstrap() {
|
|
|
24
24
|
useSyncNotifications();
|
|
25
25
|
const blockchains = useAppStore().blockchains();
|
|
26
26
|
const { canSwitchNetworkTo } = useWallets();
|
|
27
|
-
const [
|
|
28
|
-
useState
|
|
27
|
+
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
28
|
+
useState('');
|
|
29
29
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
30
30
|
const widgetContext = useContext(WidgetContext);
|
|
31
31
|
|
|
@@ -38,7 +38,7 @@ export function useBootstrap() {
|
|
|
38
38
|
|
|
39
39
|
// At the moment, we only detect the disconnection of EVM wallets.
|
|
40
40
|
useQueueManager({
|
|
41
|
-
lastConnectedWallet,
|
|
41
|
+
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
42
42
|
clearDisconnectedWallet: () => {
|
|
43
43
|
setDisconnectedWallet(undefined);
|
|
44
44
|
},
|
|
@@ -63,37 +63,14 @@ export function useBootstrap() {
|
|
|
63
63
|
* it the future we should add a safer soloution like considering array of handlers .
|
|
64
64
|
* https://github.com/rango-exchange/rango-client/pull/630/files#r1518846728
|
|
65
65
|
*/
|
|
66
|
-
widgetContext.onConnectWallet(
|
|
67
|
-
/*
|
|
68
|
-
* If no wallet was previously connected or the wallet type has changed,
|
|
69
|
-
* replace the last connected wallet with the new one from the event.
|
|
70
|
-
* Otherwise, merge updated `network` and `accounts` information from the new wallet
|
|
71
|
-
* into the existing last connected wallet without replacing the entire object.
|
|
72
|
-
*/
|
|
73
|
-
setLastConnectedWallet((lastConnectedWallet) => {
|
|
74
|
-
if (
|
|
75
|
-
!lastConnectedWallet ||
|
|
76
|
-
lastConnectedWallet.walletType !== walletFromEvent.walletType
|
|
77
|
-
) {
|
|
78
|
-
return walletFromEvent;
|
|
79
|
-
}
|
|
80
|
-
const lastConnectedWalletClone = { ...lastConnectedWallet };
|
|
81
|
-
if (walletFromEvent.network) {
|
|
82
|
-
lastConnectedWalletClone.network = walletFromEvent.network;
|
|
83
|
-
}
|
|
84
|
-
if (walletFromEvent.accounts) {
|
|
85
|
-
lastConnectedWalletClone.accounts = walletFromEvent.accounts;
|
|
86
|
-
}
|
|
87
|
-
return lastConnectedWalletClone;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
66
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
90
67
|
widgetContext.onDisconnectWallet((walletType) => {
|
|
91
68
|
setDisconnectedWallet(walletType);
|
|
92
|
-
|
|
93
|
-
walletType ===
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
69
|
+
if (
|
|
70
|
+
walletType === splitWalletNetwork(lastConnectedWalletWithNetwork)?.[0]
|
|
71
|
+
) {
|
|
72
|
+
setLastConnectedWalletWithNetwork('');
|
|
73
|
+
}
|
|
97
74
|
});
|
|
98
75
|
|
|
99
76
|
void fetchApiConfig().catch(console.log);
|
|
@@ -72,7 +72,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
72
72
|
const { result } = response;
|
|
73
73
|
|
|
74
74
|
if (!result) {
|
|
75
|
-
throw new Error(
|
|
75
|
+
throw new Error('Error fetching updated route');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
throwErrorIfResponseIsNotValid({
|
|
@@ -3,20 +3,17 @@ import type {
|
|
|
3
3
|
NeedsDerivationPathState,
|
|
4
4
|
NeedsNamespacesState,
|
|
5
5
|
} from './useStatefulConnect.types';
|
|
6
|
-
import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
7
6
|
|
|
8
7
|
export interface State {
|
|
9
|
-
status: 'init' | 'namespace' | 'derivationPath'
|
|
8
|
+
status: 'init' | 'namespace' | 'derivationPath';
|
|
10
9
|
namespace: NeedsNamespacesState | null;
|
|
11
10
|
derivationPath: NeedsDerivationPathState | null;
|
|
12
|
-
selectedNamespaces: Namespace[] | null;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export const initState: State = {
|
|
16
14
|
status: 'init',
|
|
17
15
|
namespace: null,
|
|
18
16
|
derivationPath: null,
|
|
19
|
-
selectedNamespaces: null,
|
|
20
17
|
};
|
|
21
18
|
|
|
22
19
|
export function reducer(state: State, action: Actions): State {
|
|
@@ -34,13 +31,6 @@ export function reducer(state: State, action: Actions): State {
|
|
|
34
31
|
status: 'derivationPath',
|
|
35
32
|
derivationPath: action.payload,
|
|
36
33
|
};
|
|
37
|
-
case 'detached':
|
|
38
|
-
return {
|
|
39
|
-
...state,
|
|
40
|
-
status: 'detached',
|
|
41
|
-
namespace: { targetWallet: action.payload.targetWallet },
|
|
42
|
-
selectedNamespaces: action.payload.selectedNamespaces,
|
|
43
|
-
};
|
|
44
34
|
case 'reset':
|
|
45
35
|
return initState;
|
|
46
36
|
case 'resetDerivation':
|