essential-eth 0.11.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-C4VOKUKQ.js +756 -0
- package/dist/chunk-UXC5R4JE.js +210 -0
- package/dist/conversions.d.ts +21 -0
- package/dist/conversions.js +1 -0
- package/dist/index-utils-D40THakY.d.ts +63 -0
- package/dist/index.cjs +22 -17
- package/dist/index.d.ts +5 -79
- package/dist/index.js +8 -1016
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +2 -0
- package/package.json +10 -2
- package/readme.md +19 -1
- package/dist/index.d.cts +0 -330
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
|
|
3
|
+
// src/shared/tiny-big/tiny-big.ts
|
|
4
|
+
|
|
5
|
+
// src/classes/utils/hex-to-decimal.ts
|
|
6
|
+
function hexToDecimal(hex) {
|
|
7
|
+
return BigInt(hex).toString();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/shared/tiny-big/helpers.ts
|
|
11
|
+
function stripTrailingZeroes(numberString) {
|
|
12
|
+
const isNegative = numberString.startsWith("-");
|
|
13
|
+
numberString = numberString.replace("-", "");
|
|
14
|
+
numberString = numberString.replace(
|
|
15
|
+
/\.0*$/g,
|
|
16
|
+
""
|
|
17
|
+
);
|
|
18
|
+
numberString = numberString.replace(/^0+/, "");
|
|
19
|
+
if (numberString.includes(".")) {
|
|
20
|
+
numberString = numberString.replace(/0+$/, "");
|
|
21
|
+
}
|
|
22
|
+
if (numberString.startsWith(".")) {
|
|
23
|
+
numberString = `0${numberString}`;
|
|
24
|
+
}
|
|
25
|
+
return `${isNegative ? "-" : ""}${numberString}`;
|
|
26
|
+
}
|
|
27
|
+
function scientificStrToDecimalStr(scientificString) {
|
|
28
|
+
if (!scientificString.match(
|
|
29
|
+
/e/i
|
|
30
|
+
/* lowercase and uppercase E */
|
|
31
|
+
)) {
|
|
32
|
+
return stripTrailingZeroes(scientificString);
|
|
33
|
+
}
|
|
34
|
+
let [base, power] = scientificString.split(
|
|
35
|
+
/e/i
|
|
36
|
+
);
|
|
37
|
+
const isNegative = Number(base) < 0;
|
|
38
|
+
base = base.replace("-", "");
|
|
39
|
+
base = stripTrailingZeroes(base);
|
|
40
|
+
const [wholeNumber, fraction = ""] = base.split(".");
|
|
41
|
+
if (Number(power) === 0) {
|
|
42
|
+
return `${isNegative ? "-" : ""}${stripTrailingZeroes(base)}`;
|
|
43
|
+
} else {
|
|
44
|
+
const includesDecimal = base.includes(".");
|
|
45
|
+
if (!includesDecimal) {
|
|
46
|
+
base = `${base}.`;
|
|
47
|
+
}
|
|
48
|
+
base = base.replace(".", "");
|
|
49
|
+
const baseLength = base.length;
|
|
50
|
+
let splitPaddedNumber;
|
|
51
|
+
if (Number(power) < 0) {
|
|
52
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
53
|
+
base = base.padStart(
|
|
54
|
+
baseLength + Math.abs(Number(power)) - wholeNumber.length,
|
|
55
|
+
"0"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
splitPaddedNumber = base.split("");
|
|
59
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
60
|
+
splitPaddedNumber = [".", ...splitPaddedNumber];
|
|
61
|
+
} else {
|
|
62
|
+
splitPaddedNumber.splice(
|
|
63
|
+
splitPaddedNumber.length - Math.abs(Number(power)),
|
|
64
|
+
0,
|
|
65
|
+
"."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if (fraction.length < Math.abs(Number(power))) {
|
|
70
|
+
base = base.padEnd(
|
|
71
|
+
baseLength + Math.abs(Number(power)) - fraction.length,
|
|
72
|
+
"0"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
splitPaddedNumber = base.split("");
|
|
76
|
+
if (fraction.length > Math.abs(Number(power))) {
|
|
77
|
+
splitPaddedNumber.splice(
|
|
78
|
+
splitPaddedNumber.length - Math.abs(Number(power)),
|
|
79
|
+
0,
|
|
80
|
+
"."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const toReturn = stripTrailingZeroes(splitPaddedNumber.join(""));
|
|
85
|
+
return `${isNegative ? "-" : ""}${toReturn}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/shared/tiny-big/tiny-big.ts
|
|
90
|
+
var TinyBig = class extends Big {
|
|
91
|
+
constructor(value) {
|
|
92
|
+
if (typeof value === "string" && value.startsWith("0x")) {
|
|
93
|
+
value = hexToDecimal(value);
|
|
94
|
+
}
|
|
95
|
+
super(value);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Used anytime you're passing in "value" to ethers or web3
|
|
99
|
+
* For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
|
|
100
|
+
*
|
|
101
|
+
* @returns the TinyBig represented as a hex string
|
|
102
|
+
* @example
|
|
103
|
+
* ```javascript
|
|
104
|
+
* tinyBig(293).toHexString();
|
|
105
|
+
* // '0x125'
|
|
106
|
+
* ```
|
|
107
|
+
* @example
|
|
108
|
+
* ```javascript
|
|
109
|
+
* tinyBig(681365874).toHexString();
|
|
110
|
+
* // '0x289cd172'
|
|
111
|
+
*/
|
|
112
|
+
toHexString() {
|
|
113
|
+
return `0x${BigInt(this.toString()).toString(16)}`;
|
|
114
|
+
}
|
|
115
|
+
toNumber() {
|
|
116
|
+
return Number(scientificStrToDecimalStr(super.toString()));
|
|
117
|
+
}
|
|
118
|
+
toString() {
|
|
119
|
+
if (this.toNumber() === 0) {
|
|
120
|
+
return "0";
|
|
121
|
+
}
|
|
122
|
+
return scientificStrToDecimalStr(super.toString());
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Eithers pads or shortens a string to a specified length
|
|
126
|
+
*
|
|
127
|
+
* @param str the string to pad or chop
|
|
128
|
+
* @param padChar the character to pad the string with
|
|
129
|
+
* @param length the desired length of the given string
|
|
130
|
+
* @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
|
|
131
|
+
* @example
|
|
132
|
+
* ```javascript
|
|
133
|
+
* padAndChop('essential-eth', 'a', 8);
|
|
134
|
+
* // 'tial-eth'
|
|
135
|
+
* ```
|
|
136
|
+
* @example
|
|
137
|
+
* ```javascript
|
|
138
|
+
* padAndChop('essential-eth', 'A', 20);
|
|
139
|
+
* // 'AAAAAAAessential-eth'
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
padAndChop = (str, padChar, length) => {
|
|
143
|
+
return (Array(length).fill(padChar).join("") + str).slice(length * -1);
|
|
144
|
+
};
|
|
145
|
+
toTwos(bitCount) {
|
|
146
|
+
let binaryStr;
|
|
147
|
+
if (this.gte(0)) {
|
|
148
|
+
const twosComp = this.toNumber().toString(2);
|
|
149
|
+
binaryStr = this.padAndChop(twosComp, "0", bitCount || twosComp.length);
|
|
150
|
+
} else {
|
|
151
|
+
binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
|
|
152
|
+
if (Number(binaryStr) < 0) {
|
|
153
|
+
throw new Error("Cannot calculate twos complement");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const binary = `0b${binaryStr}`;
|
|
157
|
+
const decimal = Number(binary);
|
|
158
|
+
return tinyBig(decimal);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
function tinyBig(value) {
|
|
162
|
+
return new TinyBig(value);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/shared/validate-type.ts
|
|
166
|
+
var validateType = (value, allowedTypes) => {
|
|
167
|
+
if (!allowedTypes.includes(typeof value)) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`${allowedTypes.join(" or ")} required. Received ${typeof value}`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/utils/ether-to-gwei.ts
|
|
175
|
+
function etherToGwei(etherQuantity) {
|
|
176
|
+
validateType(etherQuantity, ["string", "number", "object"]);
|
|
177
|
+
const result = tinyBig(etherQuantity).times("1000000000");
|
|
178
|
+
return tinyBig(result);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/utils/ether-to-wei.ts
|
|
182
|
+
function etherToWei(etherQuantity) {
|
|
183
|
+
validateType(etherQuantity, ["string", "number", "object"]);
|
|
184
|
+
const result = tinyBig(etherQuantity).times("1000000000000000000");
|
|
185
|
+
return tinyBig(result);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/utils/gwei-to-ether.ts
|
|
189
|
+
function gweiToEther(gweiQuantity) {
|
|
190
|
+
validateType(gweiQuantity, ["string", "number", "object"]);
|
|
191
|
+
const result = tinyBig(gweiQuantity).div("1000000000");
|
|
192
|
+
return tinyBig(result);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/utils/wei-to-ether.ts
|
|
196
|
+
function weiToEther(weiQuantity) {
|
|
197
|
+
validateType(weiQuantity, ["string", "number", "object"]);
|
|
198
|
+
try {
|
|
199
|
+
let _weiQuantity = weiQuantity;
|
|
200
|
+
if (typeof weiQuantity === "string" && weiQuantity.slice(0, 2) === "0x") {
|
|
201
|
+
_weiQuantity = BigInt(weiQuantity).toString();
|
|
202
|
+
}
|
|
203
|
+
const result = tinyBig(_weiQuantity).div("1000000000000000000");
|
|
204
|
+
return tinyBig(result);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { TinyBig, etherToGwei, etherToWei, gweiToEther, hexToDecimal, tinyBig, validateType, weiToEther };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
|
|
3
|
+
declare class TinyBig extends Big {
|
|
4
|
+
constructor(value: string | number | TinyBig | Big);
|
|
5
|
+
toHexString(): string;
|
|
6
|
+
toNumber(): number;
|
|
7
|
+
toString(): string;
|
|
8
|
+
private padAndChop;
|
|
9
|
+
toTwos(bitCount: number): Big;
|
|
10
|
+
}
|
|
11
|
+
declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
|
|
12
|
+
|
|
13
|
+
declare function etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig;
|
|
14
|
+
|
|
15
|
+
declare function etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig;
|
|
16
|
+
|
|
17
|
+
declare function gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig;
|
|
18
|
+
|
|
19
|
+
declare function weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig;
|
|
20
|
+
|
|
21
|
+
export { TinyBig, etherToGwei, etherToWei, gweiToEther, tinyBig, weiToEther };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TinyBig, etherToGwei, etherToWei, gweiToEther, tinyBig, weiToEther } from './chunk-UXC5R4JE.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import './conversions.js';
|
|
2
|
+
|
|
3
|
+
type Bytes = ArrayLike<number>;
|
|
4
|
+
type BytesLike = Bytes | string;
|
|
5
|
+
type BytesLikeWithNumber = BytesLike | number;
|
|
6
|
+
interface DataOptions {
|
|
7
|
+
allowMissingPrefix?: boolean;
|
|
8
|
+
hexPad?: 'left' | 'right' | null;
|
|
9
|
+
}
|
|
10
|
+
interface Hexable {
|
|
11
|
+
toHexString(): string;
|
|
12
|
+
}
|
|
13
|
+
type SignatureLike = {
|
|
14
|
+
r: string;
|
|
15
|
+
s?: string;
|
|
16
|
+
_vs?: string;
|
|
17
|
+
recoveryParam?: number;
|
|
18
|
+
v?: number;
|
|
19
|
+
} | BytesLike;
|
|
20
|
+
interface Signature {
|
|
21
|
+
r: string;
|
|
22
|
+
s: string;
|
|
23
|
+
_vs: string;
|
|
24
|
+
recoveryParam: number;
|
|
25
|
+
v: number;
|
|
26
|
+
yParityAndS: string;
|
|
27
|
+
compact: string;
|
|
28
|
+
}
|
|
29
|
+
declare function isBytesLike(value: any): value is BytesLike;
|
|
30
|
+
declare function isBytes(value: any): value is Bytes;
|
|
31
|
+
declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
32
|
+
declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
33
|
+
declare function stripZeros(value: BytesLike): Uint8Array;
|
|
34
|
+
declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
35
|
+
declare function isHexString(value: any, length?: number): boolean;
|
|
36
|
+
declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
37
|
+
declare function hexDataLength(data: BytesLike): number | null;
|
|
38
|
+
declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
39
|
+
declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
40
|
+
declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
41
|
+
declare function hexStripZeros(value: BytesLike): string;
|
|
42
|
+
declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|
|
43
|
+
|
|
44
|
+
declare function computeAddress(key: string): string;
|
|
45
|
+
|
|
46
|
+
declare function computePublicKey(privKey: BytesLike): string;
|
|
47
|
+
|
|
48
|
+
declare function hashMessage(message: Bytes | string): string;
|
|
49
|
+
|
|
50
|
+
declare function isAddress(address: string): boolean;
|
|
51
|
+
|
|
52
|
+
declare function keccak256(data: BytesLike): string;
|
|
53
|
+
|
|
54
|
+
declare function pack(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
|
|
55
|
+
declare function solidityKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
|
|
56
|
+
|
|
57
|
+
declare function splitSignature(signature: SignatureLike): Signature;
|
|
58
|
+
|
|
59
|
+
declare function toChecksumAddress(address: string): string;
|
|
60
|
+
|
|
61
|
+
declare function toUtf8Bytes(data: string): Uint8Array;
|
|
62
|
+
|
|
63
|
+
export { zeroPad as A, type BytesLike as B, type DataOptions as D, type Hexable as H, type Signature as S, type Bytes as a, type BytesLikeWithNumber as b, type SignatureLike as c, arrayify as d, computeAddress as e, computePublicKey as f, concat as g, hashMessage as h, hexConcat as i, hexDataLength as j, hexDataSlice as k, hexStripZeros as l, hexValue as m, hexZeroPad as n, hexlify as o, isAddress as p, isBytes as q, isBytesLike as r, isHexString as s, keccak256 as t, pack as u, solidityKeccak256 as v, splitSignature as w, stripZeros as x, toChecksumAddress as y, toUtf8Bytes as z };
|
package/dist/index.cjs
CHANGED
|
@@ -70,7 +70,8 @@ __export(index_exports, {
|
|
|
70
70
|
module.exports = __toCommonJS(index_exports);
|
|
71
71
|
|
|
72
72
|
// src/classes/utils/encode-decode-transaction.ts
|
|
73
|
-
var import_sha32 = require("sha3");
|
|
73
|
+
var import_sha32 = require("@noble/hashes/sha3.js");
|
|
74
|
+
var import_utils2 = require("@noble/hashes/utils.js");
|
|
74
75
|
|
|
75
76
|
// src/shared/tiny-big/tiny-big.ts
|
|
76
77
|
var import_big = __toESM(require("big.js"), 1);
|
|
@@ -236,7 +237,8 @@ function tinyBig(value) {
|
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
// src/utils/to-checksum-address.ts
|
|
239
|
-
var import_sha3 = require("sha3");
|
|
240
|
+
var import_sha3 = require("@noble/hashes/sha3.js");
|
|
241
|
+
var import_utils = require("@noble/hashes/utils.js");
|
|
240
242
|
|
|
241
243
|
// src/shared/validate-type.ts
|
|
242
244
|
var validateType = (value, allowedTypes) => {
|
|
@@ -254,8 +256,8 @@ function toChecksumAddress(address) {
|
|
|
254
256
|
throw new Error(`Invalid Ethereum address "${address}"`);
|
|
255
257
|
}
|
|
256
258
|
const _address = address.toLowerCase().replace(/^0x/i, "");
|
|
257
|
-
const
|
|
258
|
-
const addressHash =
|
|
259
|
+
const addressBytes = new TextEncoder().encode(_address);
|
|
260
|
+
const addressHash = (0, import_utils.bytesToHex)((0, import_sha3.keccak_256)(addressBytes));
|
|
259
261
|
let checksumAddress = "0x";
|
|
260
262
|
for (let i = 0; i < _address.length; i++) {
|
|
261
263
|
if (parseInt(addressHash[i], 16) > 7) {
|
|
@@ -301,11 +303,12 @@ function expandType(type) {
|
|
|
301
303
|
return type;
|
|
302
304
|
}
|
|
303
305
|
function encodeData(jsonABIArgument, args) {
|
|
304
|
-
const hash = new import_sha32.Keccak(256);
|
|
305
306
|
const functionString = `${jsonABIArgument.name}(${jsonABIArgument.inputs.map(
|
|
306
307
|
(input) => expandType(input.type)
|
|
307
308
|
)})`;
|
|
308
|
-
const functionHash =
|
|
309
|
+
const functionHash = (0, import_utils2.bytesToHex)(
|
|
310
|
+
(0, import_sha32.keccak_256)(new TextEncoder().encode(functionString))
|
|
311
|
+
);
|
|
309
312
|
const jsonABIInputsLength = jsonABIArgument.inputs.length;
|
|
310
313
|
let shouldValidateInputLength = true;
|
|
311
314
|
if (jsonABIArgument.inputs.find((input) => input.type.includes("["))) {
|
|
@@ -662,7 +665,7 @@ function buildRPCPostBody(method, params) {
|
|
|
662
665
|
var import_big2 = __toESM(require("big.js"), 1);
|
|
663
666
|
|
|
664
667
|
// src/logger/package-version.ts
|
|
665
|
-
var version = "0.
|
|
668
|
+
var version = "0.13.0";
|
|
666
669
|
|
|
667
670
|
// src/logger/logger.ts
|
|
668
671
|
var Logger = class {
|
|
@@ -1652,17 +1655,20 @@ function computePublicKey(privKey) {
|
|
|
1652
1655
|
}
|
|
1653
1656
|
|
|
1654
1657
|
// src/utils/keccak256.ts
|
|
1655
|
-
var import_sha33 = require("sha3");
|
|
1658
|
+
var import_sha33 = require("@noble/hashes/sha3.js");
|
|
1659
|
+
var import_utils3 = require("@noble/hashes/utils.js");
|
|
1656
1660
|
function keccak256(data) {
|
|
1657
|
-
let
|
|
1661
|
+
let bytes;
|
|
1658
1662
|
if (typeof data === "string") {
|
|
1659
|
-
|
|
1663
|
+
const hex = data.replace(/^0x/, "");
|
|
1664
|
+
bytes = new Uint8Array(hex.length / 2);
|
|
1665
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1666
|
+
bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
1667
|
+
}
|
|
1660
1668
|
} else {
|
|
1661
|
-
|
|
1669
|
+
bytes = new Uint8Array(data);
|
|
1662
1670
|
}
|
|
1663
|
-
|
|
1664
|
-
const addressHash = "0x" + keccak.update(bufferableData).digest("hex");
|
|
1665
|
-
return addressHash;
|
|
1671
|
+
return "0x" + (0, import_utils3.bytesToHex)((0, import_sha33.keccak_256)(bytes));
|
|
1666
1672
|
}
|
|
1667
1673
|
|
|
1668
1674
|
// src/utils/compute-address.ts
|
|
@@ -1696,7 +1702,7 @@ function gweiToEther(gweiQuantity) {
|
|
|
1696
1702
|
|
|
1697
1703
|
// src/utils/to-utf8-bytes.ts
|
|
1698
1704
|
function toUtf8Bytes(data) {
|
|
1699
|
-
return new
|
|
1705
|
+
return new TextEncoder().encode(data);
|
|
1700
1706
|
}
|
|
1701
1707
|
|
|
1702
1708
|
// src/utils/hash-message.ts
|
|
@@ -1726,7 +1732,6 @@ function isAddress(address) {
|
|
|
1726
1732
|
}
|
|
1727
1733
|
|
|
1728
1734
|
// src/utils/solidity-keccak256.ts
|
|
1729
|
-
var import_buffer = require("buffer");
|
|
1730
1735
|
var regexBytes = new RegExp("^bytes([0-9]+)$");
|
|
1731
1736
|
var regexNumber = new RegExp("^(u?int)([0-9]*)$");
|
|
1732
1737
|
var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
|
|
@@ -1738,7 +1743,7 @@ function _pack(type, value, isArray) {
|
|
|
1738
1743
|
}
|
|
1739
1744
|
return arrayify(value);
|
|
1740
1745
|
case "string":
|
|
1741
|
-
return
|
|
1746
|
+
return new TextEncoder().encode(value);
|
|
1742
1747
|
case "bytes":
|
|
1743
1748
|
return arrayify(value);
|
|
1744
1749
|
case "bool":
|
package/dist/index.d.ts
CHANGED
|
@@ -1,55 +1,8 @@
|
|
|
1
|
+
import { TinyBig } from './conversions.js';
|
|
2
|
+
export { etherToGwei, etherToWei, gweiToEther, tinyBig, weiToEther } from './conversions.js';
|
|
1
3
|
import Big from 'big.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constructor(value: string | number | TinyBig | Big);
|
|
5
|
-
toHexString(): string;
|
|
6
|
-
toNumber(): number;
|
|
7
|
-
toString(): string;
|
|
8
|
-
private padAndChop;
|
|
9
|
-
toTwos(bitCount: number): Big;
|
|
10
|
-
}
|
|
11
|
-
declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
|
|
12
|
-
|
|
13
|
-
type Bytes = ArrayLike<number>;
|
|
14
|
-
type BytesLike = Bytes | string;
|
|
15
|
-
type BytesLikeWithNumber = BytesLike | number;
|
|
16
|
-
interface DataOptions {
|
|
17
|
-
allowMissingPrefix?: boolean;
|
|
18
|
-
hexPad?: 'left' | 'right' | null;
|
|
19
|
-
}
|
|
20
|
-
interface Hexable {
|
|
21
|
-
toHexString(): string;
|
|
22
|
-
}
|
|
23
|
-
type SignatureLike = {
|
|
24
|
-
r: string;
|
|
25
|
-
s?: string;
|
|
26
|
-
_vs?: string;
|
|
27
|
-
recoveryParam?: number;
|
|
28
|
-
v?: number;
|
|
29
|
-
} | BytesLike;
|
|
30
|
-
interface Signature {
|
|
31
|
-
r: string;
|
|
32
|
-
s: string;
|
|
33
|
-
_vs: string;
|
|
34
|
-
recoveryParam: number;
|
|
35
|
-
v: number;
|
|
36
|
-
yParityAndS: string;
|
|
37
|
-
compact: string;
|
|
38
|
-
}
|
|
39
|
-
declare function isBytesLike(value: any): value is BytesLike;
|
|
40
|
-
declare function isBytes(value: any): value is Bytes;
|
|
41
|
-
declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
42
|
-
declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
43
|
-
declare function stripZeros(value: BytesLike): Uint8Array;
|
|
44
|
-
declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
45
|
-
declare function isHexString(value: any, length?: number): boolean;
|
|
46
|
-
declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
47
|
-
declare function hexDataLength(data: BytesLike): number | null;
|
|
48
|
-
declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
49
|
-
declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
50
|
-
declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
51
|
-
declare function hexStripZeros(value: BytesLike): string;
|
|
52
|
-
declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|
|
4
|
+
import { B as BytesLike } from './index-utils-D40THakY.js';
|
|
5
|
+
export { a as Bytes, b as BytesLikeWithNumber, D as DataOptions, H as Hexable, S as Signature, c as SignatureLike, d as arrayify, e as computeAddress, f as computePublicKey, g as concat, h as hashMessage, i as hexConcat, j as hexDataLength, k as hexDataSlice, l as hexStripZeros, m as hexValue, n as hexZeroPad, o as hexlify, p as isAddress, q as isBytes, r as isBytesLike, s as isHexString, t as keccak256, u as pack, v as solidityKeccak256, w as splitSignature, x as stripZeros, y as toChecksumAddress, z as toUtf8Bytes, A as zeroPad } from './index-utils-D40THakY.js';
|
|
53
6
|
|
|
54
7
|
type Modify$1<T, R> = Omit<T, keyof R> & R;
|
|
55
8
|
interface RPCTransaction extends RPCBlockTransaction {
|
|
@@ -300,31 +253,4 @@ declare class FallthroughProvider extends BaseProvider {
|
|
|
300
253
|
post: (body: Record<string, unknown>) => Promise<any>;
|
|
301
254
|
}
|
|
302
255
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
declare function computePublicKey(privKey: BytesLike): string;
|
|
306
|
-
|
|
307
|
-
declare function etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig;
|
|
308
|
-
|
|
309
|
-
declare function etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig;
|
|
310
|
-
|
|
311
|
-
declare function gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig;
|
|
312
|
-
|
|
313
|
-
declare function hashMessage(message: Bytes | string): string;
|
|
314
|
-
|
|
315
|
-
declare function isAddress(address: string): boolean;
|
|
316
|
-
|
|
317
|
-
declare function keccak256(data: BytesLike): string;
|
|
318
|
-
|
|
319
|
-
declare function pack(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
|
|
320
|
-
declare function solidityKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
|
|
321
|
-
|
|
322
|
-
declare function splitSignature(signature: SignatureLike): Signature;
|
|
323
|
-
|
|
324
|
-
declare function toChecksumAddress(address: string): string;
|
|
325
|
-
|
|
326
|
-
declare function toUtf8Bytes(data: string): Uint8Array;
|
|
327
|
-
|
|
328
|
-
declare function weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig;
|
|
329
|
-
|
|
330
|
-
export { AlchemyProvider, BaseContract, type BlockResponse, type BlockTag, type BlockTransactionResponse, type Bytes, type BytesLike, type BytesLikeWithNumber, type ConstructorOptions, Contract, type ContractTypes, type DataOptions, FallthroughProvider, type Filter, type FilterByBlockHash, type Hexable, type JSONABI, type JSONABIArgument, JsonRpcProvider, type Log, type Network, type RPCBlock, type RPCLog, type RPCTransaction, type RPCTransactionReceipt, type RPCTransactionRequest, type Signature, type SignatureLike, TinyBig, type TransactionReceipt, type TransactionRequest, type TransactionResponse, arrayify, computeAddress, computePublicKey, concat, etherToGwei, etherToWei, gweiToEther, hashMessage, hexConcat, hexDataLength, hexDataSlice, hexStripZeros, hexValue, hexZeroPad, hexlify, isAddress, isBytes, isBytesLike, isHexString, jsonRpcProvider, keccak256, pack, solidityKeccak256, splitSignature, stripZeros, tinyBig, toChecksumAddress, toUtf8Bytes, weiToEther, zeroPad };
|
|
256
|
+
export { AlchemyProvider, BaseContract, type BlockResponse, type BlockTag, type BlockTransactionResponse, BytesLike, type ConstructorOptions, Contract, type ContractTypes, FallthroughProvider, type Filter, type FilterByBlockHash, type JSONABI, type JSONABIArgument, JsonRpcProvider, type Log, type Network, type RPCBlock, type RPCLog, type RPCTransaction, type RPCTransactionReceipt, type RPCTransactionRequest, TinyBig, type TransactionReceipt, type TransactionRequest, type TransactionResponse, jsonRpcProvider };
|