@dodoex/wallet-web3-react 0.4.0 → 0.4.2

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 (68) hide show
  1. package/babel.config.js +9 -9
  2. package/dist/cjs/index.cjs +4 -13
  3. package/dist/cjs/locales/en.js +1 -1
  4. package/dist/cjs/locales/zh.js +1 -1
  5. package/dist/index.js +4 -13
  6. package/dist/locales/en.js +1 -1
  7. package/dist/locales/zh.js +1 -1
  8. package/dist/types/ClientProvider.d.ts +1 -1
  9. package/dist/types/LangProvider.d.ts +1 -1
  10. package/dist/types/WalletConnect/AccountPage.d.ts +1 -1
  11. package/dist/types/WalletConnect/ActivityList.d.ts +5 -4
  12. package/dist/types/WalletConnect/ConnectAlchemy/index.d.ts +2 -1
  13. package/dist/types/WalletConnect/ConnectDialog.d.ts +2 -1
  14. package/dist/types/WalletConnect/ConnectLedger/ErrorDialog.d.ts +1 -1
  15. package/dist/types/WalletConnect/ConnectLedger/LoadingDialog.d.ts +1 -1
  16. package/dist/types/WalletConnect/ConnectLedger/LockedDialog.d.ts +1 -1
  17. package/dist/types/WalletConnect/ConnectLedger/ProtocolDialog.d.ts +1 -1
  18. package/dist/types/WalletConnect/ConnectLedger/SelectAddressDialog.d.ts +1 -1
  19. package/dist/types/WalletConnect/ConnectLedger/SelectPathDialog.d.ts +1 -1
  20. package/dist/types/WalletConnect/ConnectLedger/index.d.ts +1 -1
  21. package/dist/types/WalletConnect/ConnectPage.d.ts +1 -1
  22. package/dist/types/WalletConnect/HasBalanceTokenList.d.ts +1 -1
  23. package/dist/types/WalletConnect/ReceiveTokenPage.d.ts +2 -1
  24. package/dist/types/WalletConnect/SendTokenPage.d.ts +2 -1
  25. package/dist/types/WalletConnect/WalletDialog.d.ts +2 -1
  26. package/dist/types/WalletConnectProvider.d.ts +2 -2
  27. package/dist/types/components/AddressWithLinkAndCopy.d.ts +2 -2
  28. package/dist/types/components/Dialog.d.ts +3 -3
  29. package/dist/types/components/WalletTag.d.ts +1 -1
  30. package/lingui.config.ts +13 -13
  31. package/package.json +90 -90
  32. package/rollup.config.mjs +106 -103
  33. package/src/ClientProvider.tsx +17 -17
  34. package/src/LangProvider.tsx +36 -36
  35. package/src/WalletConnect/AccountPage.tsx +498 -498
  36. package/src/WalletConnect/ActivityList.tsx +606 -606
  37. package/src/WalletConnect/ConnectAlchemy/index.tsx +248 -248
  38. package/src/WalletConnect/ConnectAlchemy/useConnectAlchemy.ts +105 -105
  39. package/src/WalletConnect/ConnectDialog.tsx +35 -35
  40. package/src/WalletConnect/ConnectLedger/ErrorDialog.tsx +61 -61
  41. package/src/WalletConnect/ConnectLedger/LockedDialog.tsx +54 -54
  42. package/src/WalletConnect/ConnectLedger/helper.ts +14 -14
  43. package/src/WalletConnect/ConnectPage.tsx +508 -508
  44. package/src/WalletConnect/HasBalanceTokenList.tsx +202 -202
  45. package/src/WalletConnect/ReceiveTokenPage.tsx +145 -145
  46. package/src/WalletConnect/SendTokenPage.tsx +251 -251
  47. package/src/WalletConnect/WalletDialog.tsx +80 -80
  48. package/src/WalletConnectProvider.tsx +57 -57
  49. package/src/components/AddressWithLinkAndCopy.tsx +202 -202
  50. package/src/components/Dialog.tsx +158 -158
  51. package/src/components/TokenLogo.tsx +167 -167
  52. package/src/components/WalletTag.tsx +117 -117
  53. package/src/constants/localstorage.ts +24 -24
  54. package/src/hooks/useConnectWallet.ts +150 -150
  55. package/src/hooks/useFetchFiatPrice.ts +53 -53
  56. package/src/hooks/useFetchTokensBalance.ts +53 -53
  57. package/src/hooks/useHasBalanceTokenList.ts +95 -95
  58. package/src/hooks/useTransactionList.ts +89 -89
  59. package/src/index.tsx +7 -7
  60. package/src/locales/en.js +1 -1
  61. package/src/locales/en.po +8 -8
  62. package/src/locales/zh.js +1 -1
  63. package/src/locales/zh.po +4 -4
  64. package/src/react19-types.d.ts +12 -0
  65. package/src/utils/formatter.ts +102 -102
  66. package/src/utils/time.ts +21 -21
  67. package/src/utils/utils.ts +8 -8
  68. package/tsconfig.json +22 -22
@@ -1,202 +1,202 @@
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
- }
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
+ }