@dodoex/wallet-web3-react 0.0.1-beta.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 -0
- package/dist/index.js +72 -0
- package/dist/types/ClientProvider.d.ts +2 -0
- package/dist/types/LangProvider.d.ts +11 -0
- package/dist/types/WalletConnect/AccountPage.d.ts +11 -0
- package/dist/types/WalletConnect/ActivityList.d.ts +20 -0
- package/dist/types/WalletConnect/ConnectAlchemy/index.d.ts +6 -0
- package/dist/types/WalletConnect/ConnectAlchemy/useConnectAlchemy.d.ts +12 -0
- package/dist/types/WalletConnect/ConnectLedger/ErrorDialog.d.ts +4 -0
- package/dist/types/WalletConnect/ConnectLedger/LoadingDialog.d.ts +3 -0
- package/dist/types/WalletConnect/ConnectLedger/LockedDialog.d.ts +4 -0
- package/dist/types/WalletConnect/ConnectLedger/ProtocolDialog.d.ts +6 -0
- package/dist/types/WalletConnect/ConnectLedger/SelectAddressDialog.d.ts +8 -0
- package/dist/types/WalletConnect/ConnectLedger/SelectPathDialog.d.ts +5 -0
- package/dist/types/WalletConnect/ConnectLedger/helper.d.ts +2 -0
- package/dist/types/WalletConnect/ConnectLedger/index.d.ts +6 -0
- package/dist/types/WalletConnect/ConnectPage.d.ts +9 -0
- package/dist/types/WalletConnect/HasBalanceTokenList.d.ts +4 -0
- package/dist/types/WalletConnect/ReceiveTokenPage.d.ts +4 -0
- package/dist/types/WalletConnect/SendTokenPage.d.ts +5 -0
- package/dist/types/WalletConnect/WalletDialog.d.ts +6 -0
- package/dist/types/WalletConnectProvider.d.ts +72 -0
- package/dist/types/components/AddressWithLinkAndCopy.d.ts +28 -0
- package/dist/types/components/Dialog.d.ts +15 -0
- package/dist/types/components/TokenLogo.d.ts +26 -0
- package/dist/types/components/WalletTag.d.ts +7 -0
- package/dist/types/constants/localstorage.d.ts +6 -0
- package/dist/types/hooks/useConnectWalet.d.ts +30 -0
- package/dist/types/hooks/useFetchFiatPrice.d.ts +3 -0
- package/dist/types/hooks/useFetchTokensBalance.d.ts +14 -0
- package/dist/types/hooks/useHasBalanceTokenList.d.ts +21 -0
- package/dist/types/hooks/useTransactionList.d.ts +272 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/utils/formatter.d.ts +20 -0
- package/dist/types/utils/time.d.ts +3 -0
- package/dist/types/utils/utils.d.ts +2 -0
- package/lingui.config.ts +13 -0
- package/locales/en.po +251 -0
- package/locales/en.ts +1 -0
- package/locales/zh.po +249 -0
- package/locales/zh.ts +1 -0
- package/package.json +68 -0
- package/rollup.config.mjs +64 -0
- package/src/ClientProvider.tsx +15 -0
- package/src/LangProvider.tsx +32 -0
- package/src/WalletConnect/AccountPage.tsx +535 -0
- package/src/WalletConnect/ActivityList.tsx +597 -0
- package/src/WalletConnect/ConnectAlchemy/index.tsx +246 -0
- package/src/WalletConnect/ConnectAlchemy/useConnectAlchemy.ts +101 -0
- package/src/WalletConnect/ConnectLedger/ErrorDialog.tsx +61 -0
- package/src/WalletConnect/ConnectLedger/LoadingDialog.tsx +106 -0
- package/src/WalletConnect/ConnectLedger/LockedDialog.tsx +54 -0
- package/src/WalletConnect/ConnectLedger/ProtocolDialog.tsx +61 -0
- package/src/WalletConnect/ConnectLedger/SelectAddressDialog.tsx +326 -0
- package/src/WalletConnect/ConnectLedger/SelectPathDialog.tsx +68 -0
- package/src/WalletConnect/ConnectLedger/helper.ts +14 -0
- package/src/WalletConnect/ConnectLedger/index.tsx +89 -0
- package/src/WalletConnect/ConnectPage.tsx +459 -0
- package/src/WalletConnect/HasBalanceTokenList.tsx +201 -0
- package/src/WalletConnect/ReceiveTokenPage.tsx +143 -0
- package/src/WalletConnect/SendTokenPage.tsx +249 -0
- package/src/WalletConnect/WalletDialog.tsx +72 -0
- package/src/WalletConnectProvider.tsx +54 -0
- package/src/components/AddressWithLinkAndCopy.tsx +200 -0
- package/src/components/Dialog.tsx +155 -0
- package/src/components/TokenLogo.tsx +165 -0
- package/src/components/WalletTag.tsx +113 -0
- package/src/constants/localstorage.ts +22 -0
- package/src/hooks/useConnectWalet.ts +144 -0
- package/src/hooks/useFetchFiatPrice.ts +51 -0
- package/src/hooks/useFetchTokensBalance.ts +52 -0
- package/src/hooks/useHasBalanceTokenList.ts +157 -0
- package/src/hooks/useTransactionList.ts +87 -0
- package/src/index.tsx +4 -0
- package/src/utils/formatter.ts +102 -0
- package/src/utils/time.ts +21 -0
- package/src/utils/utils.ts +8 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Button, Input, Box, ButtonBase } from '@dodoex/components';
|
|
2
|
+
import WalletWeb3 from '@dodoex/wallet-web3';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import {
|
|
5
|
+
alchemyWallet,
|
|
6
|
+
useConnectAlchemy,
|
|
7
|
+
useConnectAlchemyQuery,
|
|
8
|
+
USERNAME_PREFIX,
|
|
9
|
+
} from './useConnectAlchemy';
|
|
10
|
+
import { t, Trans } from '@lingui/macro';
|
|
11
|
+
import { ArrowRight } from '@dodoex/icons';
|
|
12
|
+
import { validateEmail } from '../../utils/utils';
|
|
13
|
+
import Dialog, { DialogTitle } from '../../components/Dialog';
|
|
14
|
+
|
|
15
|
+
export default function ConnectAlchemy({
|
|
16
|
+
open,
|
|
17
|
+
walletWeb3,
|
|
18
|
+
setOpen,
|
|
19
|
+
}: {
|
|
20
|
+
open: boolean;
|
|
21
|
+
walletWeb3: WalletWeb3;
|
|
22
|
+
setOpen: (open: boolean) => void;
|
|
23
|
+
}) {
|
|
24
|
+
const [email, setEmail] = React.useState('');
|
|
25
|
+
const invalidEmail = !!email && !validateEmail(email);
|
|
26
|
+
const onClose = () => setOpen(false);
|
|
27
|
+
|
|
28
|
+
useConnectAlchemyQuery({
|
|
29
|
+
walletWeb3,
|
|
30
|
+
showAlchemyConnect: () => setOpen(true),
|
|
31
|
+
});
|
|
32
|
+
const connectMutation = useConnectAlchemy({
|
|
33
|
+
walletWeb3,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Dialog open={open} onClose={onClose}>
|
|
38
|
+
<DialogTitle
|
|
39
|
+
sx={{
|
|
40
|
+
p: 20,
|
|
41
|
+
borderWidth: '0 0 1px',
|
|
42
|
+
borderStyle: 'solid',
|
|
43
|
+
borderColor: 'border.main',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Trans>Connect Alchemy</Trans>
|
|
47
|
+
</DialogTitle>
|
|
48
|
+
<Box
|
|
49
|
+
sx={{
|
|
50
|
+
p: 20,
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<Box
|
|
54
|
+
component="img"
|
|
55
|
+
src={alchemyWallet.logo}
|
|
56
|
+
sx={{
|
|
57
|
+
display: 'block',
|
|
58
|
+
mx: 'auto',
|
|
59
|
+
width: 40,
|
|
60
|
+
height: 40,
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
{connectMutation.variables?.type === 'email' &&
|
|
64
|
+
(connectMutation.isSuccess || connectMutation.isPending) ? (
|
|
65
|
+
<>
|
|
66
|
+
<Box
|
|
67
|
+
sx={{
|
|
68
|
+
mt: 20,
|
|
69
|
+
textAlign: 'center',
|
|
70
|
+
typography: 'caption',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<Trans>Log in with your email</Trans>
|
|
74
|
+
</Box>
|
|
75
|
+
<Box
|
|
76
|
+
sx={{
|
|
77
|
+
mt: 12,
|
|
78
|
+
mx: 'auto',
|
|
79
|
+
maxWidth: 300,
|
|
80
|
+
textAlign: 'center',
|
|
81
|
+
color: 'text.secondary',
|
|
82
|
+
typography: 'body2',
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<Trans>
|
|
86
|
+
Check your email and click the link to complete login
|
|
87
|
+
</Trans>
|
|
88
|
+
</Box>
|
|
89
|
+
<ButtonBase
|
|
90
|
+
sx={{
|
|
91
|
+
display: 'flex',
|
|
92
|
+
justifyContent: 'center',
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
mt: 20,
|
|
95
|
+
mx: 'auto',
|
|
96
|
+
typography: 'body2',
|
|
97
|
+
'&:hover': {
|
|
98
|
+
color: 'text.secondary',
|
|
99
|
+
},
|
|
100
|
+
}}
|
|
101
|
+
onClick={() => {
|
|
102
|
+
connectMutation.reset();
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<Trans>Go Back</Trans>
|
|
106
|
+
<Box
|
|
107
|
+
component={ArrowRight}
|
|
108
|
+
sx={{
|
|
109
|
+
width: 18,
|
|
110
|
+
height: 18,
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
</ButtonBase>
|
|
114
|
+
</>
|
|
115
|
+
) : (
|
|
116
|
+
<>
|
|
117
|
+
<Box
|
|
118
|
+
sx={{
|
|
119
|
+
mt: 20,
|
|
120
|
+
mx: 'auto',
|
|
121
|
+
textAlign: 'center',
|
|
122
|
+
maxWidth: 300,
|
|
123
|
+
typography: 'caption',
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
<Trans>Log in with your email or a passkey</Trans>
|
|
127
|
+
</Box>
|
|
128
|
+
<Input
|
|
129
|
+
placeholder={t`Enter email`}
|
|
130
|
+
fullWidth
|
|
131
|
+
height={48}
|
|
132
|
+
errorMsg={invalidEmail ? t`Invalid email` : undefined}
|
|
133
|
+
value={email}
|
|
134
|
+
onChange={(evt) => setEmail(evt.target.value)}
|
|
135
|
+
sx={{
|
|
136
|
+
mt: 20,
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
<Button
|
|
140
|
+
fullWidth
|
|
141
|
+
disabled={!email || invalidEmail}
|
|
142
|
+
sx={{
|
|
143
|
+
mt: 12,
|
|
144
|
+
}}
|
|
145
|
+
isLoading={
|
|
146
|
+
connectMutation.variables?.type === 'email' &&
|
|
147
|
+
connectMutation.isPending
|
|
148
|
+
}
|
|
149
|
+
onClick={() => {
|
|
150
|
+
connectMutation.mutate({
|
|
151
|
+
type: 'email',
|
|
152
|
+
email,
|
|
153
|
+
});
|
|
154
|
+
}}
|
|
155
|
+
>
|
|
156
|
+
<Trans>Submit</Trans>
|
|
157
|
+
</Button>
|
|
158
|
+
|
|
159
|
+
<Box
|
|
160
|
+
sx={{
|
|
161
|
+
position: 'relative',
|
|
162
|
+
mt: 20,
|
|
163
|
+
textAlign: 'center',
|
|
164
|
+
'&::before': {
|
|
165
|
+
content: '""',
|
|
166
|
+
display: 'block',
|
|
167
|
+
position: 'absolute',
|
|
168
|
+
top: '50%',
|
|
169
|
+
left: 0,
|
|
170
|
+
right: 0,
|
|
171
|
+
transform: 'translateY(-50%)',
|
|
172
|
+
height: '1px',
|
|
173
|
+
backgroundColor: 'border.main',
|
|
174
|
+
},
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
<Box
|
|
178
|
+
component="span"
|
|
179
|
+
sx={{
|
|
180
|
+
px: 8,
|
|
181
|
+
backgroundColor: 'background.paper',
|
|
182
|
+
color: 'text.secondary',
|
|
183
|
+
position: 'relative',
|
|
184
|
+
zIndex: 1,
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<Trans>or</Trans>
|
|
188
|
+
</Box>
|
|
189
|
+
</Box>
|
|
190
|
+
<Button
|
|
191
|
+
fullWidth
|
|
192
|
+
variant={Button.Variant.outlined}
|
|
193
|
+
sx={{
|
|
194
|
+
mt: 20,
|
|
195
|
+
}}
|
|
196
|
+
onClick={async () => {
|
|
197
|
+
await connectMutation.mutateAsync({
|
|
198
|
+
type: 'passkey',
|
|
199
|
+
createNew: true,
|
|
200
|
+
username: `${USERNAME_PREFIX}_${Date.now()}`,
|
|
201
|
+
});
|
|
202
|
+
if (!connectMutation.isError) {
|
|
203
|
+
onClose();
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
>
|
|
207
|
+
<Trans>Create new passkey</Trans>
|
|
208
|
+
</Button>
|
|
209
|
+
<ButtonBase
|
|
210
|
+
sx={{
|
|
211
|
+
display: 'flex',
|
|
212
|
+
justifyContent: 'center',
|
|
213
|
+
alignItems: 'center',
|
|
214
|
+
mt: 12,
|
|
215
|
+
mx: 'auto',
|
|
216
|
+
py: 8,
|
|
217
|
+
typography: 'body2',
|
|
218
|
+
'&:hover': {
|
|
219
|
+
color: 'text.secondary',
|
|
220
|
+
},
|
|
221
|
+
}}
|
|
222
|
+
onClick={async () => {
|
|
223
|
+
await connectMutation.mutateAsync({
|
|
224
|
+
type: 'passkey',
|
|
225
|
+
createNew: false,
|
|
226
|
+
});
|
|
227
|
+
if (!connectMutation.isError) {
|
|
228
|
+
onClose();
|
|
229
|
+
}
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
232
|
+
<Trans>Choose existing passkey</Trans>
|
|
233
|
+
<Box
|
|
234
|
+
component={ArrowRight}
|
|
235
|
+
sx={{
|
|
236
|
+
width: 18,
|
|
237
|
+
height: 18,
|
|
238
|
+
}}
|
|
239
|
+
/>
|
|
240
|
+
</ButtonBase>
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
243
|
+
</Box>
|
|
244
|
+
</Dialog>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import WalletWeb3, {
|
|
2
|
+
allWalletObject,
|
|
3
|
+
ConnectorParams,
|
|
4
|
+
useWalletStore,
|
|
5
|
+
WalletType,
|
|
6
|
+
} from '@dodoex/wallet-web3';
|
|
7
|
+
import { useMutation } from '@tanstack/react-query';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { connectToWallet } from '../../hooks/useConnectWalet';
|
|
10
|
+
|
|
11
|
+
export type AlchemyParams = Exclude<
|
|
12
|
+
Partial<ConnectorParams['alchemyParams']>,
|
|
13
|
+
undefined
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export const USERNAME_PREFIX = 'DODO';
|
|
17
|
+
|
|
18
|
+
export const alchemyWallet = allWalletObject.Alchemy;
|
|
19
|
+
|
|
20
|
+
export async function checkAlchemyCache(chainId: number) {
|
|
21
|
+
const alchemy = await alchemyWallet.getPackage?.();
|
|
22
|
+
if (alchemy) {
|
|
23
|
+
const signer = await alchemy.getAlchemySigner(chainId);
|
|
24
|
+
const user = await signer.getAuthDetails().catch(() => null);
|
|
25
|
+
if (user) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useConnectAlchemyQuery({
|
|
33
|
+
walletWeb3,
|
|
34
|
+
showAlchemyConnect,
|
|
35
|
+
}: {
|
|
36
|
+
walletWeb3: WalletWeb3;
|
|
37
|
+
showAlchemyConnect: () => void;
|
|
38
|
+
}) {
|
|
39
|
+
const connectMutation = useConnectAlchemy({
|
|
40
|
+
walletWeb3,
|
|
41
|
+
});
|
|
42
|
+
const { chainId } = useWalletStore();
|
|
43
|
+
const search = typeof window !== 'undefined' ? window.location.search : '';
|
|
44
|
+
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const searchParams = new URLSearchParams(search);
|
|
47
|
+
const bundle = searchParams.get('bundle');
|
|
48
|
+
if (bundle) {
|
|
49
|
+
const orgId = searchParams.get('orgId');
|
|
50
|
+
connectMutation.mutate({
|
|
51
|
+
type: 'email',
|
|
52
|
+
orgId: orgId as string | undefined,
|
|
53
|
+
bundle: bundle as string,
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
// auto connect
|
|
57
|
+
const autoConnect = async () => {
|
|
58
|
+
const cacheType = walletWeb3.connectController.getAutoCacheType();
|
|
59
|
+
if (cacheType === WalletType.Alchemy) {
|
|
60
|
+
const alchemy = await alchemyWallet.getPackage?.();
|
|
61
|
+
const signer = await alchemy.getAlchemySigner(chainId);
|
|
62
|
+
const user = await signer.getAuthDetails().catch(() => null);
|
|
63
|
+
if (user) {
|
|
64
|
+
await connectToWallet(walletWeb3, alchemy, {
|
|
65
|
+
chainId,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
showAlchemyConnect();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
autoConnect();
|
|
73
|
+
}
|
|
74
|
+
}, [search]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function useConnectAlchemy({ walletWeb3 }: { walletWeb3: WalletWeb3 }) {
|
|
78
|
+
const { chainId } = useWalletStore();
|
|
79
|
+
return useMutation({
|
|
80
|
+
mutationFn: async (authParams: AlchemyParams['authParams']) => {
|
|
81
|
+
const alchemy = await alchemyWallet.getPackage?.();
|
|
82
|
+
const signer = await alchemy.getAlchemySigner(chainId);
|
|
83
|
+
// Register by email, no need to go down. The user will open a new page from the mailbox and connect in useConnectAlchemyQuery
|
|
84
|
+
if (authParams?.type === 'email' && 'email' in authParams) {
|
|
85
|
+
const search = new URLSearchParams();
|
|
86
|
+
await signer.authenticate({
|
|
87
|
+
...authParams,
|
|
88
|
+
redirectParams: search,
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await signer.authenticate(authParams);
|
|
93
|
+
await connectToWallet(walletWeb3, alchemy, {
|
|
94
|
+
chainId,
|
|
95
|
+
alchemyParams: {
|
|
96
|
+
authParams,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Box, Button } from '@dodoex/components';
|
|
2
|
+
import { Error } from '@dodoex/icons';
|
|
3
|
+
import { Trans } from '@lingui/macro';
|
|
4
|
+
import Dialog from '../../components/Dialog';
|
|
5
|
+
|
|
6
|
+
export default function ErrorDialog({
|
|
7
|
+
error,
|
|
8
|
+
onClose,
|
|
9
|
+
}: {
|
|
10
|
+
error?: string;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<Dialog open={!!error} width={340} onClose={onClose}>
|
|
15
|
+
<Box
|
|
16
|
+
sx={{
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
p: 20,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<Box
|
|
22
|
+
component={Error}
|
|
23
|
+
sx={{
|
|
24
|
+
width: 40,
|
|
25
|
+
height: 40,
|
|
26
|
+
color: 'error.main',
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
<Box
|
|
30
|
+
sx={{
|
|
31
|
+
typography: 'caption',
|
|
32
|
+
mt: 20,
|
|
33
|
+
whiteSpace: 'pre-wrap',
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Trans>Unknown Error</Trans>
|
|
37
|
+
</Box>
|
|
38
|
+
<Box
|
|
39
|
+
sx={{
|
|
40
|
+
typography: 'h6',
|
|
41
|
+
mt: 12,
|
|
42
|
+
whiteSpace: 'pre-wrap',
|
|
43
|
+
color: 'text.secondary',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{error}
|
|
47
|
+
</Box>
|
|
48
|
+
<Button
|
|
49
|
+
onClick={onClose}
|
|
50
|
+
fullWidth
|
|
51
|
+
variant={Button.Variant.outlined}
|
|
52
|
+
sx={{
|
|
53
|
+
mt: 24,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Trans>OK</Trans>
|
|
57
|
+
</Button>
|
|
58
|
+
</Box>
|
|
59
|
+
</Dialog>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Box } from '@dodoex/components';
|
|
2
|
+
import { Trans } from '@lingui/macro';
|
|
3
|
+
import Dialog from '../../components/Dialog';
|
|
4
|
+
|
|
5
|
+
const strokeWidth = 4;
|
|
6
|
+
|
|
7
|
+
function LoadingRotate() {
|
|
8
|
+
return (
|
|
9
|
+
<Box
|
|
10
|
+
sx={{
|
|
11
|
+
position: 'relative',
|
|
12
|
+
width: 64,
|
|
13
|
+
height: 64,
|
|
14
|
+
mt: 20,
|
|
15
|
+
borderRadius: '50%',
|
|
16
|
+
borderStyle: 'solid',
|
|
17
|
+
borderWidth: strokeWidth,
|
|
18
|
+
borderColor: 'background.input',
|
|
19
|
+
animation: 'rotation 2s infinite linear',
|
|
20
|
+
'@keyframes rotation': {
|
|
21
|
+
'0%': {
|
|
22
|
+
transform: 'rotate(0deg)',
|
|
23
|
+
},
|
|
24
|
+
'100%': {
|
|
25
|
+
transform: 'rotate(360deg)',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
'& > svg': {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: `-${strokeWidth}px`,
|
|
31
|
+
right: `-${strokeWidth}px`,
|
|
32
|
+
color: 'primary.main',
|
|
33
|
+
},
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<svg
|
|
37
|
+
width="33px"
|
|
38
|
+
height="33px"
|
|
39
|
+
viewBox="0 0 33 33"
|
|
40
|
+
version="1.1"
|
|
41
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
42
|
+
>
|
|
43
|
+
<g
|
|
44
|
+
stroke="none"
|
|
45
|
+
strokeWidth="1"
|
|
46
|
+
fill="none"
|
|
47
|
+
fillRule="evenodd"
|
|
48
|
+
strokeLinecap="round"
|
|
49
|
+
strokeLinejoin="round"
|
|
50
|
+
>
|
|
51
|
+
<g
|
|
52
|
+
transform="translate(-186.000000, -375.000000)"
|
|
53
|
+
stroke="currentColor"
|
|
54
|
+
strokeWidth="4"
|
|
55
|
+
>
|
|
56
|
+
<g transform="translate(18.000000, 291.000000)">
|
|
57
|
+
<g transform="translate(40.000000, 83.000000)">
|
|
58
|
+
<path d="M159,32 C159,15.9837423 146.016258,3 130,3"></path>
|
|
59
|
+
</g>
|
|
60
|
+
</g>
|
|
61
|
+
</g>
|
|
62
|
+
</g>
|
|
63
|
+
</svg>
|
|
64
|
+
</Box>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default function LoadingDialog({ on }: { on: boolean }) {
|
|
69
|
+
return (
|
|
70
|
+
<Dialog open={on} width={340}>
|
|
71
|
+
<Box
|
|
72
|
+
sx={{
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
p: 20,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Box
|
|
80
|
+
sx={{
|
|
81
|
+
color: 'text.secondary',
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<Trans>Account</Trans>
|
|
85
|
+
</Box>
|
|
86
|
+
<LoadingRotate />
|
|
87
|
+
<Box
|
|
88
|
+
sx={{
|
|
89
|
+
mt: 20,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<Trans>Available Ledger Account</Trans>
|
|
93
|
+
</Box>
|
|
94
|
+
<Box
|
|
95
|
+
sx={{
|
|
96
|
+
mt: 8,
|
|
97
|
+
color: 'text.secondary',
|
|
98
|
+
typography: 'body2',
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<Trans>Loading...</Trans>
|
|
102
|
+
</Box>
|
|
103
|
+
</Box>
|
|
104
|
+
</Dialog>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Button, Box } from '@dodoex/components';
|
|
2
|
+
import { Lock } from '@dodoex/icons';
|
|
3
|
+
import { Trans } from '@lingui/macro';
|
|
4
|
+
import Dialog from '../../components/Dialog';
|
|
5
|
+
|
|
6
|
+
export default function LockedDialog({
|
|
7
|
+
on,
|
|
8
|
+
onClose,
|
|
9
|
+
}: {
|
|
10
|
+
on: boolean;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}) {
|
|
13
|
+
return (
|
|
14
|
+
<Dialog open={on} width={340} onClose={onClose}>
|
|
15
|
+
<Box
|
|
16
|
+
sx={{
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
py: 20,
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<Box
|
|
22
|
+
component={Lock}
|
|
23
|
+
sx={{
|
|
24
|
+
mt: 20,
|
|
25
|
+
width: 64,
|
|
26
|
+
height: 64,
|
|
27
|
+
color: 'primary.main',
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
<Box
|
|
31
|
+
sx={{
|
|
32
|
+
mt: 20,
|
|
33
|
+
whiteSpace: 'pre-wrap',
|
|
34
|
+
fontWeight: 600,
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<Trans>
|
|
38
|
+
The Ledger Device is locked\nPlease unlock from the device
|
|
39
|
+
</Trans>
|
|
40
|
+
</Box>
|
|
41
|
+
<Button
|
|
42
|
+
onClick={onClose}
|
|
43
|
+
fullWidth
|
|
44
|
+
variant={Button.Variant.outlined}
|
|
45
|
+
sx={{
|
|
46
|
+
mt: 24,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<Trans>OK</Trans>
|
|
50
|
+
</Button>
|
|
51
|
+
</Box>
|
|
52
|
+
</Dialog>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Box, Button } from '@dodoex/components';
|
|
2
|
+
import { Trans, t } from '@lingui/macro';
|
|
3
|
+
import Dialog from '../../components/Dialog';
|
|
4
|
+
import { useWalletConnectContext } from '../../WalletConnectProvider';
|
|
5
|
+
|
|
6
|
+
export default function ProtocolDialog({
|
|
7
|
+
on,
|
|
8
|
+
chainId,
|
|
9
|
+
onClose,
|
|
10
|
+
onNext,
|
|
11
|
+
}: {
|
|
12
|
+
on: boolean;
|
|
13
|
+
chainId: number;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
onNext: () => void;
|
|
16
|
+
}) {
|
|
17
|
+
const { getChain } = useWalletConnectContext();
|
|
18
|
+
const { name: ledgerAppName } = getChain(chainId) || { name: 'Unknown' };
|
|
19
|
+
const BR = '\n';
|
|
20
|
+
return (
|
|
21
|
+
<Dialog
|
|
22
|
+
open={on}
|
|
23
|
+
onClose={onClose}
|
|
24
|
+
width={340}
|
|
25
|
+
bodySx={{
|
|
26
|
+
px: 20,
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<Box
|
|
30
|
+
sx={{
|
|
31
|
+
typography: 'caption',
|
|
32
|
+
mt: 28,
|
|
33
|
+
textAlign: 'center',
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Trans>Before proceeding make sure</Trans>
|
|
37
|
+
</Box>
|
|
38
|
+
<Box
|
|
39
|
+
sx={{
|
|
40
|
+
mt: 12,
|
|
41
|
+
whiteSpace: 'pre-wrap',
|
|
42
|
+
color: 'text.secondary',
|
|
43
|
+
typography: 'body2',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{t`1、Ledger Live APP is closed${BR}2、The device plugged in via USB,NOT Bluetooth${BR}3、The device is unlocked and in the ${ledgerAppName} app${BR}4、”Blind Signing” is enabled in ${ledgerAppName} app`}
|
|
47
|
+
</Box>
|
|
48
|
+
<Button
|
|
49
|
+
onClick={onNext}
|
|
50
|
+
fullWidth
|
|
51
|
+
variant={Button.Variant.outlined}
|
|
52
|
+
sx={{
|
|
53
|
+
mt: 24,
|
|
54
|
+
mb: 20,
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Trans>Continue</Trans>
|
|
58
|
+
</Button>
|
|
59
|
+
</Dialog>
|
|
60
|
+
);
|
|
61
|
+
}
|