@reown/appkit-common-react-native 0.0.0-fix-approved-networks-20250822000414 → 0.0.0-fix-ui-changes-20250828183750
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/lib/commonjs/adapters/BlockchainAdapter.js +94 -0
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/commonjs/adapters/EvmAdapter.js +193 -0
- package/lib/commonjs/adapters/EvmAdapter.js.map +1 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js +10 -0
- package/lib/commonjs/adapters/SolanaBaseAdapter.js.map +1 -0
- package/lib/commonjs/contracts/erc20.js.map +1 -1
- package/lib/commonjs/contracts/usdt.js.map +1 -1
- package/lib/commonjs/index.js +66 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/networks/bitcoin.js +40 -0
- package/lib/commonjs/networks/bitcoin.js.map +1 -0
- package/lib/commonjs/networks/solana.js +78 -0
- package/lib/commonjs/networks/solana.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/api/blockchain-api.js +15 -0
- package/lib/commonjs/types/api/blockchain-api.js.map +1 -0
- package/lib/commonjs/types/api/events.js +6 -0
- package/lib/commonjs/types/api/events.js.map +1 -0
- package/lib/commonjs/types/api/index.js +39 -0
- package/lib/commonjs/types/api/index.js.map +1 -0
- package/lib/commonjs/types/api/wallet-api.js +6 -0
- package/lib/commonjs/types/api/wallet-api.js.map +1 -0
- package/lib/commonjs/types/blockchain/adapter.js +6 -0
- package/lib/commonjs/types/blockchain/adapter.js.map +1 -0
- package/lib/commonjs/types/blockchain/balance.js +6 -0
- package/lib/commonjs/types/blockchain/balance.js.map +1 -0
- package/lib/commonjs/types/blockchain/index.js +50 -0
- package/lib/commonjs/types/blockchain/index.js.map +1 -0
- package/lib/commonjs/types/blockchain/network.js +6 -0
- package/lib/commonjs/types/blockchain/network.js.map +1 -0
- package/lib/commonjs/types/blockchain/transaction.js +2 -0
- package/lib/commonjs/types/blockchain/transaction.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/common.js.map +1 -0
- package/lib/commonjs/types/index.js +105 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/onramp/countries.js +2 -0
- package/lib/commonjs/types/onramp/countries.js.map +1 -0
- package/lib/commonjs/types/onramp/currencies.js +2 -0
- package/lib/commonjs/types/onramp/currencies.js.map +1 -0
- package/lib/commonjs/types/onramp/errors.js +22 -0
- package/lib/commonjs/types/onramp/errors.js.map +1 -0
- package/lib/commonjs/types/onramp/index.js +50 -0
- package/lib/commonjs/types/onramp/index.js.map +1 -0
- package/lib/commonjs/types/onramp/quotes.js +2 -0
- package/lib/commonjs/types/onramp/quotes.js.map +1 -0
- package/lib/commonjs/types/siwe/config.js +6 -0
- package/lib/commonjs/types/siwe/config.js.map +1 -0
- package/lib/commonjs/types/siwe/index.js +28 -0
- package/lib/commonjs/types/siwe/index.js.map +1 -0
- package/lib/commonjs/types/siwe/message.js +6 -0
- package/lib/commonjs/types/siwe/message.js.map +1 -0
- package/lib/commonjs/types/storage.js +2 -0
- package/lib/commonjs/types/storage.js.map +1 -0
- package/lib/commonjs/types/swap/index.js +17 -0
- package/lib/commonjs/types/swap/index.js.map +1 -0
- package/lib/commonjs/types/swap/tokens.js +6 -0
- package/lib/commonjs/types/swap/tokens.js.map +1 -0
- package/lib/commonjs/types/ui.js +6 -0
- package/lib/commonjs/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
- package/lib/commonjs/types/wallet/connection.js +6 -0
- package/lib/commonjs/types/wallet/connection.js.map +1 -0
- package/lib/commonjs/types/wallet/connector.js +30 -0
- package/lib/commonjs/types/wallet/connector.js.map +1 -0
- package/lib/commonjs/types/wallet/index.js +39 -0
- package/lib/commonjs/types/wallet/index.js.map +1 -0
- package/lib/commonjs/types/wallet/wallet-info.js +6 -0
- package/lib/commonjs/types/wallet/wallet-info.js.map +1 -0
- package/lib/commonjs/utils/ConstantsUtil.js +52 -6
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/ContractUtil.js.map +1 -1
- package/lib/commonjs/utils/DateUtil.js.map +1 -1
- package/lib/commonjs/utils/ErrorUtil.js.map +1 -1
- package/lib/commonjs/utils/NamesUtil.js.map +1 -1
- package/lib/commonjs/utils/NetworkUtil.js +3 -0
- package/lib/commonjs/utils/NetworkUtil.js.map +1 -1
- package/lib/commonjs/utils/NumberUtil.js +53 -13
- package/lib/commonjs/utils/NumberUtil.js.map +1 -1
- package/lib/commonjs/utils/PresetsUtil.js +34 -21
- package/lib/commonjs/utils/PresetsUtil.js.map +1 -1
- package/lib/commonjs/utils/StringUtil.js +7 -0
- package/lib/commonjs/utils/StringUtil.js.map +1 -1
- package/lib/module/adapters/BlockchainAdapter.js +89 -0
- package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/module/adapters/EvmAdapter.js +189 -0
- package/lib/module/adapters/EvmAdapter.js.map +1 -0
- package/lib/module/adapters/SolanaBaseAdapter.js +5 -0
- package/lib/module/adapters/SolanaBaseAdapter.js.map +1 -0
- package/lib/module/contracts/erc20.js +2 -0
- package/lib/module/contracts/erc20.js.map +1 -1
- package/lib/module/contracts/usdt.js +2 -0
- package/lib/module/contracts/usdt.js.map +1 -1
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/networks/bitcoin.js +36 -0
- package/lib/module/networks/bitcoin.js.map +1 -0
- package/lib/module/networks/solana.js +74 -0
- package/lib/module/networks/solana.js.map +1 -0
- package/lib/module/types/api/blockchain-api.js +10 -0
- package/lib/module/types/api/blockchain-api.js.map +1 -0
- package/lib/module/types/api/events.js +4 -0
- package/lib/module/types/api/events.js.map +1 -0
- package/lib/module/types/api/index.js +7 -0
- package/lib/module/types/api/index.js.map +1 -0
- package/lib/module/types/api/wallet-api.js +4 -0
- package/lib/module/types/api/wallet-api.js.map +1 -0
- package/lib/module/types/blockchain/adapter.js +4 -0
- package/lib/module/types/blockchain/adapter.js.map +1 -0
- package/lib/module/types/blockchain/balance.js +4 -0
- package/lib/module/types/blockchain/balance.js.map +1 -0
- package/lib/module/types/blockchain/index.js +8 -0
- package/lib/module/types/blockchain/index.js.map +1 -0
- package/lib/module/types/blockchain/network.js +4 -0
- package/lib/module/types/blockchain/network.js.map +1 -0
- package/lib/module/types/blockchain/transaction.js +2 -0
- package/lib/module/types/blockchain/transaction.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +31 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/onramp/countries.js +2 -0
- package/lib/module/types/onramp/countries.js.map +1 -0
- package/lib/module/types/onramp/currencies.js +2 -0
- package/lib/module/types/onramp/currencies.js.map +1 -0
- package/lib/module/types/onramp/errors.js +18 -0
- package/lib/module/types/onramp/errors.js.map +1 -0
- package/lib/module/types/onramp/index.js +8 -0
- package/lib/module/types/onramp/index.js.map +1 -0
- package/lib/module/types/onramp/quotes.js +2 -0
- package/lib/module/types/onramp/quotes.js.map +1 -0
- package/lib/module/types/siwe/config.js +4 -0
- package/lib/module/types/siwe/config.js.map +1 -0
- package/lib/module/types/siwe/index.js +6 -0
- package/lib/module/types/siwe/index.js.map +1 -0
- package/lib/module/types/siwe/message.js +4 -0
- package/lib/module/types/siwe/message.js.map +1 -0
- package/lib/module/types/storage.js +2 -0
- package/lib/module/types/storage.js.map +1 -0
- package/lib/module/types/swap/index.js +5 -0
- package/lib/module/types/swap/index.js.map +1 -0
- package/lib/module/types/swap/tokens.js +4 -0
- package/lib/module/types/swap/tokens.js.map +1 -0
- package/lib/module/types/ui.js +4 -0
- package/lib/module/{utils/TypeUtil.js.map → types/ui.js.map} +1 -1
- package/lib/module/types/wallet/connection.js +4 -0
- package/lib/module/types/wallet/connection.js.map +1 -0
- package/lib/module/types/wallet/connector.js +25 -0
- package/lib/module/types/wallet/connector.js.map +1 -0
- package/lib/module/types/wallet/index.js +7 -0
- package/lib/module/types/wallet/index.js.map +1 -0
- package/lib/module/types/wallet/wallet-info.js +4 -0
- package/lib/module/types/wallet/wallet-info.js.map +1 -0
- package/lib/module/utils/ConstantsUtil.js +54 -6
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/ContractUtil.js +2 -0
- package/lib/module/utils/ContractUtil.js.map +1 -1
- package/lib/module/utils/DateUtil.js +2 -0
- package/lib/module/utils/DateUtil.js.map +1 -1
- package/lib/module/utils/ErrorUtil.js +2 -0
- package/lib/module/utils/ErrorUtil.js.map +1 -1
- package/lib/module/utils/NamesUtil.js +2 -0
- package/lib/module/utils/NamesUtil.js.map +1 -1
- package/lib/module/utils/NetworkUtil.js +5 -0
- package/lib/module/utils/NetworkUtil.js.map +1 -1
- package/lib/module/utils/NumberUtil.js +54 -11
- package/lib/module/utils/NumberUtil.js.map +1 -1
- package/lib/module/utils/PresetsUtil.js +36 -21
- package/lib/module/utils/PresetsUtil.js.map +1 -1
- package/lib/module/utils/StringUtil.js +9 -0
- package/lib/module/utils/StringUtil.js.map +1 -1
- package/lib/typescript/adapters/BlockchainAdapter.d.ts +26 -0
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts +26 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts +6 -0
- package/lib/typescript/adapters/SolanaBaseAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts +2 -0
- package/lib/typescript/adapters/__tests__/EvmAdapter.test.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/networks/bitcoin.d.ts +4 -0
- package/lib/typescript/networks/bitcoin.d.ts.map +1 -0
- package/lib/typescript/networks/solana.d.ts +5 -0
- package/lib/typescript/networks/solana.d.ts.map +1 -0
- package/lib/typescript/types/api/blockchain-api.d.ts +183 -0
- package/lib/typescript/types/api/blockchain-api.d.ts.map +1 -0
- package/lib/typescript/types/api/events.d.ts +304 -0
- package/lib/typescript/types/api/events.d.ts.map +1 -0
- package/lib/typescript/types/api/index.d.ts +4 -0
- package/lib/typescript/types/api/index.d.ts.map +1 -0
- package/lib/typescript/types/api/wallet-api.d.ts +50 -0
- package/lib/typescript/types/api/wallet-api.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/adapter.d.ts +40 -0
- package/lib/typescript/types/blockchain/adapter.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/balance.d.ts +28 -0
- package/lib/typescript/types/blockchain/balance.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/index.d.ts +5 -0
- package/lib/typescript/types/blockchain/index.d.ts.map +1 -0
- package/lib/typescript/types/blockchain/network.d.ts +47 -0
- package/lib/typescript/types/blockchain/network.d.ts.map +1 -0
- package/lib/typescript/{utils/TypeUtil.d.ts → types/blockchain/transaction.d.ts} +1 -22
- package/lib/typescript/types/blockchain/transaction.d.ts.map +1 -0
- package/lib/typescript/types/common.d.ts +24 -0
- package/lib/typescript/types/common.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +10 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/onramp/countries.d.ts +11 -0
- package/lib/typescript/types/onramp/countries.d.ts.map +1 -0
- package/lib/typescript/types/onramp/currencies.d.ts +30 -0
- package/lib/typescript/types/onramp/currencies.d.ts.map +1 -0
- package/lib/typescript/types/onramp/errors.d.ts +21 -0
- package/lib/typescript/types/onramp/errors.d.ts.map +1 -0
- package/lib/typescript/types/onramp/index.d.ts +5 -0
- package/lib/typescript/types/onramp/index.d.ts.map +1 -0
- package/lib/typescript/types/onramp/quotes.d.ts +45 -0
- package/lib/typescript/types/onramp/quotes.d.ts.map +1 -0
- package/lib/typescript/types/siwe/config.d.ts +31 -0
- package/lib/typescript/types/siwe/config.d.ts.map +1 -0
- package/lib/typescript/types/siwe/index.d.ts +3 -0
- package/lib/typescript/types/siwe/index.d.ts.map +1 -0
- package/lib/typescript/types/siwe/message.d.ts +57 -0
- package/lib/typescript/types/siwe/message.d.ts.map +1 -0
- package/lib/typescript/types/storage.d.ts +27 -0
- package/lib/typescript/types/storage.d.ts.map +1 -0
- package/lib/typescript/types/swap/index.d.ts +2 -0
- package/lib/typescript/types/swap/index.d.ts.map +1 -0
- package/lib/typescript/types/swap/tokens.d.ts +19 -0
- package/lib/typescript/types/swap/tokens.d.ts.map +1 -0
- package/lib/typescript/types/ui.d.ts +26 -0
- package/lib/typescript/types/ui.d.ts.map +1 -0
- package/lib/typescript/types/wallet/connection.d.ts +30 -0
- package/lib/typescript/types/wallet/connection.d.ts.map +1 -0
- package/lib/typescript/types/wallet/connector.d.ts +61 -0
- package/lib/typescript/types/wallet/connector.d.ts.map +1 -0
- package/lib/typescript/types/wallet/index.d.ts +4 -0
- package/lib/typescript/types/wallet/index.d.ts.map +1 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts +36 -0
- package/lib/typescript/types/wallet/wallet-info.d.ts.map +1 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts +48 -4
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NetworkUtil.d.ts +2 -0
- package/lib/typescript/utils/NetworkUtil.d.ts.map +1 -1
- package/lib/typescript/utils/NumberUtil.d.ts +39 -11
- package/lib/typescript/utils/NumberUtil.d.ts.map +1 -1
- package/lib/typescript/utils/PresetsUtil.d.ts +1 -6
- package/lib/typescript/utils/PresetsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/StringUtil.d.ts +1 -0
- package/lib/typescript/utils/StringUtil.d.ts.map +1 -1
- package/package.json +6 -16
- package/src/adapters/BlockchainAdapter.ts +126 -0
- package/src/adapters/EvmAdapter.ts +247 -0
- package/src/adapters/SolanaBaseAdapter.ts +6 -0
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +7 -1
- package/src/networks/bitcoin.ts +32 -0
- package/src/networks/solana.ts +44 -0
- package/src/types/api/blockchain-api.ts +213 -0
- package/src/types/api/events.ts +394 -0
- package/src/types/api/index.ts +4 -0
- package/src/types/api/wallet-api.ts +70 -0
- package/src/types/blockchain/adapter.ts +52 -0
- package/src/types/blockchain/balance.ts +31 -0
- package/src/types/blockchain/index.ts +5 -0
- package/src/types/blockchain/network.ts +39 -0
- package/src/{utils/TypeUtil.ts → types/blockchain/transaction.ts} +0 -26
- package/src/types/common.ts +56 -0
- package/src/types/index.ts +28 -0
- package/src/types/onramp/countries.ts +11 -0
- package/src/types/onramp/currencies.ts +32 -0
- package/src/types/onramp/errors.ts +22 -0
- package/src/types/onramp/index.ts +5 -0
- package/src/types/onramp/quotes.ts +46 -0
- package/src/types/siwe/config.ts +44 -0
- package/src/types/siwe/index.ts +3 -0
- package/src/types/siwe/message.ts +62 -0
- package/src/types/storage.ts +30 -0
- package/src/types/swap/index.ts +2 -0
- package/src/types/swap/tokens.ts +21 -0
- package/src/types/ui.ts +26 -0
- package/src/types/wallet/connection.ts +33 -0
- package/src/types/wallet/connector.ts +85 -0
- package/src/types/wallet/index.ts +4 -0
- package/src/types/wallet/wallet-info.ts +41 -0
- package/src/utils/ConstantsUtil.ts +55 -8
- package/src/utils/NetworkUtil.ts +5 -0
- package/src/utils/NumberUtil.ts +54 -11
- package/src/utils/PresetsUtil.ts +34 -26
- package/src/utils/StringUtil.ts +7 -0
- package/lib/commonjs/utils/TypeUtil.js +0 -2
- package/lib/module/utils/TypeUtil.js +0 -2
- package/lib/typescript/utils/TypeUtil.d.ts.map +0 -1
package/src/utils/NumberUtil.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as BigNumber from 'bignumber.js';
|
|
2
2
|
|
|
3
3
|
export const NumberUtil = {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a BigNumber instance from a given value.
|
|
6
|
+
* If the value is a string, commas are removed before conversion.
|
|
7
|
+
* @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
|
|
8
|
+
* @returns A BigNumber instance.
|
|
9
|
+
*/
|
|
4
10
|
bigNumber(value: BigNumber.BigNumber.Value) {
|
|
5
11
|
if (typeof value === 'string') {
|
|
6
12
|
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
@@ -10,10 +16,11 @@ export const NumberUtil = {
|
|
|
10
16
|
},
|
|
11
17
|
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @
|
|
19
|
+
* Multiplies two numbers using BigNumber for precision, especially with decimals.
|
|
20
|
+
* Handles undefined inputs by returning BigNumber(0).
|
|
21
|
+
* @param a - The first multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
22
|
+
* @param b - The second multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
23
|
+
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
17
24
|
*/
|
|
18
25
|
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined) {
|
|
19
26
|
if (a === undefined || b === undefined) {
|
|
@@ -26,6 +33,13 @@ export const NumberUtil = {
|
|
|
26
33
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
27
34
|
},
|
|
28
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
|
|
38
|
+
* @param number - The number to potentially round.
|
|
39
|
+
* @param threshold - The minimum string length of the number to trigger rounding.
|
|
40
|
+
* @param fixed - The number of decimal places to round to.
|
|
41
|
+
* @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
|
|
42
|
+
*/
|
|
29
43
|
roundNumber(number: number, threshold: number, fixed: number) {
|
|
30
44
|
const roundedNumber =
|
|
31
45
|
number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
@@ -33,6 +47,12 @@ export const NumberUtil = {
|
|
|
33
47
|
return roundedNumber;
|
|
34
48
|
},
|
|
35
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Calculates the next multiple of ten greater than or equal to the given amount.
|
|
52
|
+
* Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
|
|
53
|
+
* @param amount - The number for which to find the next multiple of ten. Optional.
|
|
54
|
+
* @returns The next multiple of ten, at least 10.
|
|
55
|
+
*/
|
|
36
56
|
nextMultipleOfTen(amount?: number) {
|
|
37
57
|
if (!amount) return 10;
|
|
38
58
|
|
|
@@ -40,10 +60,10 @@ export const NumberUtil = {
|
|
|
40
60
|
},
|
|
41
61
|
|
|
42
62
|
/**
|
|
43
|
-
*
|
|
44
|
-
* @param value - The value to format
|
|
45
|
-
* @param decimals - number of
|
|
46
|
-
* @returns
|
|
63
|
+
* Formats a number or string to a human-readable string with a specified number of decimal places, using US locale formatting.
|
|
64
|
+
* @param value - The value to format (string, number, or undefined). If undefined, returns '0.00'.
|
|
65
|
+
* @param decimals - The number of decimal places to display. Defaults to 2.
|
|
66
|
+
* @returns A locale-formatted string representation of the number.
|
|
47
67
|
*/
|
|
48
68
|
formatNumberToLocalString(value: string | number | undefined, decimals = 2) {
|
|
49
69
|
if (value === undefined) {
|
|
@@ -62,10 +82,11 @@ export const NumberUtil = {
|
|
|
62
82
|
minimumFractionDigits: decimals
|
|
63
83
|
});
|
|
64
84
|
},
|
|
85
|
+
|
|
65
86
|
/**
|
|
66
|
-
*
|
|
67
|
-
* @param value - The formatted string to parse
|
|
68
|
-
* @returns
|
|
87
|
+
* Parses a locale-formatted numeric string (e.g., with commas) back into a number.
|
|
88
|
+
* @param value - The formatted string to parse. If undefined, returns 0.
|
|
89
|
+
* @returns The parsed number, or 0 if the input is undefined.
|
|
69
90
|
*/
|
|
70
91
|
parseLocalStringToNumber(value: string | undefined) {
|
|
71
92
|
if (value === undefined) {
|
|
@@ -74,5 +95,27 @@ export const NumberUtil = {
|
|
|
74
95
|
|
|
75
96
|
// Remove any commas used as thousand separators and parse the float
|
|
76
97
|
return parseFloat(value.replace(/,/gu, ''));
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
|
|
102
|
+
* This is often required for Ethereum RPC parameters like value, gas, gasPrice.
|
|
103
|
+
* @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
|
|
104
|
+
* @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
|
|
105
|
+
* @throws Error if the value cannot be converted to BigInt.
|
|
106
|
+
*/
|
|
107
|
+
convertNumericToHexString: (value: any): string | undefined => {
|
|
108
|
+
if (value === undefined || value === null) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
// This handles BigInt, number, or string representation of a number (decimal or hex)
|
|
113
|
+
const bigIntValue = BigInt(value);
|
|
114
|
+
// Ethereum RPC spec requires "0x0" for zero, and other values to be 0x-prefixed hex.
|
|
115
|
+
|
|
116
|
+
return '0x' + bigIntValue.toString(16);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw new Error(`NumberUtil: Invalid parameter, cannot convert to hex: ${value}`);
|
|
119
|
+
}
|
|
77
120
|
}
|
|
78
121
|
};
|
package/src/utils/PresetsUtil.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import type { ConnectorType } from './TypeUtil';
|
|
2
|
-
import { ConstantsUtil } from './ConstantsUtil';
|
|
3
|
-
|
|
4
1
|
export const PresetsUtil = {
|
|
5
|
-
|
|
6
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]:
|
|
7
|
-
'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
8
|
-
} as Record<string, string>,
|
|
9
|
-
|
|
10
|
-
EIP155NetworkImageIds: {
|
|
2
|
+
NetworkImageIds: {
|
|
11
3
|
// Ethereum
|
|
12
4
|
1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
|
|
13
5
|
// Arbitrum
|
|
14
|
-
42161: '
|
|
6
|
+
42161: '3bff954d-5cb0-47a0-9a23-d20192e74600',
|
|
15
7
|
// Avalanche
|
|
16
8
|
43114: '30c46e53-e989-45fb-4549-be3bd4eb3b00',
|
|
17
9
|
// Binance Smart Chain
|
|
@@ -22,6 +14,20 @@ export const PresetsUtil = {
|
|
|
22
14
|
10: 'ab9c186a-c52f-464b-2906-ca59d760a400',
|
|
23
15
|
// Polygon
|
|
24
16
|
137: '41d04d42-da3b-4453-8506-668cc0727900',
|
|
17
|
+
// Mantle
|
|
18
|
+
5000: 'e86fae9b-b770-4eea-e520-150e12c81100',
|
|
19
|
+
// Hedera Mainnet
|
|
20
|
+
295: '6a97d510-cac8-4e58-c7ce-e8681b044c00',
|
|
21
|
+
// Sepolia
|
|
22
|
+
11_155_111: 'e909ea0a-f92a-4512-c8fc-748044ea6800',
|
|
23
|
+
// Base Sepolia
|
|
24
|
+
84532: 'a18a7ecd-e307-4360-4746-283182228e00',
|
|
25
|
+
// Unichain Sepolia
|
|
26
|
+
1301: '4eeea7ef-0014-4649-5d1d-07271a80f600',
|
|
27
|
+
// Unichain Mainnet
|
|
28
|
+
130: '2257980a-3463-48c6-cbac-a42d2a956e00',
|
|
29
|
+
// Monad Testnet
|
|
30
|
+
10_143: '0a728e83-bacb-46db-7844-948f05434900',
|
|
25
31
|
// Gnosis
|
|
26
32
|
100: '02b53f6a-e3d4-479e-1cb4-21178987d100',
|
|
27
33
|
// EVMos
|
|
@@ -45,26 +51,28 @@ export const PresetsUtil = {
|
|
|
45
51
|
// Base
|
|
46
52
|
8453: '7289c336-3981-4081-c5f4-efc26ac64a00',
|
|
47
53
|
// Aurora
|
|
48
|
-
1313161554: '3ff73439-a619-4894-9262-4470c773a100'
|
|
49
|
-
|
|
54
|
+
1313161554: '3ff73439-a619-4894-9262-4470c773a100',
|
|
55
|
+
// Ronin Mainnet
|
|
56
|
+
2020: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
57
|
+
// Saigon Testnet (a.k.a. Ronin)
|
|
58
|
+
2021: 'b8101fc0-9c19-4b6f-ec65-f6dfff106e00',
|
|
59
|
+
// Berachain Mainnet
|
|
60
|
+
80094: 'e329c2c9-59b0-4a02-83e4-212ff3779900',
|
|
61
|
+
// Abstract Mainnet
|
|
62
|
+
2741: 'fc2427d1-5af9-4a9c-8da5-6f94627cd900',
|
|
50
63
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
// Solana networks
|
|
65
|
+
/// Mainnet
|
|
66
|
+
'5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
67
|
+
/// Testnet
|
|
68
|
+
'4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': 'a1b58899-f671-4276-6a5e-56ca5bd59700',
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
// Bitcoin
|
|
71
|
+
'000000000019d6689c085ae165831e93': '0b4838db-0161-4ffe-022d-532bf03dba00',
|
|
72
|
+
// Bitcoin Testnet
|
|
73
|
+
'000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
|
|
60
74
|
} as Record<string, string>,
|
|
61
75
|
|
|
62
|
-
ConnectorTypesMap: {
|
|
63
|
-
[ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WALLET_CONNECT',
|
|
64
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]: 'COINBASE',
|
|
65
|
-
[ConstantsUtil.AUTH_CONNECTOR_ID]: 'AUTH'
|
|
66
|
-
} as Record<string, ConnectorType>,
|
|
67
|
-
|
|
68
76
|
RpcChainIds: [
|
|
69
77
|
// Ethereum
|
|
70
78
|
1,
|
package/src/utils/StringUtil.ts
CHANGED
|
@@ -5,5 +5,12 @@ export const StringUtil = {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
8
|
+
},
|
|
9
|
+
hexToString(hexValue: string) {
|
|
10
|
+
// Remove 0x prefix if present
|
|
11
|
+
const cleanHex = hexValue.startsWith('0x') ? hexValue.slice(2) : hexValue;
|
|
12
|
+
// Convert hex to decimal number, then to string
|
|
13
|
+
|
|
14
|
+
return parseInt(cleanHex, 16).toString();
|
|
8
15
|
}
|
|
9
16
|
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TypeUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeUtil.ts"],"names":[],"mappings":"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"}
|