@reown/appkit-common-react-native 2.0.0-alpha.0 → 2.0.0-alpha.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.
- package/lib/commonjs/adapters/BlockchainAdapter.js +81 -0
- package/lib/commonjs/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/commonjs/adapters/EvmAdapter.js +204 -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 +62 -1
- 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/utils/ConstantsUtil.js +31 -5
- 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 +2 -2
- package/lib/commonjs/utils/ErrorUtil.js.map +1 -1
- package/lib/commonjs/utils/NamesUtil.js.map +1 -1
- 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 +0 -18
- 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/commonjs/utils/TypeUtil.js +19 -81
- package/lib/commonjs/utils/TypeUtil.js.map +1 -1
- package/lib/module/adapters/BlockchainAdapter.js +76 -0
- package/lib/module/adapters/BlockchainAdapter.js.map +1 -0
- package/lib/module/adapters/EvmAdapter.js +200 -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 +7 -0
- 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/utils/ConstantsUtil.js +33 -5
- 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 +4 -2
- 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 +2 -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 +2 -18
- 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/module/utils/TypeUtil.js +19 -77
- package/lib/module/utils/TypeUtil.js.map +1 -1
- package/lib/typescript/adapters/BlockchainAdapter.d.ts +25 -0
- package/lib/typescript/adapters/BlockchainAdapter.d.ts.map +1 -0
- package/lib/typescript/adapters/EvmAdapter.d.ts +27 -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 +5 -0
- 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/utils/ConstantsUtil.d.ts +27 -3
- package/lib/typescript/utils/ConstantsUtil.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 +0 -5
- 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/lib/typescript/utils/TypeUtil.d.ts +203 -68
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -1
- package/package.json +7 -17
- package/src/adapters/BlockchainAdapter.ts +107 -0
- package/src/adapters/EvmAdapter.ts +259 -0
- package/src/adapters/SolanaBaseAdapter.ts +6 -0
- package/src/adapters/__tests__/EvmAdapter.test.ts +126 -0
- package/src/index.ts +5 -0
- package/src/networks/bitcoin.ts +32 -0
- package/src/networks/solana.ts +44 -0
- package/src/utils/ConstantsUtil.ts +33 -6
- package/src/utils/ErrorUtil.ts +2 -2
- package/src/utils/NumberUtil.ts +54 -11
- package/src/utils/PresetsUtil.ts +0 -25
- package/src/utils/StringUtil.ts +7 -0
- package/src/utils/TypeUtil.ts +259 -143
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
import * as BigNumber from 'bignumber.js';
|
|
2
4
|
export const NumberUtil = {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a BigNumber instance from a given value.
|
|
7
|
+
* If the value is a string, commas are removed before conversion.
|
|
8
|
+
* @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
|
|
9
|
+
* @returns A BigNumber instance.
|
|
10
|
+
*/
|
|
3
11
|
bigNumber(value) {
|
|
4
12
|
if (typeof value === 'string') {
|
|
5
13
|
return new BigNumber.BigNumber(value.replace(/,/g, ''));
|
|
@@ -7,10 +15,11 @@ export const NumberUtil = {
|
|
|
7
15
|
return new BigNumber.BigNumber(value);
|
|
8
16
|
},
|
|
9
17
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @
|
|
18
|
+
* Multiplies two numbers using BigNumber for precision, especially with decimals.
|
|
19
|
+
* Handles undefined inputs by returning BigNumber(0).
|
|
20
|
+
* @param a - The first multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
21
|
+
* @param b - The second multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
22
|
+
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
14
23
|
*/
|
|
15
24
|
multiply(a, b) {
|
|
16
25
|
if (a === undefined || b === undefined) {
|
|
@@ -20,19 +29,32 @@ export const NumberUtil = {
|
|
|
20
29
|
const bBigNumber = new BigNumber.BigNumber(typeof b === 'string' ? b.replace(/,/gu, '') : b);
|
|
21
30
|
return aBigNumber.multipliedBy(bBigNumber);
|
|
22
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
|
|
34
|
+
* @param number - The number to potentially round.
|
|
35
|
+
* @param threshold - The minimum string length of the number to trigger rounding.
|
|
36
|
+
* @param fixed - The number of decimal places to round to.
|
|
37
|
+
* @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
|
|
38
|
+
*/
|
|
23
39
|
roundNumber(number, threshold, fixed) {
|
|
24
40
|
const roundedNumber = number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
25
41
|
return roundedNumber;
|
|
26
42
|
},
|
|
43
|
+
/**
|
|
44
|
+
* Calculates the next multiple of ten greater than or equal to the given amount.
|
|
45
|
+
* Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
|
|
46
|
+
* @param amount - The number for which to find the next multiple of ten. Optional.
|
|
47
|
+
* @returns The next multiple of ten, at least 10.
|
|
48
|
+
*/
|
|
27
49
|
nextMultipleOfTen(amount) {
|
|
28
50
|
if (!amount) return 10;
|
|
29
51
|
return Math.max(Math.ceil(amount / 10) * 10, 10);
|
|
30
52
|
},
|
|
31
53
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param value - The value to format
|
|
34
|
-
* @param decimals - number of
|
|
35
|
-
* @returns
|
|
54
|
+
* Formats a number or string to a human-readable string with a specified number of decimal places, using US locale formatting.
|
|
55
|
+
* @param value - The value to format (string, number, or undefined). If undefined, returns '0.00'.
|
|
56
|
+
* @param decimals - The number of decimal places to display. Defaults to 2.
|
|
57
|
+
* @returns A locale-formatted string representation of the number.
|
|
36
58
|
*/
|
|
37
59
|
formatNumberToLocalString(value, decimals = 2) {
|
|
38
60
|
if (value === undefined) {
|
|
@@ -50,9 +72,9 @@ export const NumberUtil = {
|
|
|
50
72
|
});
|
|
51
73
|
},
|
|
52
74
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param value - The formatted string to parse
|
|
55
|
-
* @returns
|
|
75
|
+
* Parses a locale-formatted numeric string (e.g., with commas) back into a number.
|
|
76
|
+
* @param value - The formatted string to parse. If undefined, returns 0.
|
|
77
|
+
* @returns The parsed number, or 0 if the input is undefined.
|
|
56
78
|
*/
|
|
57
79
|
parseLocalStringToNumber(value) {
|
|
58
80
|
if (value === undefined) {
|
|
@@ -61,6 +83,27 @@ export const NumberUtil = {
|
|
|
61
83
|
|
|
62
84
|
// Remove any commas used as thousand separators and parse the float
|
|
63
85
|
return parseFloat(value.replace(/,/gu, ''));
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
|
|
89
|
+
* This is often required for Ethereum RPC parameters like value, gas, gasPrice.
|
|
90
|
+
* @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
|
|
91
|
+
* @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
|
|
92
|
+
* @throws Error if the value cannot be converted to BigInt.
|
|
93
|
+
*/
|
|
94
|
+
convertNumericToHexString: value => {
|
|
95
|
+
if (value === undefined || value === null) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
// This handles BigInt, number, or string representation of a number (decimal or hex)
|
|
100
|
+
const bigIntValue = BigInt(value);
|
|
101
|
+
// Ethereum RPC spec requires "0x0" for zero, and other values to be 0x-prefixed hex.
|
|
102
|
+
|
|
103
|
+
return '0x' + bigIntValue.toString(16);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw new Error(`NumberUtil: Invalid parameter, cannot convert to hex: ${value}`);
|
|
106
|
+
}
|
|
64
107
|
}
|
|
65
108
|
};
|
|
66
109
|
//# sourceMappingURL=NumberUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BigNumber","NumberUtil","bigNumber","value","replace","multiply","a","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed","nextMultipleOfTen","amount","Math","max","ceil","formatNumberToLocalString","decimals","toLocaleString","maximumFractionDigits","minimumFractionDigits","parseFloat","parseLocalStringToNumber"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":"AAAA,OAAO,KAAKA,SAAS,MAAM,cAAc;AAEzC,OAAO,MAAMC,UAAU,GAAG;
|
|
1
|
+
{"version":3,"names":["BigNumber","NumberUtil","bigNumber","value","replace","multiply","a","b","undefined","aBigNumber","bBigNumber","multipliedBy","roundNumber","number","threshold","fixed","roundedNumber","toString","length","Number","toFixed","nextMultipleOfTen","amount","Math","max","ceil","formatNumberToLocalString","decimals","toLocaleString","maximumFractionDigits","minimumFractionDigits","parseFloat","parseLocalStringToNumber","convertNumericToHexString","bigIntValue","BigInt","error","Error"],"sourceRoot":"../../../src","sources":["utils/NumberUtil.ts"],"mappings":";;AAAA,OAAO,KAAKA,SAAS,MAAM,cAAc;AAEzC,OAAO,MAAMC,UAAU,GAAG;EACxB;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACC,KAAgC,EAAE;IAC1C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAO,IAAIH,SAAS,CAACA,SAAS,CAACG,KAAK,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACzD;IAEA,OAAO,IAAIJ,SAAS,CAACA,SAAS,CAACG,KAAK,CAAC;EACvC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,QAAQA,CAACC,CAAwC,EAAEC,CAAwC,EAAE;IAC3F,IAAID,CAAC,KAAKE,SAAS,IAAID,CAAC,KAAKC,SAAS,EAAE;MACtC,OAAOR,SAAS,CAACA,SAAS,CAAC,CAAC,CAAC;IAC/B;IAEA,MAAMS,UAAU,GAAG,IAAIT,SAAS,CAACA,SAAS,CAAC,OAAOM,CAAC,KAAK,QAAQ,GAAGA,CAAC,CAACF,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAGE,CAAC,CAAC;IAC5F,MAAMI,UAAU,GAAG,IAAIV,SAAS,CAACA,SAAS,CAAC,OAAOO,CAAC,KAAK,QAAQ,GAAGA,CAAC,CAACH,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAGG,CAAC,CAAC;IAE5F,OAAOE,UAAU,CAACE,YAAY,CAACD,UAAU,CAAC;EAC5C,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,C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EAAG9B,KAAU,IAAyB;IAC7D,IAAIA,KAAK,KAAKK,SAAS,IAAIL,KAAK,KAAK,IAAI,EAAE;MACzC,OAAOK,SAAS;IAClB;IACA,IAAI;MACF;MACA,MAAM0B,WAAW,GAAGC,MAAM,CAAChC,KAAK,CAAC;MACjC;;MAEA,OAAO,IAAI,GAAG+B,WAAW,CAACjB,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC,CAAC,OAAOmB,KAAK,EAAE;MACd,MAAM,IAAIC,KAAK,CAAC,yDAAyDlC,KAAK,EAAE,CAAC;IACnF;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
2
3
|
export const PresetsUtil = {
|
|
3
|
-
ConnectorExplorerIds: {
|
|
4
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
5
|
-
},
|
|
6
4
|
NetworkImageIds: {
|
|
7
5
|
// Ethereum
|
|
8
6
|
1: 'ba0ba0cd-17c6-4806-ad93-f9d174f17900',
|
|
@@ -74,20 +72,6 @@ export const PresetsUtil = {
|
|
|
74
72
|
// Bitcoin Testnet
|
|
75
73
|
'000000000933ea01ad0ee984209779ba': '39354064-d79b-420b-065d-f980c4b78200'
|
|
76
74
|
},
|
|
77
|
-
ConnectorNamesMap: {
|
|
78
|
-
[ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WalletConnect',
|
|
79
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]: 'Coinbase Wallet',
|
|
80
|
-
[ConstantsUtil.AUTH_CONNECTOR_ID]: 'AppKit Universal Wallet'
|
|
81
|
-
},
|
|
82
|
-
ConnectorImageIds: {
|
|
83
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]: '0c2840c3-5b04-4c44-9661-fbd4b49e1800',
|
|
84
|
-
[ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400'
|
|
85
|
-
},
|
|
86
|
-
ConnectorTypesMap: {
|
|
87
|
-
[ConstantsUtil.WALLET_CONNECT_CONNECTOR_ID]: 'WALLET_CONNECT',
|
|
88
|
-
[ConstantsUtil.COINBASE_CONNECTOR_ID]: 'COINBASE',
|
|
89
|
-
[ConstantsUtil.AUTH_CONNECTOR_ID]: 'AUTH'
|
|
90
|
-
},
|
|
91
75
|
RpcChainIds: [
|
|
92
76
|
// Ethereum
|
|
93
77
|
1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["PresetsUtil","NetworkImageIds","RpcChainIds"],"sourceRoot":"../../../src","sources":["utils/PresetsUtil.ts"],"mappings":";;AAAA,OAAO,MAAMA,WAAW,GAAG;EACzBC,eAAe,EAAE;IACf;IACA,CAAC,EAAE,sCAAsC;IACzC;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,EAAE,EAAE,sCAAsC;IAC1C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,UAAU,EAAE,sCAAsC;IAClD;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,MAAM,EAAE,sCAAsC;IAC9C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,GAAG,EAAE,sCAAsC;IAC3C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,OAAO,EAAE,sCAAsC;IAC/C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,UAAU,EAAE,sCAAsC;IAClD;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,IAAI,EAAE,sCAAsC;IAC5C;IACA,KAAK,EAAE,sCAAsC;IAC7C;IACA,IAAI,EAAE,sCAAsC;IAE5C;IACA;IACA,kCAAkC,EAAE,sCAAsC;IAC1E;IACA,kCAAkC,EAAE,sCAAsC;IAE1E;IACA,kCAAkC,EAAE,sCAAsC;IAC1E;IACA,kCAAkC,EAAE;EACtC,CAA2B;EAE3BC,WAAW,EAAE;EACX;EACA,CAAC;EACD;EACA,CAAC;EACD;EACA,QAAQ;EACR;EACA,EAAE;EACF;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,MAAM;EACN;EACA,GAAG;EACH;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,UAAU;EACV;EACA,UAAU;EACV;EACA,EAAE;EACF;EACA,EAAE;EACF;EACA,KAAK;EACL;EACA,KAAK;EACL;EACA,GAAG;EACH;EACA,IAAI;EACJ;EACA,KAAK;EACL;EACA,OAAO;EACP;EACA,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAG;AAEP,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
export const StringUtil = {
|
|
2
4
|
capitalize(value) {
|
|
3
5
|
if (!value) {
|
|
4
6
|
return '';
|
|
5
7
|
}
|
|
6
8
|
return value.charAt(0).toUpperCase() + value.slice(1).toLowerCase();
|
|
9
|
+
},
|
|
10
|
+
hexToString(hexValue) {
|
|
11
|
+
// Remove 0x prefix if present
|
|
12
|
+
const cleanHex = hexValue.startsWith('0x') ? hexValue.slice(2) : hexValue;
|
|
13
|
+
// Convert hex to decimal number, then to string
|
|
14
|
+
|
|
15
|
+
return parseInt(cleanHex, 16).toString();
|
|
7
16
|
}
|
|
8
17
|
};
|
|
9
18
|
//# sourceMappingURL=StringUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StringUtil","capitalize","value","charAt","toUpperCase","slice","toLowerCase"],"sourceRoot":"../../../src","sources":["utils/StringUtil.ts"],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAG;EACxBC,UAAUA,CAACC,KAAc,EAAE;IACzB,IAAI,CAACA,KAAK,EAAE;MACV,OAAO,EAAE;IACX;IAEA,OAAOA,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,KAAK,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACrE;AACF,CAAC"}
|
|
1
|
+
{"version":3,"names":["StringUtil","capitalize","value","charAt","toUpperCase","slice","toLowerCase","hexToString","hexValue","cleanHex","startsWith","parseInt","toString"],"sourceRoot":"../../../src","sources":["utils/StringUtil.ts"],"mappings":";;AAAA,OAAO,MAAMA,UAAU,GAAG;EACxBC,UAAUA,CAACC,KAAc,EAAE;IACzB,IAAI,CAACA,KAAK,EAAE;MACV,OAAO,EAAE;IACX;IAEA,OAAOA,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,KAAK,CAACG,KAAK,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC;EACrE,CAAC;EACDC,WAAWA,CAACC,QAAgB,EAAE;IAC5B;IACA,MAAMC,QAAQ,GAAGD,QAAQ,CAACE,UAAU,CAAC,IAAI,CAAC,GAAGF,QAAQ,CAACH,KAAK,CAAC,CAAC,CAAC,GAAGG,QAAQ;IACzE;;IAEA,OAAOG,QAAQ,CAACF,QAAQ,EAAE,EAAE,CAAC,CAACG,QAAQ,CAAC,CAAC;EAC1C;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,98 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
import { EventEmitter } from 'events';
|
|
2
4
|
|
|
3
5
|
//********** Adapter Event Payloads **********//
|
|
4
6
|
|
|
5
7
|
//********** Adapter Event Map **********//
|
|
6
8
|
|
|
7
|
-
//********** Adapter Types **********//
|
|
8
|
-
export class BlockchainAdapter extends EventEmitter {
|
|
9
|
-
// Typed emit method
|
|
10
|
-
emit(event, payload) {
|
|
11
|
-
return super.emit(event, payload);
|
|
12
|
-
}
|
|
13
|
-
constructor({
|
|
14
|
-
projectId,
|
|
15
|
-
supportedNamespace
|
|
16
|
-
}) {
|
|
17
|
-
super();
|
|
18
|
-
this.projectId = projectId;
|
|
19
|
-
this.supportedNamespace = supportedNamespace;
|
|
20
|
-
}
|
|
21
|
-
setConnector(connector) {
|
|
22
|
-
this.connector = connector;
|
|
23
|
-
this.subscribeToEvents();
|
|
24
|
-
}
|
|
25
|
-
removeConnector() {
|
|
26
|
-
this.connector = undefined;
|
|
27
|
-
}
|
|
28
|
-
getProvider() {
|
|
29
|
-
if (!this.connector) throw new Error('No active connector');
|
|
30
|
-
return this.connector.getProvider();
|
|
31
|
-
}
|
|
32
|
-
subscribeToEvents() {
|
|
33
|
-
const provider = this.connector?.getProvider();
|
|
34
|
-
if (!provider) return;
|
|
35
|
-
provider.on('chainChanged', this.onChainChanged.bind(this));
|
|
36
|
-
provider.on('accountsChanged', this.onAccountsChanged.bind(this));
|
|
37
|
-
provider.on('disconnect', this.onDisconnect.bind(this));
|
|
38
|
-
}
|
|
39
|
-
onChainChanged(chainId) {
|
|
40
|
-
const _chains = this.getAccounts()?.map(account => account.split(':')[1]);
|
|
41
|
-
const shouldEmit = _chains?.some(chain => chain === chainId);
|
|
42
|
-
if (shouldEmit) {
|
|
43
|
-
this.emit('chainChanged', {
|
|
44
|
-
chainId,
|
|
45
|
-
namespace: this.getSupportedNamespace()
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
onAccountsChanged(accounts) {
|
|
50
|
-
const _accounts = this.getAccounts();
|
|
51
|
-
const shouldEmit = _accounts?.some(account => {
|
|
52
|
-
const accountAddress = account.split(':')[2];
|
|
53
|
-
return accountAddress !== undefined && accounts.includes(accountAddress);
|
|
54
|
-
});
|
|
55
|
-
if (shouldEmit) {
|
|
56
|
-
this.emit('accountsChanged', {
|
|
57
|
-
accounts,
|
|
58
|
-
namespace: this.getSupportedNamespace()
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
onDisconnect() {
|
|
63
|
-
this.emit('disconnect', {
|
|
64
|
-
namespace: this.getSupportedNamespace()
|
|
65
|
-
});
|
|
66
|
-
const provider = this.connector?.getProvider();
|
|
67
|
-
if (provider) {
|
|
68
|
-
provider.off('chainChanged', this.onChainChanged.bind(this));
|
|
69
|
-
provider.off('accountsChanged', this.onAccountsChanged.bind(this));
|
|
70
|
-
provider.off('disconnect', this.onDisconnect.bind(this));
|
|
71
|
-
}
|
|
72
|
-
this.connector = undefined;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export class EVMAdapter extends BlockchainAdapter {
|
|
76
|
-
// ens logic
|
|
77
|
-
}
|
|
78
|
-
export class SolanaBaseAdapter extends BlockchainAdapter {}
|
|
79
|
-
|
|
80
9
|
//********** Connector Types **********//
|
|
81
10
|
|
|
82
11
|
export class WalletConnector extends EventEmitter {
|
|
83
12
|
constructor({
|
|
84
|
-
type
|
|
85
|
-
provider
|
|
13
|
+
type
|
|
86
14
|
}) {
|
|
87
15
|
super();
|
|
88
16
|
this.type = type;
|
|
17
|
+
}
|
|
18
|
+
async init(ops) {
|
|
19
|
+
this.storage = ops.storage;
|
|
20
|
+
this.metadata = ops.metadata;
|
|
21
|
+
}
|
|
22
|
+
setProvider(provider) {
|
|
89
23
|
this.provider = provider;
|
|
90
24
|
}
|
|
25
|
+
async disconnect() {
|
|
26
|
+
await this.provider?.disconnect();
|
|
27
|
+
this.namespaces = undefined;
|
|
28
|
+
this.wallet = undefined;
|
|
29
|
+
this.properties = undefined;
|
|
30
|
+
}
|
|
91
31
|
}
|
|
92
32
|
|
|
93
33
|
//********** Provider Types **********//
|
|
94
34
|
|
|
95
|
-
//TODO: rename this and remove the old one ConnectorType
|
|
96
|
-
|
|
97
35
|
//********** Others **********//
|
|
36
|
+
|
|
37
|
+
//********** SIWE Types **********//
|
|
38
|
+
|
|
39
|
+
// Signed Cacao (CAIP-74)
|
|
98
40
|
//# sourceMappingURL=TypeUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EventEmitter","
|
|
1
|
+
{"version":3,"names":["EventEmitter","WalletConnector","constructor","type","init","ops","storage","metadata","setProvider","provider","disconnect","namespaces","undefined","wallet","properties"],"sourceRoot":"../../../src","sources":["utils/TypeUtil.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,QAAQ;;AAuMrC;;AAgBA;;AAgBA;;AA8BA,OAAO,MAAeC,eAAe,SAASD,YAAY,CAAC;EASzDE,WAAWA,CAAC;IAAEC;EAA8B,CAAC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,IAAI,GAAGA,IAAI;EAClB;EAEA,MAAaC,IAAIA,CAACC,GAAyB,EAAE;IAC3C,IAAI,CAACC,OAAO,GAAGD,GAAG,CAACC,OAAO;IAC1B,IAAI,CAACC,QAAQ,GAAGF,GAAG,CAACE,QAAQ;EAC9B;EAEOC,WAAWA,CAACC,QAAkB,EAAE;IACrC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC1B;EAEA,MAAaC,UAAUA,CAAA,EAAG;IACxB,MAAM,IAAI,CAACD,QAAQ,EAAEC,UAAU,CAAC,CAAC;IACjC,IAAI,CAACC,UAAU,GAAGC,SAAS;IAC3B,IAAI,CAACC,MAAM,GAAGD,SAAS;IACvB,IAAI,CAACE,UAAU,GAAGF,SAAS;EAC7B;AAUF;;AAIA;;AAmBA;;AAyEA;;AA6BA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import type { AdapterEvents, AdapterType, AppKitNetwork, BlockchainAdapterConfig, CaipAddress, ChainNamespace, GetBalanceParams, GetBalanceResponse, Provider, WalletConnector } from '../utils/TypeUtil';
|
|
4
|
+
export declare abstract class BlockchainAdapter extends EventEmitter {
|
|
5
|
+
projectId: string;
|
|
6
|
+
connector?: WalletConnector;
|
|
7
|
+
supportedNamespace: ChainNamespace;
|
|
8
|
+
adapterType: AdapterType;
|
|
9
|
+
emit<K extends keyof AdapterEvents>(event: K, payload: Parameters<AdapterEvents[K]>[0]): boolean;
|
|
10
|
+
constructor({ projectId, supportedNamespace, adapterType }: BlockchainAdapterConfig);
|
|
11
|
+
setConnector(connector: WalletConnector): void;
|
|
12
|
+
removeConnector(): void;
|
|
13
|
+
getProvider(): Provider;
|
|
14
|
+
subscribeToEvents(): void;
|
|
15
|
+
onChainChanged(chainId: string): void;
|
|
16
|
+
onAccountsChanged(accounts: string[]): void;
|
|
17
|
+
onDisconnect(): void;
|
|
18
|
+
parseUnits(value: string, decimals: number): bigint;
|
|
19
|
+
abstract disconnect(): Promise<void>;
|
|
20
|
+
abstract getSupportedNamespace(): ChainNamespace;
|
|
21
|
+
abstract getBalance(params: GetBalanceParams): Promise<GetBalanceResponse>;
|
|
22
|
+
abstract getAccounts(): CaipAddress[] | undefined;
|
|
23
|
+
abstract switchNetwork(network: AppKitNetwork): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=BlockchainAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockchainAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/BlockchainAdapter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,uBAAuB,E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il';
|
|
3
|
+
export interface WriteContractData {
|
|
4
|
+
tokenAddress: `0x${string}`;
|
|
5
|
+
receiverAddress: `0x${string}`;
|
|
6
|
+
tokenAmount: bigint;
|
|
7
|
+
fromAddress: `0x${string}`;
|
|
8
|
+
method: 'transfer' | 'transferFrom' | 'approve';
|
|
9
|
+
abi?: any;
|
|
10
|
+
spenderAddress?: `0x${string}`;
|
|
11
|
+
network: AppKitNetwork;
|
|
12
|
+
}
|
|
13
|
+
export interface SendTransactionData {
|
|
14
|
+
address: `0x${string}`;
|
|
15
|
+
network: AppKitNetwork;
|
|
16
|
+
to: `0x${string}`;
|
|
17
|
+
value: string;
|
|
18
|
+
data: string;
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class EVMAdapter extends BlockchainAdapter {
|
|
21
|
+
subscribeToEvents(): void;
|
|
22
|
+
signMessage(address: string, message: string, chain?: string): Promise<string>;
|
|
23
|
+
estimateGas({ address, to, data, chainNamespace }: any): Promise<bigint>;
|
|
24
|
+
sendTransaction(data: SendTransactionData): Promise<`0x${string}` | null>;
|
|
25
|
+
writeContract(data: WriteContractData): Promise<`0x${string}` | null>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=EvmAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvmAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/EvmAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS,CAAC;IAChD,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,cAAc,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAkDD,8BAAsB,UAAW,SAAQ,iBAAiB;IAC/C,iBAAiB,IAAI,IAAI;IAY5B,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiB9E,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAkCxE,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IAkCzE,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;CAwF5E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BlockchainAdapter } from './BlockchainAdapter';
|
|
2
|
+
export declare abstract class SolanaBaseAdapter extends BlockchainAdapter {
|
|
3
|
+
abstract signTransaction(data: any): Promise<string | null>;
|
|
4
|
+
abstract sendTransaction(data: any): Promise<string | null>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=SolanaBaseAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolanaBaseAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/SolanaBaseAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,8BAAsB,iBAAkB,SAAQ,iBAAiB;IAC/D,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAC5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvmAdapter.test.d.ts","sourceRoot":"","sources":["../../../../src/adapters/__tests__/EvmAdapter.test.ts"],"names":[],"mappings":""}
|
|
@@ -8,5 +8,10 @@ export { PresetsUtil } from './utils/PresetsUtil';
|
|
|
8
8
|
export { StringUtil } from './utils/StringUtil';
|
|
9
9
|
export { ErrorUtil } from './utils/ErrorUtil';
|
|
10
10
|
export { erc20ABI } from './contracts/erc20';
|
|
11
|
+
export { solana, solanaDevnet, solanaTestnet } from './networks/solana';
|
|
12
|
+
export { bitcoin, bitcoinTestnet } from './networks/bitcoin';
|
|
13
|
+
export { BlockchainAdapter } from './adapters/BlockchainAdapter';
|
|
14
|
+
export { EVMAdapter } from './adapters/EvmAdapter';
|
|
15
|
+
export { SolanaBaseAdapter } from './adapters/SolanaBaseAdapter';
|
|
11
16
|
export * from './utils/TypeUtil';
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,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"file":"bitcoin.d.ts","sourceRoot":"","sources":["../../../src/networks/bitcoin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,aAarB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAc5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../src/networks/solana.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,eAAO,MAAM,MAAM,EAAE,aAcpB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAY1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAW3B,CAAC"}
|
|
@@ -8,10 +8,34 @@ export declare const ConstantsUtil: {
|
|
|
8
8
|
BLOCKCHAIN_API_RPC_URL_STAGING: string;
|
|
9
9
|
PULSE_API_URL: string;
|
|
10
10
|
API_URL: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
WEB_WALLET_URL: string;
|
|
12
|
+
SECURE_SITE_DASHBOARD: string;
|
|
13
|
+
SECURE_SITE_ICON: string;
|
|
14
14
|
COINBASE_EXPLORER_ID: string;
|
|
15
|
+
PHANTOM_EXPLORER_ID: string;
|
|
16
|
+
WALLET_CONNECT_IMAGE_ID: string;
|
|
15
17
|
USDT_CONTRACT_ADDRESSES: string[];
|
|
18
|
+
PHANTOM_CUSTOM_WALLET: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
image_id: string;
|
|
22
|
+
mobile_link: string;
|
|
23
|
+
};
|
|
24
|
+
STORAGE_KEYS: {
|
|
25
|
+
WC_DEEPLINK: string;
|
|
26
|
+
RECENT_WALLET: string;
|
|
27
|
+
CONNECTED_WALLET_IMAGE_URL: string;
|
|
28
|
+
CONNECTED_CONNECTORS: string;
|
|
29
|
+
CONNECTED_SOCIAL: string;
|
|
30
|
+
ONRAMP_PREFERRED_COUNTRY: string;
|
|
31
|
+
ONRAMP_COUNTRIES: string;
|
|
32
|
+
ONRAMP_SERVICE_PROVIDERS: string;
|
|
33
|
+
ONRAMP_FIAT_LIMITS: string;
|
|
34
|
+
ONRAMP_FIAT_CURRENCIES: string;
|
|
35
|
+
ONRAMP_PREFERRED_FIAT_CURRENCY: string;
|
|
36
|
+
ONRAMP_COUNTRIES_DEFAULTS: string;
|
|
37
|
+
ACTIVE_NAMESPACE: string;
|
|
38
|
+
COINBASE_CONNECTOR_SESSION: string;
|
|
39
|
+
};
|
|
16
40
|
};
|
|
17
41
|
//# sourceMappingURL=ConstantsUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConstantsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ConstantsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"ConstantsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/ConstantsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DzB,CAAC"}
|
|
@@ -1,27 +1,55 @@
|
|
|
1
1
|
import * as BigNumber from 'bignumber.js';
|
|
2
2
|
export declare const NumberUtil: {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a BigNumber instance from a given value.
|
|
5
|
+
* If the value is a string, commas are removed before conversion.
|
|
6
|
+
* @param value - The input value (string, number, or BigNumber) to convert to a BigNumber.
|
|
7
|
+
* @returns A BigNumber instance.
|
|
8
|
+
*/
|
|
3
9
|
bigNumber(value: BigNumber.BigNumber.Value): BigNumber.BigNumber;
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
11
|
+
* Multiplies two numbers using BigNumber for precision, especially with decimals.
|
|
12
|
+
* Handles undefined inputs by returning BigNumber(0).
|
|
13
|
+
* @param a - The first multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
14
|
+
* @param b - The second multiplicand (string, number, or BigNumber). Commas are removed if it's a string.
|
|
15
|
+
* @returns The product as a BigNumber instance, or BigNumber(0) if either input is undefined.
|
|
9
16
|
*/
|
|
10
17
|
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined): BigNumber.BigNumber;
|
|
18
|
+
/**
|
|
19
|
+
* Rounds a number to a specified number of decimal places if its string representation meets a certain length threshold.
|
|
20
|
+
* @param number - The number to potentially round.
|
|
21
|
+
* @param threshold - The minimum string length of the number to trigger rounding.
|
|
22
|
+
* @param fixed - The number of decimal places to round to.
|
|
23
|
+
* @returns The rounded number (as a string if rounded, otherwise the original number) or the original number.
|
|
24
|
+
*/
|
|
11
25
|
roundNumber(number: number, threshold: number, fixed: number): string | number;
|
|
26
|
+
/**
|
|
27
|
+
* Calculates the next multiple of ten greater than or equal to the given amount.
|
|
28
|
+
* Defaults to 10 if no amount is provided or if the calculated multiple is less than 10.
|
|
29
|
+
* @param amount - The number for which to find the next multiple of ten. Optional.
|
|
30
|
+
* @returns The next multiple of ten, at least 10.
|
|
31
|
+
*/
|
|
12
32
|
nextMultipleOfTen(amount?: number): number;
|
|
13
33
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param value - The value to format
|
|
16
|
-
* @param decimals - number of
|
|
17
|
-
* @returns
|
|
34
|
+
* Formats a number or string to a human-readable string with a specified number of decimal places, using US locale formatting.
|
|
35
|
+
* @param value - The value to format (string, number, or undefined). If undefined, returns '0.00'.
|
|
36
|
+
* @param decimals - The number of decimal places to display. Defaults to 2.
|
|
37
|
+
* @returns A locale-formatted string representation of the number.
|
|
18
38
|
*/
|
|
19
39
|
formatNumberToLocalString(value: string | number | undefined, decimals?: number): string;
|
|
20
40
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param value - The formatted string to parse
|
|
23
|
-
* @returns
|
|
41
|
+
* Parses a locale-formatted numeric string (e.g., with commas) back into a number.
|
|
42
|
+
* @param value - The formatted string to parse. If undefined, returns 0.
|
|
43
|
+
* @returns The parsed number, or 0 if the input is undefined.
|
|
24
44
|
*/
|
|
25
45
|
parseLocalStringToNumber(value: string | undefined): number;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a numeric value (BigInt, number, or string representation of a number) to a 0x-prefixed hexadecimal string.
|
|
48
|
+
* This is often required for Ethereum RPC parameters like value, gas, gasPrice.
|
|
49
|
+
* @param value - The value to convert. Can be BigInt, number, or a string (decimal or hex).
|
|
50
|
+
* @returns A 0x-prefixed hexadecimal string, or undefined if the input is undefined or null.
|
|
51
|
+
* @throws Error if the value cannot be converted to BigInt.
|
|
52
|
+
*/
|
|
53
|
+
convertNumericToHexString: (value: any) => string | undefined;
|
|
26
54
|
};
|
|
27
55
|
//# sourceMappingURL=NumberUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"NumberUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/NumberUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,UAAU;IACrB;;;;;OAKG;qBACc,mBAAmB,CAAC,KAAK;IAQ1C;;;;;;OAMG;gBACS,mBAAmB,CAAC,KAAK,GAAG,SAAS,KAAK,mBAAmB,CAAC,KAAK,GAAG,SAAS;IAW3F;;;;;;OAMG;wBACiB,MAAM,aAAa,MAAM,SAAS,MAAM;IAO5D;;;;;OAKG;+BACwB,MAAM;IAMjC;;;;;OAKG;qCAC8B,MAAM,GAAG,MAAM,GAAG,SAAS;IAkB5D;;;;OAIG;oCAC6B,MAAM,GAAG,SAAS;IASlD;;;;;;OAMG;uCACgC,GAAG,KAAG,MAAM,GAAG,SAAS;CAc5D,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type { ConnectorType } from './TypeUtil';
|
|
2
1
|
export declare const PresetsUtil: {
|
|
3
|
-
ConnectorExplorerIds: Record<string, string>;
|
|
4
2
|
NetworkImageIds: Record<string, string>;
|
|
5
|
-
ConnectorNamesMap: Record<string, string>;
|
|
6
|
-
ConnectorImageIds: Record<string, string>;
|
|
7
|
-
ConnectorTypesMap: Record<string, ConnectorType>;
|
|
8
3
|
RpcChainIds: number[];
|
|
9
4
|
};
|
|
10
5
|
//# sourceMappingURL=PresetsUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"PresetsUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/PresetsUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;CA2HvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StringUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;uBACF,MAAM;
|
|
1
|
+
{"version":3,"file":"StringUtil.d.ts","sourceRoot":"","sources":["../../../src/utils/StringUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;uBACF,MAAM;0BAOH,MAAM;CAO7B,CAAC"}
|