@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,246 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
+
}
|