@rango-dev/widget-embedded 0.42.4-next.0 → 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,15 +25,15 @@
|
|
|
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.
|
|
28
|
+
"@rango-dev/provider-all": "^0.46.0",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.29.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.45.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.45.1",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.29.0",
|
|
32
|
-
"@rango-dev/signer-solana": "^0.39.
|
|
33
|
-
"@rango-dev/ui": "^0.46.
|
|
34
|
-
"@rango-dev/wallets-core": "^0.43.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.30.
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.44.
|
|
32
|
+
"@rango-dev/signer-solana": "^0.39.0",
|
|
33
|
+
"@rango-dev/ui": "^0.46.1",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.43.0",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.30.1",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.44.1",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"dayjs": "^1.11.7",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css,
|
|
1
|
+
import { css, darkTheme, IconButton, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const Title = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
@@ -11,15 +11,58 @@ export const ListContainer = styled('div', {
|
|
|
11
11
|
display: 'flex',
|
|
12
12
|
justifyContent: 'space-evenly',
|
|
13
13
|
alignItems: 'center',
|
|
14
|
-
|
|
15
|
-
rowGap: '$10',
|
|
14
|
+
gap: '$10',
|
|
16
15
|
flexWrap: 'wrap',
|
|
17
16
|
paddingTop: '$5',
|
|
18
17
|
height: '100%',
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
export const
|
|
20
|
+
export const WalletButton = styled('button', {
|
|
21
|
+
borderRadius: '$xm',
|
|
22
|
+
padding: '$10',
|
|
23
|
+
border: '0',
|
|
24
|
+
display: 'flex',
|
|
22
25
|
justifyContent: 'center',
|
|
26
|
+
$$color: '$colors$neutral100',
|
|
27
|
+
[`.${darkTheme} &`]: {
|
|
28
|
+
$$color: '$colors$neutral300',
|
|
29
|
+
},
|
|
30
|
+
backgroundColor: '$$color',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
width: 110,
|
|
34
|
+
position: 'relative',
|
|
35
|
+
|
|
36
|
+
'&:hover': {
|
|
37
|
+
$$color: '$colors$secondary100',
|
|
38
|
+
[`.${darkTheme} &`]: {
|
|
39
|
+
$$color: '$colors$neutral100',
|
|
40
|
+
},
|
|
41
|
+
backgroundColor: '$$color',
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
'&:focus-visible': {
|
|
45
|
+
$$color: '$colors$secondary100',
|
|
46
|
+
[`.${darkTheme} &`]: {
|
|
47
|
+
$$color: '$colors$info700',
|
|
48
|
+
},
|
|
49
|
+
backgroundColor: '$$color',
|
|
50
|
+
outline: 0,
|
|
51
|
+
},
|
|
52
|
+
variants: {
|
|
53
|
+
selected: {
|
|
54
|
+
true: {
|
|
55
|
+
outlineWidth: 1,
|
|
56
|
+
outlineColor: '$secondary',
|
|
57
|
+
outlineStyle: 'solid',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const ShowMoreWallets = styled(WalletButton, {
|
|
64
|
+
alignSelf: 'stretch',
|
|
65
|
+
minHeight: '93px',
|
|
23
66
|
});
|
|
24
67
|
export const ShowMoreHeader = styled('div', {
|
|
25
68
|
padding: '$20 $20 $15 $20',
|
|
@@ -6,7 +6,6 @@ import { i18n } from '@lingui/core';
|
|
|
6
6
|
import { warn } from '@rango-dev/logging-core';
|
|
7
7
|
import {
|
|
8
8
|
Divider,
|
|
9
|
-
makeInfo,
|
|
10
9
|
SelectableWallet,
|
|
11
10
|
Typography,
|
|
12
11
|
WalletState,
|
|
@@ -15,6 +14,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
15
14
|
|
|
16
15
|
import { useWallets } from '../..';
|
|
17
16
|
import { WIDGET_UI_ID } from '../../constants';
|
|
17
|
+
import { useStatefulConnect } from '../../hooks/useStatefulConnect';
|
|
18
18
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
19
19
|
import { useAppStore } from '../../store/AppStore';
|
|
20
20
|
import { useUiStore } from '../../store/ui';
|
|
@@ -49,6 +49,7 @@ export function WalletList(props: PropTypes) {
|
|
|
49
49
|
const [addingExperimentalChainStatus, setAddingExperimentalChainStatus] =
|
|
50
50
|
useState<'in-progress' | 'completed' | 'rejected' | null>(null);
|
|
51
51
|
const { suggestAndConnect } = useWallets();
|
|
52
|
+
const { handleDisconnect } = useStatefulConnect();
|
|
52
53
|
const { list } = useWalletList({
|
|
53
54
|
chain,
|
|
54
55
|
});
|
|
@@ -118,14 +119,9 @@ export function WalletList(props: PropTypes) {
|
|
|
118
119
|
walletType: wallet.type,
|
|
119
120
|
chain,
|
|
120
121
|
});
|
|
121
|
-
const isConnected = wallet.state === WalletState.CONNECTED;
|
|
122
122
|
const conciseAddress = address
|
|
123
123
|
? getConciseAddress(address, ACCOUNT_ADDRESS_MAX_CHARACTERS)
|
|
124
124
|
: '';
|
|
125
|
-
const isConnectedButDifferentThanTargetNamespace =
|
|
126
|
-
isConnected && wallet.isHub
|
|
127
|
-
? !conciseAddress
|
|
128
|
-
: !!wallet.needsNamespace && !conciseAddress;
|
|
129
125
|
|
|
130
126
|
const experimentalChain = isExperimentalChain(blockchains(), chain);
|
|
131
127
|
|
|
@@ -140,10 +136,25 @@ export function WalletList(props: PropTypes) {
|
|
|
140
136
|
experimentalChainNotAdded &&
|
|
141
137
|
wallet.state === WalletState.CONNECTED;
|
|
142
138
|
|
|
139
|
+
const connectedWalletDescription = couldAddExperimentalChain
|
|
140
|
+
? i18n.t({
|
|
141
|
+
id: 'Add {chain} chain',
|
|
142
|
+
values: { chain },
|
|
143
|
+
})
|
|
144
|
+
: conciseAddress;
|
|
145
|
+
|
|
143
146
|
const onSelectableWalletClick = async () => {
|
|
144
147
|
const isDisconnected = wallet.state === WalletState.DISCONNECTED;
|
|
148
|
+
const isConnectedButDifferentThanTargetNamespace = wallet.isHub
|
|
149
|
+
? !conciseAddress
|
|
150
|
+
: !!wallet.needsNamespace && !conciseAddress;
|
|
151
|
+
|
|
152
|
+
if (isDisconnected) {
|
|
153
|
+
setSelectedWalletToConnect(wallet);
|
|
154
|
+
} else if (isConnectedButDifferentThanTargetNamespace) {
|
|
155
|
+
// wallet is connected on a different namespace
|
|
156
|
+
await handleDisconnect(wallet.type);
|
|
145
157
|
|
|
146
|
-
if (isDisconnected || isConnectedButDifferentThanTargetNamespace) {
|
|
147
158
|
setSelectedWalletToConnect(wallet);
|
|
148
159
|
} else if (couldAddExperimentalChain) {
|
|
149
160
|
setExperimentalChainWallet({
|
|
@@ -161,32 +172,6 @@ export function WalletList(props: PropTypes) {
|
|
|
161
172
|
}
|
|
162
173
|
};
|
|
163
174
|
|
|
164
|
-
const info = makeInfo(wallet.state);
|
|
165
|
-
|
|
166
|
-
const getWalletDescription = () => {
|
|
167
|
-
if (couldAddExperimentalChain) {
|
|
168
|
-
return i18n.t({
|
|
169
|
-
id: 'Add {chain} chain',
|
|
170
|
-
values: { chain },
|
|
171
|
-
});
|
|
172
|
-
} else if (isConnectedButDifferentThanTargetNamespace) {
|
|
173
|
-
return i18n.t('Chain not connected');
|
|
174
|
-
} else if (conciseAddress) {
|
|
175
|
-
return conciseAddress;
|
|
176
|
-
}
|
|
177
|
-
return info.description;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const getWalletDescriptionColor = () => {
|
|
181
|
-
if (wallet.state === WalletState.CONNECTED) {
|
|
182
|
-
if (isConnectedButDifferentThanTargetNamespace) {
|
|
183
|
-
return 'neutral600';
|
|
184
|
-
}
|
|
185
|
-
return 'neutral700';
|
|
186
|
-
}
|
|
187
|
-
return info.color;
|
|
188
|
-
};
|
|
189
|
-
|
|
190
175
|
const blockchainDisplayName: string | undefined =
|
|
191
176
|
experimentalChainWallet?.chain
|
|
192
177
|
? getBlockchainDisplayNameFor(
|
|
@@ -226,8 +211,7 @@ export function WalletList(props: PropTypes) {
|
|
|
226
211
|
)}
|
|
227
212
|
<SelectableWallet
|
|
228
213
|
key={wallet.type}
|
|
229
|
-
description={
|
|
230
|
-
descriptionColor={getWalletDescriptionColor()}
|
|
214
|
+
description={connectedWalletDescription}
|
|
231
215
|
onClick={onSelectableWalletClick}
|
|
232
216
|
selected={isSelected(wallet.type, chain)}
|
|
233
217
|
disabled={!isActiveTab}
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from './NoResult.styles';
|
|
27
27
|
|
|
28
28
|
export function NoResult(props: PropTypes) {
|
|
29
|
-
const { fetch, error, size = 'small'
|
|
29
|
+
const { fetch, error, size = 'small' } = props;
|
|
30
30
|
const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
|
|
31
31
|
const toggleAllLiquiditySources = useAppStore().toggleAllLiquiditySources;
|
|
32
32
|
|
|
@@ -37,9 +37,6 @@ export function NoResult(props: PropTypes) {
|
|
|
37
37
|
() => toggleAllLiquiditySources(swappers, true),
|
|
38
38
|
fetch
|
|
39
39
|
);
|
|
40
|
-
if (skipAlerts) {
|
|
41
|
-
info.alert = null;
|
|
42
|
-
}
|
|
43
40
|
|
|
44
41
|
return (
|
|
45
42
|
<Container>
|
|
@@ -263,7 +263,7 @@ export function Quote(props: QuoteProps) {
|
|
|
263
263
|
variant="body"
|
|
264
264
|
color="neutral900">
|
|
265
265
|
{i18n.t({
|
|
266
|
-
id: 'Minimum
|
|
266
|
+
id: 'Minimum required slippage: {minRequiredSlippage}',
|
|
267
267
|
values: {
|
|
268
268
|
...(error?.type ===
|
|
269
269
|
QuoteErrorType.INSUFFICIENT_SLIPPAGE && {
|
|
@@ -10,17 +10,10 @@ import { errorMessages } from '../../constants/errors';
|
|
|
10
10
|
import { QuoteErrorType, QuoteWarningType } from '../../types';
|
|
11
11
|
import { getPriceImpactLevel } from '../../utils/quote';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
| 'show-info'
|
|
15
|
-
| 'change-settings'
|
|
16
|
-
| 'change-slippage'
|
|
17
|
-
| null;
|
|
18
|
-
|
|
19
|
-
export type AlertInfo = {
|
|
13
|
+
type AlertInfo = {
|
|
20
14
|
alertType: 'error' | 'warning';
|
|
21
15
|
title: string;
|
|
22
|
-
action:
|
|
23
|
-
actionButtonTitle: string | null;
|
|
16
|
+
action: 'show-info' | 'change-settings' | null;
|
|
24
17
|
};
|
|
25
18
|
|
|
26
19
|
export function makeAlerts(
|
|
@@ -31,9 +24,7 @@ export function makeAlerts(
|
|
|
31
24
|
alertType: 'warning',
|
|
32
25
|
title: '',
|
|
33
26
|
action: null,
|
|
34
|
-
actionButtonTitle: null,
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
if (error) {
|
|
38
29
|
alertInfo.alertType = 'error';
|
|
39
30
|
if (error.type === QuoteErrorType.BRIDGE_LIMIT) {
|
|
@@ -47,8 +38,7 @@ export function makeAlerts(
|
|
|
47
38
|
minRequiredSlippage: error.minRequiredSlippage,
|
|
48
39
|
},
|
|
49
40
|
});
|
|
50
|
-
alertInfo.action = 'change-
|
|
51
|
-
alertInfo.actionButtonTitle = i18n.t('Increase');
|
|
41
|
+
alertInfo.action = 'change-settings';
|
|
52
42
|
}
|
|
53
43
|
|
|
54
44
|
return alertInfo;
|
|
@@ -85,9 +75,7 @@ export function makeAlerts(
|
|
|
85
75
|
minRequiredSlippage: warning.minRequiredSlippage,
|
|
86
76
|
},
|
|
87
77
|
});
|
|
88
|
-
alertInfo.action = 'change-
|
|
89
|
-
alertInfo.actionButtonTitle = i18n.t('Increase');
|
|
90
|
-
|
|
78
|
+
alertInfo.action = 'change-settings';
|
|
91
79
|
break;
|
|
92
80
|
}
|
|
93
81
|
case QuoteWarningType.HIGH_SLIPPAGE: {
|
|
@@ -104,16 +92,3 @@ export function makeAlerts(
|
|
|
104
92
|
}
|
|
105
93
|
return null;
|
|
106
94
|
}
|
|
107
|
-
|
|
108
|
-
export function getRequiredSlippage(
|
|
109
|
-
warning: QuoteWarning | null,
|
|
110
|
-
error: BridgeLimitError | InsufficientSlippageError | null
|
|
111
|
-
) {
|
|
112
|
-
if (error?.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE) {
|
|
113
|
-
return Number(error.minRequiredSlippage);
|
|
114
|
-
}
|
|
115
|
-
if (warning?.type === QuoteWarningType.INSUFFICIENT_SLIPPAGE) {
|
|
116
|
-
return Number(warning.minRequiredSlippage);
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { darkTheme, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const Alerts = styled('div', {
|
|
4
4
|
width: '100%',
|
|
@@ -32,12 +32,3 @@ export const Action = styled('div', {
|
|
|
32
32
|
alignSelf: 'flex-start',
|
|
33
33
|
cursor: 'pointer',
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
export const SwapButton = styled(Button, {
|
|
37
|
-
'& ._text': {
|
|
38
|
-
gap: '$5',
|
|
39
|
-
display: 'flex',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
justifyContent: 'center',
|
|
42
|
-
},
|
|
43
|
-
});
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type { ActionType } from './QuoteWarningsAndErrors.helpers';
|
|
2
1
|
import type { PropTypes } from './QuoteWarningsAndErrors.types';
|
|
3
2
|
|
|
4
3
|
import { i18n } from '@lingui/core';
|
|
5
|
-
import { Alert, Button,
|
|
4
|
+
import { Alert, Button, InfoIcon } from '@rango-dev/ui';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
7
|
import { QuoteErrorType, QuoteWarningType } from '../../types';
|
|
9
8
|
import { NoResult } from '../NoResult';
|
|
10
9
|
|
|
11
10
|
import { HighValueLossWarningModal } from './HighValueLossWarningModal';
|
|
12
|
-
import {
|
|
13
|
-
getRequiredSlippage,
|
|
14
|
-
makeAlerts,
|
|
15
|
-
} from './QuoteWarningsAndErrors.helpers';
|
|
11
|
+
import { makeAlerts } from './QuoteWarningsAndErrors.helpers';
|
|
16
12
|
import { Action, Alerts } from './QuoteWarningsAndErrors.styles';
|
|
17
13
|
import { SlippageWarningModal } from './SlippageWariningModal';
|
|
18
14
|
import { UnknownPriceWarningModal } from './UnknownPriceWarningModal';
|
|
@@ -24,13 +20,11 @@ export function QuoteWarningsAndErrors(props: PropTypes) {
|
|
|
24
20
|
couldChangeSettings,
|
|
25
21
|
showWarningModal,
|
|
26
22
|
confirmationDisabled,
|
|
27
|
-
skipAlerts,
|
|
28
23
|
refetchQuote,
|
|
29
24
|
onOpenWarningModal,
|
|
30
25
|
onCloseWarningModal,
|
|
31
26
|
onConfirmWarningModal,
|
|
32
27
|
onChangeSettings,
|
|
33
|
-
onChangeSlippage,
|
|
34
28
|
} = props;
|
|
35
29
|
|
|
36
30
|
const warningModalHandlers = {
|
|
@@ -55,38 +49,14 @@ export function QuoteWarningsAndErrors(props: PropTypes) {
|
|
|
55
49
|
alertInfo.action = null;
|
|
56
50
|
}
|
|
57
51
|
|
|
58
|
-
const showAlerts = !!alertInfo
|
|
59
|
-
|
|
60
|
-
const onclickActionButton = (action: ActionType) => {
|
|
61
|
-
if (action === 'change-slippage') {
|
|
62
|
-
const quoteError =
|
|
63
|
-
error?.type === QuoteErrorType.BRIDGE_LIMIT ||
|
|
64
|
-
error?.type === QuoteErrorType.INSUFFICIENT_SLIPPAGE
|
|
65
|
-
? error
|
|
66
|
-
: null;
|
|
67
|
-
const requestedSlippage = getRequiredSlippage(warning, quoteError);
|
|
68
|
-
onChangeSlippage?.(requestedSlippage);
|
|
69
|
-
} else if (action === 'change-settings') {
|
|
70
|
-
onChangeSettings();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
52
|
+
const showAlerts = !!alertInfo;
|
|
73
53
|
|
|
74
54
|
return (
|
|
75
55
|
<>
|
|
76
|
-
{showNoResultMessage &&
|
|
77
|
-
<>
|
|
78
|
-
<Divider size={10} />
|
|
79
|
-
<NoResult
|
|
80
|
-
skipAlerts={skipAlerts}
|
|
81
|
-
error={error}
|
|
82
|
-
fetch={refetchQuote}
|
|
83
|
-
/>
|
|
84
|
-
</>
|
|
85
|
-
)}
|
|
56
|
+
{showNoResultMessage && <NoResult error={error} fetch={refetchQuote} />}
|
|
86
57
|
|
|
87
58
|
{showAlerts && (
|
|
88
59
|
<Alerts>
|
|
89
|
-
<Divider size={10} />
|
|
90
60
|
<Alert
|
|
91
61
|
title={alertInfo.title}
|
|
92
62
|
type={alertInfo.alertType}
|
|
@@ -98,15 +68,14 @@ export function QuoteWarningsAndErrors(props: PropTypes) {
|
|
|
98
68
|
</Action>
|
|
99
69
|
),
|
|
100
70
|
})}
|
|
101
|
-
{...(
|
|
102
|
-
alertInfo.action === 'change-slippage') && {
|
|
71
|
+
{...(alertInfo.action === 'change-settings' && {
|
|
103
72
|
action: (
|
|
104
73
|
<Button
|
|
105
74
|
id="widget-quote-warning-error-change-settings-btn"
|
|
106
75
|
size="xxsmall"
|
|
107
76
|
type={alertInfo.alertType}
|
|
108
|
-
onClick={
|
|
109
|
-
{
|
|
77
|
+
onClick={onChangeSettings}>
|
|
78
|
+
{i18n.t('Change')}
|
|
110
79
|
</Button>
|
|
111
80
|
),
|
|
112
81
|
})}
|
|
@@ -6,13 +6,11 @@ export interface PropTypes {
|
|
|
6
6
|
showWarningModal: boolean;
|
|
7
7
|
confirmationDisabled: boolean;
|
|
8
8
|
couldChangeSettings: boolean;
|
|
9
|
-
skipAlerts?: boolean;
|
|
10
9
|
refetchQuote: () => void;
|
|
11
10
|
onOpenWarningModal: () => void;
|
|
12
11
|
onCloseWarningModal: () => void;
|
|
13
12
|
onConfirmWarningModal: () => void;
|
|
14
13
|
onChangeSettings: () => void;
|
|
15
|
-
onChangeSlippage?: (slippage: number | null) => void;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
type ModalPropTypesKeys = keyof Omit<PropTypes, 'extraSpace' | 'loading'>;
|
|
@@ -4,17 +4,16 @@ import type {
|
|
|
4
4
|
} from '../../types';
|
|
5
5
|
|
|
6
6
|
import { i18n } from '@lingui/core';
|
|
7
|
-
import { Button, Divider, MessageBox,
|
|
7
|
+
import { Button, Divider, MessageBox, Typography } from '@rango-dev/ui';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { useNavigate } from 'react-router-dom';
|
|
10
10
|
|
|
11
11
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
12
|
+
import { useAppStore } from '../../store/AppStore';
|
|
12
13
|
import { QuoteWarningType } from '../../types';
|
|
13
14
|
import { getContainer } from '../../utils/common';
|
|
14
15
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
15
16
|
|
|
16
|
-
import { SwapButton } from './QuoteWarningsAndErrors.styles';
|
|
17
|
-
|
|
18
17
|
type PropsTypes = {
|
|
19
18
|
open: boolean;
|
|
20
19
|
confirmationDisabled: boolean;
|
|
@@ -24,13 +23,26 @@ type PropsTypes = {
|
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
export function SlippageWarningModal(props: PropsTypes) {
|
|
26
|
+
const { customSlippage, slippage } = useAppStore();
|
|
27
27
|
const { open, onClose, onConfirm, warning, confirmationDisabled } = props;
|
|
28
28
|
const navigate = useNavigate();
|
|
29
|
+
const userSlippage = customSlippage ?? slippage;
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
32
|
<WatermarkedModal
|
|
32
33
|
anchor="bottom"
|
|
33
34
|
open={open}
|
|
35
|
+
prefix={
|
|
36
|
+
<Button
|
|
37
|
+
size="small"
|
|
38
|
+
id="widget-slippage-warning-modal-change-settings-btn"
|
|
39
|
+
variant="ghost"
|
|
40
|
+
onClick={() => navigate('../' + navigationRoutes.settings)}>
|
|
41
|
+
<Typography variant="label" size="medium" color="$neutral900">
|
|
42
|
+
{i18n.t('Change settings')}
|
|
43
|
+
</Typography>
|
|
44
|
+
</Button>
|
|
45
|
+
}
|
|
34
46
|
container={getContainer()}
|
|
35
47
|
onClose={onClose}>
|
|
36
48
|
<MessageBox
|
|
@@ -42,9 +54,10 @@ export function SlippageWarningModal(props: PropsTypes) {
|
|
|
42
54
|
}
|
|
43
55
|
description={
|
|
44
56
|
warning.type === QuoteWarningType.HIGH_SLIPPAGE
|
|
45
|
-
? i18n.t(
|
|
46
|
-
'Caution, your slippage is high. Your trade may be front run.'
|
|
47
|
-
|
|
57
|
+
? i18n.t({
|
|
58
|
+
id: ' Caution, your slippage is high (={userSlippage}). Your trade may be front run.',
|
|
59
|
+
values: { userSlippage },
|
|
60
|
+
})
|
|
48
61
|
: i18n.t({
|
|
49
62
|
id: 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
|
|
50
63
|
values: {
|
|
@@ -54,7 +67,7 @@ export function SlippageWarningModal(props: PropsTypes) {
|
|
|
54
67
|
}>
|
|
55
68
|
<Divider size={18} />
|
|
56
69
|
<Divider size={32} />
|
|
57
|
-
<
|
|
70
|
+
<Button
|
|
58
71
|
id="widget-slippage-warning-modal-confirm-anyway-btn"
|
|
59
72
|
size="large"
|
|
60
73
|
type="primary"
|
|
@@ -62,19 +75,7 @@ export function SlippageWarningModal(props: PropsTypes) {
|
|
|
62
75
|
fullWidth
|
|
63
76
|
disabled={confirmationDisabled}
|
|
64
77
|
onClick={onConfirm}>
|
|
65
|
-
|
|
66
|
-
{i18n.t('Swap anyway')}
|
|
67
|
-
</SwapButton>
|
|
68
|
-
<Divider size={10} />
|
|
69
|
-
<Button
|
|
70
|
-
id="widget-slippage-warning-modal-change-slippage-btn"
|
|
71
|
-
size="large"
|
|
72
|
-
type="primary"
|
|
73
|
-
variant="outlined"
|
|
74
|
-
fullWidth
|
|
75
|
-
disabled={confirmationDisabled}
|
|
76
|
-
onClick={() => navigate('../' + navigationRoutes.settings)}>
|
|
77
|
-
{i18n.t('Change Slippage')}
|
|
78
|
+
{i18n.t('Confirm anyway')}
|
|
78
79
|
</Button>
|
|
79
80
|
</MessageBox>
|
|
80
81
|
</WatermarkedModal>
|
|
@@ -32,26 +32,3 @@ export const SlippageChip = styled(Chip, {
|
|
|
32
32
|
width: '61px',
|
|
33
33
|
flexShrink: 0,
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
export const SlippageTextFieldContainer = styled('div', {
|
|
37
|
-
borderWidth: 1,
|
|
38
|
-
borderStyle: 'solid',
|
|
39
|
-
borderRadius: '$xs',
|
|
40
|
-
flex: 1,
|
|
41
|
-
variants: {
|
|
42
|
-
status: {
|
|
43
|
-
safe: {
|
|
44
|
-
borderColor: '$secondary500',
|
|
45
|
-
},
|
|
46
|
-
error: {
|
|
47
|
-
borderColor: '$error500',
|
|
48
|
-
},
|
|
49
|
-
warning: {
|
|
50
|
-
borderColor: '$warning500',
|
|
51
|
-
},
|
|
52
|
-
empty: {
|
|
53
|
-
borderWidth: 0,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
@@ -14,14 +14,12 @@ import { MAX_SLIPPAGE, SLIPPAGES } from '../../constants/swapSettings';
|
|
|
14
14
|
import { useAppStore } from '../../store/AppStore';
|
|
15
15
|
import { getContainer } from '../../utils/common';
|
|
16
16
|
import { getSlippageValidation } from '../../utils/settings';
|
|
17
|
-
import { isValidCurrencyFormat } from '../../utils/validation';
|
|
18
17
|
|
|
19
18
|
import {
|
|
20
19
|
BaseContainer,
|
|
21
20
|
Head,
|
|
22
21
|
SlippageChip,
|
|
23
22
|
SlippageChipsContainer,
|
|
24
|
-
SlippageTextFieldContainer,
|
|
25
23
|
} from './Slippage.styles';
|
|
26
24
|
import { SlippageTooltipContent } from './SlippageTooltipContent';
|
|
27
25
|
|
|
@@ -56,8 +54,9 @@ export function Slippage() {
|
|
|
56
54
|
|
|
57
55
|
const onInput = (event: React.FormEvent<HTMLInputElement>) => {
|
|
58
56
|
const input = event.target as HTMLInputElement;
|
|
57
|
+
const regex = /^(0|[1-9]\d*)(\.\d{1,2})?$/;
|
|
59
58
|
const value = input.value;
|
|
60
|
-
if (!
|
|
59
|
+
if (!regex.test(value)) {
|
|
61
60
|
input.value = value.slice(0, -1);
|
|
62
61
|
}
|
|
63
62
|
};
|
|
@@ -91,31 +90,26 @@ export function Slippage() {
|
|
|
91
90
|
/>
|
|
92
91
|
);
|
|
93
92
|
})}
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
placeholder={i18n.t('Custom')}
|
|
117
|
-
/>
|
|
118
|
-
</SlippageTextFieldContainer>
|
|
93
|
+
<TextField
|
|
94
|
+
type="number"
|
|
95
|
+
min="0.01"
|
|
96
|
+
max="30"
|
|
97
|
+
step="0.01"
|
|
98
|
+
onInput={onInput}
|
|
99
|
+
fullWidth
|
|
100
|
+
variant="contained"
|
|
101
|
+
value={customSlippage === null ? '' : customSlippage}
|
|
102
|
+
color="dark"
|
|
103
|
+
onChange={onSlippageValueChange}
|
|
104
|
+
suffix={
|
|
105
|
+
customSlippage && (
|
|
106
|
+
<Typography variant="body" size="small">
|
|
107
|
+
%
|
|
108
|
+
</Typography>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
placeholder={i18n.t('Custom')}
|
|
112
|
+
/>
|
|
119
113
|
</SlippageChipsContainer>
|
|
120
114
|
|
|
121
115
|
{slippageValidation && (
|