@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.
Files changed (40) hide show
  1. package/babel.config.js +9 -9
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +1 -1
  4. package/lingui.config.ts +13 -13
  5. package/package.json +90 -77
  6. package/rollup.config.mjs +100 -100
  7. package/src/ClientProvider.tsx +17 -15
  8. package/src/LangProvider.tsx +36 -34
  9. package/src/WalletConnect/AccountPage.tsx +496 -494
  10. package/src/WalletConnect/ActivityList.tsx +606 -604
  11. package/src/WalletConnect/ConnectAlchemy/index.tsx +248 -246
  12. package/src/WalletConnect/ConnectAlchemy/useConnectAlchemy.ts +105 -105
  13. package/src/WalletConnect/ConnectDialog.tsx +35 -33
  14. package/src/WalletConnect/ConnectLedger/ErrorDialog.tsx +61 -61
  15. package/src/WalletConnect/ConnectLedger/LockedDialog.tsx +54 -54
  16. package/src/WalletConnect/ConnectLedger/helper.ts +14 -14
  17. package/src/WalletConnect/ConnectLedger/index.tsx +2 -0
  18. package/src/WalletConnect/ConnectPage.tsx +508 -506
  19. package/src/WalletConnect/HasBalanceTokenList.tsx +202 -200
  20. package/src/WalletConnect/ReceiveTokenPage.tsx +145 -143
  21. package/src/WalletConnect/SendTokenPage.tsx +251 -249
  22. package/src/WalletConnect/WalletDialog.tsx +80 -78
  23. package/src/WalletConnectProvider.tsx +57 -55
  24. package/src/components/AddressWithLinkAndCopy.tsx +202 -200
  25. package/src/components/Dialog.tsx +158 -156
  26. package/src/components/TokenLogo.tsx +167 -165
  27. package/src/components/WalletTag.tsx +117 -115
  28. package/src/constants/localstorage.ts +24 -22
  29. package/src/hooks/useConnectWallet.ts +150 -148
  30. package/src/hooks/useFetchFiatPrice.ts +53 -51
  31. package/src/hooks/useFetchTokensBalance.ts +53 -51
  32. package/src/hooks/useHasBalanceTokenList.ts +95 -93
  33. package/src/hooks/useTransactionList.ts +89 -87
  34. package/src/index.tsx +7 -7
  35. package/src/locales/en.po +51 -51
  36. package/src/locales/zh.po +51 -51
  37. package/src/utils/formatter.ts +102 -102
  38. package/src/utils/time.ts +21 -21
  39. package/src/utils/utils.ts +8 -8
  40. 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,78 +1,91 @@
1
- {
2
- "name": "@dodoex/wallet-web3-react",
3
- "version": "0.2.1",
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
- "peerDependencies": {
42
- "@dodoex/wallet-web3": ">=0.0.70",
43
- "@dodoex/contract-request": ">=1.x",
44
- "@dodoex/dodo-contract-request": ">=1.x",
45
- "@dodoex/icons": ">=2.0.2",
46
- "@dodoex/api": ">=3.0.2",
47
- "@dodoex/components": ">=3.0.4",
48
- "react": ">=17.0.2",
49
- "react-dom": ">=17.0.2"
50
- },
51
- "devDependencies": {
52
- "@lingui/cli": "^4.11.4",
53
- "@lingui/loader": "^4.11.4",
54
- "@rollup/plugin-replace": "^6.0.2",
55
- "@rollup/plugin-terser": "^0.4.4",
56
- "@rollup/plugin-typescript": "^12.1.1",
57
- "@rollup/plugin-url": "^8.0.2",
58
- "@svgr/rollup": "^8.1.0",
59
- "@types/identicon.js": "^2.3.5",
60
- "@types/react-infinite-scroller": "^1.2.5",
61
- "babel-plugin-macros": "^3.1.0",
62
- "rollup": "^4.28.0",
63
- "rollup-plugin-clear": "^2.0.7",
64
- "rollup-plugin-import-css": "^3.5.7",
65
- "typescript": "^5.6.3"
66
- },
67
- "dependencies": {
68
- "@lingui/macro": "^4.11.4",
69
- "@lingui/react": "^4.11.4",
70
- "@tanstack/react-query": "^5.18.1",
71
- "bignumber.js": "^9.1.2",
72
- "copy-to-clipboard": "^3.3.3",
73
- "dayjs": "^1.11.13",
74
- "identicon.js": "^2.3.3",
75
- "qrcode.react": "^4.2.0",
76
- "react-infinite-scroller": "^1.2.6"
77
- }
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
+ }
78
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
+ ];
@@ -1,15 +1,17 @@
1
- import { createTheme, ThemeProvider } from '@dodoex/components';
2
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
- import LangProvider from './LangProvider';
4
-
5
- export default function ClientProvider({ children }: React.PropsWithChildren) {
6
- const queryClient = new QueryClient();
7
- const theme = createTheme();
8
- return (
9
- <QueryClientProvider client={queryClient}>
10
- <ThemeProvider theme={theme}>
11
- <LangProvider>{children}</LangProvider>
12
- </ThemeProvider>
13
- </QueryClientProvider>
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
+ }
@@ -1,34 +1,36 @@
1
- import { i18n } from '@lingui/core';
2
- import { I18nProvider } from '@lingui/react';
3
- import { ReactNode, useEffect } from 'react';
4
-
5
- export const supportedLang = ['en', 'zh'];
6
- export type SupportedLang = typeof supportedLang[number];
7
-
8
- export const defaultLang: SupportedLang = 'en';
9
-
10
- interface LangProviderProps {
11
- locale?: SupportedLang;
12
- children: ReactNode;
13
- }
14
-
15
- export async function loadI18(locale: SupportedLang = defaultLang) {
16
- try {
17
- const catalog = await import(`./locales/${locale}.js`);
18
- i18n.load(locale, catalog.messages || catalog.default.messages);
19
- } catch (error) {
20
- console.error(error);
21
- }
22
- i18n.activate(locale);
23
- }
24
- export function LangProvider({ locale, children }: LangProviderProps) {
25
- useEffect(() => {
26
- const loadLocale = async () => {
27
- await loadI18(locale);
28
- };
29
- loadLocale();
30
- }, [locale]);
31
- return <I18nProvider i18n={i18n}>{children}</I18nProvider>;
32
- }
33
-
34
- export default LangProvider;
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;