essential-eth 0.9.0 → 0.9.1-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/cjs/classes/Contract.js +38 -34
- package/dist/cjs/classes/test/Contract/crv.test.js +146 -339
- package/dist/cjs/classes/test/Contract/ens-abi.d.ts +1 -1
- package/dist/cjs/classes/test/Contract/ens.test.js +9 -66
- package/dist/cjs/classes/test/Contract/fei.test.js +11 -11
- package/dist/cjs/classes/test/Contract/foo-abi.d.ts +1 -1
- package/dist/cjs/classes/test/Contract/uni.test.js +66 -164
- package/dist/cjs/classes/utils/clean-block.js +4 -4
- package/dist/cjs/classes/utils/clean-log.js +4 -4
- package/dist/cjs/classes/utils/clean-transaction-receipt.js +4 -4
- package/dist/cjs/classes/utils/clean-transaction.js +4 -4
- package/dist/cjs/classes/utils/encode-decode-transaction.js +10 -10
- package/dist/cjs/classes/utils/fetchers.d.ts +8 -2
- package/dist/cjs/classes/utils/fetchers.js +20 -12
- package/dist/cjs/classes/utils/prepare-transaction.js +4 -4
- package/dist/cjs/index.d.ts +21 -22
- package/dist/cjs/index.js +21 -22
- package/dist/cjs/index.umd.js +1 -1
- package/dist/cjs/index.umd.js.map +1 -1
- package/dist/cjs/logger/logger.js +79 -41
- package/dist/cjs/logger/package-version.d.ts +1 -1
- package/dist/cjs/logger/package-version.js +1 -1
- package/dist/cjs/providers/AlchemyProvider.js +22 -22
- package/dist/cjs/providers/BaseProvider.js +471 -404
- package/dist/cjs/providers/FallthroughProvider.js +62 -30
- package/dist/cjs/providers/JsonRpcProvider.js +52 -31
- package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +9 -9
- package/dist/cjs/providers/test/get-transaction-count.test.js +54 -91
- package/dist/cjs/providers/test/json-rpc-provider/call.test.js +87 -148
- package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +45 -116
- package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +36 -74
- package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +13 -9
- package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +191 -254
- package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +106 -135
- package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +48 -73
- package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +11 -8
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/get-logs.test.js +219 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +149 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +37 -79
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +136 -157
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +121 -162
- package/dist/cjs/providers/test/mock-of.js +0 -5
- package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
- package/dist/cjs/providers/test/rpc-urls.js +5 -4
- package/dist/cjs/providers/test/test-alchemy-provider.test.js +5 -5
- package/dist/cjs/providers/utils/chains-info.d.ts +5 -448
- package/dist/cjs/providers/utils/chains-info.js +13 -1344
- package/dist/cjs/shared/tiny-big/helpers.js +18 -18
- package/dist/cjs/shared/tiny-big/tiny-big.js +96 -56
- package/dist/cjs/shared/tiny-big/tiny-big.test.js +2 -2
- package/dist/cjs/shared/validate-type.d.ts +1 -1
- package/dist/cjs/shared/validate-type.js +4 -4
- package/dist/cjs/types/Block.types.d.ts +3 -3
- package/dist/cjs/types/Contract.types.d.ts +4 -4
- package/dist/cjs/types/Transaction.types.d.ts +5 -5
- package/dist/cjs/utils/bytes.d.ts +4 -4
- package/dist/cjs/utils/bytes.js +3 -3
- package/dist/cjs/utils/tests/bytes/arrayify.test.js +48 -24
- package/dist/cjs/utils/tests/bytes/concat.test.js +5 -3
- package/dist/cjs/utils/tests/bytes/hex-concat.test.js +15 -13
- package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +49 -32
- package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +15 -16
- package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +57 -40
- package/dist/cjs/utils/tests/bytes/hex-value.test.js +118 -62
- package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +71 -33
- package/dist/cjs/utils/tests/bytes/hexlify.test.js +45 -29
- package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +10 -11
- package/dist/cjs/utils/tests/bytes/is-bytes.test.js +70 -27
- package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +37 -28
- package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +94 -45
- package/dist/cjs/utils/tests/bytes/zero-pad.test.js +98 -34
- package/dist/cjs/utils/tests/compute-address.test.js +42 -20
- package/dist/cjs/utils/tests/compute-public-key.test.js +20 -9
- package/dist/cjs/utils/tests/ether-to-wei.test.js +5 -13
- package/dist/cjs/utils/tests/hash-message.test.js +26 -15
- package/dist/cjs/utils/tests/is-address.test.js +2 -9
- package/dist/cjs/utils/tests/keccak256.test.js +36 -12
- package/dist/cjs/utils/tests/solidity-keccak256.test.js +43 -42
- package/dist/cjs/utils/tests/split-signature.test.js +29 -8
- package/dist/cjs/utils/tests/to-checksum-address.test.js +1 -4
- package/dist/cjs/utils/tests/to-utf8-bytes.test.js +28 -8
- package/dist/cjs/utils/tests/wei-to-ether.test.js +10 -20
- package/dist/esm/classes/test/Contract/ens-abi.d.ts +1 -1
- package/dist/esm/classes/test/Contract/foo-abi.d.ts +1 -1
- package/dist/esm/classes/utils/fetchers.d.ts +8 -2
- package/dist/esm/classes/utils/fetchers.js +6 -3
- package/dist/esm/index.d.ts +21 -22
- package/dist/esm/index.js +16 -17
- package/dist/esm/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/dist/esm/providers/FallthroughProvider.js +3 -3
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +142 -0
- package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
- package/dist/esm/providers/test/rpc-urls.js +7 -4
- package/dist/esm/providers/utils/chains-info.d.ts +5 -448
- package/dist/esm/providers/utils/chains-info.js +13 -1344
- package/dist/esm/shared/validate-type.d.ts +1 -1
- package/dist/esm/types/Block.types.d.ts +3 -3
- package/dist/esm/types/Contract.types.d.ts +4 -4
- package/dist/esm/types/Transaction.types.d.ts +5 -5
- package/dist/esm/utils/bytes.d.ts +4 -4
- package/package.json +22 -50
- package/readme.md +15 -38
- package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
7
|
if (Array.isArray(arr)) return arr;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function _iterable_to_array_limit(arr, i) {
|
|
10
10
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
11
|
if (_i == null) return;
|
|
12
12
|
var _arr = [];
|
|
@@ -30,19 +30,19 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
30
30
|
}
|
|
31
31
|
return _arr;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function _non_iterable_rest() {
|
|
34
34
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function _sliced_to_array(arr, i) {
|
|
37
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
40
|
if (!o) return;
|
|
41
|
-
if (typeof o === "string") return
|
|
41
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
42
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
43
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
44
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
46
|
}
|
|
47
47
|
import { Keccak } from "sha3";
|
|
48
48
|
import { tinyBig } from "../../shared/tiny-big/tiny-big";
|
|
@@ -139,7 +139,7 @@ var hexTrue = "0".repeat(63) + "1";
|
|
|
139
139
|
}
|
|
140
140
|
}, []);
|
|
141
141
|
var encodedArgs = argsWithTypes.map(function(param) {
|
|
142
|
-
var _param =
|
|
142
|
+
var _param = _sliced_to_array(param, 2), arg = _param[0], inputType = _param[1];
|
|
143
143
|
var rawArg = arg;
|
|
144
144
|
switch(inputType){
|
|
145
145
|
case "bool":
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
export declare function buildFetchInit<T>(body: T): {
|
|
2
|
+
method: string;
|
|
3
|
+
headers: {
|
|
4
|
+
'Content-Type': string;
|
|
5
|
+
};
|
|
6
|
+
body: string;
|
|
7
|
+
};
|
|
1
8
|
export declare function post(url: string, body: Record<string, unknown>): Promise<any>;
|
|
2
|
-
|
|
9
|
+
export type RPCMethodName = 'eth_getBlockByNumber' | 'eth_getBlockByHash' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice' | 'eth_getBalance' | 'eth_getTransactionByHash' | 'eth_getTransactionReceipt' | 'eth_getTransactionCount' | 'eth_getCode' | 'eth_blockNumber' | 'eth_estimateGas' | 'eth_getLogs';
|
|
3
10
|
export declare function buildRPCPostBody(method: RPCMethodName, params: unknown[]): {
|
|
4
11
|
jsonrpc: string;
|
|
5
12
|
id: number;
|
|
6
13
|
method: RPCMethodName;
|
|
7
14
|
params: unknown[];
|
|
8
15
|
};
|
|
9
|
-
export {};
|
|
@@ -12,7 +12,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
12
12
|
Promise.resolve(value).then(_next, _throw);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
16
|
return function() {
|
|
17
17
|
var self = this, args = arguments;
|
|
18
18
|
return new Promise(function(resolve, reject) {
|
|
@@ -27,7 +27,7 @@ function _asyncToGenerator(fn) {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
31
|
var f, y, t, g, _ = {
|
|
32
32
|
label: 0,
|
|
33
33
|
sent: function() {
|
|
@@ -121,8 +121,22 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
121
121
|
done: true
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
import unfetch from "isomorphic-unfetch";
|
|
126
|
+
/**
|
|
127
|
+
* Forms the init field for http fetching
|
|
128
|
+
*
|
|
129
|
+
* @param body
|
|
130
|
+
* @internal
|
|
131
|
+
*/ export function buildFetchInit(body) {
|
|
132
|
+
return {
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: {
|
|
135
|
+
"Content-Type": "application/json"
|
|
136
|
+
},
|
|
137
|
+
body: JSON.stringify(body)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
126
140
|
/**
|
|
127
141
|
* Makes a post request with the specified JSON data, normally to the a Ethereum JSON RPC API endpoint
|
|
128
142
|
*
|
|
@@ -139,16 +153,10 @@ import unfetch from "isomorphic-unfetch";
|
|
|
139
153
|
* // '0x312faeb995df61d4'
|
|
140
154
|
* ```
|
|
141
155
|
*/ export function post(url, body) {
|
|
142
|
-
return unfetch(url, {
|
|
143
|
-
|
|
144
|
-
headers: {
|
|
145
|
-
"Content-Type": "application/json"
|
|
146
|
-
},
|
|
147
|
-
body: JSON.stringify(body)
|
|
148
|
-
}).then(function() {
|
|
149
|
-
var _ref = _asyncToGenerator(function(r) {
|
|
156
|
+
return unfetch(url, buildFetchInit(body)).then(function() {
|
|
157
|
+
var _ref = _async_to_generator(function(r) {
|
|
150
158
|
var t;
|
|
151
|
-
return
|
|
159
|
+
return _ts_generator(this, function(_state) {
|
|
152
160
|
switch(_state.label){
|
|
153
161
|
case 0:
|
|
154
162
|
return [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
2
|
if (key in obj) {
|
|
3
3
|
Object.defineProperty(obj, key, {
|
|
4
4
|
value: value,
|
|
@@ -18,7 +18,7 @@ function _instanceof(left, right) {
|
|
|
18
18
|
return left instanceof right;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _object_spread(target) {
|
|
22
22
|
for(var i = 1; i < arguments.length; i++){
|
|
23
23
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
24
24
|
var ownKeys = Object.keys(source);
|
|
@@ -28,7 +28,7 @@ function _objectSpread(target) {
|
|
|
28
28
|
}));
|
|
29
29
|
}
|
|
30
30
|
ownKeys.forEach(function(key) {
|
|
31
|
-
|
|
31
|
+
_define_property(target, key, source[key]);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
return target;
|
|
@@ -40,7 +40,7 @@ import { hexlify } from "../../utils/bytes";
|
|
|
40
40
|
* @param transaction
|
|
41
41
|
* @example
|
|
42
42
|
*/ export function prepareTransaction(transaction) {
|
|
43
|
-
var preparedTransaction =
|
|
43
|
+
var preparedTransaction = _object_spread({}, transaction);
|
|
44
44
|
Object.keys(transaction).forEach(function(key) {
|
|
45
45
|
switch(key){
|
|
46
46
|
case "gas":
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
export { Contract, BaseContract } from './classes/Contract';
|
|
2
|
+
export { AlchemyProvider } from './providers/AlchemyProvider';
|
|
3
|
+
export { FallthroughProvider, ConstructorOptions, } from './providers/FallthroughProvider';
|
|
4
|
+
export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
|
|
5
|
+
export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
|
|
6
|
+
export { BlockResponse, RPCBlock, BlockTag } from './types/Block.types';
|
|
7
|
+
export { ContractTypes, JSONABI, JSONABIArgument, } from './types/Contract.types';
|
|
8
|
+
export { Filter, FilterByBlockHash } from './types/Filter.types';
|
|
9
|
+
export { Network } from './types/Network.types';
|
|
10
|
+
export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse, } from './types/Transaction.types';
|
|
11
|
+
export { computeAddress } from './utils/compute-address';
|
|
12
|
+
export { computePublicKey } from './utils/compute-public-key';
|
|
13
|
+
export { etherToGwei } from './utils/ether-to-gwei';
|
|
14
|
+
export { etherToWei } from './utils/ether-to-wei';
|
|
15
|
+
export { gweiToEther } from './utils/gwei-to-ether';
|
|
16
|
+
export { hashMessage } from './utils/hash-message';
|
|
17
|
+
export { isAddress } from './utils/is-address';
|
|
18
|
+
export { splitSignature } from './utils/split-signature';
|
|
19
|
+
export { toChecksumAddress } from './utils/to-checksum-address';
|
|
20
|
+
export { toUtf8Bytes } from './utils/to-utf8-bytes';
|
|
21
|
+
export { weiToEther } from './utils/wei-to-ether';
|
|
22
22
|
export * from './utils/bytes';
|
|
23
23
|
export * from './utils/hash-message';
|
|
24
24
|
export * from './utils/keccak256';
|
|
25
25
|
export * from './utils/solidity-keccak256';
|
|
26
|
-
export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, AlchemyProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, Filter, FilterByBlockHash, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
export { Contract, BaseContract } from "./classes/Contract";
|
|
2
|
+
export { AlchemyProvider } from "./providers/AlchemyProvider";
|
|
3
|
+
export { FallthroughProvider, ConstructorOptions } from "./providers/FallthroughProvider";
|
|
4
|
+
export { jsonRpcProvider, JsonRpcProvider } from "./providers/JsonRpcProvider";
|
|
5
|
+
export { tinyBig, TinyBig } from "./shared/tiny-big/tiny-big";
|
|
6
|
+
export { BlockResponse, RPCBlock, BlockTag } from "./types/Block.types";
|
|
7
|
+
export { ContractTypes, JSONABI, JSONABIArgument } from "./types/Contract.types";
|
|
8
|
+
export { Filter, FilterByBlockHash } from "./types/Filter.types";
|
|
9
|
+
export { Network } from "./types/Network.types";
|
|
10
|
+
export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse } from "./types/Transaction.types";
|
|
11
|
+
export { computeAddress } from "./utils/compute-address";
|
|
12
|
+
export { computePublicKey } from "./utils/compute-public-key";
|
|
13
|
+
export { etherToGwei } from "./utils/ether-to-gwei";
|
|
14
|
+
export { etherToWei } from "./utils/ether-to-wei";
|
|
15
|
+
export { gweiToEther } from "./utils/gwei-to-ether";
|
|
16
|
+
export { hashMessage } from "./utils/hash-message";
|
|
17
|
+
export { isAddress } from "./utils/is-address";
|
|
18
|
+
export { splitSignature } from "./utils/split-signature";
|
|
19
|
+
export { toChecksumAddress } from "./utils/to-checksum-address";
|
|
20
|
+
export { toUtf8Bytes } from "./utils/to-utf8-bytes";
|
|
21
|
+
export { weiToEther } from "./utils/wei-to-ether";
|
|
22
22
|
export * from "./utils/bytes";
|
|
23
23
|
export * from "./utils/hash-message";
|
|
24
24
|
export * from "./utils/keccak256";
|
|
25
25
|
export * from "./utils/solidity-keccak256";
|
|
26
|
-
export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, AlchemyProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, /* classes */ Contract, TinyBig, /* types */ BaseContract, BlockResponse, ContractTypes, Filter, FilterByBlockHash, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions };
|