@dodoex/wallet-web3-react 0.2.1 → 0.3.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/babel.config.js +9 -9
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/lingui.config.ts +13 -13
- package/package.json +90 -77
- package/rollup.config.mjs +100 -100
- package/src/ClientProvider.tsx +17 -15
- package/src/LangProvider.tsx +36 -34
- package/src/WalletConnect/AccountPage.tsx +496 -494
- package/src/WalletConnect/ActivityList.tsx +606 -604
- package/src/WalletConnect/ConnectAlchemy/index.tsx +248 -246
- package/src/WalletConnect/ConnectAlchemy/useConnectAlchemy.ts +105 -105
- package/src/WalletConnect/ConnectDialog.tsx +35 -33
- package/src/WalletConnect/ConnectLedger/ErrorDialog.tsx +61 -61
- package/src/WalletConnect/ConnectLedger/LockedDialog.tsx +54 -54
- package/src/WalletConnect/ConnectLedger/helper.ts +14 -14
- package/src/WalletConnect/ConnectLedger/index.tsx +2 -0
- package/src/WalletConnect/ConnectPage.tsx +508 -506
- package/src/WalletConnect/HasBalanceTokenList.tsx +202 -200
- package/src/WalletConnect/ReceiveTokenPage.tsx +145 -143
- package/src/WalletConnect/SendTokenPage.tsx +251 -249
- package/src/WalletConnect/WalletDialog.tsx +80 -78
- package/src/WalletConnectProvider.tsx +57 -55
- package/src/components/AddressWithLinkAndCopy.tsx +202 -200
- package/src/components/Dialog.tsx +158 -156
- package/src/components/TokenLogo.tsx +167 -165
- package/src/components/WalletTag.tsx +117 -115
- package/src/constants/localstorage.ts +24 -22
- package/src/hooks/useConnectWallet.ts +150 -148
- package/src/hooks/useFetchFiatPrice.ts +53 -51
- package/src/hooks/useFetchTokensBalance.ts +53 -51
- package/src/hooks/useHasBalanceTokenList.ts +95 -93
- package/src/hooks/useTransactionList.ts +89 -87
- package/src/index.tsx +7 -7
- package/src/locales/en.po +51 -51
- package/src/locales/zh.po +51 -51
- package/src/utils/formatter.ts +102 -102
- package/src/utils/time.ts +21 -21
- package/src/utils/utils.ts +8 -8
- package/tsconfig.json +23 -23
|
@@ -1,200 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
balanceListData
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
EmptyDataIcon,
|
|
6
|
+
LoadingSkeleton,
|
|
7
|
+
Skeleton,
|
|
8
|
+
TooltipToast,
|
|
9
|
+
useTheme,
|
|
10
|
+
} from '@dodoex/components';
|
|
11
|
+
import { Trans } from '@lingui/macro';
|
|
12
|
+
import { ArrowTopRightBorder, Copy } from '@dodoex/icons';
|
|
13
|
+
import copy from 'copy-to-clipboard';
|
|
14
|
+
import { increaseArray } from '../utils/utils';
|
|
15
|
+
import { useWalletConnectContext } from '../WalletConnectProvider';
|
|
16
|
+
import TokenLogo from '../components/TokenLogo';
|
|
17
|
+
import { formatReadableNumber, formatShortNumber } from '../utils/formatter';
|
|
18
|
+
import { useHasBalanceTokenList } from '../hooks/useHasBalanceTokenList';
|
|
19
|
+
|
|
20
|
+
export default function HasBalanceTokenList({
|
|
21
|
+
balanceListData,
|
|
22
|
+
}: {
|
|
23
|
+
balanceListData: ReturnType<typeof useHasBalanceTokenList>;
|
|
24
|
+
}) {
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const { onClickToken, getChain } = useWalletConnectContext();
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
{balanceListData.tokenLoading &&
|
|
30
|
+
increaseArray(3).map((_, i) => (
|
|
31
|
+
<Skeleton
|
|
32
|
+
key={i}
|
|
33
|
+
height={40}
|
|
34
|
+
sx={{
|
|
35
|
+
mx: 20,
|
|
36
|
+
my: 16,
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
{!balanceListData.tokenLoading && !balanceListData.hasBalanceList.length && (
|
|
41
|
+
<Box
|
|
42
|
+
sx={{
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
gap: 12,
|
|
47
|
+
mt: 56,
|
|
48
|
+
color: 'text.secondary',
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<EmptyDataIcon />
|
|
52
|
+
<Trans>No tokens</Trans>
|
|
53
|
+
</Box>
|
|
54
|
+
)}
|
|
55
|
+
{balanceListData.hasBalanceList.map((token) => {
|
|
56
|
+
return (
|
|
57
|
+
<Box
|
|
58
|
+
key={token.address}
|
|
59
|
+
sx={{
|
|
60
|
+
display: 'flex',
|
|
61
|
+
justifyContent: 'space-between',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
gap: 12,
|
|
64
|
+
px: 20,
|
|
65
|
+
py: 16,
|
|
66
|
+
overflow: 'hidden',
|
|
67
|
+
...(onClickToken
|
|
68
|
+
? {
|
|
69
|
+
cursor: 'pointer',
|
|
70
|
+
'&:hover': {
|
|
71
|
+
backgroundColor: 'hover.default',
|
|
72
|
+
'& .token-operate': {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
: {}),
|
|
78
|
+
}}
|
|
79
|
+
onClick={() => {
|
|
80
|
+
if (onClickToken) {
|
|
81
|
+
onClickToken(token);
|
|
82
|
+
}
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<Box
|
|
86
|
+
sx={{
|
|
87
|
+
display: 'flex',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
gap: 12,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<TokenLogo
|
|
93
|
+
address={token.address}
|
|
94
|
+
chainId={token.chainId}
|
|
95
|
+
logoURI={token.logoURI}
|
|
96
|
+
width={40}
|
|
97
|
+
height={40}
|
|
98
|
+
/>
|
|
99
|
+
<div>
|
|
100
|
+
<Box
|
|
101
|
+
sx={{
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
gap: 4,
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{token.name}
|
|
108
|
+
<Box
|
|
109
|
+
className="token-operate"
|
|
110
|
+
sx={{
|
|
111
|
+
display: 'flex',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
gap: 4,
|
|
114
|
+
[theme.breakpoints.up('tablet')]: {
|
|
115
|
+
display: 'none',
|
|
116
|
+
},
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
<TooltipToast arrow={false} title={<Trans>Copied</Trans>}>
|
|
120
|
+
<Box
|
|
121
|
+
component={Copy}
|
|
122
|
+
sx={{
|
|
123
|
+
width: 14,
|
|
124
|
+
height: 14,
|
|
125
|
+
cursor: 'pointer',
|
|
126
|
+
color: 'text.secondary',
|
|
127
|
+
'&:hover': {
|
|
128
|
+
color: 'text.primary',
|
|
129
|
+
},
|
|
130
|
+
}}
|
|
131
|
+
onClick={() => {
|
|
132
|
+
copy(token.address);
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
</TooltipToast>
|
|
136
|
+
<Box
|
|
137
|
+
component="a"
|
|
138
|
+
href={`https://${getChain(token.chainId)?.scanUrl}${
|
|
139
|
+
token.address ? `/address/${token.address}` : ''
|
|
140
|
+
}`}
|
|
141
|
+
rel="noopener noreferrer"
|
|
142
|
+
target="_blank"
|
|
143
|
+
sx={{
|
|
144
|
+
display: 'flex',
|
|
145
|
+
width: 14,
|
|
146
|
+
height: 14,
|
|
147
|
+
color: 'text.secondary',
|
|
148
|
+
'&:hover': {
|
|
149
|
+
color: 'text.primary',
|
|
150
|
+
},
|
|
151
|
+
}}
|
|
152
|
+
onClick={(evt) => {
|
|
153
|
+
evt.stopPropagation();
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<Box
|
|
157
|
+
component={ArrowTopRightBorder}
|
|
158
|
+
sx={{
|
|
159
|
+
width: 14,
|
|
160
|
+
height: 14,
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
</Box>
|
|
164
|
+
</Box>
|
|
165
|
+
</Box>
|
|
166
|
+
<div className="text-sm text-secondary">
|
|
167
|
+
{`${formatReadableNumber({ input: token.balance })} ${
|
|
168
|
+
token.symbol
|
|
169
|
+
}`}
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</Box>
|
|
173
|
+
<LoadingSkeleton
|
|
174
|
+
loading={balanceListData.fiatPriceQuery.isLoading}
|
|
175
|
+
loadingProps={{
|
|
176
|
+
width: 100,
|
|
177
|
+
}}
|
|
178
|
+
title={
|
|
179
|
+
token.fiatPriceBalance
|
|
180
|
+
? `$${formatReadableNumber({
|
|
181
|
+
input: token.fiatPriceBalance,
|
|
182
|
+
})}`
|
|
183
|
+
: undefined
|
|
184
|
+
}
|
|
185
|
+
sx={{
|
|
186
|
+
overflow: 'hidden',
|
|
187
|
+
textOverflow: 'ellipsis',
|
|
188
|
+
whiteSpace: 'nowrap',
|
|
189
|
+
typography: 'h5',
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
$
|
|
193
|
+
{token.fiatPriceBalance
|
|
194
|
+
? formatShortNumber(token.fiatPriceBalance)
|
|
195
|
+
: '-'}
|
|
196
|
+
</LoadingSkeleton>
|
|
197
|
+
</Box>
|
|
198
|
+
);
|
|
199
|
+
})}
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
}
|