essential-eth 0.5.5 → 0.5.10-next.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/{lib/esm → dist}/classes/Contract.d.ts +11 -11
- package/dist/classes/test/Contract/crv-abi.d.ts +2 -0
- package/dist/classes/test/Contract/ens-abi.d.ts +2 -0
- package/dist/classes/test/Contract/fei-abi.d.ts +2 -0
- package/dist/classes/test/Contract/foo-abi.d.ts +2 -0
- package/dist/classes/test/Contract/uniswap-abi.d.ts +2 -0
- package/dist/classes/utils/clean-block.d.ts +3 -0
- package/dist/classes/utils/clean-log.d.ts +2 -0
- package/{lib/esm → dist}/classes/utils/clean-transaction-receipt.d.ts +2 -2
- package/{lib/esm → dist}/classes/utils/clean-transaction.d.ts +2 -2
- package/{lib/cjs → dist}/classes/utils/encode-decode-transaction.d.ts +4 -4
- package/{lib/cjs → dist}/classes/utils/fetchers.d.ts +9 -9
- package/{lib/esm → dist}/classes/utils/hex-to-decimal.d.ts +1 -1
- package/dist/classes/utils/prepare-transaction.d.ts +2 -0
- package/{lib/cjs → dist}/index.d.ts +25 -24
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.mjs +2 -0
- package/dist/index.modern.mjs.map +1 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/{lib/esm → dist}/logger/logger.d.ts +11 -11
- package/dist/logger/package-version.d.ts +1 -0
- package/{lib/esm → dist}/providers/BaseProvider.d.ts +24 -19
- package/{lib/esm → dist}/providers/FallthroughProvider.d.ts +11 -11
- package/{lib/esm → dist}/providers/JsonRpcProvider.d.ts +7 -7
- package/{lib/cjs → dist}/providers/test/rpc-urls.d.ts +11 -11
- package/{lib/esm → dist}/providers/utils/chains-info.d.ts +467 -412
- package/{lib/cjs → dist}/shared/tiny-big/helpers.d.ts +1 -1
- package/{lib/esm → dist}/shared/tiny-big/tiny-big.d.ts +10 -10
- package/{lib/cjs → dist}/shared/validate-type.d.ts +3 -3
- package/{lib/cjs → dist}/types/Block.types.d.ts +40 -37
- package/{lib/cjs → dist}/types/Contract.types.d.ts +24 -24
- package/dist/types/Filter.types.d.ts +12 -0
- package/{lib/esm → dist}/types/Network.types.d.ts +5 -5
- package/{lib/cjs → dist}/types/Transaction.types.d.ts +113 -96
- package/{lib/esm → dist}/utils/bytes.d.ts +40 -40
- package/{lib/esm → dist}/utils/compute-address.d.ts +1 -1
- package/{lib/esm → dist}/utils/compute-public-key.d.ts +2 -2
- package/{lib/esm → dist}/utils/ether-to-gwei.d.ts +3 -3
- package/dist/utils/ether-to-wei.d.ts +3 -0
- package/dist/utils/gwei-to-ether.d.ts +3 -0
- package/{lib/esm → dist}/utils/hash-message.d.ts +2 -2
- package/{lib/esm → dist}/utils/is-address.d.ts +1 -1
- package/dist/utils/keccak256.d.ts +2 -0
- package/{lib/esm → dist}/utils/solidity-keccak256.d.ts +2 -2
- package/{lib/esm → dist}/utils/split-signature.d.ts +2 -2
- package/{lib/esm → dist}/utils/to-checksum-address.d.ts +1 -1
- package/{lib/cjs → dist}/utils/to-utf8-bytes.d.ts +1 -1
- package/dist/utils/wei-to-ether.d.ts +3 -0
- package/package.json +45 -14
- package/readme.md +643 -291
- package/lib/cjs/classes/Contract.d.ts +0 -72
- package/lib/cjs/classes/Contract.js +0 -129
- package/lib/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/crv-abi.js +0 -488
- package/lib/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/ens-abi.js +0 -453
- package/lib/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/fei-abi.js +0 -526
- package/lib/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/foo-abi.js +0 -42
- package/lib/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/lib/cjs/classes/test/Contract/uniswap-abi.js +0 -121
- package/lib/cjs/classes/utils/clean-block.d.ts +0 -6
- package/lib/cjs/classes/utils/clean-block.js +0 -47
- package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -5
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +0 -55
- package/lib/cjs/classes/utils/clean-transaction.d.ts +0 -5
- package/lib/cjs/classes/utils/clean-transaction.js +0 -42
- package/lib/cjs/classes/utils/encode-decode-transaction.js +0 -113
- package/lib/cjs/classes/utils/fetchers.js +0 -51
- package/lib/cjs/classes/utils/hex-to-decimal.d.ts +0 -5
- package/lib/cjs/classes/utils/hex-to-decimal.js +0 -11
- package/lib/cjs/index.js +0 -54
- package/lib/cjs/logger/logger.d.ts +0 -11
- package/lib/cjs/logger/logger.js +0 -36
- package/lib/cjs/logger/package-version.d.ts +0 -1
- package/lib/cjs/logger/package-version.js +0 -5
- package/lib/cjs/providers/BaseProvider.d.ts +0 -284
- package/lib/cjs/providers/BaseProvider.js +0 -380
- package/lib/cjs/providers/FallthroughProvider.d.ts +0 -24
- package/lib/cjs/providers/FallthroughProvider.js +0 -65
- package/lib/cjs/providers/JsonRpcProvider.d.ts +0 -27
- package/lib/cjs/providers/JsonRpcProvider.js +0 -40
- package/lib/cjs/providers/test/rpc-urls.js +0 -14
- package/lib/cjs/providers/utils/chains-info.d.ts +0 -412
- package/lib/cjs/providers/utils/chains-info.js +0 -1237
- package/lib/cjs/shared/tiny-big/helpers.js +0 -71
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +0 -32
- package/lib/cjs/shared/tiny-big/tiny-big.js +0 -71
- package/lib/cjs/shared/validate-type.js +0 -9
- package/lib/cjs/types/Block.types.js +0 -2
- package/lib/cjs/types/Contract.types.js +0 -2
- package/lib/cjs/types/Network.types.d.ts +0 -8
- package/lib/cjs/types/Network.types.js +0 -2
- package/lib/cjs/types/Transaction.types.js +0 -2
- package/lib/cjs/utils/bytes.d.ts +0 -172
- package/lib/cjs/utils/bytes.js +0 -564
- package/lib/cjs/utils/compute-address.d.ts +0 -8
- package/lib/cjs/utils/compute-address.js +0 -24
- package/lib/cjs/utils/compute-public-key.d.ts +0 -9
- package/lib/cjs/utils/compute-public-key.js +0 -17
- package/lib/cjs/utils/ether-to-gwei.d.ts +0 -26
- package/lib/cjs/utils/ether-to-gwei.js +0 -34
- package/lib/cjs/utils/ether-to-wei.d.ts +0 -26
- package/lib/cjs/utils/ether-to-wei.js +0 -34
- package/lib/cjs/utils/gwei-to-ether.d.ts +0 -26
- package/lib/cjs/utils/gwei-to-ether.js +0 -34
- package/lib/cjs/utils/hash-message.d.ts +0 -12
- package/lib/cjs/utils/hash-message.js +0 -26
- package/lib/cjs/utils/is-address.d.ts +0 -24
- package/lib/cjs/utils/is-address.js +0 -39
- package/lib/cjs/utils/keccak256.d.ts +0 -2
- package/lib/cjs/utils/keccak256.js +0 -17
- package/lib/cjs/utils/solidity-keccak256.d.ts +0 -29
- package/lib/cjs/utils/solidity-keccak256.js +0 -118
- package/lib/cjs/utils/split-signature.d.ts +0 -26
- package/lib/cjs/utils/split-signature.js +0 -165
- package/lib/cjs/utils/to-checksum-address.d.ts +0 -17
- package/lib/cjs/utils/to-checksum-address.js +0 -46
- package/lib/cjs/utils/to-utf8-bytes.js +0 -7
- package/lib/cjs/utils/wei-to-ether.d.ts +0 -26
- package/lib/cjs/utils/wei-to-ether.js +0 -34
- package/lib/esm/classes/Contract.js +0 -65
- package/lib/esm/classes/test/Contract/crv-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/crv-abi.js +0 -470
- package/lib/esm/classes/test/Contract/ens-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/ens-abi.js +0 -435
- package/lib/esm/classes/test/Contract/fei-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/fei-abi.js +0 -521
- package/lib/esm/classes/test/Contract/foo-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/foo-abi.js +0 -33
- package/lib/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/lib/esm/classes/test/Contract/uniswap-abi.js +0 -116
- package/lib/esm/classes/utils/clean-block.d.ts +0 -3
- package/lib/esm/classes/utils/clean-block.js +0 -36
- package/lib/esm/classes/utils/clean-transaction-receipt.js +0 -48
- package/lib/esm/classes/utils/clean-transaction.js +0 -33
- package/lib/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
- package/lib/esm/classes/utils/encode-decode-transaction.js +0 -98
- package/lib/esm/classes/utils/fetchers.d.ts +0 -9
- package/lib/esm/classes/utils/fetchers.js +0 -43
- package/lib/esm/classes/utils/hex-to-decimal.js +0 -3
- package/lib/esm/index.d.ts +0 -24
- package/lib/esm/index.js +0 -20
- package/lib/esm/logger/logger.js +0 -33
- package/lib/esm/logger/package-version.d.ts +0 -1
- package/lib/esm/logger/package-version.js +0 -1
- package/lib/esm/providers/BaseProvider.js +0 -107
- package/lib/esm/providers/FallthroughProvider.js +0 -41
- package/lib/esm/providers/JsonRpcProvider.js +0 -15
- package/lib/esm/providers/test/rpc-urls.d.ts +0 -11
- package/lib/esm/providers/test/rpc-urls.js +0 -11
- package/lib/esm/providers/utils/chains-info.js +0 -1233
- package/lib/esm/shared/tiny-big/helpers.d.ts +0 -1
- package/lib/esm/shared/tiny-big/helpers.js +0 -58
- package/lib/esm/shared/tiny-big/tiny-big.js +0 -41
- package/lib/esm/shared/validate-type.d.ts +0 -3
- package/lib/esm/shared/validate-type.js +0 -5
- package/lib/esm/types/Block.types.d.ts +0 -36
- package/lib/esm/types/Block.types.js +0 -1
- package/lib/esm/types/Contract.types.d.ts +0 -24
- package/lib/esm/types/Contract.types.js +0 -1
- package/lib/esm/types/Network.types.js +0 -1
- package/lib/esm/types/Transaction.types.d.ts +0 -87
- package/lib/esm/types/Transaction.types.js +0 -1
- package/lib/esm/utils/bytes.js +0 -245
- package/lib/esm/utils/compute-address.js +0 -11
- package/lib/esm/utils/compute-public-key.js +0 -6
- package/lib/esm/utils/ether-to-gwei.js +0 -7
- package/lib/esm/utils/ether-to-wei.d.ts +0 -3
- package/lib/esm/utils/ether-to-wei.js +0 -7
- package/lib/esm/utils/gwei-to-ether.d.ts +0 -3
- package/lib/esm/utils/gwei-to-ether.js +0 -7
- package/lib/esm/utils/hash-message.js +0 -12
- package/lib/esm/utils/is-address.js +0 -12
- package/lib/esm/utils/keccak256.d.ts +0 -2
- package/lib/esm/utils/keccak256.js +0 -13
- package/lib/esm/utils/solidity-keccak256.js +0 -85
- package/lib/esm/utils/split-signature.js +0 -126
- package/lib/esm/utils/to-checksum-address.js +0 -25
- package/lib/esm/utils/to-utf8-bytes.d.ts +0 -1
- package/lib/esm/utils/to-utf8-bytes.js +0 -3
- package/lib/esm/utils/wei-to-ether.d.ts +0 -3
- package/lib/esm/utils/wei-to-ether.js +0 -7
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scientificStrToDecimalStr = void 0;
|
|
4
|
-
// strips both leading and trailing zeroes
|
|
5
|
-
function stripTrailingZeroes(numberString) {
|
|
6
|
-
const isNegative = numberString.startsWith('-');
|
|
7
|
-
numberString = numberString.replace('-', '');
|
|
8
|
-
numberString = numberString.replace(/\.0*$/g, '' /* for numbers like "1.0" -> "1" */);
|
|
9
|
-
numberString = numberString.replace(/^0+/, '');
|
|
10
|
-
// for numbers like "1.10" -> "1.1"
|
|
11
|
-
if (numberString.includes('.')) {
|
|
12
|
-
numberString = numberString.replace(/0+$/, '');
|
|
13
|
-
}
|
|
14
|
-
if (numberString.startsWith('.')) {
|
|
15
|
-
// so that ".1" returns as "0.1"
|
|
16
|
-
numberString = `0${numberString}`;
|
|
17
|
-
}
|
|
18
|
-
return `${isNegative ? '-' : ''}${numberString}`;
|
|
19
|
-
}
|
|
20
|
-
function scientificStrToDecimalStr(scientificString) {
|
|
21
|
-
// Does not contain "e" nor "E"
|
|
22
|
-
if (!scientificString.match(/e/i /* lowercase and uppercase E */)) {
|
|
23
|
-
return stripTrailingZeroes(scientificString);
|
|
24
|
-
}
|
|
25
|
-
// eslint-disable-next-line prefer-const
|
|
26
|
-
let [base, power] = scientificString.split(/e/i /* lowercase and uppercase E */);
|
|
27
|
-
// remove the leading "-" if negative
|
|
28
|
-
const isNegative = Number(base) < 0;
|
|
29
|
-
base = base.replace('-', '');
|
|
30
|
-
base = stripTrailingZeroes(base);
|
|
31
|
-
const [wholeNumber, fraction /* move decimal this many places */ = ''] = base.split('.');
|
|
32
|
-
if (Number(power) === 0) {
|
|
33
|
-
return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const includesDecimal = base.includes('.');
|
|
37
|
-
if (!includesDecimal) {
|
|
38
|
-
base = `${base}.`;
|
|
39
|
-
}
|
|
40
|
-
base = base.replace('.', '');
|
|
41
|
-
const baseLength = base.length;
|
|
42
|
-
let splitPaddedNumber;
|
|
43
|
-
if (Number(power) < 0) {
|
|
44
|
-
// move decimal left
|
|
45
|
-
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
46
|
-
base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
|
|
47
|
-
}
|
|
48
|
-
splitPaddedNumber = base.split('');
|
|
49
|
-
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
50
|
-
// starts with zeroes
|
|
51
|
-
splitPaddedNumber = ['.', ...splitPaddedNumber];
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// move decimal right
|
|
59
|
-
if (fraction.length < Math.abs(Number(power))) {
|
|
60
|
-
base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
|
|
61
|
-
}
|
|
62
|
-
splitPaddedNumber = base.split('');
|
|
63
|
-
if (fraction.length > Math.abs(Number(power))) {
|
|
64
|
-
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
|
|
68
|
-
return `${isNegative ? '-' : ''}${toReturn}`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.scientificStrToDecimalStr = scientificStrToDecimalStr;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Big from 'big.js';
|
|
2
|
-
/**
|
|
3
|
-
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
4
|
-
* * This is the return type of every operation on ether, wei, etc.
|
|
5
|
-
*/
|
|
6
|
-
export declare class TinyBig extends Big {
|
|
7
|
-
constructor(value: string | number | TinyBig | Big);
|
|
8
|
-
/**
|
|
9
|
-
* Used anytime you're passing in "value" to ethers or web3
|
|
10
|
-
* For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
|
|
11
|
-
*/
|
|
12
|
-
toHexString(): string;
|
|
13
|
-
toNumber(): number;
|
|
14
|
-
toString(): string;
|
|
15
|
-
/**
|
|
16
|
-
* @param {String} str
|
|
17
|
-
* @param {String} padChar
|
|
18
|
-
* @param {Number} length
|
|
19
|
-
*/
|
|
20
|
-
private padAndChop;
|
|
21
|
-
toTwos(bitCount: number): Big;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```javascript
|
|
28
|
-
* tinyBig(10).times(3).toNumber()
|
|
29
|
-
* // 30
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.tinyBig = exports.TinyBig = void 0;
|
|
7
|
-
const big_js_1 = __importDefault(require("big.js"));
|
|
8
|
-
const helpers_1 = require("./helpers");
|
|
9
|
-
/**
|
|
10
|
-
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
11
|
-
* * This is the return type of every operation on ether, wei, etc.
|
|
12
|
-
*/
|
|
13
|
-
class TinyBig extends big_js_1.default {
|
|
14
|
-
constructor(value) {
|
|
15
|
-
super(value);
|
|
16
|
-
/**
|
|
17
|
-
* @param {String} str
|
|
18
|
-
* @param {String} padChar
|
|
19
|
-
* @param {Number} length
|
|
20
|
-
*/
|
|
21
|
-
this.padAndChop = (str, padChar, length) => {
|
|
22
|
-
return (Array(length).fill(padChar).join('') + str).slice(length * -1);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Used anytime you're passing in "value" to ethers or web3
|
|
27
|
-
* For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
|
|
28
|
-
*/
|
|
29
|
-
toHexString() {
|
|
30
|
-
return `0x${BigInt(this.toString()).toString(16)}`;
|
|
31
|
-
}
|
|
32
|
-
toNumber() {
|
|
33
|
-
return Number((0, helpers_1.scientificStrToDecimalStr)(super.toString()));
|
|
34
|
-
}
|
|
35
|
-
toString() {
|
|
36
|
-
if (this.toNumber() === 0) {
|
|
37
|
-
return '0';
|
|
38
|
-
}
|
|
39
|
-
return (0, helpers_1.scientificStrToDecimalStr)(super.toString());
|
|
40
|
-
}
|
|
41
|
-
toTwos(bitCount) {
|
|
42
|
-
let binaryStr;
|
|
43
|
-
if (this.gte(0)) {
|
|
44
|
-
const twosComp = this.toNumber().toString(2);
|
|
45
|
-
binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
|
|
49
|
-
if (Number(binaryStr) < 0) {
|
|
50
|
-
throw new Error('Cannot calculate twos complement');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const binary = `0b${binaryStr}`;
|
|
54
|
-
const decimal = Number(binary);
|
|
55
|
-
return tinyBig(decimal);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.TinyBig = TinyBig;
|
|
59
|
-
/**
|
|
60
|
-
* Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```javascript
|
|
64
|
-
* tinyBig(10).times(3).toNumber()
|
|
65
|
-
* // 30
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
function tinyBig(value) {
|
|
69
|
-
return new TinyBig(value);
|
|
70
|
-
}
|
|
71
|
-
exports.tinyBig = tinyBig;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateType = void 0;
|
|
4
|
-
const validateType = (value, allowedTypes) => {
|
|
5
|
-
if (!allowedTypes.includes(typeof value)) {
|
|
6
|
-
throw new Error(`${allowedTypes.join(' or ')} required. Received ${typeof value}`);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
exports.validateType = validateType;
|
package/lib/cjs/utils/bytes.d.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
export declare type Bytes = ArrayLike<number>;
|
|
2
|
-
/**
|
|
3
|
-
* @example
|
|
4
|
-
* [1,2,3]
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* 0x123
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* '0x123'
|
|
11
|
-
*/
|
|
12
|
-
export declare type BytesLike = Bytes | string;
|
|
13
|
-
export declare type BytesLikeWithNumber = BytesLike | number;
|
|
14
|
-
export interface DataOptions {
|
|
15
|
-
allowMissingPrefix?: boolean;
|
|
16
|
-
hexPad?: 'left' | 'right' | null;
|
|
17
|
-
}
|
|
18
|
-
export interface Hexable {
|
|
19
|
-
toHexString(): string;
|
|
20
|
-
}
|
|
21
|
-
export declare type SignatureLike = {
|
|
22
|
-
r: string;
|
|
23
|
-
s?: string;
|
|
24
|
-
_vs?: string;
|
|
25
|
-
recoveryParam?: number;
|
|
26
|
-
v?: number;
|
|
27
|
-
} | BytesLike;
|
|
28
|
-
export interface Signature {
|
|
29
|
-
r: string;
|
|
30
|
-
s: string;
|
|
31
|
-
_vs: string;
|
|
32
|
-
recoveryParam: number;
|
|
33
|
-
v: number;
|
|
34
|
-
yParityAndS: string;
|
|
35
|
-
compact: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
|
|
39
|
-
* * Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```js
|
|
43
|
-
* isBytesLike([1,2,3]);
|
|
44
|
-
* // true
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```js
|
|
49
|
-
* isBytesLike(false);
|
|
50
|
-
* // false
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```js
|
|
55
|
-
* isBytesLike(new Uint8Array(1));
|
|
56
|
-
* // true
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function isBytesLike(value: any): value is BytesLike;
|
|
60
|
-
/**
|
|
61
|
-
* Returns true if and only if value is a valid [Bytes](#bytes)
|
|
62
|
-
* * Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```js
|
|
66
|
-
* isBytes([1,2,3]);
|
|
67
|
-
* // true
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```js
|
|
72
|
-
* isBytes(false);
|
|
73
|
-
* // false
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```js
|
|
78
|
-
* isBytes(new Uint8Array(1));
|
|
79
|
-
* // true
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export declare function isBytes(value: any): value is Bytes;
|
|
83
|
-
/**
|
|
84
|
-
* Converts DataHexStringOrArrayish to a Uint8Array
|
|
85
|
-
* * Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```js
|
|
89
|
-
* arrayify(1);
|
|
90
|
-
* // Uint8Array(1) [ 1 ]
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```js
|
|
95
|
-
* arrayify(0x1234);
|
|
96
|
-
* // Uint8Array(2) [ 18, 52 ]
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```js
|
|
101
|
-
* arrayify('0x1', { hexPad: 'right' });
|
|
102
|
-
* // Uint8Array(1) [ 16 ]
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
106
|
-
/**
|
|
107
|
-
* Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
|
|
108
|
-
* * Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```js
|
|
112
|
-
* concat([0, 1]);
|
|
113
|
-
* // Uint8Array(2) [ 0, 1 ]
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
117
|
-
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
118
|
-
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
119
|
-
/**
|
|
120
|
-
* Returns true if and only if object is a valid hex string.
|
|
121
|
-
* If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
|
|
122
|
-
* * Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
|
|
123
|
-
*/
|
|
124
|
-
export declare function isHexString(value: any, length?: number): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* @example
|
|
127
|
-
* ```js
|
|
128
|
-
* hexlify(4);
|
|
129
|
-
* // '0x04'
|
|
130
|
-
*
|
|
131
|
-
* hexlify(14);
|
|
132
|
-
* // '0x0e'
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
136
|
-
export declare function hexDataLength(data: BytesLike): number | null;
|
|
137
|
-
export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
138
|
-
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
139
|
-
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
140
|
-
export declare function hexStripZeros(value: BytesLike): string;
|
|
141
|
-
/**
|
|
142
|
-
* Returns a hex string padded to a specified length of bytes.
|
|
143
|
-
*
|
|
144
|
-
* Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
|
|
145
|
-
*
|
|
146
|
-
* Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
|
|
147
|
-
*
|
|
148
|
-
* @param hexValue - A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
|
|
149
|
-
* @param length - The final length in bytes
|
|
150
|
-
*
|
|
151
|
-
* @throws - If the value is not a hex string or number
|
|
152
|
-
* @throws - If the value is longer than the length
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```javascript
|
|
156
|
-
* hexZeroPad('0x60', 2);
|
|
157
|
-
* // '0x0060'
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```javascript
|
|
162
|
-
* hexZeroPad(0x60, 3);
|
|
163
|
-
* // '0x000060'
|
|
164
|
-
* ```
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* ```javascript
|
|
168
|
-
* hexZeroPad('12345', 1);
|
|
169
|
-
* // Throws
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
export declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|