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.
Files changed (112) hide show
  1. package/dist/cjs/classes/Contract.js +38 -34
  2. package/dist/cjs/classes/test/Contract/crv.test.js +146 -339
  3. package/dist/cjs/classes/test/Contract/ens-abi.d.ts +1 -1
  4. package/dist/cjs/classes/test/Contract/ens.test.js +9 -66
  5. package/dist/cjs/classes/test/Contract/fei.test.js +11 -11
  6. package/dist/cjs/classes/test/Contract/foo-abi.d.ts +1 -1
  7. package/dist/cjs/classes/test/Contract/uni.test.js +66 -164
  8. package/dist/cjs/classes/utils/clean-block.js +4 -4
  9. package/dist/cjs/classes/utils/clean-log.js +4 -4
  10. package/dist/cjs/classes/utils/clean-transaction-receipt.js +4 -4
  11. package/dist/cjs/classes/utils/clean-transaction.js +4 -4
  12. package/dist/cjs/classes/utils/encode-decode-transaction.js +10 -10
  13. package/dist/cjs/classes/utils/fetchers.d.ts +8 -2
  14. package/dist/cjs/classes/utils/fetchers.js +20 -12
  15. package/dist/cjs/classes/utils/prepare-transaction.js +4 -4
  16. package/dist/cjs/index.d.ts +21 -21
  17. package/dist/cjs/index.js +21 -21
  18. package/dist/cjs/index.umd.js +1 -1
  19. package/dist/cjs/index.umd.js.map +1 -1
  20. package/dist/cjs/logger/logger.js +79 -41
  21. package/dist/cjs/logger/package-version.d.ts +1 -1
  22. package/dist/cjs/logger/package-version.js +1 -1
  23. package/dist/cjs/providers/AlchemyProvider.d.ts +4 -0
  24. package/dist/cjs/providers/AlchemyProvider.js +84 -0
  25. package/dist/cjs/providers/BaseProvider.js +471 -404
  26. package/dist/cjs/providers/FallthroughProvider.js +74 -38
  27. package/dist/cjs/providers/JsonRpcProvider.js +52 -31
  28. package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +9 -9
  29. package/dist/cjs/providers/test/get-transaction-count.test.js +54 -91
  30. package/dist/cjs/providers/test/json-rpc-provider/call.test.js +87 -148
  31. package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +45 -116
  32. package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +36 -74
  33. package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +27 -94
  34. package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +191 -278
  35. package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +106 -135
  36. package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +48 -73
  37. package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +29 -64
  38. package/dist/cjs/providers/test/json-rpc-provider/get-logs/get-logs.test.js +219 -0
  39. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  40. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +149 -0
  41. package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +37 -79
  42. package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +136 -157
  43. package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +121 -162
  44. package/dist/cjs/providers/test/mock-of.d.ts +2 -0
  45. package/dist/cjs/providers/test/mock-of.js +9 -0
  46. package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
  47. package/dist/cjs/providers/test/rpc-urls.js +12 -6
  48. package/dist/cjs/providers/test/test-alchemy-provider.test.js +151 -0
  49. package/dist/cjs/providers/utils/chains-info.d.ts +5 -448
  50. package/dist/cjs/providers/utils/chains-info.js +13 -1344
  51. package/dist/cjs/shared/tiny-big/helpers.js +18 -18
  52. package/dist/cjs/shared/tiny-big/tiny-big.js +96 -56
  53. package/dist/cjs/shared/tiny-big/tiny-big.test.js +2 -2
  54. package/dist/cjs/shared/validate-type.d.ts +1 -1
  55. package/dist/cjs/shared/validate-type.js +4 -4
  56. package/dist/cjs/types/Block.types.d.ts +3 -3
  57. package/dist/cjs/types/Contract.types.d.ts +4 -4
  58. package/dist/cjs/types/Transaction.types.d.ts +5 -5
  59. package/dist/cjs/utils/bytes.d.ts +4 -4
  60. package/dist/cjs/utils/bytes.js +3 -3
  61. package/dist/cjs/utils/tests/bytes/arrayify.test.js +48 -24
  62. package/dist/cjs/utils/tests/bytes/concat.test.js +5 -3
  63. package/dist/cjs/utils/tests/bytes/hex-concat.test.js +15 -13
  64. package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +49 -32
  65. package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +15 -16
  66. package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +57 -40
  67. package/dist/cjs/utils/tests/bytes/hex-value.test.js +118 -62
  68. package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +71 -33
  69. package/dist/cjs/utils/tests/bytes/hexlify.test.js +45 -29
  70. package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +10 -11
  71. package/dist/cjs/utils/tests/bytes/is-bytes.test.js +70 -27
  72. package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +37 -28
  73. package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +94 -45
  74. package/dist/cjs/utils/tests/bytes/zero-pad.test.js +98 -34
  75. package/dist/cjs/utils/tests/compute-address.test.js +42 -20
  76. package/dist/cjs/utils/tests/compute-public-key.test.js +20 -9
  77. package/dist/cjs/utils/tests/ether-to-wei.test.js +5 -13
  78. package/dist/cjs/utils/tests/hash-message.test.js +26 -15
  79. package/dist/cjs/utils/tests/is-address.test.js +2 -9
  80. package/dist/cjs/utils/tests/keccak256.test.js +36 -12
  81. package/dist/cjs/utils/tests/solidity-keccak256.test.js +43 -42
  82. package/dist/cjs/utils/tests/split-signature.test.js +29 -8
  83. package/dist/cjs/utils/tests/to-checksum-address.test.js +1 -4
  84. package/dist/cjs/utils/tests/to-utf8-bytes.test.js +28 -8
  85. package/dist/cjs/utils/tests/wei-to-ether.test.js +10 -20
  86. package/dist/esm/classes/test/Contract/ens-abi.d.ts +1 -1
  87. package/dist/esm/classes/test/Contract/foo-abi.d.ts +1 -1
  88. package/dist/esm/classes/utils/fetchers.d.ts +8 -2
  89. package/dist/esm/classes/utils/fetchers.js +6 -3
  90. package/dist/esm/index.d.ts +21 -21
  91. package/dist/esm/index.js +16 -16
  92. package/dist/esm/logger/package-version.d.ts +1 -1
  93. package/dist/esm/logger/package-version.js +1 -1
  94. package/dist/esm/providers/AlchemyProvider.d.ts +4 -0
  95. package/dist/esm/providers/AlchemyProvider.js +7 -0
  96. package/dist/esm/providers/FallthroughProvider.js +15 -7
  97. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  98. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +142 -0
  99. package/dist/esm/providers/test/mock-of.d.ts +2 -0
  100. package/dist/esm/providers/test/mock-of.js +1 -0
  101. package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
  102. package/dist/esm/providers/test/rpc-urls.js +14 -6
  103. package/dist/esm/providers/utils/chains-info.d.ts +5 -448
  104. package/dist/esm/providers/utils/chains-info.js +13 -1344
  105. package/dist/esm/shared/validate-type.d.ts +1 -1
  106. package/dist/esm/types/Block.types.d.ts +3 -3
  107. package/dist/esm/types/Contract.types.d.ts +4 -4
  108. package/dist/esm/types/Transaction.types.d.ts +5 -5
  109. package/dist/esm/utils/bytes.d.ts +4 -4
  110. package/package.json +23 -51
  111. package/readme.md +16 -38
  112. package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
@@ -1,9 +1,9 @@
1
- function _arrayLikeToArray(arr, len) {
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 _arrayWithHoles(arr) {
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 _asyncToGenerator(fn) {
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 _classCallCheck(instance, Constructor) {
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 _iterableToArrayLimit(arr, i) {
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 _nonIterableRest() {
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 _slicedToArray(arr, i) {
71
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
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 _unsupportedIterableToArray(o, minLen) {
100
+ function _unsupported_iterable_to_array(o, minLen) {
74
101
  if (!o) return;
75
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
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 _arrayLikeToArray(o, minLen);
106
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
80
107
  }
81
- var __generator = this && this.__generator || function(thisArg, body) {
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
- _classCallCheck(this, BaseProvider);
239
+ _class_call_check(this, BaseProvider);
213
240
  /**
214
241
  * @ignore
215
- */ this._rpcUrls = [];
242
+ */ _define_property(this, "_rpcUrls", []);
216
243
  /**
217
244
  * @ignore
218
- */ this._post = function(body) {
245
+ */ _define_property(this, "_post", function(body) {
219
246
  return post(_this.selectRpcUrl(), body);
220
- };
247
+ });
221
248
  this._rpcUrls = rpcUrls;
222
249
  }
223
- var _proto = BaseProvider.prototype;
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
- */ _proto.getNetwork = function getNetwork() {
242
- var _this = this;
243
- return _asyncToGenerator(function() {
244
- var hexChainId, chainId, info;
245
- return __generator(this, function(_state) {
246
- switch(_state.label){
247
- case 0:
248
- return [
249
- 4,
250
- _this.post(buildRPCPostBody("eth_chainId", []))
251
- ];
252
- case 1:
253
- hexChainId = _state.sent();
254
- chainId = hexToDecimal(hexChainId);
255
- info = chainsInfo[chainId];
256
- return [
257
- 2,
258
- {
259
- chainId: Number(chainId),
260
- name: info[0] || "unknown",
261
- ensAddress: info[1] || null
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
- */ _proto.getBlockNumber = function getBlockNumber() {
281
- var _this = this;
282
- return _asyncToGenerator(function() {
283
- var currentBlockNumber;
284
- return __generator(this, function(_state) {
285
- switch(_state.label){
286
- case 0:
287
- return [
288
- 4,
289
- _this.post(buildRPCPostBody("eth_blockNumber", []))
290
- ];
291
- case 1:
292
- currentBlockNumber = _state.sent();
293
- return [
294
- 2,
295
- Number(hexToDecimal(currentBlockNumber))
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
- */ _proto.getTransaction = function getTransaction(transactionHash) {
336
- var _this = this;
337
- return _asyncToGenerator(function() {
338
- var _ref, rpcTransaction, blockNumber, cleanedTransaction;
339
- return __generator(this, function(_state) {
340
- switch(_state.label){
341
- case 0:
342
- return [
343
- 4,
344
- Promise.all([
345
- _this.post(buildRPCPostBody("eth_getTransactionByHash", [
346
- transactionHash
347
- ])),
348
- _this.getBlock("latest")
349
- ])
350
- ];
351
- case 1:
352
- _ref = _slicedToArray.apply(void 0, [
353
- _state.sent(),
354
- 2
355
- ]), rpcTransaction = _ref[0], blockNumber = _ref[1];
356
- cleanedTransaction = cleanTransaction(rpcTransaction);
357
- // https://ethereum.stackexchange.com/questions/2881/how-to-get-the-transaction-confirmations-using-the-json-rpc
358
- cleanedTransaction.confirmations = blockNumber.number - cleanedTransaction.blockNumber + 1;
359
- return [
360
- 2,
361
- cleanedTransaction
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
- */ _proto.getTransactionReceipt = function getTransactionReceipt(transactionHash) {
427
- var _this = this;
428
- return _asyncToGenerator(function() {
429
- var _ref, rpcTransaction, blockNumber, cleanedTransactionReceipt;
430
- return __generator(this, function(_state) {
431
- switch(_state.label){
432
- case 0:
433
- return [
434
- 4,
435
- Promise.all([
436
- _this.post(buildRPCPostBody("eth_getTransactionReceipt", [
437
- transactionHash
438
- ])),
439
- _this.getBlock("latest")
440
- ])
441
- ];
442
- case 1:
443
- _ref = _slicedToArray.apply(void 0, [
444
- _state.sent(),
445
- 2
446
- ]), rpcTransaction = _ref[0], blockNumber = _ref[1];
447
- cleanedTransactionReceipt = cleanTransactionReceipt(rpcTransaction);
448
- cleanedTransactionReceipt.confirmations = blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
449
- return [
450
- 2,
451
- cleanedTransactionReceipt
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
- */ _proto.getTransactionCount = function getTransactionCount(address) {
482
- var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
483
- var _this = this;
484
- return _asyncToGenerator(function() {
485
- var transactionCount;
486
- return __generator(this, function(_state) {
487
- switch(_state.label){
488
- case 0:
489
- blockTag = prepBlockTag(blockTag);
490
- return [
491
- 4,
492
- _this.post(buildRPCPostBody("eth_getTransactionCount", [
493
- address,
494
- blockTag
495
- ]))
496
- ];
497
- case 1:
498
- transactionCount = _state.sent();
499
- return [
500
- 2,
501
- Number(hexToDecimal(transactionCount))
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
- */ _proto.getBlock = function getBlock() {
550
- var timeFrame = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "latest", returnTransactionObjects = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
551
- var _this = this;
552
- return _asyncToGenerator(function() {
553
- var type, rpcBlock;
554
- return __generator(this, function(_state) {
555
- switch(_state.label){
556
- case 0:
557
- type = "Number";
558
- if (typeof timeFrame === "string" && timeFrame.length === 66) {
559
- // use endpoint that accepts string
560
- type = "Hash";
561
- } else {
562
- timeFrame = prepBlockTag(timeFrame);
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
- return [
565
- 4,
566
- _this.post(buildRPCPostBody("eth_getBlockBy".concat(type), [
567
- timeFrame,
568
- returnTransactionObjects
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
- */ _proto.getGasPrice = function getGasPrice() {
594
- var _this = this;
595
- return _asyncToGenerator(function() {
596
- var hexGasPrice;
597
- return __generator(this, function(_state) {
598
- switch(_state.label){
599
- case 0:
600
- return [
601
- 4,
602
- _this.post(buildRPCPostBody("eth_gasPrice", []))
603
- ];
604
- case 1:
605
- hexGasPrice = _state.sent();
606
- return [
607
- 2,
608
- tinyBig(hexToDecimal(hexGasPrice))
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
- */ _proto.getBalance = function getBalance(address) {
629
- var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
630
- var _this = this;
631
- return _asyncToGenerator(function() {
632
- var hexBalance;
633
- return __generator(this, function(_state) {
634
- switch(_state.label){
635
- case 0:
636
- blockTag = prepBlockTag(blockTag);
637
- return [
638
- 4,
639
- _this.post(buildRPCPostBody("eth_getBalance", [
640
- address,
641
- blockTag
642
- ]))
643
- ];
644
- case 1:
645
- hexBalance = _state.sent();
646
- return [
647
- 2,
648
- tinyBig(hexToDecimal(hexBalance))
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
- */ _proto.getCode = function getCode(address) {
669
- var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
670
- var _this = this;
671
- return _asyncToGenerator(function() {
672
- var contractCode;
673
- return __generator(this, function(_state) {
674
- switch(_state.label){
675
- case 0:
676
- blockTag = prepBlockTag(blockTag);
677
- return [
678
- 4,
679
- _this.post(buildRPCPostBody("eth_getCode", [
680
- address,
681
- blockTag
682
- ]))
683
- ];
684
- case 1:
685
- contractCode = _state.sent();
686
- return [
687
- 2,
688
- contractCode
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
- */ _proto.estimateGas = function estimateGas(transaction) {
714
- var _this = this;
715
- return _asyncToGenerator(function() {
716
- var rpcTransaction, gasUsed;
717
- return __generator(this, function(_state) {
718
- switch(_state.label){
719
- case 0:
720
- rpcTransaction = prepareTransaction(transaction);
721
- return [
722
- 4,
723
- _this.post(buildRPCPostBody("eth_estimateGas", [
724
- rpcTransaction
725
- ]))
726
- ];
727
- case 1:
728
- gasUsed = _state.sent();
729
- return [
730
- 2,
731
- tinyBig(hexToDecimal(gasUsed))
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
- */ _proto.getFeeData = function getFeeData() {
756
- var _this = this;
757
- return _asyncToGenerator(function() {
758
- var _ref, block, gasPrice, lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas;
759
- return __generator(this, function(_state) {
760
- switch(_state.label){
761
- case 0:
762
- return [
763
- 4,
764
- Promise.all([
765
- _this.getBlock("latest"),
766
- _this.getGasPrice()
767
- ])
768
- ];
769
- case 1:
770
- _ref = _slicedToArray.apply(void 0, [
771
- _state.sent(),
772
- 2
773
- ]), block = _ref[0], gasPrice = _ref[1];
774
- lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
775
- if (block && block.baseFeePerGas) {
776
- // We may want to compute this more accurately in the future,
777
- // using the formula "check if the base fee is correct".
778
- // See: https://eips.ethereum.org/EIPS/eip-1559
779
- lastBaseFeePerGas = block.baseFeePerGas;
780
- maxPriorityFeePerGas = tinyBig("1500000000");
781
- maxFeePerGas = tinyBig(block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas));
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
- return [
784
- 2,
785
- {
786
- lastBaseFeePerGas: lastBaseFeePerGas,
787
- maxFeePerGas: maxFeePerGas,
788
- maxPriorityFeePerGas: maxPriorityFeePerGas,
789
- gasPrice: gasPrice
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
- */ _proto.getLogs = function getLogs(filter) {
836
- var _this = this;
837
- return _asyncToGenerator(function() {
838
- var filterByRange, rpcLogs, logs;
839
- return __generator(this, function(_state) {
840
- switch(_state.label){
841
- case 0:
842
- filterByRange = filter;
843
- if (filterByRange.fromBlock) filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
844
- if (filterByRange.toBlock) filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
845
- return [
846
- 4,
847
- _this.post(buildRPCPostBody("eth_getLogs", [
848
- filter
849
- ]))
850
- ];
851
- case 1:
852
- rpcLogs = _state.sent();
853
- logs = rpcLogs.map(function(log) {
854
- return cleanLog(log, false);
855
- });
856
- return [
857
- 2,
858
- logs
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
- */ _proto.call = function call(transaction) {
880
- var blockTag = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "latest";
881
- var _this = this;
882
- return _asyncToGenerator(function() {
883
- var rpcTransaction, transactionRes;
884
- return __generator(this, function(_state) {
885
- switch(_state.label){
886
- case 0:
887
- if (transaction.gasPrice && (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
888
- logger.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")', {
889
- gasPrice: transaction.gasPrice,
890
- maxFeePerGas: transaction.maxFeePerGas,
891
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
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
- if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
895
- logger.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"', {
896
- maxFeePerGas: transaction.maxFeePerGas,
897
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
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
  }();