@rango-dev/widget-embedded 0.60.2-next.2 → 0.60.2-next.3
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/CustomTokenModal/CustomTokenModal.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/utils/meta.d.ts +4 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/CustomTokenModal/CustomTokenModal.tsx +7 -2
- package/src/components/TokenList/TokenList.tsx +18 -15
- package/src/utils/meta.ts +13 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +0 -3
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +0 -1
- package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +0 -14
package/package.json
CHANGED
|
@@ -13,10 +13,10 @@ import React from 'react';
|
|
|
13
13
|
|
|
14
14
|
import { DEFAULT_TOKEN_IMAGE_SRC } from '../../constants/customTokens';
|
|
15
15
|
import { getContainer } from '../../utils/common';
|
|
16
|
+
import { createTokenExplorerUrl } from '../../utils/meta';
|
|
16
17
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
17
18
|
|
|
18
19
|
import { CUSTOM_TOKEN_LEARN_MORE_LINK } from './CustomTokenModal.constants';
|
|
19
|
-
import { generateExplorerLink } from './CustomTokenModal.helpers';
|
|
20
20
|
import {
|
|
21
21
|
Container,
|
|
22
22
|
FlexCenteredContainer,
|
|
@@ -29,7 +29,12 @@ const MAX_SYMBOL_LENGTH_THRESHOLD = 9;
|
|
|
29
29
|
export function CustomTokenModal(props: PropTypes) {
|
|
30
30
|
const { open, onClose, token, onExit, onSubmitClick, blockchain } = props;
|
|
31
31
|
|
|
32
|
-
const explorerLink =
|
|
32
|
+
const explorerLink = token.address
|
|
33
|
+
? createTokenExplorerUrl({
|
|
34
|
+
contractAddress: token.address,
|
|
35
|
+
blockchainMeta: blockchain,
|
|
36
|
+
})
|
|
37
|
+
: undefined;
|
|
33
38
|
|
|
34
39
|
const onClickLearnMore = () =>
|
|
35
40
|
window.open(CUSTOM_TOKEN_LEARN_MORE_LINK, '_blank');
|
|
@@ -25,7 +25,7 @@ import { useAppStore } from '../../store/AppStore';
|
|
|
25
25
|
import { useQuoteStore } from '../../store/quote';
|
|
26
26
|
import { createTintsAndShades } from '../../utils/colors';
|
|
27
27
|
import { getContainer } from '../../utils/common';
|
|
28
|
-
import { findBlockchain } from '../../utils/meta';
|
|
28
|
+
import { createTokenExplorerUrl, findBlockchain } from '../../utils/meta';
|
|
29
29
|
import { formatBalance } from '../../utils/wallets';
|
|
30
30
|
import { ImportCustomToken } from '../ImportCustomToken';
|
|
31
31
|
|
|
@@ -81,8 +81,7 @@ const renderDesc = (props: RenderDescProps) => {
|
|
|
81
81
|
<div
|
|
82
82
|
className={`${tokenAddressStyles()} ${
|
|
83
83
|
!name && tokenWithoutNameStyles()
|
|
84
|
-
}`}
|
|
85
|
-
>
|
|
84
|
+
}`}>
|
|
86
85
|
{length > 10
|
|
87
86
|
? `${address.slice(0, 5)}...${address.slice(length - 6, length)}`
|
|
88
87
|
: address}{' '}
|
|
@@ -91,8 +90,7 @@ const renderDesc = (props: RenderDescProps) => {
|
|
|
91
90
|
href={url}
|
|
92
91
|
target="_blank"
|
|
93
92
|
rel="nofollow noreferrer"
|
|
94
|
-
onClick={(e) => e.stopPropagation()}
|
|
95
|
-
>
|
|
93
|
+
onClick={(e) => e.stopPropagation()}>
|
|
96
94
|
<ExternalLinkIcon size={12} />
|
|
97
95
|
</StyledLink>
|
|
98
96
|
</div>
|
|
@@ -153,8 +151,7 @@ export function TokenList(props: PropTypes) {
|
|
|
153
151
|
type="primary"
|
|
154
152
|
size="small"
|
|
155
153
|
className="widget-token-list-item-import-btn"
|
|
156
|
-
onClick={handleClick}
|
|
157
|
-
>
|
|
154
|
+
onClick={handleClick}>
|
|
158
155
|
<Typography variant="body" size="xsmall" color="background">
|
|
159
156
|
{t('import')}
|
|
160
157
|
</Typography>
|
|
@@ -187,8 +184,7 @@ export function TokenList(props: PropTypes) {
|
|
|
187
184
|
<Typography
|
|
188
185
|
variant="body"
|
|
189
186
|
className={usdValueStyles()}
|
|
190
|
-
size="xsmall"
|
|
191
|
-
>
|
|
187
|
+
size="xsmall">
|
|
192
188
|
{`$${tokenBalance.usdValue}`}
|
|
193
189
|
</Typography>
|
|
194
190
|
)}
|
|
@@ -266,6 +262,13 @@ export function TokenList(props: PropTypes) {
|
|
|
266
262
|
}
|
|
267
263
|
};
|
|
268
264
|
|
|
265
|
+
const url = address
|
|
266
|
+
? createTokenExplorerUrl({
|
|
267
|
+
contractAddress: address,
|
|
268
|
+
blockchainMeta: blockchain,
|
|
269
|
+
})
|
|
270
|
+
: undefined;
|
|
271
|
+
|
|
269
272
|
return (
|
|
270
273
|
<ListItemContainer>
|
|
271
274
|
<StyledListItemButton
|
|
@@ -306,8 +309,7 @@ export function TokenList(props: PropTypes) {
|
|
|
306
309
|
<TagTitle
|
|
307
310
|
variant="body"
|
|
308
311
|
size="xsmall"
|
|
309
|
-
css={customCssForTagTitle}
|
|
310
|
-
>
|
|
312
|
+
css={customCssForTagTitle}>
|
|
311
313
|
{token.blockchain}
|
|
312
314
|
</TagTitle>
|
|
313
315
|
</Tag>
|
|
@@ -321,16 +323,17 @@ export function TokenList(props: PropTypes) {
|
|
|
321
323
|
) : undefined
|
|
322
324
|
}
|
|
323
325
|
description={
|
|
324
|
-
typeof token !== 'string' &&
|
|
326
|
+
typeof token !== 'string' &&
|
|
327
|
+
!!blockchain.info &&
|
|
328
|
+
!!address &&
|
|
329
|
+
!!url
|
|
325
330
|
? renderDesc({
|
|
326
331
|
address,
|
|
327
332
|
token,
|
|
328
333
|
customCssForTag,
|
|
329
334
|
customCssForTagTitle,
|
|
330
335
|
name: token.name,
|
|
331
|
-
url
|
|
332
|
-
.split('{wallet}')
|
|
333
|
-
.join(address),
|
|
336
|
+
url,
|
|
334
337
|
})
|
|
335
338
|
: token.name || undefined
|
|
336
339
|
}
|
package/src/utils/meta.ts
CHANGED
|
@@ -70,3 +70,16 @@ export function isValidTokenAddress(
|
|
|
70
70
|
const valid = regex.filter((r) => new RegExp(r).test(address)).length > 0;
|
|
71
71
|
return valid;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
export function createTokenExplorerUrl(params: {
|
|
75
|
+
contractAddress: string;
|
|
76
|
+
blockchainMeta: BlockchainMeta;
|
|
77
|
+
}): string | undefined {
|
|
78
|
+
const { contractAddress, blockchainMeta } = params;
|
|
79
|
+
|
|
80
|
+
if (blockchainMeta.info?.tokenUrl) {
|
|
81
|
+
return blockchainMeta.info.tokenUrl.replace('{address}', contractAddress);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return blockchainMeta.info?.addressUrl.replace('{wallet}', contractAddress);
|
|
85
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomTokenModal.helpers.d.ts","sourceRoot":"","sources":["../../../src/components/CustomTokenModal/CustomTokenModal.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,UAAU,EAAE,cAAc,GACzB,MAAM,CAQR"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { BlockchainMeta } from 'rango-types';
|
|
2
|
-
|
|
3
|
-
export function generateExplorerLink(
|
|
4
|
-
address: string | null,
|
|
5
|
-
blockchain: BlockchainMeta
|
|
6
|
-
): string {
|
|
7
|
-
const explorerLinkPattern = blockchain.info?.addressUrl;
|
|
8
|
-
|
|
9
|
-
if (!explorerLinkPattern || !address) {
|
|
10
|
-
return '';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return explorerLinkPattern.replace('{wallet}', address);
|
|
14
|
-
}
|