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,17 +1,44 @@
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
- function _classCallCheck(instance, Constructor) {
9
+ function _class_call_check(instance, Constructor) {
10
10
  if (!(instance instanceof Constructor)) {
11
11
  throw new TypeError("Cannot call a class as a function");
12
12
  }
13
13
  }
14
- function _iterableToArrayLimit(arr, i) {
14
+ function _defineProperties(target, props) {
15
+ for(var i = 0; i < props.length; i++){
16
+ var descriptor = props[i];
17
+ descriptor.enumerable = descriptor.enumerable || false;
18
+ descriptor.configurable = true;
19
+ if ("value" in descriptor) descriptor.writable = true;
20
+ Object.defineProperty(target, descriptor.key, descriptor);
21
+ }
22
+ }
23
+ function _create_class(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ return Constructor;
27
+ }
28
+ function _define_property(obj, key, value) {
29
+ if (key in obj) {
30
+ Object.defineProperty(obj, key, {
31
+ value: value,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ });
36
+ } else {
37
+ obj[key] = value;
38
+ }
39
+ return obj;
40
+ }
41
+ function _iterable_to_array_limit(arr, i) {
15
42
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
16
43
  if (_i == null) return;
17
44
  var _arr = [];
@@ -35,58 +62,69 @@ function _iterableToArrayLimit(arr, i) {
35
62
  }
36
63
  return _arr;
37
64
  }
38
- function _nonIterableRest() {
65
+ function _non_iterable_rest() {
39
66
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40
67
  }
41
- function _slicedToArray(arr, i) {
42
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
68
+ function _sliced_to_array(arr, i) {
69
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
43
70
  }
44
- function _unsupportedIterableToArray(o, minLen) {
71
+ function _unsupported_iterable_to_array(o, minLen) {
45
72
  if (!o) return;
46
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
73
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
47
74
  var n = Object.prototype.toString.call(o).slice(8, -1);
48
75
  if (n === "Object" && o.constructor) n = o.constructor.name;
49
76
  if (n === "Map" || n === "Set") return Array.from(n);
50
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
77
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
51
78
  }
52
79
  import { version } from "./package-version";
53
80
  var Logger = /*#__PURE__*/ function() {
54
81
  "use strict";
55
82
  function Logger() {
56
- _classCallCheck(this, Logger);
83
+ _class_call_check(this, Logger);
84
+ _define_property(this, "packageVersion", void 0);
57
85
  this.packageVersion = version;
58
86
  }
59
- var _proto = Logger.prototype;
60
- _proto.throwError = function throwError(message, args) {
61
- var argsLength = Object.keys(args).length;
62
- throw new Error("".concat(message, " (").concat(Object.entries(args).map(function(param, index) {
63
- var _param = _slicedToArray(param, 2), key = _param[0], value = _param[1];
64
- return "".concat(key, "=").concat(value).concat(index < argsLength - 1 && ", ");
65
- }), ", version=essential-eth@").concat(this.packageVersion, ")"));
66
- };
67
- _proto.throwArgumentError = function throwArgumentError(message, arg, value) {
68
- throw new Error("".concat(message, ' (argument="').concat(arg, '" value=').concat(value, ", version=essential-eth@").concat(this.packageVersion, ")"));
69
- };
70
- _proto.checkSafeUint53 = function checkSafeUint53(value) {
71
- var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "value not safe";
72
- if (typeof value !== "number") {
73
- return;
74
- }
75
- if (value < 0 || value >= 0x1fffffffffffff) {
76
- this.throwError(message, {
77
- operation: "checkSafeInteger",
78
- fault: "out-of-safe-range",
79
- value: value
80
- });
81
- }
82
- if (value % 1) {
83
- this.throwError(message, {
84
- operation: "checkSafeInteger",
85
- fault: "non-integer",
86
- value: value
87
- });
87
+ _create_class(Logger, [
88
+ {
89
+ key: "throwError",
90
+ value: function throwError(message, args) {
91
+ var argsLength = Object.keys(args).length;
92
+ throw new Error("".concat(message, " (").concat(Object.entries(args).map(function(param, index) {
93
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
94
+ return "".concat(key, "=").concat(value).concat(index < argsLength - 1 && ", ");
95
+ }), ", version=essential-eth@").concat(this.packageVersion, ")"));
96
+ }
97
+ },
98
+ {
99
+ key: "throwArgumentError",
100
+ value: function throwArgumentError(message, arg, value) {
101
+ throw new Error("".concat(message, ' (argument="').concat(arg, '" value=').concat(value, ", version=essential-eth@").concat(this.packageVersion, ")"));
102
+ }
103
+ },
104
+ {
105
+ key: "checkSafeUint53",
106
+ value: function checkSafeUint53(value) {
107
+ var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "value not safe";
108
+ if (typeof value !== "number") {
109
+ return;
110
+ }
111
+ if (value < 0 || value >= 0x1fffffffffffff) {
112
+ this.throwError(message, {
113
+ operation: "checkSafeInteger",
114
+ fault: "out-of-safe-range",
115
+ value: value
116
+ });
117
+ }
118
+ if (value % 1) {
119
+ this.throwError(message, {
120
+ operation: "checkSafeInteger",
121
+ fault: "non-integer",
122
+ value: value
123
+ });
124
+ }
125
+ }
88
126
  }
89
- };
127
+ ]);
90
128
  return Logger;
91
129
  }();
92
130
  export var logger = new Logger();
@@ -1 +1 @@
1
- export declare const version = "0.8.0";
1
+ export declare const version = "0.9.1-next.0";
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export var version = "0.8.0";
2
+ export var version = "0.9.1-next.0";
@@ -0,0 +1,4 @@
1
+ import { JsonRpcProvider } from './JsonRpcProvider';
2
+ export declare class AlchemyProvider extends JsonRpcProvider {
3
+ constructor(apiKey: string, network?: string);
4
+ }
@@ -0,0 +1,84 @@
1
+ function _assert_this_initialized(self) {
2
+ if (self === void 0) {
3
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4
+ }
5
+ return self;
6
+ }
7
+ function _class_call_check(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+ function _get_prototype_of(o) {
13
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
14
+ return o.__proto__ || Object.getPrototypeOf(o);
15
+ };
16
+ return _get_prototype_of(o);
17
+ }
18
+ function _inherits(subClass, superClass) {
19
+ if (typeof superClass !== "function" && superClass !== null) {
20
+ throw new TypeError("Super expression must either be null or a function");
21
+ }
22
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
23
+ constructor: {
24
+ value: subClass,
25
+ writable: true,
26
+ configurable: true
27
+ }
28
+ });
29
+ if (superClass) _set_prototype_of(subClass, superClass);
30
+ }
31
+ function _possible_constructor_return(self, call) {
32
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
33
+ return call;
34
+ }
35
+ return _assert_this_initialized(self);
36
+ }
37
+ function _set_prototype_of(o, p) {
38
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
39
+ o.__proto__ = p;
40
+ return o;
41
+ };
42
+ return _set_prototype_of(o, p);
43
+ }
44
+ function _type_of(obj) {
45
+ "@swc/helpers - typeof";
46
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
47
+ }
48
+ function _is_native_reflect_construct() {
49
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
50
+ if (Reflect.construct.sham) return false;
51
+ if (typeof Proxy === "function") return true;
52
+ try {
53
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
54
+ return true;
55
+ } catch (e) {
56
+ return false;
57
+ }
58
+ }
59
+ function _create_super(Derived) {
60
+ var hasNativeReflectConstruct = _is_native_reflect_construct();
61
+ return function _createSuperInternal() {
62
+ var Super = _get_prototype_of(Derived), result;
63
+ if (hasNativeReflectConstruct) {
64
+ var NewTarget = _get_prototype_of(this).constructor;
65
+ result = Reflect.construct(Super, arguments, NewTarget);
66
+ } else {
67
+ result = Super.apply(this, arguments);
68
+ }
69
+ return _possible_constructor_return(this, result);
70
+ };
71
+ }
72
+ import { JsonRpcProvider } from "./JsonRpcProvider";
73
+ export var AlchemyProvider = /*#__PURE__*/ function(JsonRpcProvider) {
74
+ "use strict";
75
+ _inherits(AlchemyProvider, JsonRpcProvider);
76
+ var _super = _create_super(AlchemyProvider);
77
+ function AlchemyProvider(apiKey) {
78
+ var network = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "mainnet";
79
+ _class_call_check(this, AlchemyProvider);
80
+ var alchemyUrl = "https://eth-".concat(network, ".alchemyapi.io/v2/").concat(apiKey);
81
+ return _super.call(this, alchemyUrl);
82
+ }
83
+ return AlchemyProvider;
84
+ }(JsonRpcProvider);