@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,200 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
const {
|
|
144
|
-
|
|
145
|
-
const
|
|
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
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
BoxProps,
|
|
6
|
+
HoverOpacity,
|
|
7
|
+
HoverAddBackground,
|
|
8
|
+
HoverAddUnderLine,
|
|
9
|
+
useTheme,
|
|
10
|
+
ButtonBase,
|
|
11
|
+
} from '@dodoex/components';
|
|
12
|
+
import { ArrowRight, ArrowTopRightBorder } from '@dodoex/icons';
|
|
13
|
+
import { useWalletStore } from '@dodoex/wallet-web3';
|
|
14
|
+
import { useWalletConnectContext } from '../WalletConnectProvider';
|
|
15
|
+
|
|
16
|
+
export function truncatePoolAddress(address: string): string {
|
|
17
|
+
if (address.length <= 10) {
|
|
18
|
+
return address;
|
|
19
|
+
}
|
|
20
|
+
return `${address.slice(0, 6)}...${address.slice(
|
|
21
|
+
address.length - 4,
|
|
22
|
+
address.length,
|
|
23
|
+
)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface AddressTextProps {
|
|
27
|
+
sx?: BoxProps['sx'];
|
|
28
|
+
truncate?: boolean;
|
|
29
|
+
address: string;
|
|
30
|
+
disabledAddress?: boolean;
|
|
31
|
+
addressHoverColor?: string;
|
|
32
|
+
addressHoverShowIcon?: boolean;
|
|
33
|
+
handleOpen?: (
|
|
34
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
35
|
+
type: 'address' | 'icon',
|
|
36
|
+
) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Props extends AddressTextProps {
|
|
40
|
+
showCopy?: boolean;
|
|
41
|
+
size?: 'small' | 'medium' | 'big';
|
|
42
|
+
newTab?: boolean;
|
|
43
|
+
iconSize?: number;
|
|
44
|
+
iconSpace?: number;
|
|
45
|
+
iconDarkHover?: boolean;
|
|
46
|
+
customChainId?: number;
|
|
47
|
+
onAddressClick?: (
|
|
48
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
49
|
+
) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function AddressText({
|
|
53
|
+
truncate,
|
|
54
|
+
address,
|
|
55
|
+
disabledAddress,
|
|
56
|
+
sx,
|
|
57
|
+
handleOpen,
|
|
58
|
+
addressHoverColor,
|
|
59
|
+
addressHoverShowIcon,
|
|
60
|
+
}: AddressTextProps & {
|
|
61
|
+
typography?: string;
|
|
62
|
+
domain?: string;
|
|
63
|
+
}) {
|
|
64
|
+
if (disabledAddress) {
|
|
65
|
+
return <Box>{truncate ? truncatePoolAddress(address) : address}</Box>;
|
|
66
|
+
}
|
|
67
|
+
return (
|
|
68
|
+
<HoverAddUnderLine
|
|
69
|
+
lineSx={{
|
|
70
|
+
bottom: -1,
|
|
71
|
+
}}
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
lineColor={addressHoverColor ?? (sx?.color || '')}
|
|
74
|
+
hoverSx={{
|
|
75
|
+
color: 'addressHoverColor',
|
|
76
|
+
'& svg': {
|
|
77
|
+
display: 'inline-block',
|
|
78
|
+
},
|
|
79
|
+
}}
|
|
80
|
+
className="truncate-address-link"
|
|
81
|
+
>
|
|
82
|
+
<Box
|
|
83
|
+
onClick={(evt) => {
|
|
84
|
+
handleOpen?.(evt, 'address');
|
|
85
|
+
}}
|
|
86
|
+
sx={{
|
|
87
|
+
display: 'flex',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
cursor: 'pointer',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{truncate ? truncatePoolAddress(address) : address}
|
|
93
|
+
{addressHoverShowIcon ? (
|
|
94
|
+
<Box
|
|
95
|
+
component={ArrowRight}
|
|
96
|
+
sx={{
|
|
97
|
+
display: 'none',
|
|
98
|
+
width: 14,
|
|
99
|
+
height: 14,
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
''
|
|
104
|
+
)}
|
|
105
|
+
</Box>
|
|
106
|
+
</HoverAddUnderLine>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function AddressWithLink({
|
|
111
|
+
address,
|
|
112
|
+
truncate,
|
|
113
|
+
size = 'medium',
|
|
114
|
+
iconSize,
|
|
115
|
+
iconSpace: iconSpaceProps,
|
|
116
|
+
sx,
|
|
117
|
+
iconDarkHover,
|
|
118
|
+
disabledAddress,
|
|
119
|
+
addressHoverColor,
|
|
120
|
+
addressHoverShowIcon,
|
|
121
|
+
customChainId,
|
|
122
|
+
handleOpen,
|
|
123
|
+
onAddressClick,
|
|
124
|
+
}: Props) {
|
|
125
|
+
const theme = useTheme();
|
|
126
|
+
|
|
127
|
+
const isBig = size === 'big';
|
|
128
|
+
const isMedium = size === 'medium';
|
|
129
|
+
|
|
130
|
+
const IconHoverBox = iconDarkHover ? HoverAddBackground : HoverOpacity;
|
|
131
|
+
const getIconSpace = (isMediumRes?: boolean) => {
|
|
132
|
+
let iconSpace = isMediumRes ? 12 : 8;
|
|
133
|
+
if (iconSpaceProps) {
|
|
134
|
+
iconSpace = iconSpaceProps;
|
|
135
|
+
}
|
|
136
|
+
if (iconDarkHover) {
|
|
137
|
+
iconSpace -= 3;
|
|
138
|
+
}
|
|
139
|
+
return iconSpace;
|
|
140
|
+
};
|
|
141
|
+
// eslint-disable-next-line no-nested-ternary
|
|
142
|
+
const typography = isBig ? 'h5' : isMedium ? 'body1' : 'body2';
|
|
143
|
+
const { chainId: currentChainId } = useWalletStore();
|
|
144
|
+
const chainId = customChainId ?? currentChainId;
|
|
145
|
+
const { getChain } = useWalletConnectContext();
|
|
146
|
+
|
|
147
|
+
const handleOpenResult: AddressTextProps['handleOpen'] = (evt, type) => {
|
|
148
|
+
if (handleOpen) {
|
|
149
|
+
handleOpen(evt, type);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (chainId) {
|
|
153
|
+
evt.stopPropagation();
|
|
154
|
+
const scanUrl = getChain(chainId)?.scanUrl;
|
|
155
|
+
if (!scanUrl) return;
|
|
156
|
+
window.open(`https://${scanUrl}${address ? `/address/${address}` : ''}`);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<Box
|
|
162
|
+
sx={{
|
|
163
|
+
display: 'flex',
|
|
164
|
+
alignItems: 'center',
|
|
165
|
+
typography,
|
|
166
|
+
color: theme.palette.text.primary,
|
|
167
|
+
lineHeight: 'normal',
|
|
168
|
+
...(sx || {}),
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
<AddressText
|
|
172
|
+
truncate={truncate}
|
|
173
|
+
address={address}
|
|
174
|
+
disabledAddress={disabledAddress}
|
|
175
|
+
sx={sx}
|
|
176
|
+
typography={typography}
|
|
177
|
+
handleOpen={onAddressClick ?? handleOpenResult}
|
|
178
|
+
addressHoverColor={addressHoverColor}
|
|
179
|
+
addressHoverShowIcon={addressHoverShowIcon}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
<IconHoverBox
|
|
183
|
+
sx={{
|
|
184
|
+
display: 'inline-flex',
|
|
185
|
+
ml: getIconSpace(isMedium),
|
|
186
|
+
cursor: 'pointer',
|
|
187
|
+
}}
|
|
188
|
+
onClick={(evt) => {
|
|
189
|
+
handleOpenResult(evt, 'icon');
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<Box
|
|
193
|
+
component={ArrowTopRightBorder}
|
|
194
|
+
sx={{
|
|
195
|
+
width: iconSize || (isMedium ? 16 : 14),
|
|
196
|
+
height: iconSize || (isMedium ? 16 : 14),
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
</IconHoverBox>
|
|
200
|
+
</Box>
|
|
201
|
+
);
|
|
202
|
+
}
|