essential-eth 0.8.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 -21
- package/dist/cjs/index.js +21 -21
- 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.d.ts +4 -0
- package/dist/cjs/providers/AlchemyProvider.js +84 -0
- package/dist/cjs/providers/BaseProvider.js +471 -404
- package/dist/cjs/providers/FallthroughProvider.js +74 -38
- 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 +27 -94
- package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +191 -278
- 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 +29 -64
- 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.d.ts +2 -0
- package/dist/cjs/providers/test/mock-of.js +9 -0
- package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
- package/dist/cjs/providers/test/rpc-urls.js +12 -6
- package/dist/cjs/providers/test/test-alchemy-provider.test.js +151 -0
- 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 -21
- package/dist/esm/index.js +16 -16
- package/dist/esm/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/dist/esm/providers/AlchemyProvider.d.ts +4 -0
- package/dist/esm/providers/AlchemyProvider.js +7 -0
- package/dist/esm/providers/FallthroughProvider.js +15 -7
- 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/mock-of.d.ts +2 -0
- package/dist/esm/providers/test/mock-of.js +1 -0
- package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
- package/dist/esm/providers/test/rpc-urls.js +14 -6
- 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 +23 -51
- package/readme.md +16 -38
- package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
|
@@ -1,9 +1,9 @@
|
|
|
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
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -20,7 +20,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
20
20
|
Promise.resolve(value).then(_next, _throw);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
24
|
return function() {
|
|
25
25
|
var self = this, args = arguments;
|
|
26
26
|
return new Promise(function(resolve, reject) {
|
|
@@ -35,12 +35,39 @@ function _asyncToGenerator(fn) {
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function _class_call_check(instance, Constructor) {
|
|
39
39
|
if (!(instance instanceof Constructor)) {
|
|
40
40
|
throw new TypeError("Cannot call a class as a function");
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function _defineProperties(target, props) {
|
|
44
|
+
for(var i = 0; i < props.length; i++){
|
|
45
|
+
var descriptor = props[i];
|
|
46
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
47
|
+
descriptor.configurable = true;
|
|
48
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
49
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
53
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
+
return Constructor;
|
|
56
|
+
}
|
|
57
|
+
function _define_property(obj, key, value) {
|
|
58
|
+
if (key in obj) {
|
|
59
|
+
Object.defineProperty(obj, key, {
|
|
60
|
+
value: value,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
obj[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
function _iterable_to_array_limit(arr, i) {
|
|
44
71
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
45
72
|
if (_i == null) return;
|
|
46
73
|
var _arr = [];
|
|
@@ -64,21 +91,21 @@ function _iterableToArrayLimit(arr, i) {
|
|
|
64
91
|
}
|
|
65
92
|
return _arr;
|
|
66
93
|
}
|
|
67
|
-
function
|
|
94
|
+
function _non_iterable_rest() {
|
|
68
95
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
69
96
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
97
|
+
function _sliced_to_array(arr, i) {
|
|
98
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
72
99
|
}
|
|
73
|
-
function
|
|
100
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
74
101
|
if (!o) return;
|
|
75
|
-
if (typeof o === "string") return
|
|
102
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
76
103
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
77
104
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
78
105
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
79
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return
|
|
106
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
80
107
|
}
|
|
81
|
-
|
|
108
|
+
function _ts_generator(thisArg, body) {
|
|
82
109
|
var f, y, t, g, _ = {
|
|
83
110
|
label: 0,
|
|
84
111
|
sent: function() {
|
|
@@ -172,7 +199,7 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
172
199
|
done: true
|
|
173
200
|
};
|
|
174
201
|
}
|
|
175
|
-
}
|
|
202
|
+
}
|
|
176
203
|
import { cleanBlock } from "../classes/utils/clean-block";
|
|
177
204
|
import { cleanLog } from "../classes/utils/clean-log";
|
|
178
205
|
import { cleanTransaction } from "../classes/utils/clean-transaction";
|
|
@@ -209,19 +236,21 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
209
236
|
"use strict";
|
|
210
237
|
function BaseProvider(rpcUrls) {
|
|
211
238
|
var _this = this;
|
|
212
|
-
|
|
239
|
+
_class_call_check(this, BaseProvider);
|
|
213
240
|
/**
|
|
214
241
|
* @ignore
|
|
215
|
-
*/ this
|
|
242
|
+
*/ _define_property(this, "_rpcUrls", []);
|
|
216
243
|
/**
|
|
217
244
|
* @ignore
|
|
218
|
-
*/ this
|
|
245
|
+
*/ _define_property(this, "_post", function(body) {
|
|
219
246
|
return post(_this.selectRpcUrl(), body);
|
|
220
|
-
};
|
|
247
|
+
});
|
|
221
248
|
this._rpcUrls = rpcUrls;
|
|
222
249
|
}
|
|
223
|
-
|
|
224
|
-
|
|
250
|
+
_create_class(BaseProvider, [
|
|
251
|
+
{
|
|
252
|
+
key: "getNetwork",
|
|
253
|
+
value: /**
|
|
225
254
|
* Gets information (name, chainId, and ensAddress when applicable) about the network the provider is connected to.
|
|
226
255
|
*
|
|
227
256
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getNetwork`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getNetwork) in ethers.js
|
|
@@ -238,34 +267,37 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
238
267
|
* jsonRpcProvider('https://free-eth-node.com/api/MATIC').getNetwork();
|
|
239
268
|
* // { chainId: 137, name: 'MATIC', ensAddress: null }
|
|
240
269
|
* ```
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
*/ function getNetwork() {
|
|
271
|
+
var _this = this;
|
|
272
|
+
return _async_to_generator(function() {
|
|
273
|
+
var hexChainId, chainId, info;
|
|
274
|
+
return _ts_generator(this, function(_state) {
|
|
275
|
+
switch(_state.label){
|
|
276
|
+
case 0:
|
|
277
|
+
return [
|
|
278
|
+
4,
|
|
279
|
+
_this.post(buildRPCPostBody("eth_chainId", []))
|
|
280
|
+
];
|
|
281
|
+
case 1:
|
|
282
|
+
hexChainId = _state.sent();
|
|
283
|
+
chainId = hexToDecimal(hexChainId);
|
|
284
|
+
info = chainsInfo[chainId];
|
|
285
|
+
return [
|
|
286
|
+
2,
|
|
287
|
+
{
|
|
288
|
+
chainId: Number(chainId),
|
|
289
|
+
name: info[0] || "unknown",
|
|
290
|
+
ensAddress: info[1] || null
|
|
291
|
+
}
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
})();
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
key: "getBlockNumber",
|
|
300
|
+
value: /**
|
|
269
301
|
* Gets the number of the most recently mined block on the network the provider is connected to.
|
|
270
302
|
*
|
|
271
303
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber) in ethers.js
|
|
@@ -277,28 +309,31 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
277
309
|
* await provider.getBlockNumber();
|
|
278
310
|
* // 1053312
|
|
279
311
|
* ```
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
312
|
+
*/ function getBlockNumber() {
|
|
313
|
+
var _this = this;
|
|
314
|
+
return _async_to_generator(function() {
|
|
315
|
+
var currentBlockNumber;
|
|
316
|
+
return _ts_generator(this, function(_state) {
|
|
317
|
+
switch(_state.label){
|
|
318
|
+
case 0:
|
|
319
|
+
return [
|
|
320
|
+
4,
|
|
321
|
+
_this.post(buildRPCPostBody("eth_blockNumber", []))
|
|
322
|
+
];
|
|
323
|
+
case 1:
|
|
324
|
+
currentBlockNumber = _state.sent();
|
|
325
|
+
return [
|
|
326
|
+
2,
|
|
327
|
+
Number(hexToDecimal(currentBlockNumber))
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
})();
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
key: "getTransaction",
|
|
336
|
+
value: /**
|
|
302
337
|
* Gets information about a specified transaction, even if it hasn't been mined yet.
|
|
303
338
|
*
|
|
304
339
|
* * [Similar](/docs/api#isd) to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction) in ethers.js, does not have `wait` method that waits until the transaction has been mined
|
|
@@ -332,39 +367,42 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
332
367
|
* // confirmations: 298140,
|
|
333
368
|
* // }
|
|
334
369
|
* ```
|
|
335
|
-
*/
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
370
|
+
*/ function getTransaction(transactionHash) {
|
|
371
|
+
var _this = this;
|
|
372
|
+
return _async_to_generator(function() {
|
|
373
|
+
var _ref, rpcTransaction, blockNumber, cleanedTransaction;
|
|
374
|
+
return _ts_generator(this, function(_state) {
|
|
375
|
+
switch(_state.label){
|
|
376
|
+
case 0:
|
|
377
|
+
return [
|
|
378
|
+
4,
|
|
379
|
+
Promise.all([
|
|
380
|
+
_this.post(buildRPCPostBody("eth_getTransactionByHash", [
|
|
381
|
+
transactionHash
|
|
382
|
+
])),
|
|
383
|
+
_this.getBlock("latest")
|
|
384
|
+
])
|
|
385
|
+
];
|
|
386
|
+
case 1:
|
|
387
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
388
|
+
_state.sent(),
|
|
389
|
+
2
|
|
390
|
+
]), rpcTransaction = _ref[0], blockNumber = _ref[1];
|
|
391
|
+
cleanedTransaction = cleanTransaction(rpcTransaction);
|
|
392
|
+
// https://ethereum.stackexchange.com/questions/2881/how-to-get-the-transaction-confirmations-using-the-json-rpc
|
|
393
|
+
cleanedTransaction.confirmations = blockNumber.number - cleanedTransaction.blockNumber + 1;
|
|
394
|
+
return [
|
|
395
|
+
2,
|
|
396
|
+
cleanedTransaction
|
|
397
|
+
];
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
})();
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
key: "getTransactionReceipt",
|
|
405
|
+
value: /**
|
|
368
406
|
* Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by [`getTransaction`](/docs/api/modules#gettransaction).
|
|
369
407
|
*
|
|
370
408
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt) in ethers.js
|
|
@@ -423,38 +461,41 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
423
461
|
* // confirmations: 298171,
|
|
424
462
|
* // }
|
|
425
463
|
* ```
|
|
426
|
-
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
464
|
+
*/ function getTransactionReceipt(transactionHash) {
|
|
465
|
+
var _this = this;
|
|
466
|
+
return _async_to_generator(function() {
|
|
467
|
+
var _ref, rpcTransaction, blockNumber, cleanedTransactionReceipt;
|
|
468
|
+
return _ts_generator(this, function(_state) {
|
|
469
|
+
switch(_state.label){
|
|
470
|
+
case 0:
|
|
471
|
+
return [
|
|
472
|
+
4,
|
|
473
|
+
Promise.all([
|
|
474
|
+
_this.post(buildRPCPostBody("eth_getTransactionReceipt", [
|
|
475
|
+
transactionHash
|
|
476
|
+
])),
|
|
477
|
+
_this.getBlock("latest")
|
|
478
|
+
])
|
|
479
|
+
];
|
|
480
|
+
case 1:
|
|
481
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
482
|
+
_state.sent(),
|
|
483
|
+
2
|
|
484
|
+
]), rpcTransaction = _ref[0], blockNumber = _ref[1];
|
|
485
|
+
cleanedTransactionReceipt = cleanTransactionReceipt(rpcTransaction);
|
|
486
|
+
cleanedTransactionReceipt.confirmations = blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
|
|
487
|
+
return [
|
|
488
|
+
2,
|
|
489
|
+
cleanedTransactionReceipt
|
|
490
|
+
];
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
})();
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
key: "getTransactionCount",
|
|
498
|
+
value: /**
|
|
458
499
|
* Returns the number of sent transactions by an address, from genesis (or as far back as a provider looks) up to specified block.
|
|
459
500
|
*
|
|
460
501
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getTransactionCount`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionCount) in ethers.js
|
|
@@ -478,33 +519,36 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
478
519
|
* await provider.getTransactionCount('0x71660c4005ba85c37ccec55d0c4493e66fe775d3', 14649390);
|
|
479
520
|
* // 1053312
|
|
480
521
|
* ```
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
522
|
+
*/ function getTransactionCount(address) {
|
|
523
|
+
var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
|
|
524
|
+
var _this = this;
|
|
525
|
+
return _async_to_generator(function() {
|
|
526
|
+
var transactionCount;
|
|
527
|
+
return _ts_generator(this, function(_state) {
|
|
528
|
+
switch(_state.label){
|
|
529
|
+
case 0:
|
|
530
|
+
blockTag = prepBlockTag(blockTag);
|
|
531
|
+
return [
|
|
532
|
+
4,
|
|
533
|
+
_this.post(buildRPCPostBody("eth_getTransactionCount", [
|
|
534
|
+
address,
|
|
535
|
+
blockTag
|
|
536
|
+
]))
|
|
537
|
+
];
|
|
538
|
+
case 1:
|
|
539
|
+
transactionCount = _state.sent();
|
|
540
|
+
return [
|
|
541
|
+
2,
|
|
542
|
+
Number(hexToDecimal(transactionCount))
|
|
543
|
+
];
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
})();
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
key: "getBlock",
|
|
551
|
+
value: /**
|
|
508
552
|
* Gets information about a certain block, optionally with full transaction objects.
|
|
509
553
|
*
|
|
510
554
|
* * [Similar](/docs/api#isd) to [`ethers.provider.getBlock`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getLogs) in ethers.js, includes some additional information. Can also return block with full transaction objects, similar to [`ethers.providers.getBlockWithTransactions`]
|
|
@@ -546,39 +590,42 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
546
590
|
* // uncles: [],
|
|
547
591
|
* // }
|
|
548
592
|
* ```
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
593
|
+
*/ function getBlock() {
|
|
594
|
+
var timeFrame = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "latest", returnTransactionObjects = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
595
|
+
var _this = this;
|
|
596
|
+
return _async_to_generator(function() {
|
|
597
|
+
var type, rpcBlock;
|
|
598
|
+
return _ts_generator(this, function(_state) {
|
|
599
|
+
switch(_state.label){
|
|
600
|
+
case 0:
|
|
601
|
+
type = "Number";
|
|
602
|
+
if (typeof timeFrame === "string" && timeFrame.length === 66) {
|
|
603
|
+
// use endpoint that accepts string
|
|
604
|
+
type = "Hash";
|
|
605
|
+
} else {
|
|
606
|
+
timeFrame = prepBlockTag(timeFrame);
|
|
607
|
+
}
|
|
608
|
+
return [
|
|
609
|
+
4,
|
|
610
|
+
_this.post(buildRPCPostBody("eth_getBlockBy".concat(type), [
|
|
611
|
+
timeFrame,
|
|
612
|
+
returnTransactionObjects
|
|
613
|
+
]))
|
|
614
|
+
];
|
|
615
|
+
case 1:
|
|
616
|
+
rpcBlock = _state.sent();
|
|
617
|
+
return [
|
|
618
|
+
2,
|
|
619
|
+
cleanBlock(rpcBlock, returnTransactionObjects)
|
|
620
|
+
];
|
|
563
621
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
case 1:
|
|
572
|
-
rpcBlock = _state.sent();
|
|
573
|
-
return [
|
|
574
|
-
2,
|
|
575
|
-
cleanBlock(rpcBlock, returnTransactionObjects)
|
|
576
|
-
];
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
})();
|
|
580
|
-
};
|
|
581
|
-
/**
|
|
622
|
+
});
|
|
623
|
+
})();
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
key: "getGasPrice",
|
|
628
|
+
value: /**
|
|
582
629
|
* Gives an estimate of the current gas price in wei.
|
|
583
630
|
*
|
|
584
631
|
* * [Similar](/docs/api#isd) to [`ethers.provider.getGasPrice`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getGasPrice) in ethers.js, does not have a parameter specifying what unit you'd like to return. See also [`weiToEther`](/docs/api/modules#weitoether) and [`etherToGwei`](/docs/api/modules#ethertogwei)
|
|
@@ -590,28 +637,31 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
590
637
|
* await provider.getGasPrice();
|
|
591
638
|
* // 52493941856
|
|
592
639
|
* ```
|
|
593
|
-
*/
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
640
|
+
*/ function getGasPrice() {
|
|
641
|
+
var _this = this;
|
|
642
|
+
return _async_to_generator(function() {
|
|
643
|
+
var hexGasPrice;
|
|
644
|
+
return _ts_generator(this, function(_state) {
|
|
645
|
+
switch(_state.label){
|
|
646
|
+
case 0:
|
|
647
|
+
return [
|
|
648
|
+
4,
|
|
649
|
+
_this.post(buildRPCPostBody("eth_gasPrice", []))
|
|
650
|
+
];
|
|
651
|
+
case 1:
|
|
652
|
+
hexGasPrice = _state.sent();
|
|
653
|
+
return [
|
|
654
|
+
2,
|
|
655
|
+
tinyBig(hexToDecimal(hexGasPrice))
|
|
656
|
+
];
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
})();
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
key: "getBalance",
|
|
664
|
+
value: /**
|
|
615
665
|
* Returns the balance of the account in wei.
|
|
616
666
|
*
|
|
617
667
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getBalance`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBalance) in ethers.js
|
|
@@ -625,33 +675,36 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
625
675
|
* await provider.getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8');
|
|
626
676
|
* // 28798127851528138
|
|
627
677
|
* ```
|
|
628
|
-
*/
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
678
|
+
*/ function getBalance(address) {
|
|
679
|
+
var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
|
|
680
|
+
var _this = this;
|
|
681
|
+
return _async_to_generator(function() {
|
|
682
|
+
var hexBalance;
|
|
683
|
+
return _ts_generator(this, function(_state) {
|
|
684
|
+
switch(_state.label){
|
|
685
|
+
case 0:
|
|
686
|
+
blockTag = prepBlockTag(blockTag);
|
|
687
|
+
return [
|
|
688
|
+
4,
|
|
689
|
+
_this.post(buildRPCPostBody("eth_getBalance", [
|
|
690
|
+
address,
|
|
691
|
+
blockTag
|
|
692
|
+
]))
|
|
693
|
+
];
|
|
694
|
+
case 1:
|
|
695
|
+
hexBalance = _state.sent();
|
|
696
|
+
return [
|
|
697
|
+
2,
|
|
698
|
+
tinyBig(hexToDecimal(hexBalance))
|
|
699
|
+
];
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
})();
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
key: "getCode",
|
|
707
|
+
value: /**
|
|
655
708
|
* Gets the code of a contract on a specified block.
|
|
656
709
|
*
|
|
657
710
|
* * [Identical](/docs/api#isd) to [`ethers.provider.getCode`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getCode) in ethers.js
|
|
@@ -665,33 +718,36 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
665
718
|
* await jsonRpcProvider().getCode('0xaC6095720221C79C6E7C638d260A2eFBC5D8d880', 'latest');
|
|
666
719
|
* // '0x608060405234801561001057600080fd5b506004361061...'
|
|
667
720
|
* ```
|
|
668
|
-
*/
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
721
|
+
*/ function getCode(address) {
|
|
722
|
+
var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
|
|
723
|
+
var _this = this;
|
|
724
|
+
return _async_to_generator(function() {
|
|
725
|
+
var contractCode;
|
|
726
|
+
return _ts_generator(this, function(_state) {
|
|
727
|
+
switch(_state.label){
|
|
728
|
+
case 0:
|
|
729
|
+
blockTag = prepBlockTag(blockTag);
|
|
730
|
+
return [
|
|
731
|
+
4,
|
|
732
|
+
_this.post(buildRPCPostBody("eth_getCode", [
|
|
733
|
+
address,
|
|
734
|
+
blockTag
|
|
735
|
+
]))
|
|
736
|
+
];
|
|
737
|
+
case 1:
|
|
738
|
+
contractCode = _state.sent();
|
|
739
|
+
return [
|
|
740
|
+
2,
|
|
741
|
+
contractCode
|
|
742
|
+
];
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
})();
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
key: "estimateGas",
|
|
750
|
+
value: /**
|
|
695
751
|
* Returns an estimate of the amount of gas that would be required to submit transaction to the network.
|
|
696
752
|
* An estimate may not be accurate since there could be another transaction on the network that was not accounted for.
|
|
697
753
|
*
|
|
@@ -710,31 +766,34 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
710
766
|
* });
|
|
711
767
|
* // { TinyBig: "27938" }
|
|
712
768
|
* ```
|
|
713
|
-
*/
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
769
|
+
*/ function estimateGas(transaction) {
|
|
770
|
+
var _this = this;
|
|
771
|
+
return _async_to_generator(function() {
|
|
772
|
+
var rpcTransaction, gasUsed;
|
|
773
|
+
return _ts_generator(this, function(_state) {
|
|
774
|
+
switch(_state.label){
|
|
775
|
+
case 0:
|
|
776
|
+
rpcTransaction = prepareTransaction(transaction);
|
|
777
|
+
return [
|
|
778
|
+
4,
|
|
779
|
+
_this.post(buildRPCPostBody("eth_estimateGas", [
|
|
780
|
+
rpcTransaction
|
|
781
|
+
]))
|
|
782
|
+
];
|
|
783
|
+
case 1:
|
|
784
|
+
gasUsed = _state.sent();
|
|
785
|
+
return [
|
|
786
|
+
2,
|
|
787
|
+
tinyBig(hexToDecimal(gasUsed))
|
|
788
|
+
];
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
})();
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
key: "getFeeData",
|
|
796
|
+
value: /**
|
|
738
797
|
* Returns the current recommended FeeData to use in a transaction.
|
|
739
798
|
* For an EIP-1559 transaction, the maxFeePerGas and maxPriorityFeePerGas should be used.
|
|
740
799
|
* For legacy transactions and networks which do not support EIP-1559, the gasPrice should be used.Returns an estimate of the amount of gas that would be required to submit transaction to the network.
|
|
@@ -752,48 +811,51 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
752
811
|
* // maxPriorityFeePerGas: { TinyBig: "1500000000" }
|
|
753
812
|
* // }
|
|
754
813
|
* ```
|
|
755
|
-
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
814
|
+
*/ function getFeeData() {
|
|
815
|
+
var _this = this;
|
|
816
|
+
return _async_to_generator(function() {
|
|
817
|
+
var _ref, block, gasPrice, lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas;
|
|
818
|
+
return _ts_generator(this, function(_state) {
|
|
819
|
+
switch(_state.label){
|
|
820
|
+
case 0:
|
|
821
|
+
return [
|
|
822
|
+
4,
|
|
823
|
+
Promise.all([
|
|
824
|
+
_this.getBlock("latest"),
|
|
825
|
+
_this.getGasPrice()
|
|
826
|
+
])
|
|
827
|
+
];
|
|
828
|
+
case 1:
|
|
829
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
830
|
+
_state.sent(),
|
|
831
|
+
2
|
|
832
|
+
]), block = _ref[0], gasPrice = _ref[1];
|
|
833
|
+
lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
|
|
834
|
+
if (block && block.baseFeePerGas) {
|
|
835
|
+
// We may want to compute this more accurately in the future,
|
|
836
|
+
// using the formula "check if the base fee is correct".
|
|
837
|
+
// See: https://eips.ethereum.org/EIPS/eip-1559
|
|
838
|
+
lastBaseFeePerGas = block.baseFeePerGas;
|
|
839
|
+
maxPriorityFeePerGas = tinyBig("1500000000");
|
|
840
|
+
maxFeePerGas = tinyBig(block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas));
|
|
841
|
+
}
|
|
842
|
+
return [
|
|
843
|
+
2,
|
|
844
|
+
{
|
|
845
|
+
lastBaseFeePerGas: lastBaseFeePerGas,
|
|
846
|
+
maxFeePerGas: maxFeePerGas,
|
|
847
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
|
848
|
+
gasPrice: gasPrice
|
|
849
|
+
}
|
|
850
|
+
];
|
|
782
851
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
];
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
})();
|
|
795
|
-
};
|
|
796
|
-
/**
|
|
852
|
+
});
|
|
853
|
+
})();
|
|
854
|
+
}
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
key: "getLogs",
|
|
858
|
+
value: /**
|
|
797
859
|
* Returns transaction receipt event logs that match a specified filter.
|
|
798
860
|
* May return `[]` if parameters are too broad, even if logs exist.
|
|
799
861
|
*
|
|
@@ -832,36 +894,39 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
832
894
|
* }
|
|
833
895
|
* ]
|
|
834
896
|
* ```
|
|
835
|
-
*/
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
897
|
+
*/ function getLogs(filter) {
|
|
898
|
+
var _this = this;
|
|
899
|
+
return _async_to_generator(function() {
|
|
900
|
+
var filterByRange, rpcLogs, logs;
|
|
901
|
+
return _ts_generator(this, function(_state) {
|
|
902
|
+
switch(_state.label){
|
|
903
|
+
case 0:
|
|
904
|
+
filterByRange = filter;
|
|
905
|
+
if (filterByRange.fromBlock) filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
|
|
906
|
+
if (filterByRange.toBlock) filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
|
|
907
|
+
return [
|
|
908
|
+
4,
|
|
909
|
+
_this.post(buildRPCPostBody("eth_getLogs", [
|
|
910
|
+
filter
|
|
911
|
+
]))
|
|
912
|
+
];
|
|
913
|
+
case 1:
|
|
914
|
+
rpcLogs = _state.sent();
|
|
915
|
+
logs = rpcLogs.map(function(log) {
|
|
916
|
+
return cleanLog(log, false);
|
|
917
|
+
});
|
|
918
|
+
return [
|
|
919
|
+
2,
|
|
920
|
+
logs
|
|
921
|
+
];
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
})();
|
|
925
|
+
}
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
key: "call",
|
|
929
|
+
value: /**
|
|
865
930
|
* Returns the result of adding a transaction to the blockchain without actually adding that transaction to the blockchain.
|
|
866
931
|
* Does not require any ether as gas.
|
|
867
932
|
*
|
|
@@ -876,45 +941,47 @@ export var BaseProvider = /*#__PURE__*/ function() {
|
|
|
876
941
|
* await provider.call({ to: "0x6b175474e89094c44da98b954eedeac495271d0f", data: "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE" });
|
|
877
942
|
* // '0x0000000000000000000000000000000000000000000000000858898f93629000'
|
|
878
943
|
* ```
|
|
879
|
-
*/
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
944
|
+
*/ function call(transaction) {
|
|
945
|
+
var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
|
|
946
|
+
var _this = this;
|
|
947
|
+
return _async_to_generator(function() {
|
|
948
|
+
var rpcTransaction, transactionRes;
|
|
949
|
+
return _ts_generator(this, function(_state) {
|
|
950
|
+
switch(_state.label){
|
|
951
|
+
case 0:
|
|
952
|
+
if (transaction.gasPrice && (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
|
|
953
|
+
logger.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")', {
|
|
954
|
+
gasPrice: transaction.gasPrice,
|
|
955
|
+
maxFeePerGas: transaction.maxFeePerGas,
|
|
956
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
|
|
960
|
+
logger.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"', {
|
|
961
|
+
maxFeePerGas: transaction.maxFeePerGas,
|
|
962
|
+
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
blockTag = prepBlockTag(blockTag);
|
|
966
|
+
rpcTransaction = prepareTransaction(transaction);
|
|
967
|
+
return [
|
|
968
|
+
4,
|
|
969
|
+
_this.post(buildRPCPostBody("eth_call", [
|
|
970
|
+
rpcTransaction,
|
|
971
|
+
blockTag
|
|
972
|
+
]))
|
|
973
|
+
];
|
|
974
|
+
case 1:
|
|
975
|
+
transactionRes = _state.sent();
|
|
976
|
+
return [
|
|
977
|
+
2,
|
|
978
|
+
transactionRes
|
|
979
|
+
];
|
|
893
980
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
blockTag = prepBlockTag(blockTag);
|
|
901
|
-
rpcTransaction = prepareTransaction(transaction);
|
|
902
|
-
return [
|
|
903
|
-
4,
|
|
904
|
-
_this.post(buildRPCPostBody("eth_call", [
|
|
905
|
-
rpcTransaction,
|
|
906
|
-
blockTag
|
|
907
|
-
]))
|
|
908
|
-
];
|
|
909
|
-
case 1:
|
|
910
|
-
transactionRes = _state.sent();
|
|
911
|
-
return [
|
|
912
|
-
2,
|
|
913
|
-
transactionRes
|
|
914
|
-
];
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
})();
|
|
918
|
-
};
|
|
981
|
+
});
|
|
982
|
+
})();
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
]);
|
|
919
986
|
return BaseProvider;
|
|
920
987
|
}();
|