@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,143 +1,145 @@
1
- import { useWalletStore } from '@dodoex/wallet-web3';
2
- import { ArrowBack, Copy } from '@dodoex/icons';
3
- import { Trans } from '@lingui/macro';
4
- import React from 'react';
5
- import copy from 'copy-to-clipboard';
6
- import { QRCodeSVG } from 'qrcode.react';
7
- import { DialogTitle } from '../components/Dialog';
8
- import { Box, ButtonBase, Tooltip } from '@dodoex/components';
9
-
10
- export default function ReceiveTokenPage({
11
- onClose,
12
- onBack,
13
- }: {
14
- onClose: () => void;
15
- onBack: () => void;
16
- }) {
17
- const { account } = useWalletStore();
18
- const [showCopyTooltip, setShowCopyTooltip] = React.useState(false);
19
- const autoCloseShowCopyTooltip = React.useCallback(() => {
20
- const time = setTimeout(() => {
21
- setShowCopyTooltip(false);
22
- }, 1500);
23
-
24
- return () => {
25
- clearTimeout(time);
26
- };
27
- }, []);
28
-
29
- if (!account) return null;
30
-
31
- return (
32
- <>
33
- <DialogTitle onClose={onClose}>
34
- <ButtonBase
35
- onClick={onBack}
36
- sx={{
37
- display: 'flex',
38
- gap: 8,
39
- alignItems: 'center',
40
- typography: 'caption',
41
- }}
42
- >
43
- <Box
44
- component={ArrowBack}
45
- sx={{
46
- width: 16,
47
- height: 16,
48
- }}
49
- />
50
- <Trans>Receive</Trans>
51
- </ButtonBase>
52
- </DialogTitle>
53
- <Box
54
- sx={{
55
- display: 'flex',
56
- flexDirection: 'column',
57
- flex: 1,
58
- overflowY: 'auto',
59
- }}
60
- >
61
- <Box
62
- sx={{
63
- display: 'flex',
64
- flexDirection: 'column',
65
- justifyContent: 'space-between',
66
- alignItems: 'center',
67
- flex: 1,
68
- pt: 28,
69
- pb: 20,
70
- width: 326,
71
- mx: 'auto',
72
- }}
73
- >
74
- <Box>
75
- <Box
76
- sx={{
77
- p: 36,
78
- borderRadius: 12,
79
- border: 'solid 1px',
80
- borderColor: 'border.main',
81
- }}
82
- >
83
- <QRCodeSVG id="qrcode" size={252} value={account} level="M" />
84
- </Box>
85
- <Box
86
- sx={{
87
- mt: 12,
88
- color: 'text.secondary',
89
- wordBreak: 'break-all',
90
- textAlign: 'center',
91
- }}
92
- >
93
- {account}
94
- </Box>
95
- </Box>
96
- <Tooltip
97
- onlyClick
98
- arrow={false}
99
- title={<Trans>Copied</Trans>}
100
- open={showCopyTooltip}
101
- onOpen={() => {
102
- setShowCopyTooltip(true);
103
- autoCloseShowCopyTooltip();
104
- }}
105
- onClose={() => setShowCopyTooltip(false)}
106
- >
107
- <ButtonBase
108
- onClick={() => {
109
- copy(account);
110
- }}
111
- sx={{
112
- display: 'flex',
113
- alignItems: 'center',
114
- justifyContent: 'center',
115
- gap: 4,
116
- mt: 12,
117
- px: 16,
118
- py: 6,
119
- width: '100%',
120
- height: 48,
121
- fontWeight: 600,
122
- backgroundColor: 'background.paperDarkContrast',
123
- borderRadius: 8,
124
- '&:hover': {
125
- opacity: 0.7,
126
- },
127
- }}
128
- >
129
- <Box
130
- component={Copy}
131
- sx={{
132
- width: 18,
133
- height: 18,
134
- }}
135
- />
136
- <Trans>Copy wallet address</Trans>
137
- </ButtonBase>
138
- </Tooltip>
139
- </Box>
140
- </Box>
141
- </>
142
- );
143
- }
1
+ 'use client';
2
+
3
+ import { useWalletStore } from '@dodoex/wallet-web3';
4
+ import { ArrowBack, Copy } from '@dodoex/icons';
5
+ import { Trans } from '@lingui/macro';
6
+ import React from 'react';
7
+ import copy from 'copy-to-clipboard';
8
+ import { QRCodeSVG } from 'qrcode.react';
9
+ import { DialogTitle } from '../components/Dialog';
10
+ import { Box, ButtonBase, Tooltip } from '@dodoex/components';
11
+
12
+ export default function ReceiveTokenPage({
13
+ onClose,
14
+ onBack,
15
+ }: {
16
+ onClose: () => void;
17
+ onBack: () => void;
18
+ }) {
19
+ const { account } = useWalletStore();
20
+ const [showCopyTooltip, setShowCopyTooltip] = React.useState(false);
21
+ const autoCloseShowCopyTooltip = React.useCallback(() => {
22
+ const time = setTimeout(() => {
23
+ setShowCopyTooltip(false);
24
+ }, 1500);
25
+
26
+ return () => {
27
+ clearTimeout(time);
28
+ };
29
+ }, []);
30
+
31
+ if (!account) return null;
32
+
33
+ return (
34
+ <>
35
+ <DialogTitle onClose={onClose}>
36
+ <ButtonBase
37
+ onClick={onBack}
38
+ sx={{
39
+ display: 'flex',
40
+ gap: 8,
41
+ alignItems: 'center',
42
+ typography: 'caption',
43
+ }}
44
+ >
45
+ <Box
46
+ component={ArrowBack}
47
+ sx={{
48
+ width: 16,
49
+ height: 16,
50
+ }}
51
+ />
52
+ <Trans>Receive</Trans>
53
+ </ButtonBase>
54
+ </DialogTitle>
55
+ <Box
56
+ sx={{
57
+ display: 'flex',
58
+ flexDirection: 'column',
59
+ flex: 1,
60
+ overflowY: 'auto',
61
+ }}
62
+ >
63
+ <Box
64
+ sx={{
65
+ display: 'flex',
66
+ flexDirection: 'column',
67
+ justifyContent: 'space-between',
68
+ alignItems: 'center',
69
+ flex: 1,
70
+ pt: 28,
71
+ pb: 20,
72
+ width: 326,
73
+ mx: 'auto',
74
+ }}
75
+ >
76
+ <Box>
77
+ <Box
78
+ sx={{
79
+ p: 36,
80
+ borderRadius: 12,
81
+ border: 'solid 1px',
82
+ borderColor: 'border.main',
83
+ }}
84
+ >
85
+ <QRCodeSVG id="qrcode" size={252} value={account} level="M" />
86
+ </Box>
87
+ <Box
88
+ sx={{
89
+ mt: 12,
90
+ color: 'text.secondary',
91
+ wordBreak: 'break-all',
92
+ textAlign: 'center',
93
+ }}
94
+ >
95
+ {account}
96
+ </Box>
97
+ </Box>
98
+ <Tooltip
99
+ onlyClick
100
+ arrow={false}
101
+ title={<Trans>Copied</Trans>}
102
+ open={showCopyTooltip}
103
+ onOpen={() => {
104
+ setShowCopyTooltip(true);
105
+ autoCloseShowCopyTooltip();
106
+ }}
107
+ onClose={() => setShowCopyTooltip(false)}
108
+ >
109
+ <ButtonBase
110
+ onClick={() => {
111
+ copy(account);
112
+ }}
113
+ sx={{
114
+ display: 'flex',
115
+ alignItems: 'center',
116
+ justifyContent: 'center',
117
+ gap: 4,
118
+ mt: 12,
119
+ px: 16,
120
+ py: 6,
121
+ width: '100%',
122
+ height: 48,
123
+ fontWeight: 600,
124
+ backgroundColor: 'background.paperDarkContrast',
125
+ borderRadius: 8,
126
+ '&:hover': {
127
+ opacity: 0.7,
128
+ },
129
+ }}
130
+ >
131
+ <Box
132
+ component={Copy}
133
+ sx={{
134
+ width: 18,
135
+ height: 18,
136
+ }}
137
+ />
138
+ <Trans>Copy wallet address</Trans>
139
+ </ButtonBase>
140
+ </Tooltip>
141
+ </Box>
142
+ </Box>
143
+ </>
144
+ );
145
+ }