@dodoex/wallet-web3-react 0.4.0 → 0.4.2

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 (68) hide show
  1. package/babel.config.js +9 -9
  2. package/dist/cjs/index.cjs +4 -13
  3. package/dist/cjs/locales/en.js +1 -1
  4. package/dist/cjs/locales/zh.js +1 -1
  5. package/dist/index.js +4 -13
  6. package/dist/locales/en.js +1 -1
  7. package/dist/locales/zh.js +1 -1
  8. package/dist/types/ClientProvider.d.ts +1 -1
  9. package/dist/types/LangProvider.d.ts +1 -1
  10. package/dist/types/WalletConnect/AccountPage.d.ts +1 -1
  11. package/dist/types/WalletConnect/ActivityList.d.ts +5 -4
  12. package/dist/types/WalletConnect/ConnectAlchemy/index.d.ts +2 -1
  13. package/dist/types/WalletConnect/ConnectDialog.d.ts +2 -1
  14. package/dist/types/WalletConnect/ConnectLedger/ErrorDialog.d.ts +1 -1
  15. package/dist/types/WalletConnect/ConnectLedger/LoadingDialog.d.ts +1 -1
  16. package/dist/types/WalletConnect/ConnectLedger/LockedDialog.d.ts +1 -1
  17. package/dist/types/WalletConnect/ConnectLedger/ProtocolDialog.d.ts +1 -1
  18. package/dist/types/WalletConnect/ConnectLedger/SelectAddressDialog.d.ts +1 -1
  19. package/dist/types/WalletConnect/ConnectLedger/SelectPathDialog.d.ts +1 -1
  20. package/dist/types/WalletConnect/ConnectLedger/index.d.ts +1 -1
  21. package/dist/types/WalletConnect/ConnectPage.d.ts +1 -1
  22. package/dist/types/WalletConnect/HasBalanceTokenList.d.ts +1 -1
  23. package/dist/types/WalletConnect/ReceiveTokenPage.d.ts +2 -1
  24. package/dist/types/WalletConnect/SendTokenPage.d.ts +2 -1
  25. package/dist/types/WalletConnect/WalletDialog.d.ts +2 -1
  26. package/dist/types/WalletConnectProvider.d.ts +2 -2
  27. package/dist/types/components/AddressWithLinkAndCopy.d.ts +2 -2
  28. package/dist/types/components/Dialog.d.ts +3 -3
  29. package/dist/types/components/WalletTag.d.ts +1 -1
  30. package/lingui.config.ts +13 -13
  31. package/package.json +90 -90
  32. package/rollup.config.mjs +106 -103
  33. package/src/ClientProvider.tsx +17 -17
  34. package/src/LangProvider.tsx +36 -36
  35. package/src/WalletConnect/AccountPage.tsx +498 -498
  36. package/src/WalletConnect/ActivityList.tsx +606 -606
  37. package/src/WalletConnect/ConnectAlchemy/index.tsx +248 -248
  38. package/src/WalletConnect/ConnectAlchemy/useConnectAlchemy.ts +105 -105
  39. package/src/WalletConnect/ConnectDialog.tsx +35 -35
  40. package/src/WalletConnect/ConnectLedger/ErrorDialog.tsx +61 -61
  41. package/src/WalletConnect/ConnectLedger/LockedDialog.tsx +54 -54
  42. package/src/WalletConnect/ConnectLedger/helper.ts +14 -14
  43. package/src/WalletConnect/ConnectPage.tsx +508 -508
  44. package/src/WalletConnect/HasBalanceTokenList.tsx +202 -202
  45. package/src/WalletConnect/ReceiveTokenPage.tsx +145 -145
  46. package/src/WalletConnect/SendTokenPage.tsx +251 -251
  47. package/src/WalletConnect/WalletDialog.tsx +80 -80
  48. package/src/WalletConnectProvider.tsx +57 -57
  49. package/src/components/AddressWithLinkAndCopy.tsx +202 -202
  50. package/src/components/Dialog.tsx +158 -158
  51. package/src/components/TokenLogo.tsx +167 -167
  52. package/src/components/WalletTag.tsx +117 -117
  53. package/src/constants/localstorage.ts +24 -24
  54. package/src/hooks/useConnectWallet.ts +150 -150
  55. package/src/hooks/useFetchFiatPrice.ts +53 -53
  56. package/src/hooks/useFetchTokensBalance.ts +53 -53
  57. package/src/hooks/useHasBalanceTokenList.ts +95 -95
  58. package/src/hooks/useTransactionList.ts +89 -89
  59. package/src/index.tsx +7 -7
  60. package/src/locales/en.js +1 -1
  61. package/src/locales/en.po +8 -8
  62. package/src/locales/zh.js +1 -1
  63. package/src/locales/zh.po +4 -4
  64. package/src/react19-types.d.ts +12 -0
  65. package/src/utils/formatter.ts +102 -102
  66. package/src/utils/time.ts +21 -21
  67. package/src/utils/utils.ts +8 -8
  68. package/tsconfig.json +22 -22
package/src/locales/zh.js CHANGED
@@ -1 +1 @@
1
- /*eslint-disable*/module.exports={messages:JSON.parse("{\"Sz0SkD\":[\"1、Ledger Live APP is closed\",[\"BR\"],\"2、The device plugged in via USB,NOT Bluetooth\",[\"BR\"],\"3、The device is unlocked and in the \",[\"ledgerAppName\"],\" app\",[\"BR\"],\"4、”Blind Signing” is enabled in \",[\"ledgerAppName\"],\" app\"],\"AeXO77\":\"Account\",\"XJOV1Y\":\"Activity\",\"OBdohg\":\"Add Liquidity\",\"Du6bPw\":\"Address\",\"Z7ZXbT\":\"Approve\",\"vN+hAq\":\"Available Ledger Account\",\"fsBGk0\":\"Balance\",\"E/yE9x\":\"Before proceeding make sure\",\"3UCJ3e\":\"Check your email and click the link to complete login\",\"Mlg3Ds\":\"Choose existing passkey\",\"zXCpR0\":\"Claim Rewards\",\"RETKSh\":\"Connect Alchemy\",\"CtByM7\":\"Connect Wallet\",\"QHcLEN\":\"Connected\",\"9zb2WA\":\"Connecting\",\"xGVfLh\":\"Continue\",\"6V3Ea3\":\"Copied\",\"gCNLBV\":\"Copy wallet address\",\"14s9LL\":\"Create Liquidity Mining\",\"OzjK0A\":\"Create new passkey\",\"WZRsOg\":\"End mining\\\\n\",\"6KnyG0\":\"Enter email\",\"7Bj3x9\":\"Failed\",\"sr0UJD\":\"Go Back\",\"S0kLOH\":\"ID\",\"9ow2PX\":\"Installed Wallet\",\"B2Tpo0\":\"Invalid email\",\"rwC96V\":\"Invalid wallet address\",\"xHr8Pp\":\"Last connection\",\"EYDfo2\":\"Loading more\",\"Z3FXyt\":\"Loading...\",\"6Ui8nZ\":\"Log in with your email\",\"3y6FjD\":\"Log in with your email or a passkey\",\"yN5k0R\":\"More Wallets\",\"JE8mMQ\":\"No tokens\",\"zga9sT\":\"OK\",\"U8oDGg\":\"On-chain transaction records\",\"BzEFor\":\"or\",\"UbRKMZ\":\"Pending\",\"8OiU8L\":\"Pool Creation\",\"lDgVWA\":\"Receive\",\"pkRuyd\":\"Receiver address\",\"3XBvkd\":\"Remove Liquidity\",\"OfhWJH\":\"Reset\",\"JlFcis\":\"Send\",\"JYKRJS\":\"Stake\",\"hQRttt\":\"Submit\",\"KAbcm2\":\"Succeeded\",\"vH2C/2\":\"Swap\",\"kdetxi\":\"The Ledger Device is locked\\nPlease unlock from the device\",\"FzJ11V\":\"This is empty\",\"TP9/K5\":\"Token\",\"zPGNJm\":\"Transfer\",\"LobdAW\":\"Unknown Error\"}")};
1
+ /*eslint-disable*/module.exports={messages:JSON.parse("{\"14s9LL\":[\"Create Liquidity Mining\"],\"3UCJ3e\":[\"Check your email and click the link to complete login\"],\"3XBvkd\":[\"Remove Liquidity\"],\"3y6FjD\":[\"Log in with your email or a passkey\"],\"6KnyG0\":[\"Enter email\"],\"6Ui8nZ\":[\"Log in with your email\"],\"6V3Ea3\":[\"Copied\"],\"7Bj3x9\":[\"Failed\"],\"8OiU8L\":[\"Pool Creation\"],\"9ow2PX\":[\"Installed Wallet\"],\"9zb2WA\":[\"Connecting\"],\"AeXO77\":[\"Account\"],\"B2Tpo0\":[\"Invalid email\"],\"BzEFor\":[\"or\"],\"CtByM7\":[\"Connect Wallet\"],\"Du6bPw\":[\"Address\"],\"E/yE9x\":[\"Before proceeding make sure\"],\"EYDfo2\":[\"Loading more\"],\"FzJ11V\":[\"This is empty\"],\"JE8mMQ\":[\"No tokens\"],\"JYKRJS\":[\"Stake\"],\"JlFcis\":[\"Send\"],\"KAbcm2\":[\"Succeeded\"],\"LobdAW\":[\"Unknown Error\"],\"Mlg3Ds\":[\"Choose existing passkey\"],\"OBdohg\":[\"Add Liquidity\"],\"OfhWJH\":[\"Reset\"],\"OzjK0A\":[\"Create new passkey\"],\"QHcLEN\":[\"Connected\"],\"RETKSh\":[\"Connect Alchemy\"],\"S0kLOH\":[\"ID\"],\"Sz0SkD\":[\"1、Ledger Live APP is closed\",[\"BR\"],\"2、The device plugged in via USB,NOT Bluetooth\",[\"BR\"],\"3、The device is unlocked and in the \",[\"ledgerAppName\"],\" app\",[\"BR\"],\"4、”Blind Signing” is enabled in \",[\"ledgerAppName\"],\" app\"],\"TP9/K5\":[\"Token\"],\"U8oDGg\":[\"On-chain transaction records\"],\"UbRKMZ\":[\"Pending\"],\"XJOV1Y\":[\"Activity\"],\"Z3FXyt\":[\"Loading...\"],\"Z7ZXbT\":[\"Approve\"],\"fsBGk0\":[\"Balance\"],\"gCNLBV\":[\"Copy wallet address\"],\"gPbbTL\":[\"The Ledger Device is locked\\\\nPlease unlock from the device\"],\"hQRttt\":[\"Submit\"],\"lDgVWA\":[\"Receive\"],\"pkRuyd\":[\"Receiver address\"],\"rwC96V\":[\"Invalid wallet address\"],\"sr0UJD\":[\"Go Back\"],\"vH2C/2\":[\"Swap\"],\"vN+hAq\":[\"Available Ledger Account\"],\"xGVfLh\":[\"Continue\"],\"xHr8Pp\":[\"Last connection\"],\"yN5k0R\":[\"More Wallets\"],\"z5vMiF\":[\"End mining\\n\"],\"zPGNJm\":[\"Transfer\"],\"zXCpR0\":[\"Claim Rewards\"],\"zga9sT\":[\"OK\"]}")};
package/src/locales/zh.po CHANGED
@@ -105,7 +105,9 @@ msgid "Create new passkey"
105
105
  msgstr ""
106
106
 
107
107
  #: src/WalletConnect/ActivityList.tsx:402
108
- msgid "End mining\\n"
108
+ msgid ""
109
+ "End mining\n"
110
+ ""
109
111
  msgstr ""
110
112
 
111
113
  #: src/WalletConnect/ConnectAlchemy/index.tsx:131
@@ -227,9 +229,7 @@ msgid "Swap"
227
229
  msgstr ""
228
230
 
229
231
  #: src/WalletConnect/ConnectLedger/LockedDialog.tsx:37
230
- msgid ""
231
- "The Ledger Device is locked\n"
232
- "Please unlock from the device"
232
+ msgid "The Ledger Device is locked\\nPlease unlock from the device"
233
233
  msgstr ""
234
234
 
235
235
  #: src/WalletConnect/ActivityList.tsx:137
@@ -0,0 +1,12 @@
1
+ // React 19 compatibility patch for older component libraries
2
+ // These properties were removed from React 19 types but some component libraries still require them
3
+
4
+ import * as React from 'react';
5
+
6
+ declare module 'react' {
7
+ interface DOMAttributes<T> {
8
+ placeholder?: string | undefined;
9
+ onPointerEnterCapture?: React.PointerEventHandler<T> | undefined;
10
+ onPointerLeaveCapture?: React.PointerEventHandler<T> | undefined;
11
+ }
12
+ }
@@ -1,102 +1,102 @@
1
- import BigNumber from 'bignumber.js';
2
-
3
- const kilo = 1000;
4
- const million = 1000000;
5
- // const billion = 1000000000;
6
- function getNegative(num: number) {
7
- return new BigNumber(num).negated();
8
- }
9
- /**
10
- * format to short number, like: -0.12 -> 0, 0.0000123->0.000012, 123.234 -> 123.23, 1234.12 -> 1.23K, 1000000.123->1.00M
11
- * @param n
12
- */
13
- export function formatShortNumber(n?: BigNumber, showDecimals = 4): string {
14
- if (!n || n.isNaN()) {
15
- return '-';
16
- }
17
- if (n.eq(0)) {
18
- return '0';
19
- }
20
- if (n.lte(0.000001) && n.gte(-0.000001)) {
21
- return n.toExponential(2);
22
- }
23
- if (n.lt(1) && n.gt(-1)) {
24
- return formatReadableNumber({ input: n, showDecimals });
25
- }
26
- if (n.lt(kilo) && n.gt(getNegative(kilo))) {
27
- return formatReadableNumber({ input: n, showDecimals });
28
- }
29
- if (n.lt(million) && n.gt(getNegative(million))) {
30
- return `${formatReadableNumber({ input: n.div(kilo), showDecimals: 2 })}K`;
31
- }
32
- return `${formatReadableNumber({
33
- input: n.div(million),
34
- showDecimals: 2,
35
- })}M`;
36
- }
37
-
38
- /**
39
- * format to readable number, like: 0.00 -> 0, 1.00 -> 1, 1.235 -> 1.23, 1.230 -> 1.23
40
- * @param input
41
- */
42
- export function formatReadableNumber({
43
- input,
44
- showDecimals = 4,
45
- showPrecisionDecimals = 2,
46
- exponentialDecimalsAmount = 8,
47
- showIntegerOnly = false,
48
- showDecimalsOnly = false,
49
- noGroupSeparator = false,
50
- roundingMode = BigNumber.ROUND_DOWN,
51
- }: {
52
- input: BigNumber | number | string;
53
- showDecimals?: number;
54
- showIntegerOnly?: boolean;
55
- showDecimalsOnly?: boolean;
56
- showPrecisionDecimals?: number;
57
- exponentialDecimalsAmount?: number;
58
- noGroupSeparator?: boolean;
59
- roundingMode?: BigNumber.RoundingMode;
60
- }): string {
61
- const source = new BigNumber(input);
62
- if (source.isNaN()) {
63
- return '-';
64
- }
65
- let amount = source.dp(showDecimals, roundingMode);
66
- if (amount.eq(0) && (source.gt(0) || source.lt(0))) {
67
- const significantDigits = showPrecisionDecimals ?? showDecimals;
68
- amount = source.sd(significantDigits, BigNumber.ROUND_DOWN);
69
- const amountDP = amount.dp();
70
- if (
71
- amountDP &&
72
- amountDP > exponentialDecimalsAmount &&
73
- !showDecimalsOnly &&
74
- !showIntegerOnly
75
- ) {
76
- return amount.toExponential();
77
- }
78
-
79
- amount = source.sd(
80
- showPrecisionDecimals ?? showDecimals,
81
- BigNumber.ROUND_DOWN,
82
- );
83
- }
84
- if (showIntegerOnly) {
85
- amount = amount.integerValue(BigNumber.ROUND_DOWN);
86
- }
87
- if (showDecimalsOnly) {
88
- amount = amount.minus(amount.integerValue(BigNumber.ROUND_DOWN));
89
- }
90
-
91
- if (noGroupSeparator) {
92
- return amount.toFormat({
93
- decimalSeparator: '.',
94
- groupSeparator: '',
95
- groupSize: 3,
96
- secondaryGroupSize: 0,
97
- fractionGroupSeparator: '',
98
- fractionGroupSize: 0,
99
- });
100
- }
101
- return amount.toFormat();
102
- }
1
+ import BigNumber from 'bignumber.js';
2
+
3
+ const kilo = 1000;
4
+ const million = 1000000;
5
+ // const billion = 1000000000;
6
+ function getNegative(num: number) {
7
+ return new BigNumber(num).negated();
8
+ }
9
+ /**
10
+ * format to short number, like: -0.12 -> 0, 0.0000123->0.000012, 123.234 -> 123.23, 1234.12 -> 1.23K, 1000000.123->1.00M
11
+ * @param n
12
+ */
13
+ export function formatShortNumber(n?: BigNumber, showDecimals = 4): string {
14
+ if (!n || n.isNaN()) {
15
+ return '-';
16
+ }
17
+ if (n.eq(0)) {
18
+ return '0';
19
+ }
20
+ if (n.lte(0.000001) && n.gte(-0.000001)) {
21
+ return n.toExponential(2);
22
+ }
23
+ if (n.lt(1) && n.gt(-1)) {
24
+ return formatReadableNumber({ input: n, showDecimals });
25
+ }
26
+ if (n.lt(kilo) && n.gt(getNegative(kilo))) {
27
+ return formatReadableNumber({ input: n, showDecimals });
28
+ }
29
+ if (n.lt(million) && n.gt(getNegative(million))) {
30
+ return `${formatReadableNumber({ input: n.div(kilo), showDecimals: 2 })}K`;
31
+ }
32
+ return `${formatReadableNumber({
33
+ input: n.div(million),
34
+ showDecimals: 2,
35
+ })}M`;
36
+ }
37
+
38
+ /**
39
+ * format to readable number, like: 0.00 -> 0, 1.00 -> 1, 1.235 -> 1.23, 1.230 -> 1.23
40
+ * @param input
41
+ */
42
+ export function formatReadableNumber({
43
+ input,
44
+ showDecimals = 4,
45
+ showPrecisionDecimals = 2,
46
+ exponentialDecimalsAmount = 8,
47
+ showIntegerOnly = false,
48
+ showDecimalsOnly = false,
49
+ noGroupSeparator = false,
50
+ roundingMode = BigNumber.ROUND_DOWN,
51
+ }: {
52
+ input: BigNumber | number | string;
53
+ showDecimals?: number;
54
+ showIntegerOnly?: boolean;
55
+ showDecimalsOnly?: boolean;
56
+ showPrecisionDecimals?: number;
57
+ exponentialDecimalsAmount?: number;
58
+ noGroupSeparator?: boolean;
59
+ roundingMode?: BigNumber.RoundingMode;
60
+ }): string {
61
+ const source = new BigNumber(input);
62
+ if (source.isNaN()) {
63
+ return '-';
64
+ }
65
+ let amount = source.dp(showDecimals, roundingMode);
66
+ if (amount.eq(0) && (source.gt(0) || source.lt(0))) {
67
+ const significantDigits = showPrecisionDecimals ?? showDecimals;
68
+ amount = source.sd(significantDigits, BigNumber.ROUND_DOWN);
69
+ const amountDP = amount.dp();
70
+ if (
71
+ amountDP &&
72
+ amountDP > exponentialDecimalsAmount &&
73
+ !showDecimalsOnly &&
74
+ !showIntegerOnly
75
+ ) {
76
+ return amount.toExponential();
77
+ }
78
+
79
+ amount = source.sd(
80
+ showPrecisionDecimals ?? showDecimals,
81
+ BigNumber.ROUND_DOWN,
82
+ );
83
+ }
84
+ if (showIntegerOnly) {
85
+ amount = amount.integerValue(BigNumber.ROUND_DOWN);
86
+ }
87
+ if (showDecimalsOnly) {
88
+ amount = amount.minus(amount.integerValue(BigNumber.ROUND_DOWN));
89
+ }
90
+
91
+ if (noGroupSeparator) {
92
+ return amount.toFormat({
93
+ decimalSeparator: '.',
94
+ groupSeparator: '',
95
+ groupSize: 3,
96
+ secondaryGroupSize: 0,
97
+ fractionGroupSeparator: '',
98
+ fractionGroupSize: 0,
99
+ });
100
+ }
101
+ return amount.toFormat();
102
+ }
package/src/utils/time.ts CHANGED
@@ -1,21 +1,21 @@
1
- import dayjs from 'dayjs';
2
-
3
- export function formatReadableTimeAgo({ time }: { time: number }) {
4
- if (!time) {
5
- return '';
6
- }
7
- const start = dayjs(time);
8
- const end = dayjs();
9
- const diffHours = end.diff(start, 'h');
10
- if (diffHours > 24) {
11
- return start.format('YYYY/MM/DD HH:MM');
12
- }
13
- if (diffHours >= 1) {
14
- return `${diffHours}h ago`;
15
- }
16
- const diffMinute = end.diff(start, 'm');
17
- if (diffMinute >= 1) {
18
- return `${diffMinute}min ago`;
19
- }
20
- return `${end.diff(start, 's')}s`;
21
- }
1
+ import dayjs from 'dayjs';
2
+
3
+ export function formatReadableTimeAgo({ time }: { time: number }) {
4
+ if (!time) {
5
+ return '';
6
+ }
7
+ const start = dayjs(time);
8
+ const end = dayjs();
9
+ const diffHours = end.diff(start, 'h');
10
+ if (diffHours > 24) {
11
+ return start.format('YYYY/MM/DD HH:MM');
12
+ }
13
+ if (diffHours >= 1) {
14
+ return `${diffHours}h ago`;
15
+ }
16
+ const diffMinute = end.diff(start, 'm');
17
+ if (diffMinute >= 1) {
18
+ return `${diffMinute}min ago`;
19
+ }
20
+ return `${end.diff(start, 's')}s`;
21
+ }
@@ -1,8 +1,8 @@
1
- export const increaseArray = (len: number) => {
2
- return Object.keys(new Array(len + 1).join(','));
3
- };
4
-
5
- export const validateEmail = (email: string) => {
6
- const re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/g;
7
- return re.test(email);
8
- };
1
+ export const increaseArray = (len: number) => {
2
+ return Object.keys(new Array(len + 1).join(','));
3
+ };
4
+
5
+ export const validateEmail = (email: string) => {
6
+ const re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/g;
7
+ return re.test(email);
8
+ };
package/tsconfig.json CHANGED
@@ -1,22 +1,22 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["dom", "dom.iterable", "esnext"],
4
- "allowJs": true,
5
- "skipLibCheck": true,
6
- "strict": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "noEmit": false,
9
- "esModuleInterop": true,
10
- "module": "esnext",
11
- "moduleResolution": "node",
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "downlevelIteration": true,
15
- "newLine": "CRLF",
16
- "declaration": true,
17
- "jsx": "preserve",
18
- "target": "es2016"
19
- },
20
- "exclude": ["node_modules", "types", "src/locales"],
21
- "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx"]
22
- }
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "allowJs": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "noEmit": false,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "node",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "downlevelIteration": true,
15
+ "newLine": "CRLF",
16
+ "declaration": true,
17
+ "jsx": "preserve",
18
+ "target": "es2016"
19
+ },
20
+ "exclude": ["node_modules", "types", "src/locales"],
21
+ "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.tsx"]
22
+ }