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