@dodoex/wallet-web3-react 0.2.0 → 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 +91 -76
- 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 -146
- 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
package/lingui.config.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
locales: ['en', 'zh'],
|
|
3
|
-
sourceLocale: 'en',
|
|
4
|
-
catalogs: [
|
|
5
|
-
{
|
|
6
|
-
path: 'src/locales/{locale}',
|
|
7
|
-
include: ['src'],
|
|
8
|
-
},
|
|
9
|
-
],
|
|
10
|
-
format: 'po',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default config;
|
|
1
|
+
const config = {
|
|
2
|
+
locales: ['en', 'zh'],
|
|
3
|
+
sourceLocale: 'en',
|
|
4
|
+
catalogs: [
|
|
5
|
+
{
|
|
6
|
+
path: 'src/locales/{locale}',
|
|
7
|
+
include: ['src'],
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
format: 'po',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,76 +1,91 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dodoex/wallet-web3-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"source": "src/index.tsx",
|
|
5
|
-
"types": "dist/types/index.d.ts",
|
|
6
|
-
"typings": "dist/types/index.d.ts",
|
|
7
|
-
"main": "dist/cjs/index.cjs",
|
|
8
|
-
"module": "dist/index.js",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"start": "yarn workspace doc start",
|
|
11
|
-
"build": "yarn extract && yarn compile && rollup -c",
|
|
12
|
-
"extract": "lingui extract --clean",
|
|
13
|
-
"compile": "lingui compile"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"last 1
|
|
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
|
-
"@lingui/
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"identicon.js": "^2.3.
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@dodoex/wallet-web3-react",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"source": "src/index.tsx",
|
|
5
|
+
"types": "dist/types/index.d.ts",
|
|
6
|
+
"typings": "dist/types/index.d.ts",
|
|
7
|
+
"main": "dist/cjs/index.cjs",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "yarn workspace doc start",
|
|
11
|
+
"build": "yarn extract && yarn compile && rollup -c",
|
|
12
|
+
"extract": "lingui extract --clean",
|
|
13
|
+
"compile": "lingui compile",
|
|
14
|
+
"release.npm-publish": "npm publish --access public",
|
|
15
|
+
"release.npm-publish-beta": "npm publish --tag beta"
|
|
16
|
+
},
|
|
17
|
+
"author": "",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org"
|
|
21
|
+
},
|
|
22
|
+
"license": "GPL-3.0-or-later",
|
|
23
|
+
"description": "",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"dodo",
|
|
26
|
+
"wallet",
|
|
27
|
+
"ethereum"
|
|
28
|
+
],
|
|
29
|
+
"browserslist": {
|
|
30
|
+
"production": [
|
|
31
|
+
">0.2%",
|
|
32
|
+
"not dead",
|
|
33
|
+
"not op_mini all"
|
|
34
|
+
],
|
|
35
|
+
"development": [
|
|
36
|
+
"last 1 chrome version",
|
|
37
|
+
"last 1 firefox version",
|
|
38
|
+
"last 1 safari version"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"types": "./dist/types/index.d.ts",
|
|
44
|
+
"import": "./dist/index.js",
|
|
45
|
+
"require": "./dist/cjs/index.cjs",
|
|
46
|
+
"default": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./locales/*": {
|
|
49
|
+
"import": "./dist/locales/*.js",
|
|
50
|
+
"require": "./dist/cjs/locales/*.js",
|
|
51
|
+
"default": "./dist/locales/*.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@dodoex/wallet-web3": ">=0.0.70",
|
|
56
|
+
"@dodoex/contract-request": ">=1.x",
|
|
57
|
+
"@dodoex/dodo-contract-request": ">=1.x",
|
|
58
|
+
"@dodoex/icons": ">=2.0.2",
|
|
59
|
+
"@dodoex/api": ">=3.0.2",
|
|
60
|
+
"@dodoex/components": ">=3.0.4",
|
|
61
|
+
"react": ">=17.0.2 <20.0.0",
|
|
62
|
+
"react-dom": ">=17.0.2 <20.0.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@lingui/cli": "^4.11.4",
|
|
66
|
+
"@lingui/loader": "^4.11.4",
|
|
67
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
68
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
69
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
70
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
71
|
+
"@svgr/rollup": "^8.1.0",
|
|
72
|
+
"@types/identicon.js": "^2.3.5",
|
|
73
|
+
"@types/react-infinite-scroller": "^1.2.5",
|
|
74
|
+
"babel-plugin-macros": "^3.1.0",
|
|
75
|
+
"rollup": "^4.28.0",
|
|
76
|
+
"rollup-plugin-clear": "^2.0.7",
|
|
77
|
+
"rollup-plugin-import-css": "^3.5.7",
|
|
78
|
+
"typescript": "^5.6.3"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@lingui/macro": "^4.11.4",
|
|
82
|
+
"@lingui/react": "^4.11.4",
|
|
83
|
+
"@tanstack/react-query": "^5.18.1",
|
|
84
|
+
"bignumber.js": "^9.1.2",
|
|
85
|
+
"copy-to-clipboard": "^3.3.3",
|
|
86
|
+
"dayjs": "^1.11.13",
|
|
87
|
+
"identicon.js": "^2.3.3",
|
|
88
|
+
"qrcode.react": "^4.2.0",
|
|
89
|
+
"react-infinite-scroller": "^1.2.6"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/rollup.config.mjs
CHANGED
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { babel } from '@rollup/plugin-babel';
|
|
2
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
-
import json from '@rollup/plugin-json';
|
|
4
|
-
import typescript from '@rollup/plugin-typescript';
|
|
5
|
-
import terser from '@rollup/plugin-terser';
|
|
6
|
-
import url from '@rollup/plugin-url';
|
|
7
|
-
import replace from '@rollup/plugin-replace';
|
|
8
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
9
|
-
import svgr from '@svgr/rollup';
|
|
10
|
-
import pkg from './package.json' with { type: 'json' };
|
|
11
|
-
import globby from 'globby';
|
|
12
|
-
import css from 'rollup-plugin-import-css';
|
|
13
|
-
import clear from 'rollup-plugin-clear';
|
|
14
|
-
|
|
15
|
-
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
16
|
-
const baseConfig = {
|
|
17
|
-
input: pkg.source,
|
|
18
|
-
jsx: {
|
|
19
|
-
mode: 'preserve',
|
|
20
|
-
factory: 'React.createElement',
|
|
21
|
-
fragment: 'React.Fragment',
|
|
22
|
-
importSource: 'react'
|
|
23
|
-
},
|
|
24
|
-
plugins: [
|
|
25
|
-
replace({
|
|
26
|
-
'../locales/${locale}.js': './locales/${locale}.js',
|
|
27
|
-
delimiters: ['', ''],
|
|
28
|
-
}),
|
|
29
|
-
url(),
|
|
30
|
-
svgr({
|
|
31
|
-
svgo: true,
|
|
32
|
-
svgoConfig: {
|
|
33
|
-
plugins: [
|
|
34
|
-
{
|
|
35
|
-
name: 'removeViewBox',
|
|
36
|
-
active: false,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
json(),
|
|
42
|
-
typescript(),
|
|
43
|
-
commonjs(),
|
|
44
|
-
resolve(),
|
|
45
|
-
babel({
|
|
46
|
-
extensions,
|
|
47
|
-
babelHelpers: 'bundled',
|
|
48
|
-
}),
|
|
49
|
-
css(),
|
|
50
|
-
clear({
|
|
51
|
-
// required, point out which directories should be clear.
|
|
52
|
-
targets: ['dist'],
|
|
53
|
-
// optional, whether clear the directores when rollup recompile on --watch mode.
|
|
54
|
-
watch: true, // default: false
|
|
55
|
-
}),
|
|
56
|
-
],
|
|
57
|
-
external: [
|
|
58
|
-
...Object.keys(pkg.dependencies || {}).filter(
|
|
59
|
-
(key) => !['@dodoex/icons'].includes(key),
|
|
60
|
-
),
|
|
61
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const localesConfig = globby.sync('src/locales/*.js').map((inputFile) => ({
|
|
66
|
-
input: inputFile,
|
|
67
|
-
output: [
|
|
68
|
-
{
|
|
69
|
-
dir: 'dist/locales',
|
|
70
|
-
format: 'esm',
|
|
71
|
-
sourcemap: false,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
dir: 'dist/cjs/locales',
|
|
75
|
-
sourcemap: false,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
}));
|
|
79
|
-
|
|
80
|
-
export default [
|
|
81
|
-
{
|
|
82
|
-
output: [
|
|
83
|
-
{
|
|
84
|
-
dir: 'dist',
|
|
85
|
-
format: 'es',
|
|
86
|
-
plugins: [terser()],
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
dir: 'dist',
|
|
90
|
-
entryFileNames: '[name].cjs',
|
|
91
|
-
chunkFileNames: '[name]-[hash].cjs',
|
|
92
|
-
format: 'cjs',
|
|
93
|
-
sourcemap: false,
|
|
94
|
-
plugins: [terser()],
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
...baseConfig,
|
|
98
|
-
},
|
|
99
|
-
...localesConfig,
|
|
100
|
-
];
|
|
1
|
+
import { babel } from '@rollup/plugin-babel';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import json from '@rollup/plugin-json';
|
|
4
|
+
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
import terser from '@rollup/plugin-terser';
|
|
6
|
+
import url from '@rollup/plugin-url';
|
|
7
|
+
import replace from '@rollup/plugin-replace';
|
|
8
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
9
|
+
import svgr from '@svgr/rollup';
|
|
10
|
+
import pkg from './package.json' with { type: 'json' };
|
|
11
|
+
import globby from 'globby';
|
|
12
|
+
import css from 'rollup-plugin-import-css';
|
|
13
|
+
import clear from 'rollup-plugin-clear';
|
|
14
|
+
|
|
15
|
+
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
|
|
16
|
+
const baseConfig = {
|
|
17
|
+
input: pkg.source,
|
|
18
|
+
jsx: {
|
|
19
|
+
mode: 'preserve',
|
|
20
|
+
factory: 'React.createElement',
|
|
21
|
+
fragment: 'React.Fragment',
|
|
22
|
+
importSource: 'react'
|
|
23
|
+
},
|
|
24
|
+
plugins: [
|
|
25
|
+
replace({
|
|
26
|
+
'../locales/${locale}.js': './locales/${locale}.js',
|
|
27
|
+
delimiters: ['', ''],
|
|
28
|
+
}),
|
|
29
|
+
url(),
|
|
30
|
+
svgr({
|
|
31
|
+
svgo: true,
|
|
32
|
+
svgoConfig: {
|
|
33
|
+
plugins: [
|
|
34
|
+
{
|
|
35
|
+
name: 'removeViewBox',
|
|
36
|
+
active: false,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
json(),
|
|
42
|
+
typescript(),
|
|
43
|
+
commonjs(),
|
|
44
|
+
resolve(),
|
|
45
|
+
babel({
|
|
46
|
+
extensions,
|
|
47
|
+
babelHelpers: 'bundled',
|
|
48
|
+
}),
|
|
49
|
+
css(),
|
|
50
|
+
clear({
|
|
51
|
+
// required, point out which directories should be clear.
|
|
52
|
+
targets: ['dist'],
|
|
53
|
+
// optional, whether clear the directores when rollup recompile on --watch mode.
|
|
54
|
+
watch: true, // default: false
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
external: [
|
|
58
|
+
...Object.keys(pkg.dependencies || {}).filter(
|
|
59
|
+
(key) => !['@dodoex/icons'].includes(key),
|
|
60
|
+
),
|
|
61
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const localesConfig = globby.sync('src/locales/*.js').map((inputFile) => ({
|
|
66
|
+
input: inputFile,
|
|
67
|
+
output: [
|
|
68
|
+
{
|
|
69
|
+
dir: 'dist/locales',
|
|
70
|
+
format: 'esm',
|
|
71
|
+
sourcemap: false,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
dir: 'dist/cjs/locales',
|
|
75
|
+
sourcemap: false,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
export default [
|
|
81
|
+
{
|
|
82
|
+
output: [
|
|
83
|
+
{
|
|
84
|
+
dir: 'dist',
|
|
85
|
+
format: 'es',
|
|
86
|
+
plugins: [terser()],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
dir: 'dist',
|
|
90
|
+
entryFileNames: '[name].cjs',
|
|
91
|
+
chunkFileNames: '[name]-[hash].cjs',
|
|
92
|
+
format: 'cjs',
|
|
93
|
+
sourcemap: false,
|
|
94
|
+
plugins: [terser()],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
...baseConfig,
|
|
98
|
+
},
|
|
99
|
+
...localesConfig,
|
|
100
|
+
];
|
package/src/ClientProvider.tsx
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createTheme, ThemeProvider } from '@dodoex/components';
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
|
+
import LangProvider from './LangProvider';
|
|
6
|
+
|
|
7
|
+
export default function ClientProvider({ children }: React.PropsWithChildren) {
|
|
8
|
+
const queryClient = new QueryClient();
|
|
9
|
+
const theme = createTheme();
|
|
10
|
+
return (
|
|
11
|
+
<QueryClientProvider client={queryClient}>
|
|
12
|
+
<ThemeProvider theme={theme}>
|
|
13
|
+
<LangProvider>{children}</LangProvider>
|
|
14
|
+
</ThemeProvider>
|
|
15
|
+
</QueryClientProvider>
|
|
16
|
+
);
|
|
17
|
+
}
|
package/src/LangProvider.tsx
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import { I18nProvider } from '@lingui/react';
|
|
5
|
+
import { ReactNode, useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
export const supportedLang = ['en', 'zh'];
|
|
8
|
+
export type SupportedLang = typeof supportedLang[number];
|
|
9
|
+
|
|
10
|
+
export const defaultLang: SupportedLang = 'en';
|
|
11
|
+
|
|
12
|
+
interface LangProviderProps {
|
|
13
|
+
locale?: SupportedLang;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function loadI18(locale: SupportedLang = defaultLang) {
|
|
18
|
+
try {
|
|
19
|
+
const catalog = await import(`./locales/${locale}.js`);
|
|
20
|
+
i18n.load(locale, catalog.messages || catalog.default.messages);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(error);
|
|
23
|
+
}
|
|
24
|
+
i18n.activate(locale);
|
|
25
|
+
}
|
|
26
|
+
export function LangProvider({ locale, children }: LangProviderProps) {
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const loadLocale = async () => {
|
|
29
|
+
await loadI18(locale);
|
|
30
|
+
};
|
|
31
|
+
loadLocale();
|
|
32
|
+
}, [locale]);
|
|
33
|
+
return <I18nProvider i18n={i18n}>{children}</I18nProvider>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default LangProvider;
|