@dodoex/wallet-web3-react 0.1.0 → 0.2.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.
@@ -1,8 +1,9 @@
1
1
  import WalletWeb3 from '@dodoex/wallet-web3';
2
2
  import { ConnectPageProps } from './ConnectPage';
3
- export default function ConnectDialog({ open, onClose, walletWeb3, onConnectWallet, }: {
3
+ export default function ConnectDialog({ open, onClose, walletWeb3, onConnectWallet, WalletTag, }: {
4
4
  open: boolean;
5
5
  onClose: () => void;
6
6
  walletWeb3: WalletWeb3;
7
7
  onConnectWallet?: ConnectPageProps['onConnectWallet'];
8
+ WalletTag?: ConnectPageProps['WalletTag'];
8
9
  }): JSX.Element;
@@ -1,5 +1,10 @@
1
+ import React from 'react';
1
2
  import WalletWeb3 from '@dodoex/wallet-web3';
2
3
  import { WalletItem } from '../hooks/useConnectWallet';
4
+ import { WalletTagProps } from '../components/WalletTag';
5
+ export type ConnectDialogWalletTag = React.FC<WalletTagProps & {
6
+ children?: React.ReactNode;
7
+ }>;
3
8
  export interface ConnectPageProps {
4
9
  chainId: number;
5
10
  account?: string;
@@ -7,6 +12,7 @@ export interface ConnectPageProps {
7
12
  showOtherInjectWallet?: boolean;
8
13
  onClose: () => void;
9
14
  onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
15
+ WalletTag?: ConnectDialogWalletTag;
10
16
  }
11
- declare function ConnectPage({ chainId, account, walletWeb3, showOtherInjectWallet, onClose, onConnectWallet, }: ConnectPageProps): JSX.Element;
17
+ declare function ConnectPage({ chainId, account, walletWeb3, showOtherInjectWallet, onClose, onConnectWallet, WalletTag, }: ConnectPageProps): JSX.Element;
12
18
  export default ConnectPage;
@@ -1,8 +1,9 @@
1
1
  import WalletWeb3 from '@dodoex/wallet-web3';
2
2
  import { ConnectPageProps } from './ConnectPage';
3
- export default function WalletDialog({ open, onClose, walletWeb3, onConnectWallet, }: {
3
+ export default function WalletDialog({ open, onClose, walletWeb3, onConnectWallet, WalletTag, }: {
4
4
  open: boolean;
5
5
  onClose: () => void;
6
6
  walletWeb3: WalletWeb3;
7
7
  onConnectWallet?: ConnectPageProps['onConnectWallet'];
8
+ WalletTag?: ConnectPageProps['WalletTag'];
8
9
  }): JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { WalletItem } from '../hooks/useConnectWallet';
2
- export default function WalletTag({ loading, wallet, isChecked, installed, }: {
2
+ export interface WalletTagProps {
3
3
  loading: boolean;
4
4
  wallet: WalletItem;
5
5
  isChecked: boolean;
6
6
  installed: boolean;
7
- }): JSX.Element | null;
7
+ }
8
+ export default function WalletTag({ loading, wallet, isChecked, installed, }: WalletTagProps): JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodoex/wallet-web3-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "source": "src/index.tsx",
5
5
  "types": "dist/types/index.d.ts",
6
6
  "typings": "dist/types/index.d.ts",
@@ -10,7 +10,9 @@
10
10
  "start": "yarn workspace doc start",
11
11
  "build": "yarn extract && yarn compile && rollup -c",
12
12
  "extract": "lingui extract --clean",
13
- "compile": "lingui compile"
13
+ "compile": "lingui compile",
14
+ "release.npm-publish": "npm publish --access public",
15
+ "release.npm-publish-beta": "npm publish --tag beta"
14
16
  },
15
17
  "author": "",
16
18
  "publishConfig": {
@@ -73,4 +75,4 @@
73
75
  "qrcode.react": "^4.2.0",
74
76
  "react-infinite-scroller": "^1.2.6"
75
77
  }
76
- }
78
+ }
@@ -8,11 +8,13 @@ export default function ConnectDialog({
8
8
  onClose,
9
9
  walletWeb3,
10
10
  onConnectWallet,
11
+ WalletTag,
11
12
  }: {
12
13
  open: boolean;
13
14
  onClose: () => void;
14
15
  walletWeb3: WalletWeb3;
15
16
  onConnectWallet?: ConnectPageProps['onConnectWallet'];
17
+ WalletTag?: ConnectPageProps['WalletTag'];
16
18
  }) {
17
19
  const { account, chainId: connectChainId } = useWalletStore();
18
20
  return (
@@ -24,6 +26,7 @@ export default function ConnectDialog({
24
26
  showOtherInjectWallet
25
27
  onClose={onClose}
26
28
  onConnectWallet={onConnectWallet}
29
+ WalletTag={WalletTag}
27
30
  />
28
31
  </Dialog>
29
32
  );
@@ -3,7 +3,7 @@ import WalletWeb3, { useWalletStore, WalletType } from '@dodoex/wallet-web3';
3
3
  import { useConnectWallet, WalletItem } from '../hooks/useConnectWallet';
4
4
  import { alpha, Box, ButtonBase, Checkbox, useTheme } from '@dodoex/components';
5
5
  import { useWalletConnectContext } from '../WalletConnectProvider';
6
- import WalletTag from '../components/WalletTag';
6
+ import WalletTag, { WalletTagProps } from '../components/WalletTag';
7
7
  import { ArrowRight, More } from '@dodoex/icons';
8
8
  import { Trans } from '@lingui/macro';
9
9
  import ConnectLedger from './ConnectLedger';
@@ -20,6 +20,12 @@ const walletGroupStyle = {
20
20
  py: 6,
21
21
  };
22
22
 
23
+ export type ConnectDialogWalletTag = React.FC<
24
+ WalletTagProps & {
25
+ children?: React.ReactNode;
26
+ }
27
+ >;
28
+
23
29
  function WalletGroupItem({
24
30
  chainId,
25
31
  wallet,
@@ -33,6 +39,7 @@ function WalletGroupItem({
33
39
  onShowLedgerConnect,
34
40
  onShowAlchemyConnect,
35
41
  onConnectWallet,
42
+ WalletTag: WalletTagProps,
36
43
  }: {
37
44
  chainId?: number;
38
45
  wallet: WalletItem;
@@ -46,6 +53,7 @@ function WalletGroupItem({
46
53
  onShowLedgerConnect: () => void;
47
54
  onShowAlchemyConnect: () => void;
48
55
  onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
56
+ WalletTag?: ConnectDialogWalletTag;
49
57
  }) {
50
58
  const theme = useTheme();
51
59
  const isChecked =
@@ -178,12 +186,28 @@ function WalletGroupItem({
178
186
  />
179
187
  {wallet.title}
180
188
  </Box>
181
- <WalletTag
182
- loading={loading}
183
- wallet={wallet}
184
- isChecked={isChecked}
185
- installed={!!installed}
186
- />
189
+ {WalletTagProps ? (
190
+ <WalletTagProps
191
+ loading={loading}
192
+ wallet={wallet}
193
+ isChecked={isChecked}
194
+ installed={!!installed}
195
+ >
196
+ <WalletTag
197
+ loading={loading}
198
+ wallet={wallet}
199
+ isChecked={isChecked}
200
+ installed={!!installed}
201
+ />
202
+ </WalletTagProps>
203
+ ) : (
204
+ <WalletTag
205
+ loading={loading}
206
+ wallet={wallet}
207
+ isChecked={isChecked}
208
+ installed={!!installed}
209
+ />
210
+ )}
187
211
  </Box>
188
212
  );
189
213
  }
@@ -195,6 +219,7 @@ export interface ConnectPageProps {
195
219
  showOtherInjectWallet?: boolean;
196
220
  onClose: () => void;
197
221
  onConnectWallet?: (wallet: WalletItem) => void | Promise<void>;
222
+ WalletTag?: ConnectDialogWalletTag;
198
223
  }
199
224
  function ConnectPage({
200
225
  chainId,
@@ -203,6 +228,7 @@ function ConnectPage({
203
228
  showOtherInjectWallet,
204
229
  onClose,
205
230
  onConnectWallet,
231
+ WalletTag,
206
232
  }: ConnectPageProps) {
207
233
  const theme = useTheme();
208
234
  const highlightBackgroundColor =
@@ -286,6 +312,7 @@ function ConnectPage({
286
312
  onShowLedgerConnect={() => setShowLedgerConnect(true)}
287
313
  onShowAlchemyConnect={() => setShowAlchemyConnect(true)}
288
314
  onConnectWallet={onConnectWallet}
315
+ WalletTag={WalletTag}
289
316
  />
290
317
  );
291
318
  })}
@@ -11,11 +11,13 @@ export default function WalletDialog({
11
11
  onClose,
12
12
  walletWeb3,
13
13
  onConnectWallet,
14
+ WalletTag,
14
15
  }: {
15
16
  open: boolean;
16
17
  onClose: () => void;
17
18
  walletWeb3: WalletWeb3;
18
19
  onConnectWallet?: ConnectPageProps['onConnectWallet'];
20
+ WalletTag?: ConnectPageProps['WalletTag'];
19
21
  }) {
20
22
  const { SendTokenPage, chainId: selectedChainId } = useWalletConnectContext();
21
23
  const { account, chainId: connectChainId, connected } = useWalletStore();
@@ -68,6 +70,7 @@ export default function WalletDialog({
68
70
  showOtherInjectWallet
69
71
  onClose={onClose}
70
72
  onConnectWallet={onConnectWallet}
73
+ WalletTag={WalletTag}
71
74
  />
72
75
  )}
73
76
  </Dialog>
@@ -3,17 +3,19 @@ import { WalletType } from '@dodoex/wallet-web3';
3
3
  import { Trans } from '@lingui/macro';
4
4
  import { WalletItem } from '../hooks/useConnectWallet';
5
5
 
6
+ export interface WalletTagProps {
7
+ loading: boolean;
8
+ wallet: WalletItem;
9
+ isChecked: boolean;
10
+ installed: boolean;
11
+ };
12
+
6
13
  export default function WalletTag({
7
14
  loading,
8
15
  wallet,
9
16
  isChecked,
10
17
  installed,
11
- }: {
12
- loading: boolean;
13
- wallet: WalletItem;
14
- isChecked: boolean;
15
- installed: boolean;
16
- }) {
18
+ }: WalletTagProps) {
17
19
  const theme = useTheme();
18
20
  const greenColor = theme.palette.success.main;
19
21
  const connectedColor = theme.palette.mode === 'light' ? '#EB8D27' : '#FFE804';
@@ -87,6 +87,8 @@ export function useWalletListByNetwork(
87
87
  React.useEffect(() => {
88
88
  const computed = async () => {
89
89
  if (walletWeb3 && chainId !== undefined) {
90
+ // Reset disabled state before getting wallet list
91
+ await walletWeb3.setDisabledState();
90
92
  const walletListOrigin = walletWeb3.getWalletList(chainId, {
91
93
  eip6963WalletList,
92
94
  });
package/src/locales/en.po CHANGED
@@ -68,15 +68,15 @@ msgstr "Claim Rewards"
68
68
  msgid "Connect Alchemy"
69
69
  msgstr "Connect Alchemy"
70
70
 
71
- #: src/WalletConnect/ConnectPage.tsx:253
71
+ #: src/WalletConnect/ConnectPage.tsx:279
72
72
  msgid "Connect Wallet"
73
73
  msgstr "Connect Wallet"
74
74
 
75
- #: src/components/WalletTag.tsx:58
75
+ #: src/components/WalletTag.tsx:60
76
76
  msgid "Connected"
77
77
  msgstr "Connected"
78
78
 
79
- #: src/components/WalletTag.tsx:42
79
+ #: src/components/WalletTag.tsx:44
80
80
  msgid "Connecting"
81
81
  msgstr "Connecting"
82
82
 
@@ -124,7 +124,7 @@ msgstr "Go Back"
124
124
  msgid "ID"
125
125
  msgstr "ID"
126
126
 
127
- #: src/components/WalletTag.tsx:107
127
+ #: src/components/WalletTag.tsx:109
128
128
  msgid "Installed Wallet"
129
129
  msgstr "Installed Wallet"
130
130
 
@@ -136,7 +136,7 @@ msgstr "Invalid email"
136
136
  msgid "Invalid wallet address"
137
137
  msgstr "Invalid wallet address"
138
138
 
139
- #: src/components/WalletTag.tsx:74
139
+ #: src/components/WalletTag.tsx:76
140
140
  msgid "Last connection"
141
141
  msgstr "Last connection"
142
142
 
@@ -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:362
159
+ #: src/WalletConnect/ConnectPage.tsx:389
160
160
  msgid "More Wallets"
161
161
  msgstr "More Wallets"
162
162
 
package/src/locales/zh.po CHANGED
@@ -68,15 +68,15 @@ msgstr ""
68
68
  msgid "Connect Alchemy"
69
69
  msgstr ""
70
70
 
71
- #: src/WalletConnect/ConnectPage.tsx:253
71
+ #: src/WalletConnect/ConnectPage.tsx:279
72
72
  msgid "Connect Wallet"
73
73
  msgstr ""
74
74
 
75
- #: src/components/WalletTag.tsx:58
75
+ #: src/components/WalletTag.tsx:60
76
76
  msgid "Connected"
77
77
  msgstr ""
78
78
 
79
- #: src/components/WalletTag.tsx:42
79
+ #: src/components/WalletTag.tsx:44
80
80
  msgid "Connecting"
81
81
  msgstr ""
82
82
 
@@ -124,7 +124,7 @@ msgstr ""
124
124
  msgid "ID"
125
125
  msgstr ""
126
126
 
127
- #: src/components/WalletTag.tsx:107
127
+ #: src/components/WalletTag.tsx:109
128
128
  msgid "Installed Wallet"
129
129
  msgstr ""
130
130
 
@@ -136,7 +136,7 @@ msgstr ""
136
136
  msgid "Invalid wallet address"
137
137
  msgstr ""
138
138
 
139
- #: src/components/WalletTag.tsx:74
139
+ #: src/components/WalletTag.tsx:76
140
140
  msgid "Last connection"
141
141
  msgstr ""
142
142
 
@@ -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:362
159
+ #: src/WalletConnect/ConnectPage.tsx:389
160
160
  msgid "More Wallets"
161
161
  msgstr ""
162
162