@rango-dev/widget-embedded 0.60.1-next.0 → 0.60.2-next.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/CHANGELOG.md +4 -0
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.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/wallets.d.ts +1 -2
- package/dist/constants/wallets.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/utils/wallets.d.ts +1 -1
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +0 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/ConfirmWalletsModal/WalletList.tsx +16 -166
- package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +0 -5
- package/src/components/TokenList/TokenList.tsx +12 -12
- package/src/components/WalletStatefulConnect/index.ts +0 -1
- package/src/constants/wallets.ts +1 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +45 -3316
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +26 -228
- package/src/hooks/useWalletList.ts +6 -29
- package/src/store/utils/wallets.ts +1 -1
- package/src/test-utils/fixtures.ts +0 -39
- package/src/utils/common.ts +0 -1
- package/src/utils/wallets.ts +0 -32
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts +0 -9
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts +0 -6
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts.map +0 -1
- package/src/components/WalletStatefulConnect/ExperimentalChain.tsx +0 -39
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts +0 -53
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx +0 -36
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.2-next.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.12.1",
|
|
28
|
-
"@rango-dev/provider-all": "^0.62.
|
|
28
|
+
"@rango-dev/provider-all": "^0.62.2-next.0",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.33.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.62.0",
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.62.1-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.33.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.48.0",
|
|
33
|
-
"@rango-dev/ui": "^0.63.0",
|
|
34
|
-
"@rango-dev/wallets-core": "^0.59.0",
|
|
35
|
-
"@rango-dev/wallets-react": "^0.46.0",
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.60.0",
|
|
33
|
+
"@rango-dev/ui": "^0.63.1-next.0",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.59.1-next.0",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.46.1-next.0",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.60.1-next.0",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"crypto-browserify": "^3.12.1",
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { PropTypes } from './WalletList.type';
|
|
2
|
-
import type { Wallet } from '../../types';
|
|
3
2
|
import type { ExtendedModalWalletInfo } from '../../utils/wallets';
|
|
4
3
|
|
|
5
4
|
import { i18n } from '@lingui/core';
|
|
6
5
|
import { warn } from '@rango-dev/logging-core';
|
|
7
6
|
import {
|
|
8
|
-
Divider,
|
|
9
7
|
makeInfo,
|
|
10
8
|
SelectableWallet,
|
|
11
9
|
Typography,
|
|
@@ -13,42 +11,24 @@ import {
|
|
|
13
11
|
} from '@rango-dev/ui';
|
|
14
12
|
import React, { useEffect, useState } from 'react';
|
|
15
13
|
|
|
16
|
-
import { useWallets } from '../..';
|
|
17
|
-
import { WIDGET_UI_ID } from '../../constants';
|
|
18
14
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
19
15
|
import { useAppStore } from '../../store/AppStore';
|
|
20
16
|
import { useUiStore } from '../../store/ui';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
getAddress,
|
|
24
|
-
getConciseAddress,
|
|
25
|
-
isExperimentalChain,
|
|
26
|
-
} from '../../utils/wallets';
|
|
27
|
-
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
17
|
+
import { getAddress, getConciseAddress } from '../../utils/wallets';
|
|
28
18
|
import { StatefulConnectModal } from '../StatefulConnectModal';
|
|
29
|
-
import { ExperimentalChain } from '../WalletStatefulConnect';
|
|
30
|
-
import { ExperimentalChainStatus } from '../WalletStatefulConnect/ExperimentalChainStatus';
|
|
31
19
|
|
|
32
20
|
import { ShowMoreWallets } from './ConfirmWallets.styles';
|
|
33
21
|
|
|
34
22
|
const ACCOUNT_ADDRESS_MAX_CHARACTERS = 7;
|
|
35
|
-
const TIME_TO_CLOSE_MODAL = 3_000;
|
|
36
23
|
|
|
37
24
|
export function WalletList(props: PropTypes) {
|
|
38
25
|
const { chain, quoteChains, isSelected, selectWallet, limit, onShowMore } =
|
|
39
26
|
props;
|
|
40
27
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
41
28
|
|
|
42
|
-
const {
|
|
29
|
+
const { connectedWallets } = useAppStore();
|
|
43
30
|
const [selectedWalletToConnect, setSelectedWalletToConnect] =
|
|
44
31
|
useState<ExtendedModalWalletInfo>();
|
|
45
|
-
const [experimentalChainWallet, setExperimentalChainWallet] =
|
|
46
|
-
useState<Wallet | null>(null);
|
|
47
|
-
const [showExperimentalChainModal, setShowExperimentalChainModal] =
|
|
48
|
-
useState(false);
|
|
49
|
-
const [addingExperimentalChainStatus, setAddingExperimentalChainStatus] =
|
|
50
|
-
useState<'in-progress' | 'completed' | 'rejected' | null>(null);
|
|
51
|
-
const { suggestAndConnect } = useWallets();
|
|
52
32
|
const { list } = useWalletList({
|
|
53
33
|
chain,
|
|
54
34
|
});
|
|
@@ -57,45 +37,6 @@ export function WalletList(props: PropTypes) {
|
|
|
57
37
|
const numberOfSupportedWallets = list.length;
|
|
58
38
|
const shouldShowMoreWallets = limit && numberOfSupportedWallets - limit > 0;
|
|
59
39
|
|
|
60
|
-
const addExperimentalChain = async (wallet: Wallet) => {
|
|
61
|
-
setShowExperimentalChainModal(false);
|
|
62
|
-
setAddingExperimentalChainStatus('in-progress');
|
|
63
|
-
try {
|
|
64
|
-
// 1. Finding wallet with namespaces info.
|
|
65
|
-
const walletWithNamespace = list.find(
|
|
66
|
-
(wallet) => wallet.type === wallet.type
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
* 2. Getting namespaces info.
|
|
71
|
-
* Legacy and hub have different structure to handle each situation.
|
|
72
|
-
*/
|
|
73
|
-
const needsNamespace = walletWithNamespace?.isHub
|
|
74
|
-
? walletWithNamespace.properties?.find(
|
|
75
|
-
(item) => item.name === 'namespaces'
|
|
76
|
-
)?.value
|
|
77
|
-
: walletWithNamespace?.needsNamespace;
|
|
78
|
-
|
|
79
|
-
// 3. Finding target namespace.
|
|
80
|
-
const allBlockChains = blockchains();
|
|
81
|
-
const namespace = needsNamespace?.data.find((ns) =>
|
|
82
|
-
ns
|
|
83
|
-
.getSupportedChains(allBlockChains)
|
|
84
|
-
.some((chain) => chain.name === wallet.chain)
|
|
85
|
-
);
|
|
86
|
-
if (!namespace) {
|
|
87
|
-
throw new Error('Requested chain is not supported');
|
|
88
|
-
}
|
|
89
|
-
await suggestAndConnect(wallet.walletType, {
|
|
90
|
-
namespace: namespace.value,
|
|
91
|
-
network: wallet.chain,
|
|
92
|
-
});
|
|
93
|
-
setAddingExperimentalChainStatus('completed');
|
|
94
|
-
} catch {
|
|
95
|
-
setAddingExperimentalChainStatus('rejected');
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
40
|
useEffect(() => {
|
|
100
41
|
setSortedList((sortedList) => {
|
|
101
42
|
const selectedWalletIndex = list.findIndex((wallet) =>
|
|
@@ -115,29 +56,6 @@ export function WalletList(props: PropTypes) {
|
|
|
115
56
|
});
|
|
116
57
|
}, [JSON.stringify(list)]);
|
|
117
58
|
|
|
118
|
-
const modalContainer = document.getElementById(
|
|
119
|
-
WIDGET_UI_ID.SWAP_BOX_ID
|
|
120
|
-
) as HTMLDivElement;
|
|
121
|
-
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
124
|
-
if (
|
|
125
|
-
addingExperimentalChainStatus === 'completed' ||
|
|
126
|
-
addingExperimentalChainStatus === 'rejected'
|
|
127
|
-
) {
|
|
128
|
-
timeout = setTimeout(
|
|
129
|
-
() => setAddingExperimentalChainStatus(null),
|
|
130
|
-
TIME_TO_CLOSE_MODAL
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return () => {
|
|
135
|
-
if (timeout) {
|
|
136
|
-
clearTimeout(timeout);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}, [addingExperimentalChainStatus]);
|
|
140
|
-
|
|
141
59
|
return (
|
|
142
60
|
<>
|
|
143
61
|
{sortedList.slice(0, limit).map((wallet) => {
|
|
@@ -155,35 +73,11 @@ export function WalletList(props: PropTypes) {
|
|
|
155
73
|
const isConnectedButDifferentThanTargetNamespace =
|
|
156
74
|
isConnected && !!wallet.needsNamespace && !conciseAddress;
|
|
157
75
|
|
|
158
|
-
const experimentalChain = isExperimentalChain(blockchains(), chain);
|
|
159
|
-
|
|
160
|
-
const experimentalChainNotAdded = !connectedWallets.find(
|
|
161
|
-
(connectedWallet) =>
|
|
162
|
-
connectedWallet.walletType === wallet.type &&
|
|
163
|
-
connectedWallet.chain === chain
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const couldAddExperimentalChain =
|
|
167
|
-
experimentalChain &&
|
|
168
|
-
experimentalChainNotAdded &&
|
|
169
|
-
wallet.state === WalletState.CONNECTED;
|
|
170
|
-
|
|
171
76
|
const onSelectableWalletClick = async () => {
|
|
172
77
|
const isDisconnected = wallet.state === WalletState.DISCONNECTED;
|
|
173
78
|
|
|
174
|
-
if (
|
|
175
|
-
isDisconnected ||
|
|
176
|
-
(isConnectedButDifferentThanTargetNamespace &&
|
|
177
|
-
!couldAddExperimentalChain)
|
|
178
|
-
) {
|
|
79
|
+
if (isDisconnected || isConnectedButDifferentThanTargetNamespace) {
|
|
179
80
|
setSelectedWalletToConnect(wallet);
|
|
180
|
-
} else if (couldAddExperimentalChain) {
|
|
181
|
-
setExperimentalChainWallet({
|
|
182
|
-
walletType: wallet.type,
|
|
183
|
-
chain,
|
|
184
|
-
address: address ?? '',
|
|
185
|
-
});
|
|
186
|
-
setShowExperimentalChainModal(true);
|
|
187
81
|
} else {
|
|
188
82
|
selectWallet({
|
|
189
83
|
walletType: wallet.type,
|
|
@@ -196,12 +90,7 @@ export function WalletList(props: PropTypes) {
|
|
|
196
90
|
const info = makeInfo(wallet.state);
|
|
197
91
|
|
|
198
92
|
const getWalletDescription = () => {
|
|
199
|
-
if (
|
|
200
|
-
return i18n.t({
|
|
201
|
-
id: 'Add {chain} chain',
|
|
202
|
-
values: { chain },
|
|
203
|
-
});
|
|
204
|
-
} else if (isConnectedButDifferentThanTargetNamespace) {
|
|
93
|
+
if (isConnectedButDifferentThanTargetNamespace) {
|
|
205
94
|
return i18n.t('Chain not connected');
|
|
206
95
|
} else if (conciseAddress) {
|
|
207
96
|
return conciseAddress;
|
|
@@ -223,57 +112,17 @@ export function WalletList(props: PropTypes) {
|
|
|
223
112
|
return info.color;
|
|
224
113
|
};
|
|
225
114
|
|
|
226
|
-
const blockchainDisplayName: string | undefined =
|
|
227
|
-
experimentalChainWallet?.chain
|
|
228
|
-
? getBlockchainDisplayNameFor(
|
|
229
|
-
experimentalChainWallet.chain,
|
|
230
|
-
blockchains()
|
|
231
|
-
)
|
|
232
|
-
: undefined;
|
|
233
115
|
return (
|
|
234
|
-
<
|
|
235
|
-
{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
id="widget-wallets-list-experimental-chain-container"
|
|
245
|
-
displayName={blockchainDisplayName}
|
|
246
|
-
onConfirm={() => {
|
|
247
|
-
void addExperimentalChain(experimentalChainWallet);
|
|
248
|
-
}}
|
|
249
|
-
/>
|
|
250
|
-
</WatermarkedModal>
|
|
251
|
-
)}
|
|
252
|
-
{addingExperimentalChainStatus && (
|
|
253
|
-
<WatermarkedModal
|
|
254
|
-
id="widget-wallets-list-experimental-chain-watermarked-modal"
|
|
255
|
-
open={!!addingExperimentalChainStatus}
|
|
256
|
-
onClose={setAddingExperimentalChainStatus.bind(null, null)}
|
|
257
|
-
container={modalContainer}>
|
|
258
|
-
<ExperimentalChainStatus
|
|
259
|
-
status={addingExperimentalChainStatus}
|
|
260
|
-
displayName={blockchainDisplayName}
|
|
261
|
-
image={wallet.image}
|
|
262
|
-
/>
|
|
263
|
-
<Divider direction="vertical" size={32} />
|
|
264
|
-
</WatermarkedModal>
|
|
265
|
-
)}
|
|
266
|
-
<SelectableWallet
|
|
267
|
-
key={wallet.type}
|
|
268
|
-
id="widget-wallets-list-selectable-wallet-btn"
|
|
269
|
-
description={getWalletDescription()}
|
|
270
|
-
descriptionColor={getWalletDescriptionColor()}
|
|
271
|
-
onClick={onSelectableWalletClick}
|
|
272
|
-
selected={isSelected(wallet.type, chain)}
|
|
273
|
-
disabled={!isActiveTab}
|
|
274
|
-
{...wallet}
|
|
275
|
-
/>
|
|
276
|
-
</React.Fragment>
|
|
116
|
+
<SelectableWallet
|
|
117
|
+
key={wallet.type}
|
|
118
|
+
id="widget-wallets-list-selectable-wallet-btn"
|
|
119
|
+
description={getWalletDescription()}
|
|
120
|
+
descriptionColor={getWalletDescriptionColor()}
|
|
121
|
+
onClick={onSelectableWalletClick}
|
|
122
|
+
selected={isSelected(wallet.type, chain)}
|
|
123
|
+
disabled={!isActiveTab}
|
|
124
|
+
{...wallet}
|
|
125
|
+
/>
|
|
277
126
|
);
|
|
278
127
|
})}
|
|
279
128
|
<StatefulConnectModal
|
|
@@ -301,7 +150,8 @@ export function WalletList(props: PropTypes) {
|
|
|
301
150
|
<ShowMoreWallets
|
|
302
151
|
selected={false}
|
|
303
152
|
onClick={onShowMore}
|
|
304
|
-
id="widget-wallets-list-show-more-wallets-btn"
|
|
153
|
+
id="widget-wallets-list-show-more-wallets-btn"
|
|
154
|
+
>
|
|
305
155
|
<Typography variant="label" size="medium">
|
|
306
156
|
{i18n.t('Show more wallets')}
|
|
307
157
|
<Typography variant="label" size="medium" color="$primary">
|
|
@@ -4,11 +4,6 @@ export function generateExplorerLink(
|
|
|
4
4
|
address: string | null,
|
|
5
5
|
blockchain: BlockchainMeta
|
|
6
6
|
): string {
|
|
7
|
-
// We don't have Cosmos explorer url in API.
|
|
8
|
-
if (blockchain.type === 'COSMOS') {
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
7
|
const explorerLinkPattern = blockchain.info?.addressUrl;
|
|
13
8
|
|
|
14
9
|
if (!explorerLinkPattern || !address) {
|
|
@@ -81,7 +81,8 @@ const renderDesc = (props: RenderDescProps) => {
|
|
|
81
81
|
<div
|
|
82
82
|
className={`${tokenAddressStyles()} ${
|
|
83
83
|
!name && tokenWithoutNameStyles()
|
|
84
|
-
}`}
|
|
84
|
+
}`}
|
|
85
|
+
>
|
|
85
86
|
{length > 10
|
|
86
87
|
? `${address.slice(0, 5)}...${address.slice(length - 6, length)}`
|
|
87
88
|
: address}{' '}
|
|
@@ -90,7 +91,8 @@ const renderDesc = (props: RenderDescProps) => {
|
|
|
90
91
|
href={url}
|
|
91
92
|
target="_blank"
|
|
92
93
|
rel="nofollow noreferrer"
|
|
93
|
-
onClick={(e) => e.stopPropagation()}
|
|
94
|
+
onClick={(e) => e.stopPropagation()}
|
|
95
|
+
>
|
|
94
96
|
<ExternalLinkIcon size={12} />
|
|
95
97
|
</StyledLink>
|
|
96
98
|
</div>
|
|
@@ -151,7 +153,8 @@ export function TokenList(props: PropTypes) {
|
|
|
151
153
|
type="primary"
|
|
152
154
|
size="small"
|
|
153
155
|
className="widget-token-list-item-import-btn"
|
|
154
|
-
onClick={handleClick}
|
|
156
|
+
onClick={handleClick}
|
|
157
|
+
>
|
|
155
158
|
<Typography variant="body" size="xsmall" color="background">
|
|
156
159
|
{t('import')}
|
|
157
160
|
</Typography>
|
|
@@ -184,7 +187,8 @@ export function TokenList(props: PropTypes) {
|
|
|
184
187
|
<Typography
|
|
185
188
|
variant="body"
|
|
186
189
|
className={usdValueStyles()}
|
|
187
|
-
size="xsmall"
|
|
190
|
+
size="xsmall"
|
|
191
|
+
>
|
|
188
192
|
{`$${tokenBalance.usdValue}`}
|
|
189
193
|
</Typography>
|
|
190
194
|
)}
|
|
@@ -292,9 +296,7 @@ export function TokenList(props: PropTypes) {
|
|
|
292
296
|
</ImageSection>
|
|
293
297
|
}
|
|
294
298
|
title={
|
|
295
|
-
|
|
296
|
-
!!token.name ||
|
|
297
|
-
(!token.name && !address) ? (
|
|
299
|
+
!!token.name || (!token.name && !address) ? (
|
|
298
300
|
<Title>
|
|
299
301
|
<Typography variant="title" size="xmedium">
|
|
300
302
|
{token.symbol}
|
|
@@ -304,7 +306,8 @@ export function TokenList(props: PropTypes) {
|
|
|
304
306
|
<TagTitle
|
|
305
307
|
variant="body"
|
|
306
308
|
size="xsmall"
|
|
307
|
-
css={customCssForTagTitle}
|
|
309
|
+
css={customCssForTagTitle}
|
|
310
|
+
>
|
|
308
311
|
{token.blockchain}
|
|
309
312
|
</TagTitle>
|
|
310
313
|
</Tag>
|
|
@@ -318,10 +321,7 @@ export function TokenList(props: PropTypes) {
|
|
|
318
321
|
) : undefined
|
|
319
322
|
}
|
|
320
323
|
description={
|
|
321
|
-
typeof token !== 'string' &&
|
|
322
|
-
!!blockchain.info &&
|
|
323
|
-
!!address &&
|
|
324
|
-
blockchain.type !== 'COSMOS'
|
|
324
|
+
typeof token !== 'string' && !!blockchain.info && !!address
|
|
325
325
|
? renderDesc({
|
|
326
326
|
address,
|
|
327
327
|
token,
|
package/src/constants/wallets.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const MOST_USED_BLOCKCHAINS = ['ETH'
|
|
1
|
+
export const MOST_USED_BLOCKCHAINS = ['ETH'];
|