@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,248 +1,248 @@
1
- 'use client';
2
-
3
- import { Button, Input, Box, ButtonBase } from '@dodoex/components';
4
- import WalletWeb3 from '@dodoex/wallet-web3';
5
- import React from 'react';
6
- import {
7
- alchemyWallet,
8
- useConnectAlchemy,
9
- useConnectAlchemyQuery,
10
- USERNAME_PREFIX,
11
- } from './useConnectAlchemy';
12
- import { t, Trans } from '@lingui/macro';
13
- import { ArrowRight } from '@dodoex/icons';
14
- import { validateEmail } from '../../utils/utils';
15
- import Dialog, { DialogTitle } from '../../components/Dialog';
16
-
17
- export default function ConnectAlchemy({
18
- open,
19
- walletWeb3,
20
- setOpen,
21
- }: {
22
- open: boolean;
23
- walletWeb3: WalletWeb3;
24
- setOpen: (open: boolean) => void;
25
- }) {
26
- const [email, setEmail] = React.useState('');
27
- const invalidEmail = !!email && !validateEmail(email);
28
- const onClose = () => setOpen(false);
29
-
30
- useConnectAlchemyQuery({
31
- walletWeb3,
32
- showAlchemyConnect: () => setOpen(true),
33
- });
34
- const connectMutation = useConnectAlchemy({
35
- walletWeb3,
36
- });
37
-
38
- return (
39
- <Dialog open={open} onClose={onClose}>
40
- <DialogTitle
41
- sx={{
42
- p: 20,
43
- borderWidth: '0 0 1px',
44
- borderStyle: 'solid',
45
- borderColor: 'border.main',
46
- }}
47
- >
48
- <Trans>Connect Alchemy</Trans>
49
- </DialogTitle>
50
- <Box
51
- sx={{
52
- p: 20,
53
- }}
54
- >
55
- <Box
56
- component="img"
57
- src={alchemyWallet.logo}
58
- sx={{
59
- display: 'block',
60
- mx: 'auto',
61
- width: 40,
62
- height: 40,
63
- }}
64
- />
65
- {connectMutation.variables?.type === 'email' &&
66
- (connectMutation.isSuccess || connectMutation.isPending) ? (
67
- <>
68
- <Box
69
- sx={{
70
- mt: 20,
71
- textAlign: 'center',
72
- typography: 'caption',
73
- }}
74
- >
75
- <Trans>Log in with your email</Trans>
76
- </Box>
77
- <Box
78
- sx={{
79
- mt: 12,
80
- mx: 'auto',
81
- maxWidth: 300,
82
- textAlign: 'center',
83
- color: 'text.secondary',
84
- typography: 'body2',
85
- }}
86
- >
87
- <Trans>
88
- Check your email and click the link to complete login
89
- </Trans>
90
- </Box>
91
- <ButtonBase
92
- sx={{
93
- display: 'flex',
94
- justifyContent: 'center',
95
- alignItems: 'center',
96
- mt: 20,
97
- mx: 'auto',
98
- typography: 'body2',
99
- '&:hover': {
100
- color: 'text.secondary',
101
- },
102
- }}
103
- onClick={() => {
104
- connectMutation.reset();
105
- }}
106
- >
107
- <Trans>Go Back</Trans>
108
- <Box
109
- component={ArrowRight}
110
- sx={{
111
- width: 18,
112
- height: 18,
113
- }}
114
- />
115
- </ButtonBase>
116
- </>
117
- ) : (
118
- <>
119
- <Box
120
- sx={{
121
- mt: 20,
122
- mx: 'auto',
123
- textAlign: 'center',
124
- maxWidth: 300,
125
- typography: 'caption',
126
- }}
127
- >
128
- <Trans>Log in with your email or a passkey</Trans>
129
- </Box>
130
- <Input
131
- placeholder={t`Enter email`}
132
- fullWidth
133
- height={48}
134
- errorMsg={invalidEmail ? t`Invalid email` : undefined}
135
- value={email}
136
- onChange={(evt) => setEmail(evt.target.value)}
137
- sx={{
138
- mt: 20,
139
- }}
140
- />
141
- <Button
142
- fullWidth
143
- disabled={!email || invalidEmail}
144
- sx={{
145
- mt: 12,
146
- }}
147
- isLoading={
148
- connectMutation.variables?.type === 'email' &&
149
- connectMutation.isPending
150
- }
151
- onClick={() => {
152
- connectMutation.mutate({
153
- type: 'email',
154
- email,
155
- });
156
- }}
157
- >
158
- <Trans>Submit</Trans>
159
- </Button>
160
-
161
- <Box
162
- sx={{
163
- position: 'relative',
164
- mt: 20,
165
- textAlign: 'center',
166
- '&::before': {
167
- content: '""',
168
- display: 'block',
169
- position: 'absolute',
170
- top: '50%',
171
- left: 0,
172
- right: 0,
173
- transform: 'translateY(-50%)',
174
- height: '1px',
175
- backgroundColor: 'border.main',
176
- },
177
- }}
178
- >
179
- <Box
180
- component="span"
181
- sx={{
182
- px: 8,
183
- backgroundColor: 'background.paper',
184
- color: 'text.secondary',
185
- position: 'relative',
186
- zIndex: 1,
187
- }}
188
- >
189
- <Trans>or</Trans>
190
- </Box>
191
- </Box>
192
- <Button
193
- fullWidth
194
- variant={Button.Variant.outlined}
195
- sx={{
196
- mt: 20,
197
- }}
198
- onClick={async () => {
199
- await connectMutation.mutateAsync({
200
- type: 'passkey',
201
- createNew: true,
202
- username: `${USERNAME_PREFIX}_${Date.now()}`,
203
- });
204
- if (!connectMutation.isError) {
205
- onClose();
206
- }
207
- }}
208
- >
209
- <Trans>Create new passkey</Trans>
210
- </Button>
211
- <ButtonBase
212
- sx={{
213
- display: 'flex',
214
- justifyContent: 'center',
215
- alignItems: 'center',
216
- mt: 12,
217
- mx: 'auto',
218
- py: 8,
219
- typography: 'body2',
220
- '&:hover': {
221
- color: 'text.secondary',
222
- },
223
- }}
224
- onClick={async () => {
225
- await connectMutation.mutateAsync({
226
- type: 'passkey',
227
- createNew: false,
228
- });
229
- if (!connectMutation.isError) {
230
- onClose();
231
- }
232
- }}
233
- >
234
- <Trans>Choose existing passkey</Trans>
235
- <Box
236
- component={ArrowRight}
237
- sx={{
238
- width: 18,
239
- height: 18,
240
- }}
241
- />
242
- </ButtonBase>
243
- </>
244
- )}
245
- </Box>
246
- </Dialog>
247
- );
248
- }
1
+ 'use client';
2
+
3
+ import { Button, Input, Box, ButtonBase } from '@dodoex/components';
4
+ import WalletWeb3 from '@dodoex/wallet-web3';
5
+ import React from 'react';
6
+ import {
7
+ alchemyWallet,
8
+ useConnectAlchemy,
9
+ useConnectAlchemyQuery,
10
+ USERNAME_PREFIX,
11
+ } from './useConnectAlchemy';
12
+ import { t, Trans } from '@lingui/macro';
13
+ import { ArrowRight } from '@dodoex/icons';
14
+ import { validateEmail } from '../../utils/utils';
15
+ import Dialog, { DialogTitle } from '../../components/Dialog';
16
+
17
+ export default function ConnectAlchemy({
18
+ open,
19
+ walletWeb3,
20
+ setOpen,
21
+ }: {
22
+ open: boolean;
23
+ walletWeb3: WalletWeb3;
24
+ setOpen: (open: boolean) => void;
25
+ }) {
26
+ const [email, setEmail] = React.useState('');
27
+ const invalidEmail = !!email && !validateEmail(email);
28
+ const onClose = () => setOpen(false);
29
+
30
+ useConnectAlchemyQuery({
31
+ walletWeb3,
32
+ showAlchemyConnect: () => setOpen(true),
33
+ });
34
+ const connectMutation = useConnectAlchemy({
35
+ walletWeb3,
36
+ });
37
+
38
+ return (
39
+ <Dialog open={open} onClose={onClose}>
40
+ <DialogTitle
41
+ sx={{
42
+ p: 20,
43
+ borderWidth: '0 0 1px',
44
+ borderStyle: 'solid',
45
+ borderColor: 'border.main',
46
+ }}
47
+ >
48
+ <Trans>Connect Alchemy</Trans>
49
+ </DialogTitle>
50
+ <Box
51
+ sx={{
52
+ p: 20,
53
+ }}
54
+ >
55
+ <Box
56
+ component="img"
57
+ src={alchemyWallet.logo}
58
+ sx={{
59
+ display: 'block',
60
+ mx: 'auto',
61
+ width: 40,
62
+ height: 40,
63
+ }}
64
+ />
65
+ {connectMutation.variables?.type === 'email' &&
66
+ (connectMutation.isSuccess || connectMutation.isPending) ? (
67
+ <>
68
+ <Box
69
+ sx={{
70
+ mt: 20,
71
+ textAlign: 'center',
72
+ typography: 'caption',
73
+ }}
74
+ >
75
+ <Trans>Log in with your email</Trans>
76
+ </Box>
77
+ <Box
78
+ sx={{
79
+ mt: 12,
80
+ mx: 'auto',
81
+ maxWidth: 300,
82
+ textAlign: 'center',
83
+ color: 'text.secondary',
84
+ typography: 'body2',
85
+ }}
86
+ >
87
+ <Trans>
88
+ Check your email and click the link to complete login
89
+ </Trans>
90
+ </Box>
91
+ <ButtonBase
92
+ sx={{
93
+ display: 'flex',
94
+ justifyContent: 'center',
95
+ alignItems: 'center',
96
+ mt: 20,
97
+ mx: 'auto',
98
+ typography: 'body2',
99
+ '&:hover': {
100
+ color: 'text.secondary',
101
+ },
102
+ }}
103
+ onClick={() => {
104
+ connectMutation.reset();
105
+ }}
106
+ >
107
+ <Trans>Go Back</Trans>
108
+ <Box
109
+ component={ArrowRight}
110
+ sx={{
111
+ width: 18,
112
+ height: 18,
113
+ }}
114
+ />
115
+ </ButtonBase>
116
+ </>
117
+ ) : (
118
+ <>
119
+ <Box
120
+ sx={{
121
+ mt: 20,
122
+ mx: 'auto',
123
+ textAlign: 'center',
124
+ maxWidth: 300,
125
+ typography: 'caption',
126
+ }}
127
+ >
128
+ <Trans>Log in with your email or a passkey</Trans>
129
+ </Box>
130
+ <Input
131
+ placeholder={t`Enter email`}
132
+ fullWidth
133
+ height={48}
134
+ errorMsg={invalidEmail ? t`Invalid email` : undefined}
135
+ value={email}
136
+ onChange={(evt) => setEmail(evt.target.value)}
137
+ sx={{
138
+ mt: 20,
139
+ }}
140
+ />
141
+ <Button
142
+ fullWidth
143
+ disabled={!email || invalidEmail}
144
+ sx={{
145
+ mt: 12,
146
+ }}
147
+ isLoading={
148
+ connectMutation.variables?.type === 'email' &&
149
+ connectMutation.isPending
150
+ }
151
+ onClick={() => {
152
+ connectMutation.mutate({
153
+ type: 'email',
154
+ email,
155
+ });
156
+ }}
157
+ >
158
+ <Trans>Submit</Trans>
159
+ </Button>
160
+
161
+ <Box
162
+ sx={{
163
+ position: 'relative',
164
+ mt: 20,
165
+ textAlign: 'center',
166
+ '&::before': {
167
+ content: '""',
168
+ display: 'block',
169
+ position: 'absolute',
170
+ top: '50%',
171
+ left: 0,
172
+ right: 0,
173
+ transform: 'translateY(-50%)',
174
+ height: '1px',
175
+ backgroundColor: 'border.main',
176
+ },
177
+ }}
178
+ >
179
+ <Box
180
+ component="span"
181
+ sx={{
182
+ px: 8,
183
+ backgroundColor: 'background.paper',
184
+ color: 'text.secondary',
185
+ position: 'relative',
186
+ zIndex: 1,
187
+ }}
188
+ >
189
+ <Trans>or</Trans>
190
+ </Box>
191
+ </Box>
192
+ <Button
193
+ fullWidth
194
+ variant={Button.Variant.outlined}
195
+ sx={{
196
+ mt: 20,
197
+ }}
198
+ onClick={async () => {
199
+ await connectMutation.mutateAsync({
200
+ type: 'passkey',
201
+ createNew: true,
202
+ username: `${USERNAME_PREFIX}_${Date.now()}`,
203
+ });
204
+ if (!connectMutation.isError) {
205
+ onClose();
206
+ }
207
+ }}
208
+ >
209
+ <Trans>Create new passkey</Trans>
210
+ </Button>
211
+ <ButtonBase
212
+ sx={{
213
+ display: 'flex',
214
+ justifyContent: 'center',
215
+ alignItems: 'center',
216
+ mt: 12,
217
+ mx: 'auto',
218
+ py: 8,
219
+ typography: 'body2',
220
+ '&:hover': {
221
+ color: 'text.secondary',
222
+ },
223
+ }}
224
+ onClick={async () => {
225
+ await connectMutation.mutateAsync({
226
+ type: 'passkey',
227
+ createNew: false,
228
+ });
229
+ if (!connectMutation.isError) {
230
+ onClose();
231
+ }
232
+ }}
233
+ >
234
+ <Trans>Choose existing passkey</Trans>
235
+ <Box
236
+ component={ArrowRight}
237
+ sx={{
238
+ width: 18,
239
+ height: 18,
240
+ }}
241
+ />
242
+ </ButtonBase>
243
+ </>
244
+ )}
245
+ </Box>
246
+ </Dialog>
247
+ );
248
+ }