essential-eth 0.5.11-next.0 → 0.5.13-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/dist/{classes → cjs/classes}/Contract.d.ts +0 -0
- package/dist/cjs/classes/Contract.js +140 -0
- package/dist/{classes → cjs/classes}/test/Contract/crv-abi.d.ts +0 -0
- package/dist/cjs/classes/test/Contract/crv-abi.js +488 -0
- package/dist/{classes → cjs/classes}/test/Contract/ens-abi.d.ts +0 -0
- package/dist/cjs/classes/test/Contract/ens-abi.js +453 -0
- package/dist/{classes → cjs/classes}/test/Contract/fei-abi.d.ts +0 -0
- package/dist/cjs/classes/test/Contract/fei-abi.js +526 -0
- package/dist/{classes → cjs/classes}/test/Contract/foo-abi.d.ts +0 -0
- package/dist/cjs/classes/test/Contract/foo-abi.js +42 -0
- package/dist/{classes → cjs/classes}/test/Contract/uniswap-abi.d.ts +0 -0
- package/dist/cjs/classes/test/Contract/uniswap-abi.js +121 -0
- package/dist/{classes → cjs/classes}/utils/clean-block.d.ts +0 -0
- package/dist/cjs/classes/utils/clean-block.js +160 -0
- package/dist/{classes → cjs/classes}/utils/clean-log.d.ts +0 -0
- package/dist/cjs/classes/utils/clean-log.js +37 -0
- package/dist/{classes → cjs/classes}/utils/clean-transaction-receipt.d.ts +0 -0
- package/dist/cjs/classes/utils/clean-transaction-receipt.js +50 -0
- package/dist/{classes → cjs/classes}/utils/clean-transaction.d.ts +0 -0
- package/dist/cjs/classes/utils/clean-transaction.js +51 -0
- package/dist/{classes → cjs/classes}/utils/encode-decode-transaction.d.ts +0 -0
- package/dist/cjs/classes/utils/encode-decode-transaction.js +137 -0
- package/dist/{classes → cjs/classes}/utils/fetchers.d.ts +0 -0
- package/dist/cjs/classes/utils/fetchers.js +81 -0
- package/dist/{classes → cjs/classes}/utils/hex-to-decimal.d.ts +0 -0
- package/dist/cjs/classes/utils/hex-to-decimal.js +24 -0
- package/dist/{classes → cjs/classes}/utils/prepare-transaction.d.ts +0 -0
- package/dist/cjs/classes/utils/prepare-transaction.js +45 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- package/dist/cjs/index.js +54 -0
- package/dist/cjs/index.umd.js +2 -0
- package/dist/cjs/index.umd.js.map +1 -0
- package/dist/{logger → cjs/logger}/logger.d.ts +0 -0
- package/dist/cjs/logger/logger.js +36 -0
- package/dist/cjs/logger/package-version.d.ts +1 -0
- package/dist/cjs/logger/package-version.js +5 -0
- package/dist/{providers → cjs/providers}/BaseProvider.d.ts +0 -0
- package/dist/cjs/providers/BaseProvider.js +512 -0
- package/dist/{providers → cjs/providers}/FallthroughProvider.d.ts +0 -0
- package/dist/cjs/providers/FallthroughProvider.js +65 -0
- package/dist/{providers → cjs/providers}/JsonRpcProvider.d.ts +0 -0
- package/dist/cjs/providers/JsonRpcProvider.js +46 -0
- package/dist/{providers → cjs/providers}/test/rpc-urls.d.ts +0 -0
- package/dist/cjs/providers/test/rpc-urls.js +14 -0
- package/dist/{providers → cjs/providers}/utils/chains-info.d.ts +0 -0
- package/dist/cjs/providers/utils/chains-info.js +1402 -0
- package/dist/{shared → cjs/shared}/tiny-big/helpers.d.ts +0 -0
- package/dist/cjs/shared/tiny-big/helpers.js +97 -0
- package/dist/{shared → cjs/shared}/tiny-big/tiny-big.d.ts +0 -0
- package/dist/cjs/shared/tiny-big/tiny-big.js +101 -0
- package/dist/{shared → cjs/shared}/validate-type.d.ts +0 -0
- package/dist/cjs/shared/validate-type.js +9 -0
- package/dist/{types → cjs/types}/Block.types.d.ts +0 -0
- package/dist/cjs/types/Block.types.js +2 -0
- package/dist/{types → cjs/types}/Contract.types.d.ts +0 -0
- package/dist/cjs/types/Contract.types.js +2 -0
- package/dist/{types → cjs/types}/Filter.types.d.ts +0 -0
- package/dist/cjs/types/Filter.types.js +2 -0
- package/dist/{types → cjs/types}/Network.types.d.ts +0 -0
- package/dist/cjs/types/Network.types.js +2 -0
- package/dist/{types → cjs/types}/Transaction.types.d.ts +0 -0
- package/dist/cjs/types/Transaction.types.js +2 -0
- package/dist/{utils → cjs/utils}/bytes.d.ts +0 -0
- package/dist/cjs/utils/bytes.js +711 -0
- package/dist/{utils → cjs/utils}/compute-address.d.ts +0 -0
- package/dist/cjs/utils/compute-address.js +33 -0
- package/dist/{utils → cjs/utils}/compute-public-key.d.ts +0 -0
- package/dist/cjs/utils/compute-public-key.js +26 -0
- package/dist/{utils → cjs/utils}/ether-to-gwei.d.ts +0 -0
- package/dist/cjs/utils/ether-to-gwei.js +35 -0
- package/dist/{utils → cjs/utils}/ether-to-wei.d.ts +0 -0
- package/dist/cjs/utils/ether-to-wei.js +35 -0
- package/dist/{utils → cjs/utils}/gwei-to-ether.d.ts +0 -0
- package/dist/cjs/utils/gwei-to-ether.js +35 -0
- package/dist/{utils → cjs/utils}/hash-message.d.ts +0 -0
- package/dist/cjs/utils/hash-message.js +28 -0
- package/dist/{utils → cjs/utils}/is-address.d.ts +0 -0
- package/dist/cjs/utils/is-address.js +39 -0
- package/dist/{utils → cjs/utils}/keccak256.d.ts +0 -0
- package/dist/cjs/utils/keccak256.js +31 -0
- package/dist/{utils → cjs/utils}/solidity-keccak256.d.ts +0 -0
- package/dist/cjs/utils/solidity-keccak256.js +138 -0
- package/dist/{utils → cjs/utils}/split-signature.d.ts +0 -0
- package/dist/cjs/utils/split-signature.js +163 -0
- package/dist/{utils → cjs/utils}/to-checksum-address.d.ts +0 -0
- package/dist/cjs/utils/to-checksum-address.js +46 -0
- package/dist/{utils → cjs/utils}/to-utf8-bytes.d.ts +0 -0
- package/dist/cjs/utils/to-utf8-bytes.js +21 -0
- package/dist/{utils → cjs/utils}/wei-to-ether.d.ts +0 -0
- package/dist/cjs/utils/wei-to-ether.js +45 -0
- package/dist/esm/classes/Contract.d.ts +11 -0
- package/dist/esm/classes/Contract.js +65 -0
- package/dist/esm/classes/test/Contract/crv-abi.d.ts +2 -0
- package/dist/esm/classes/test/Contract/crv-abi.js +470 -0
- package/dist/esm/classes/test/Contract/ens-abi.d.ts +2 -0
- package/dist/esm/classes/test/Contract/ens-abi.js +435 -0
- package/dist/esm/classes/test/Contract/fei-abi.d.ts +2 -0
- package/dist/esm/classes/test/Contract/fei-abi.js +521 -0
- package/dist/esm/classes/test/Contract/foo-abi.d.ts +2 -0
- package/dist/esm/classes/test/Contract/foo-abi.js +33 -0
- package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +2 -0
- package/dist/esm/classes/test/Contract/uniswap-abi.js +116 -0
- package/dist/esm/classes/utils/clean-block.d.ts +3 -0
- package/dist/esm/classes/utils/clean-block.js +35 -0
- package/dist/esm/classes/utils/clean-log.d.ts +2 -0
- package/dist/esm/classes/utils/clean-log.js +26 -0
- package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +2 -0
- package/dist/esm/classes/utils/clean-transaction-receipt.js +34 -0
- package/dist/esm/classes/utils/clean-transaction.d.ts +2 -0
- package/dist/esm/classes/utils/clean-transaction.js +33 -0
- package/dist/esm/classes/utils/encode-decode-transaction.d.ts +4 -0
- package/dist/esm/classes/utils/encode-decode-transaction.js +98 -0
- package/dist/esm/classes/utils/fetchers.d.ts +9 -0
- package/dist/esm/classes/utils/fetchers.js +43 -0
- package/dist/esm/classes/utils/hex-to-decimal.d.ts +1 -0
- package/dist/esm/classes/utils/hex-to-decimal.js +3 -0
- package/dist/esm/classes/utils/prepare-transaction.d.ts +2 -0
- package/dist/esm/classes/utils/prepare-transaction.js +34 -0
- package/dist/esm/index.d.ts +25 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/logger/logger.d.ts +11 -0
- package/dist/esm/logger/logger.js +33 -0
- package/dist/esm/logger/package-version.d.ts +1 -0
- package/dist/esm/logger/package-version.js +1 -0
- package/dist/esm/providers/BaseProvider.d.ts +24 -0
- package/dist/esm/providers/BaseProvider.js +157 -0
- package/dist/esm/providers/FallthroughProvider.d.ts +11 -0
- package/dist/esm/providers/FallthroughProvider.js +41 -0
- package/dist/esm/providers/JsonRpcProvider.d.ts +7 -0
- package/dist/esm/providers/JsonRpcProvider.js +15 -0
- package/dist/esm/providers/test/rpc-urls.d.ts +11 -0
- package/dist/esm/providers/test/rpc-urls.js +11 -0
- package/dist/esm/providers/utils/chains-info.d.ts +467 -0
- package/dist/esm/providers/utils/chains-info.js +1398 -0
- package/dist/esm/shared/tiny-big/helpers.d.ts +1 -0
- package/dist/esm/shared/tiny-big/helpers.js +58 -0
- package/dist/esm/shared/tiny-big/tiny-big.d.ts +10 -0
- package/dist/esm/shared/tiny-big/tiny-big.js +45 -0
- package/dist/esm/shared/validate-type.d.ts +3 -0
- package/dist/esm/shared/validate-type.js +5 -0
- package/dist/esm/types/Block.types.d.ts +40 -0
- package/dist/esm/types/Block.types.js +1 -0
- package/dist/esm/types/Contract.types.d.ts +24 -0
- package/dist/esm/types/Contract.types.js +1 -0
- package/dist/esm/types/Filter.types.d.ts +12 -0
- package/dist/esm/types/Filter.types.js +1 -0
- package/dist/esm/types/Network.types.d.ts +5 -0
- package/dist/esm/types/Network.types.js +1 -0
- package/dist/esm/types/Transaction.types.d.ts +113 -0
- package/dist/esm/types/Transaction.types.js +1 -0
- package/dist/esm/utils/bytes.d.ts +40 -0
- package/dist/esm/utils/bytes.js +245 -0
- package/dist/esm/utils/compute-address.d.ts +1 -0
- package/dist/esm/utils/compute-address.js +11 -0
- package/dist/esm/utils/compute-public-key.d.ts +2 -0
- package/dist/esm/utils/compute-public-key.js +6 -0
- package/dist/esm/utils/ether-to-gwei.d.ts +3 -0
- package/dist/esm/utils/ether-to-gwei.js +7 -0
- package/dist/esm/utils/ether-to-wei.d.ts +3 -0
- package/dist/esm/utils/ether-to-wei.js +7 -0
- package/dist/esm/utils/gwei-to-ether.d.ts +3 -0
- package/dist/esm/utils/gwei-to-ether.js +7 -0
- package/dist/esm/utils/hash-message.d.ts +2 -0
- package/dist/esm/utils/hash-message.js +12 -0
- package/dist/esm/utils/is-address.d.ts +1 -0
- package/dist/esm/utils/is-address.js +12 -0
- package/dist/esm/utils/keccak256.d.ts +2 -0
- package/dist/esm/utils/keccak256.js +13 -0
- package/dist/esm/utils/solidity-keccak256.d.ts +2 -0
- package/dist/esm/utils/solidity-keccak256.js +85 -0
- package/dist/esm/utils/split-signature.d.ts +2 -0
- package/dist/esm/utils/split-signature.js +126 -0
- package/dist/esm/utils/to-checksum-address.d.ts +1 -0
- package/dist/esm/utils/to-checksum-address.js +25 -0
- package/dist/esm/utils/to-utf8-bytes.d.ts +1 -0
- package/dist/esm/utils/to-utf8-bytes.js +3 -0
- package/dist/esm/utils/wei-to-ether.d.ts +3 -0
- package/dist/esm/utils/wei-to-ether.js +16 -0
- package/package.json +10 -14
- package/readme.md +5 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.modern.mjs +0 -2
- package/dist/index.modern.mjs.map +0 -1
- package/dist/index.module.js +0 -2
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/logger/package-version.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function scientificStrToDecimalStr(scientificString: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function stripTrailingZeroes(numberString) {
|
|
2
|
+
const isNegative = numberString.startsWith('-');
|
|
3
|
+
numberString = numberString.replace('-', '');
|
|
4
|
+
numberString = numberString.replace(/\.0*$/g, '');
|
|
5
|
+
numberString = numberString.replace(/^0+/, '');
|
|
6
|
+
if (numberString.includes('.')) {
|
|
7
|
+
numberString = numberString.replace(/0+$/, '');
|
|
8
|
+
}
|
|
9
|
+
if (numberString.startsWith('.')) {
|
|
10
|
+
numberString = `0${numberString}`;
|
|
11
|
+
}
|
|
12
|
+
return `${isNegative ? '-' : ''}${numberString}`;
|
|
13
|
+
}
|
|
14
|
+
export function scientificStrToDecimalStr(scientificString) {
|
|
15
|
+
if (!scientificString.match(/e/i)) {
|
|
16
|
+
return stripTrailingZeroes(scientificString);
|
|
17
|
+
}
|
|
18
|
+
let [base, power] = scientificString.split(/e/i);
|
|
19
|
+
const isNegative = Number(base) < 0;
|
|
20
|
+
base = base.replace('-', '');
|
|
21
|
+
base = stripTrailingZeroes(base);
|
|
22
|
+
const [wholeNumber, fraction = ''] = base.split('.');
|
|
23
|
+
if (Number(power) === 0) {
|
|
24
|
+
return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const includesDecimal = base.includes('.');
|
|
28
|
+
if (!includesDecimal) {
|
|
29
|
+
base = `${base}.`;
|
|
30
|
+
}
|
|
31
|
+
base = base.replace('.', '');
|
|
32
|
+
const baseLength = base.length;
|
|
33
|
+
let splitPaddedNumber;
|
|
34
|
+
if (Number(power) < 0) {
|
|
35
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
36
|
+
base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
|
|
37
|
+
}
|
|
38
|
+
splitPaddedNumber = base.split('');
|
|
39
|
+
if (wholeNumber.length < Math.abs(Number(power))) {
|
|
40
|
+
splitPaddedNumber = ['.', ...splitPaddedNumber];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (fraction.length < Math.abs(Number(power))) {
|
|
48
|
+
base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
|
|
49
|
+
}
|
|
50
|
+
splitPaddedNumber = base.split('');
|
|
51
|
+
if (fraction.length > Math.abs(Number(power))) {
|
|
52
|
+
splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
|
|
56
|
+
return `${isNegative ? '-' : ''}${toReturn}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
export declare class TinyBig extends Big {
|
|
3
|
+
constructor(value: string | number | TinyBig | Big);
|
|
4
|
+
toHexString(): string;
|
|
5
|
+
toNumber(): number;
|
|
6
|
+
toString(): string;
|
|
7
|
+
private padAndChop;
|
|
8
|
+
toTwos(bitCount: number): Big;
|
|
9
|
+
}
|
|
10
|
+
export declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Big from 'big.js';
|
|
2
|
+
import { hexToDecimal } from '../../classes/utils/hex-to-decimal';
|
|
3
|
+
import { scientificStrToDecimalStr } from './helpers';
|
|
4
|
+
export class TinyBig extends Big {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
if (typeof value === 'string' && value.startsWith('0x')) {
|
|
7
|
+
value = hexToDecimal(value);
|
|
8
|
+
}
|
|
9
|
+
super(value);
|
|
10
|
+
this.padAndChop = (str, padChar, length) => {
|
|
11
|
+
return (Array(length).fill(padChar).join('') + str).slice(length * -1);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
toHexString() {
|
|
15
|
+
return `0x${BigInt(this.toString()).toString(16)}`;
|
|
16
|
+
}
|
|
17
|
+
toNumber() {
|
|
18
|
+
return Number(scientificStrToDecimalStr(super.toString()));
|
|
19
|
+
}
|
|
20
|
+
toString() {
|
|
21
|
+
if (this.toNumber() === 0) {
|
|
22
|
+
return '0';
|
|
23
|
+
}
|
|
24
|
+
return scientificStrToDecimalStr(super.toString());
|
|
25
|
+
}
|
|
26
|
+
toTwos(bitCount) {
|
|
27
|
+
let binaryStr;
|
|
28
|
+
if (this.gte(0)) {
|
|
29
|
+
const twosComp = this.toNumber().toString(2);
|
|
30
|
+
binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
|
|
34
|
+
if (Number(binaryStr) < 0) {
|
|
35
|
+
throw new Error('Cannot calculate twos complement');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const binary = `0b${binaryStr}`;
|
|
39
|
+
const decimal = Number(binary);
|
|
40
|
+
return tinyBig(decimal);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function tinyBig(value) {
|
|
44
|
+
return new TinyBig(value);
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TinyBig } from './../shared/tiny-big/tiny-big';
|
|
2
|
+
import type { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
|
|
3
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
4
|
+
export declare type BlockResponse = Modify<RPCBlock, {
|
|
5
|
+
baseFeePerGas: TinyBig;
|
|
6
|
+
difficulty: TinyBig;
|
|
7
|
+
gasLimit: TinyBig;
|
|
8
|
+
gasUsed: TinyBig;
|
|
9
|
+
nonce: TinyBig;
|
|
10
|
+
number: number;
|
|
11
|
+
size: TinyBig;
|
|
12
|
+
timestamp: TinyBig;
|
|
13
|
+
totalDifficulty: TinyBig;
|
|
14
|
+
transactions: Array<string | BlockTransactionResponse>;
|
|
15
|
+
}>;
|
|
16
|
+
export interface RPCBlock {
|
|
17
|
+
baseFeePerGas: string;
|
|
18
|
+
difficulty: string;
|
|
19
|
+
extraData: string;
|
|
20
|
+
gasLimit: string;
|
|
21
|
+
gasUsed: string;
|
|
22
|
+
hash: string;
|
|
23
|
+
logsBloom: string;
|
|
24
|
+
miner: string;
|
|
25
|
+
mixHash: string;
|
|
26
|
+
nonce: string;
|
|
27
|
+
number: string;
|
|
28
|
+
parentHash: string;
|
|
29
|
+
receiptsRoot: string;
|
|
30
|
+
sha3Uncles: string;
|
|
31
|
+
size: string;
|
|
32
|
+
stateRoot: string;
|
|
33
|
+
timestamp: string;
|
|
34
|
+
totalDifficulty: string;
|
|
35
|
+
transactions: Array<string | RPCTransaction>;
|
|
36
|
+
transactionsRoot: string;
|
|
37
|
+
uncles: Array<string>;
|
|
38
|
+
}
|
|
39
|
+
export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare type ContractTypes = 'bool' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' | 'bytes32[]' | 'address' | 'address payable' | 'address[4]' | 'address[100]' | 'uint256' | 'uint256[100]' | 'uint8' | 'uint32' | string;
|
|
2
|
+
export declare type ContractInterface = JSONABI;
|
|
3
|
+
export declare type ContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
|
|
4
|
+
export interface JSONABIArgument {
|
|
5
|
+
anonymous?: false;
|
|
6
|
+
inputs: {
|
|
7
|
+
internalType?: ContractTypes | string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: ContractTypes;
|
|
10
|
+
indexed?: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
name?: string;
|
|
13
|
+
outputs?: {
|
|
14
|
+
internalType?: ContractTypes | string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: ContractTypes;
|
|
17
|
+
}[];
|
|
18
|
+
stateMutability?: 'view' | 'nonpayable' | string;
|
|
19
|
+
type: 'function' | 'event' | 'constructor' | 'error' | 'fallback';
|
|
20
|
+
gas?: number;
|
|
21
|
+
constant?: boolean;
|
|
22
|
+
payable?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare type JSONABI = JSONABIArgument[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BlockTag } from './Block.types';
|
|
2
|
+
export interface EventFilter {
|
|
3
|
+
address?: string;
|
|
4
|
+
topics?: Array<string | Array<string> | null>;
|
|
5
|
+
}
|
|
6
|
+
export interface Filter extends EventFilter {
|
|
7
|
+
fromBlock?: BlockTag;
|
|
8
|
+
toBlock?: BlockTag;
|
|
9
|
+
}
|
|
10
|
+
export interface FilterByBlockHash extends EventFilter {
|
|
11
|
+
blockHash?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type Big from 'big.js';
|
|
2
|
+
import type { TinyBig } from '../shared/tiny-big/tiny-big';
|
|
3
|
+
import type { BytesLike } from './../utils/bytes';
|
|
4
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
5
|
+
export interface RPCTransaction extends RPCBlockTransaction {
|
|
6
|
+
maxFeePerGas: string;
|
|
7
|
+
maxPriorityFeePerGas: string;
|
|
8
|
+
}
|
|
9
|
+
export declare type TransactionResponse = Modify<RPCTransaction, {
|
|
10
|
+
blockNumber: number;
|
|
11
|
+
chainId: number;
|
|
12
|
+
gas: TinyBig;
|
|
13
|
+
gasLimit: TinyBig;
|
|
14
|
+
gasPrice: TinyBig;
|
|
15
|
+
nonce: TinyBig;
|
|
16
|
+
transactionIndex: number;
|
|
17
|
+
type: number;
|
|
18
|
+
v: number;
|
|
19
|
+
value: TinyBig;
|
|
20
|
+
} & {
|
|
21
|
+
maxFeePerGas: TinyBig;
|
|
22
|
+
maxPriorityFeePerGas: TinyBig;
|
|
23
|
+
confirmations: number;
|
|
24
|
+
}>;
|
|
25
|
+
export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
|
|
26
|
+
blockNumber: number;
|
|
27
|
+
cumulativeGasUsed: TinyBig;
|
|
28
|
+
effectiveGasPrice: TinyBig;
|
|
29
|
+
gasUsed: TinyBig;
|
|
30
|
+
logs: Array<Log>;
|
|
31
|
+
status: number;
|
|
32
|
+
transactionIndex: number;
|
|
33
|
+
type: number;
|
|
34
|
+
} & {
|
|
35
|
+
byzantium: boolean;
|
|
36
|
+
confirmations: number;
|
|
37
|
+
}>;
|
|
38
|
+
export interface RPCTransactionRequest {
|
|
39
|
+
from?: string;
|
|
40
|
+
to: string;
|
|
41
|
+
gas?: string;
|
|
42
|
+
gasPrice?: string;
|
|
43
|
+
value?: string;
|
|
44
|
+
data?: BytesLike;
|
|
45
|
+
nonce?: string;
|
|
46
|
+
maxPriorityFeePerGas?: string;
|
|
47
|
+
maxFeePerGas?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface TransactionRequest {
|
|
50
|
+
to?: string;
|
|
51
|
+
from?: string;
|
|
52
|
+
nonce?: TinyBig | string | Big | number;
|
|
53
|
+
gas?: TinyBig | number | Big | string;
|
|
54
|
+
gasPrice?: TinyBig | Big | string | number;
|
|
55
|
+
data?: BytesLike;
|
|
56
|
+
value?: TinyBig | string | Big | number;
|
|
57
|
+
chainId?: number;
|
|
58
|
+
type?: number;
|
|
59
|
+
maxPriorityFeePerGas?: TinyBig | string | Big | number;
|
|
60
|
+
maxFeePerGas?: TinyBig | string | Big | number;
|
|
61
|
+
}
|
|
62
|
+
export declare type Log = Modify<RPCLog, {
|
|
63
|
+
blockNumber: number;
|
|
64
|
+
logIndex: number;
|
|
65
|
+
transactionIndex: number;
|
|
66
|
+
}>;
|
|
67
|
+
export declare type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
|
|
68
|
+
export interface RPCBlockTransaction {
|
|
69
|
+
blockHash: string;
|
|
70
|
+
blockNumber: string;
|
|
71
|
+
chainId: string;
|
|
72
|
+
from: string;
|
|
73
|
+
gas: string;
|
|
74
|
+
gasPrice: string;
|
|
75
|
+
hash: string;
|
|
76
|
+
input: string;
|
|
77
|
+
nonce: string;
|
|
78
|
+
r: string;
|
|
79
|
+
s: string;
|
|
80
|
+
to: string;
|
|
81
|
+
transactionIndex: string;
|
|
82
|
+
type: string;
|
|
83
|
+
v: string;
|
|
84
|
+
value: string;
|
|
85
|
+
}
|
|
86
|
+
export interface RPCTransactionReceipt {
|
|
87
|
+
blockHash: string;
|
|
88
|
+
blockNumber: string;
|
|
89
|
+
contractAddress: string;
|
|
90
|
+
cumulativeGasUsed: string;
|
|
91
|
+
effectiveGasPrice: string;
|
|
92
|
+
from: string;
|
|
93
|
+
gasUsed: string;
|
|
94
|
+
logs: Array<RPCLog>;
|
|
95
|
+
logsBloom: string;
|
|
96
|
+
status: string;
|
|
97
|
+
to: string;
|
|
98
|
+
transactionHash: string;
|
|
99
|
+
transactionIndex: string;
|
|
100
|
+
type: string;
|
|
101
|
+
}
|
|
102
|
+
export interface RPCLog {
|
|
103
|
+
address: string;
|
|
104
|
+
blockHash: string;
|
|
105
|
+
blockNumber: string;
|
|
106
|
+
data: string;
|
|
107
|
+
logIndex: string;
|
|
108
|
+
removed?: boolean;
|
|
109
|
+
topics: Array<string>;
|
|
110
|
+
transactionHash: string;
|
|
111
|
+
transactionIndex: string;
|
|
112
|
+
}
|
|
113
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare type Bytes = ArrayLike<number>;
|
|
2
|
+
export declare type BytesLike = Bytes | string;
|
|
3
|
+
export declare type BytesLikeWithNumber = BytesLike | number;
|
|
4
|
+
export interface DataOptions {
|
|
5
|
+
allowMissingPrefix?: boolean;
|
|
6
|
+
hexPad?: 'left' | 'right' | null;
|
|
7
|
+
}
|
|
8
|
+
export interface Hexable {
|
|
9
|
+
toHexString(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare type SignatureLike = {
|
|
12
|
+
r: string;
|
|
13
|
+
s?: string;
|
|
14
|
+
_vs?: string;
|
|
15
|
+
recoveryParam?: number;
|
|
16
|
+
v?: number;
|
|
17
|
+
} | BytesLike;
|
|
18
|
+
export interface Signature {
|
|
19
|
+
r: string;
|
|
20
|
+
s: string;
|
|
21
|
+
_vs: string;
|
|
22
|
+
recoveryParam: number;
|
|
23
|
+
v: number;
|
|
24
|
+
yParityAndS: string;
|
|
25
|
+
compact: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function isBytesLike(value: any): value is BytesLike;
|
|
28
|
+
export declare function isBytes(value: any): value is Bytes;
|
|
29
|
+
export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
30
|
+
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
31
|
+
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
32
|
+
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
33
|
+
export declare function isHexString(value: any, length?: number): boolean;
|
|
34
|
+
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
35
|
+
export declare function hexDataLength(data: BytesLike): number | null;
|
|
36
|
+
export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
37
|
+
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
38
|
+
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
39
|
+
export declare function hexStripZeros(value: BytesLike): string;
|
|
40
|
+
export declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { logger } from '../logger/logger';
|
|
2
|
+
function isHexable(value) {
|
|
3
|
+
return !!value.toHexString;
|
|
4
|
+
}
|
|
5
|
+
export function isBytesLike(value) {
|
|
6
|
+
return (isHexString(value) && !(value.length % 2)) || isBytes(value);
|
|
7
|
+
}
|
|
8
|
+
function isInteger(value) {
|
|
9
|
+
return typeof value === 'number' && value == value && value % 1 === 0;
|
|
10
|
+
}
|
|
11
|
+
export function isBytes(value) {
|
|
12
|
+
if (value == null) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (value.constructor === Uint8Array) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (typeof value === 'string') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (!isInteger(value.length) || value.length < 0) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
for (let i = 0; i < value.length; i++) {
|
|
25
|
+
const v = value[i];
|
|
26
|
+
if (!isInteger(v) || v < 0 || v >= 256) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
export function arrayify(value, options) {
|
|
33
|
+
if (!options) {
|
|
34
|
+
options = {};
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'number') {
|
|
37
|
+
logger.checkSafeUint53(value, 'invalid arrayify value');
|
|
38
|
+
const result = [];
|
|
39
|
+
while (value) {
|
|
40
|
+
result.unshift(value & 0xff);
|
|
41
|
+
value = parseInt(String(value / 256));
|
|
42
|
+
}
|
|
43
|
+
if (result.length === 0) {
|
|
44
|
+
result.push(0);
|
|
45
|
+
}
|
|
46
|
+
return new Uint8Array(result);
|
|
47
|
+
}
|
|
48
|
+
if (options.allowMissingPrefix &&
|
|
49
|
+
typeof value === 'string' &&
|
|
50
|
+
value.substring(0, 2) !== '0x') {
|
|
51
|
+
value = '0x' + value;
|
|
52
|
+
}
|
|
53
|
+
if (isHexable(value)) {
|
|
54
|
+
value = value.toHexString();
|
|
55
|
+
}
|
|
56
|
+
if (isHexString(value)) {
|
|
57
|
+
let hex = value.substring(2);
|
|
58
|
+
if (hex.length % 2) {
|
|
59
|
+
if (options.hexPad === 'left') {
|
|
60
|
+
hex = '0' + hex;
|
|
61
|
+
}
|
|
62
|
+
else if (options.hexPad === 'right') {
|
|
63
|
+
hex += '0';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const result = [];
|
|
70
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
71
|
+
result.push(parseInt(hex.substring(i, i + 2), 16));
|
|
72
|
+
}
|
|
73
|
+
return new Uint8Array(result);
|
|
74
|
+
}
|
|
75
|
+
if (isBytes(value)) {
|
|
76
|
+
return new Uint8Array(value);
|
|
77
|
+
}
|
|
78
|
+
return logger.throwArgumentError('invalid arrayify value', 'value', value);
|
|
79
|
+
}
|
|
80
|
+
export function concat(arrayOfBytesLike) {
|
|
81
|
+
const objects = arrayOfBytesLike.map((item) => arrayify(item));
|
|
82
|
+
const length = objects.reduce((accum, item) => accum + item.length, 0);
|
|
83
|
+
const result = new Uint8Array(length);
|
|
84
|
+
objects.reduce((offset, object) => {
|
|
85
|
+
result.set(object, offset);
|
|
86
|
+
return offset + object.length;
|
|
87
|
+
}, 0);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
export function stripZeros(value) {
|
|
91
|
+
let result = arrayify(value);
|
|
92
|
+
if (result.length === 0) {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
let start = 0;
|
|
96
|
+
while (start < result.length && result[start] === 0) {
|
|
97
|
+
start++;
|
|
98
|
+
}
|
|
99
|
+
if (start) {
|
|
100
|
+
result = result.slice(start);
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
export function zeroPad(value, length) {
|
|
105
|
+
value = arrayify(value);
|
|
106
|
+
if (value.length > length) {
|
|
107
|
+
logger.throwArgumentError('value out of range', 'value', value);
|
|
108
|
+
}
|
|
109
|
+
const result = new Uint8Array(length);
|
|
110
|
+
result.set(value, length - value.length);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
export function isHexString(value, length) {
|
|
114
|
+
if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (length && value.length !== 2 + 2 * length) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
const HexCharacters = '0123456789abcdef';
|
|
123
|
+
export function hexlify(value, options) {
|
|
124
|
+
if (!options) {
|
|
125
|
+
options = {};
|
|
126
|
+
}
|
|
127
|
+
if (typeof value === 'number') {
|
|
128
|
+
logger.checkSafeUint53(value, 'invalid hexlify value');
|
|
129
|
+
let hex = '';
|
|
130
|
+
while (value) {
|
|
131
|
+
hex = HexCharacters[value & 0xf] + hex;
|
|
132
|
+
value = Math.floor(value / 16);
|
|
133
|
+
}
|
|
134
|
+
if (hex.length) {
|
|
135
|
+
if (hex.length % 2) {
|
|
136
|
+
hex = '0' + hex;
|
|
137
|
+
}
|
|
138
|
+
return '0x' + hex;
|
|
139
|
+
}
|
|
140
|
+
return '0x00';
|
|
141
|
+
}
|
|
142
|
+
if (typeof value === 'bigint') {
|
|
143
|
+
value = value.toString(16);
|
|
144
|
+
if (value.length % 2) {
|
|
145
|
+
return '0x0' + value;
|
|
146
|
+
}
|
|
147
|
+
return '0x' + value;
|
|
148
|
+
}
|
|
149
|
+
if (options.allowMissingPrefix &&
|
|
150
|
+
typeof value === 'string' &&
|
|
151
|
+
value.substring(0, 2) !== '0x') {
|
|
152
|
+
value = '0x' + value;
|
|
153
|
+
}
|
|
154
|
+
if (isHexable(value)) {
|
|
155
|
+
return value.toHexString();
|
|
156
|
+
}
|
|
157
|
+
if (isHexString(value)) {
|
|
158
|
+
if (value.length % 2) {
|
|
159
|
+
if (options.hexPad === 'left') {
|
|
160
|
+
value = '0x0' + value.substring(2);
|
|
161
|
+
}
|
|
162
|
+
else if (options.hexPad === 'right') {
|
|
163
|
+
value += '0';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return value.toLowerCase();
|
|
170
|
+
}
|
|
171
|
+
if (isBytes(value)) {
|
|
172
|
+
let result = '0x';
|
|
173
|
+
for (let i = 0; i < value.length; i++) {
|
|
174
|
+
const v = value[i];
|
|
175
|
+
result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
return logger.throwArgumentError('invalid hexlify value', 'value', value);
|
|
180
|
+
}
|
|
181
|
+
export function hexDataLength(data) {
|
|
182
|
+
if (typeof data !== 'string') {
|
|
183
|
+
data = hexlify(data);
|
|
184
|
+
}
|
|
185
|
+
else if (!isHexString(data) || data.length % 2) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
return (data.length - 2) / 2;
|
|
189
|
+
}
|
|
190
|
+
export function hexDataSlice(data, offset, endOffset) {
|
|
191
|
+
if (typeof data !== 'string') {
|
|
192
|
+
data = hexlify(data);
|
|
193
|
+
}
|
|
194
|
+
else if (!isHexString(data) || data.length % 2) {
|
|
195
|
+
logger.throwArgumentError('invalid hexData', 'value', data);
|
|
196
|
+
}
|
|
197
|
+
offset = 2 + 2 * offset;
|
|
198
|
+
if (endOffset != null) {
|
|
199
|
+
return '0x' + data.substring(offset, 2 + 2 * endOffset);
|
|
200
|
+
}
|
|
201
|
+
return '0x' + data.substring(offset);
|
|
202
|
+
}
|
|
203
|
+
export function hexConcat(items) {
|
|
204
|
+
let result = '0x';
|
|
205
|
+
items.forEach((item) => {
|
|
206
|
+
result += hexlify(item).substring(2);
|
|
207
|
+
});
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
export function hexValue(value) {
|
|
211
|
+
const trimmed = hexStripZeros(hexlify(value, { hexPad: 'left' }));
|
|
212
|
+
if (trimmed === '0x') {
|
|
213
|
+
return '0x0';
|
|
214
|
+
}
|
|
215
|
+
return trimmed;
|
|
216
|
+
}
|
|
217
|
+
export function hexStripZeros(value) {
|
|
218
|
+
if (typeof value !== 'string') {
|
|
219
|
+
value = hexlify(value);
|
|
220
|
+
}
|
|
221
|
+
if (!isHexString(value)) {
|
|
222
|
+
logger.throwArgumentError('invalid hex string', 'value', value);
|
|
223
|
+
}
|
|
224
|
+
value = value.substring(2);
|
|
225
|
+
let offset = 0;
|
|
226
|
+
while (offset < value.length && value[offset] === '0') {
|
|
227
|
+
offset++;
|
|
228
|
+
}
|
|
229
|
+
return '0x' + value.substring(offset);
|
|
230
|
+
}
|
|
231
|
+
export function hexZeroPad(value, length) {
|
|
232
|
+
if (typeof value !== 'string') {
|
|
233
|
+
value = hexlify(value);
|
|
234
|
+
}
|
|
235
|
+
else if (!isHexString(value)) {
|
|
236
|
+
logger.throwArgumentError('invalid hex string', 'value', value);
|
|
237
|
+
}
|
|
238
|
+
if (value.length > 2 * length + 2) {
|
|
239
|
+
logger.throwError('value out of range', { value, length });
|
|
240
|
+
}
|
|
241
|
+
while (value.length < 2 * length + 2) {
|
|
242
|
+
value = '0x0' + value.substring(2);
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function computeAddress(key: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { computePublicKey, toChecksumAddress } from '..';
|
|
2
|
+
import { hexDataSlice } from './bytes';
|
|
3
|
+
import { keccak256 } from './keccak256';
|
|
4
|
+
export function computeAddress(key) {
|
|
5
|
+
if (!key.startsWith('0x04') &&
|
|
6
|
+
!key.startsWith('0x03') &&
|
|
7
|
+
!key.startsWith('0x02')) {
|
|
8
|
+
key = computePublicKey(key);
|
|
9
|
+
}
|
|
10
|
+
return toChecksumAddress(hexDataSlice(keccak256(hexDataSlice(key, 1)), 12));
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { tinyBig } from '../shared/tiny-big/tiny-big';
|
|
2
|
+
import { validateType } from '../shared/validate-type';
|
|
3
|
+
export function etherToGwei(etherQuantity) {
|
|
4
|
+
validateType(etherQuantity, ['string', 'number', 'object']);
|
|
5
|
+
const result = tinyBig(etherQuantity).times('1000000000');
|
|
6
|
+
return tinyBig(result);
|
|
7
|
+
}
|