@dodoex/wallet-web3-react 0.0.1-beta.8 → 0.0.1
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/dist/index.cjs +5 -5
- package/dist/index.js +5 -5
- package/dist/types/WalletConnect/ConnectDialog.d.ts +8 -0
- package/dist/types/WalletConnect/ConnectPage.d.ts +5 -2
- package/dist/types/WalletConnect/WalletDialog.d.ts +3 -1
- package/dist/types/hooks/useConnectWallet.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +4 -4
- package/src/WalletConnect/ConnectDialog.tsx +30 -0
- package/src/WalletConnect/ConnectPage.tsx +26 -7
- package/src/WalletConnect/WalletDialog.tsx +6 -3
- package/src/hooks/useConnectWallet.ts +2 -0
- package/src/index.tsx +2 -0
- package/src/locales/en.po +2 -2
- package/src/locales/zh.po +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import WalletWeb3 from '@dodoex/wallet-web3';
|
|
2
|
+
import { ConnectPageProps } from './ConnectPage';
|
|
3
|
+
export default function ConnectDialog({ open, onClose, walletWeb3, onConnectWallet, }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
walletWeb3: WalletWeb3;
|
|
7
|
+
onConnectWallet?: ConnectPageProps['onConnectWallet'];
|
|
8
|
+
}): JSX.Element;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import WalletWeb3 from '@dodoex/wallet-web3';
|
|
2
|
-
|
|
2
|
+
import { WalletItem } from '../hooks/useConnectWallet';
|
|
3
|
+
export interface ConnectPageProps {
|
|
3
4
|
chainId: number;
|
|
4
5
|
account?: string;
|
|
5
6
|
walletWeb3?: WalletWeb3;
|
|
6
7
|
showOtherInjectWallet?: boolean;
|
|
7
8
|
onClose: () => void;
|
|
8
|
-
|
|
9
|
+
onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
declare function ConnectPage({ chainId, account, walletWeb3, showOtherInjectWallet, onClose, onConnectWallet, }: ConnectPageProps): JSX.Element;
|
|
9
12
|
export default ConnectPage;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import WalletWeb3 from '@dodoex/wallet-web3';
|
|
2
|
-
|
|
2
|
+
import { ConnectPageProps } from './ConnectPage';
|
|
3
|
+
export default function WalletDialog({ open, onClose, walletWeb3, onConnectWallet, }: {
|
|
3
4
|
open: boolean;
|
|
4
5
|
onClose: () => void;
|
|
5
6
|
walletWeb3: WalletWeb3;
|
|
7
|
+
onConnectWallet?: ConnectPageProps['onConnectWallet'];
|
|
6
8
|
}): JSX.Element;
|
|
@@ -7,6 +7,7 @@ export interface WalletItem {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
isLastConnection: boolean;
|
|
9
9
|
isInstalled?: boolean;
|
|
10
|
+
source: Wallet;
|
|
10
11
|
}
|
|
11
12
|
export declare const useConnectWallet: ({ walletWeb3, matchTestChain, showOtherInjectWallet, selectedChainId, hasTermsOfServiceLink, }: {
|
|
12
13
|
walletWeb3?: WalletWeb3;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export { WalletConnectProvider } from './WalletConnectProvider';
|
|
|
3
3
|
export { default as ClientProvider } from './ClientProvider';
|
|
4
4
|
export { default as LangProvider } from './LangProvider';
|
|
5
5
|
export { useWalletListByNetwork } from './hooks/useConnectWallet';
|
|
6
|
+
export { default as ConnectDialog } from './WalletConnect/ConnectDialog';
|
|
7
|
+
export { default as ConnectPage } from './WalletConnect/ConnectPage';
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dodoex/wallet-web3-react",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"source": "src/index.tsx",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"typings": "dist/index.d.ts",
|
|
5
|
+
"types": "dist/types/index.d.ts",
|
|
6
|
+
"typings": "dist/types/index.d.ts",
|
|
7
7
|
"main": "dist/cjs/index.cjs",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@dodoex/wallet-web3": "0.0.
|
|
36
|
+
"@dodoex/wallet-web3": "0.0.62",
|
|
37
37
|
"@dodoex/contract-request": ">=1.x",
|
|
38
38
|
"@dodoex/dodo-contract-request": ">=1.x",
|
|
39
39
|
"@dodoex/icons": ">=2.0.2",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import WalletWeb3, { useWalletStore } from '@dodoex/wallet-web3';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Dialog from '../components/Dialog';
|
|
4
|
+
import ConnectPage, { ConnectPageProps } from './ConnectPage';
|
|
5
|
+
|
|
6
|
+
export default function ConnectDialog({
|
|
7
|
+
open,
|
|
8
|
+
onClose,
|
|
9
|
+
walletWeb3,
|
|
10
|
+
onConnectWallet,
|
|
11
|
+
}: {
|
|
12
|
+
open: boolean;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
walletWeb3: WalletWeb3;
|
|
15
|
+
onConnectWallet?: ConnectPageProps['onConnectWallet'];
|
|
16
|
+
}) {
|
|
17
|
+
const { account, chainId: connectChainId } = useWalletStore();
|
|
18
|
+
return (
|
|
19
|
+
<Dialog open={open} onClose={onClose} width={420}>
|
|
20
|
+
<ConnectPage
|
|
21
|
+
chainId={connectChainId}
|
|
22
|
+
account={account}
|
|
23
|
+
walletWeb3={walletWeb3}
|
|
24
|
+
showOtherInjectWallet
|
|
25
|
+
onClose={onClose}
|
|
26
|
+
onConnectWallet={onConnectWallet}
|
|
27
|
+
/>
|
|
28
|
+
</Dialog>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -32,6 +32,7 @@ function WalletGroupItem({
|
|
|
32
32
|
disabledClick,
|
|
33
33
|
onShowLedgerConnect,
|
|
34
34
|
onShowAlchemyConnect,
|
|
35
|
+
onConnectWallet,
|
|
35
36
|
}: {
|
|
36
37
|
chainId?: number;
|
|
37
38
|
wallet: WalletItem;
|
|
@@ -44,6 +45,7 @@ function WalletGroupItem({
|
|
|
44
45
|
disabledClick: () => void;
|
|
45
46
|
onShowLedgerConnect: () => void;
|
|
46
47
|
onShowAlchemyConnect: () => void;
|
|
48
|
+
onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
|
|
47
49
|
}) {
|
|
48
50
|
const theme = useTheme();
|
|
49
51
|
const isChecked =
|
|
@@ -96,6 +98,19 @@ function WalletGroupItem({
|
|
|
96
98
|
try {
|
|
97
99
|
await Promise.race([
|
|
98
100
|
(async () => {
|
|
101
|
+
if (onConnectWallet) {
|
|
102
|
+
try {
|
|
103
|
+
await onConnectWallet(wallet);
|
|
104
|
+
const connectedChainId = useWalletStore.getState().chainId;
|
|
105
|
+
if (onConnected) {
|
|
106
|
+
onConnected(connectedChainId, wallet);
|
|
107
|
+
}
|
|
108
|
+
} finally {
|
|
109
|
+
setLoading(false);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
99
114
|
if (
|
|
100
115
|
switchNetwork &&
|
|
101
116
|
wallet.currentType === activeWalletType &&
|
|
@@ -173,19 +188,22 @@ function WalletGroupItem({
|
|
|
173
188
|
);
|
|
174
189
|
}
|
|
175
190
|
|
|
191
|
+
export interface ConnectPageProps {
|
|
192
|
+
chainId: number;
|
|
193
|
+
account?: string;
|
|
194
|
+
walletWeb3?: WalletWeb3;
|
|
195
|
+
showOtherInjectWallet?: boolean;
|
|
196
|
+
onClose: () => void;
|
|
197
|
+
onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
|
|
198
|
+
}
|
|
176
199
|
function ConnectPage({
|
|
177
200
|
chainId,
|
|
178
201
|
account,
|
|
179
202
|
walletWeb3,
|
|
180
203
|
showOtherInjectWallet,
|
|
181
204
|
onClose,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
account?: string;
|
|
185
|
-
walletWeb3?: WalletWeb3;
|
|
186
|
-
showOtherInjectWallet?: boolean;
|
|
187
|
-
onClose: () => void;
|
|
188
|
-
}) {
|
|
205
|
+
onConnectWallet,
|
|
206
|
+
}: ConnectPageProps) {
|
|
189
207
|
const theme = useTheme();
|
|
190
208
|
const highlightBackgroundColor =
|
|
191
209
|
theme.palette.mode === 'dark' ? alpha('#F1F902', 0.1) : '#F1F902';
|
|
@@ -267,6 +285,7 @@ function ConnectPage({
|
|
|
267
285
|
disabledClick={disabledClick}
|
|
268
286
|
onShowLedgerConnect={() => setShowLedgerConnect(true)}
|
|
269
287
|
onShowAlchemyConnect={() => setShowAlchemyConnect(true)}
|
|
288
|
+
onConnectWallet={onConnectWallet}
|
|
270
289
|
/>
|
|
271
290
|
);
|
|
272
291
|
})}
|
|
@@ -2,7 +2,7 @@ import WalletWeb3, { useWalletStore } from '@dodoex/wallet-web3';
|
|
|
2
2
|
import AccountPage from './AccountPage';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import Dialog from '../components/Dialog';
|
|
5
|
-
import ConnectPage from './ConnectPage';
|
|
5
|
+
import ConnectPage, { ConnectPageProps } from './ConnectPage';
|
|
6
6
|
import ReceiveTokenPage from './ReceiveTokenPage';
|
|
7
7
|
import { useWalletConnectContext } from '../WalletConnectProvider';
|
|
8
8
|
|
|
@@ -10,13 +10,15 @@ export default function WalletDialog({
|
|
|
10
10
|
open,
|
|
11
11
|
onClose,
|
|
12
12
|
walletWeb3,
|
|
13
|
+
onConnectWallet,
|
|
13
14
|
}: {
|
|
14
15
|
open: boolean;
|
|
15
16
|
onClose: () => void;
|
|
16
17
|
walletWeb3: WalletWeb3;
|
|
18
|
+
onConnectWallet?: ConnectPageProps['onConnectWallet'];
|
|
17
19
|
}) {
|
|
18
20
|
const { SendTokenPage, chainId: selectedChainId } = useWalletConnectContext();
|
|
19
|
-
const { account, chainId: connectChainId } = useWalletStore();
|
|
21
|
+
const { account, chainId: connectChainId, connected } = useWalletStore();
|
|
20
22
|
const [showSendTokenPage, setShowSendTokenPage] = React.useState(false);
|
|
21
23
|
const [showReceiveTokenPage, setShowReceiveTokenPage] = React.useState(false);
|
|
22
24
|
return (
|
|
@@ -28,7 +30,7 @@ export default function WalletDialog({
|
|
|
28
30
|
height: account && !!SendTokenPage ? '80vh' : undefined,
|
|
29
31
|
}}
|
|
30
32
|
>
|
|
31
|
-
{!!SendTokenPage && account ? (
|
|
33
|
+
{!!SendTokenPage && account && connected?.wallet ? (
|
|
32
34
|
<>
|
|
33
35
|
{showSendTokenPage ? (
|
|
34
36
|
<>
|
|
@@ -65,6 +67,7 @@ export default function WalletDialog({
|
|
|
65
67
|
walletWeb3={walletWeb3}
|
|
66
68
|
showOtherInjectWallet
|
|
67
69
|
onClose={onClose}
|
|
70
|
+
onConnectWallet={onConnectWallet}
|
|
68
71
|
/>
|
|
69
72
|
)}
|
|
70
73
|
</Dialog>
|
|
@@ -13,6 +13,7 @@ export interface WalletItem {
|
|
|
13
13
|
disabled?: boolean;
|
|
14
14
|
isLastConnection: boolean;
|
|
15
15
|
isInstalled?: boolean;
|
|
16
|
+
source: Wallet;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const useConnectWallet = ({
|
|
@@ -104,6 +105,7 @@ export function useWalletListByNetwork(
|
|
|
104
105
|
title: item.showName,
|
|
105
106
|
icon: item.logo,
|
|
106
107
|
currentType: item.type,
|
|
108
|
+
source: item,
|
|
107
109
|
onClick: (providerPackageOptions) => {
|
|
108
110
|
try {
|
|
109
111
|
return connectToWallet(
|
package/src/index.tsx
CHANGED
|
@@ -3,3 +3,5 @@ export { WalletConnectProvider } from './WalletConnectProvider';
|
|
|
3
3
|
export { default as ClientProvider } from './ClientProvider';
|
|
4
4
|
export { default as LangProvider } from './LangProvider';
|
|
5
5
|
export { useWalletListByNetwork } from './hooks/useConnectWallet';
|
|
6
|
+
export { default as ConnectDialog } from './WalletConnect/ConnectDialog';
|
|
7
|
+
export { default as ConnectPage } from './WalletConnect/ConnectPage';
|
package/src/locales/en.po
CHANGED
|
@@ -68,7 +68,7 @@ msgstr "Claim Rewards"
|
|
|
68
68
|
msgid "Connect Alchemy"
|
|
69
69
|
msgstr "Connect Alchemy"
|
|
70
70
|
|
|
71
|
-
#: src/WalletConnect/ConnectPage.tsx:
|
|
71
|
+
#: src/WalletConnect/ConnectPage.tsx:253
|
|
72
72
|
msgid "Connect Wallet"
|
|
73
73
|
msgstr "Connect Wallet"
|
|
74
74
|
|
|
@@ -156,7 +156,7 @@ msgstr "Log in with your email"
|
|
|
156
156
|
msgid "Log in with your email or a passkey"
|
|
157
157
|
msgstr "Log in with your email or a passkey"
|
|
158
158
|
|
|
159
|
-
#: src/WalletConnect/ConnectPage.tsx:
|
|
159
|
+
#: src/WalletConnect/ConnectPage.tsx:362
|
|
160
160
|
msgid "More Wallets"
|
|
161
161
|
msgstr "More Wallets"
|
|
162
162
|
|
package/src/locales/zh.po
CHANGED
|
@@ -68,7 +68,7 @@ msgstr ""
|
|
|
68
68
|
msgid "Connect Alchemy"
|
|
69
69
|
msgstr ""
|
|
70
70
|
|
|
71
|
-
#: src/WalletConnect/ConnectPage.tsx:
|
|
71
|
+
#: src/WalletConnect/ConnectPage.tsx:253
|
|
72
72
|
msgid "Connect Wallet"
|
|
73
73
|
msgstr ""
|
|
74
74
|
|
|
@@ -156,7 +156,7 @@ msgstr ""
|
|
|
156
156
|
msgid "Log in with your email or a passkey"
|
|
157
157
|
msgstr ""
|
|
158
158
|
|
|
159
|
-
#: src/WalletConnect/ConnectPage.tsx:
|
|
159
|
+
#: src/WalletConnect/ConnectPage.tsx:362
|
|
160
160
|
msgid "More Wallets"
|
|
161
161
|
msgstr ""
|
|
162
162
|
|