essential-eth 0.9.0 → 0.9.1-next.1

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 (134) hide show
  1. package/dist/cjs/classes/Contract.js +66 -307
  2. package/dist/cjs/classes/test/Contract/crv-abi.js +256 -252
  3. package/dist/cjs/classes/test/Contract/ens-abi.d.ts +1 -1
  4. package/dist/cjs/classes/test/Contract/ens-abi.js +212 -497
  5. package/dist/cjs/classes/test/Contract/fei-abi.js +284 -605
  6. package/dist/cjs/classes/test/Contract/foo-abi.d.ts +1 -1
  7. package/dist/cjs/classes/test/Contract/foo-abi.js +21 -44
  8. package/dist/cjs/classes/test/Contract/uniswap-abi.js +68 -64
  9. package/dist/cjs/classes/utils/clean-block.js +30 -52
  10. package/dist/cjs/classes/utils/clean-log.js +20 -42
  11. package/dist/cjs/classes/utils/clean-transaction-receipt.js +30 -51
  12. package/dist/cjs/classes/utils/clean-transaction.js +30 -52
  13. package/dist/cjs/classes/utils/encode-decode-transaction.js +107 -148
  14. package/dist/cjs/classes/utils/fetchers.d.ts +8 -2
  15. package/dist/cjs/classes/utils/fetchers.js +52 -166
  16. package/dist/cjs/classes/utils/hex-to-decimal.js +6 -1
  17. package/dist/cjs/classes/utils/prepare-transaction.js +36 -59
  18. package/dist/cjs/index.d.ts +21 -22
  19. package/dist/cjs/index.js +56 -26
  20. package/dist/cjs/index.umd.js +1 -1
  21. package/dist/cjs/index.umd.js.map +1 -1
  22. package/dist/cjs/logger/logger.js +23 -79
  23. package/dist/cjs/logger/package-version.d.ts +1 -1
  24. package/dist/cjs/logger/package-version.js +4 -1
  25. package/dist/cjs/providers/AlchemyProvider.js +9 -82
  26. package/dist/cjs/providers/BaseProvider.js +511 -882
  27. package/dist/cjs/providers/FallthroughProvider.js +46 -123
  28. package/dist/cjs/providers/JsonRpcProvider.js +28 -93
  29. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  30. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +152 -0
  31. package/dist/cjs/providers/test/mock-of.js +6 -8
  32. package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
  33. package/dist/cjs/providers/test/rpc-urls.js +23 -14
  34. package/dist/cjs/providers/utils/chains-info.d.ts +5 -448
  35. package/dist/cjs/providers/utils/chains-info.js +16 -1345
  36. package/dist/cjs/shared/tiny-big/helpers.js +42 -93
  37. package/dist/cjs/shared/tiny-big/tiny-big.js +72 -161
  38. package/dist/cjs/shared/validate-type.d.ts +1 -1
  39. package/dist/cjs/shared/validate-type.js +7 -7
  40. package/dist/cjs/types/Block.types.d.ts +3 -3
  41. package/dist/cjs/types/Block.types.js +2 -1
  42. package/dist/cjs/types/Contract.types.d.ts +4 -4
  43. package/dist/cjs/types/Contract.types.js +2 -1
  44. package/dist/cjs/types/FeeData.types.js +2 -1
  45. package/dist/cjs/types/Filter.types.js +2 -1
  46. package/dist/cjs/types/Network.types.js +2 -3
  47. package/dist/cjs/types/Transaction.types.d.ts +5 -5
  48. package/dist/cjs/types/Transaction.types.js +2 -1
  49. package/dist/cjs/utils/bytes.d.ts +4 -4
  50. package/dist/cjs/utils/bytes.js +318 -286
  51. package/dist/cjs/utils/compute-address.js +15 -8
  52. package/dist/cjs/utils/compute-public-key.js +10 -5
  53. package/dist/cjs/utils/ether-to-gwei.js +11 -10
  54. package/dist/cjs/utils/ether-to-wei.js +11 -10
  55. package/dist/cjs/utils/gwei-to-ether.js +11 -10
  56. package/dist/cjs/utils/hash-message.js +16 -11
  57. package/dist/cjs/utils/is-address.js +12 -8
  58. package/dist/cjs/utils/keccak256.js +14 -8
  59. package/dist/cjs/utils/solidity-keccak256.js +60 -49
  60. package/dist/cjs/utils/split-signature.js +73 -55
  61. package/dist/cjs/utils/to-checksum-address.js +20 -15
  62. package/dist/cjs/utils/to-utf8-bytes.js +6 -1
  63. package/dist/cjs/utils/wei-to-ether.js +15 -13
  64. package/dist/esm/classes/test/Contract/ens-abi.d.ts +1 -1
  65. package/dist/esm/classes/test/Contract/foo-abi.d.ts +1 -1
  66. package/dist/esm/classes/utils/fetchers.d.ts +8 -2
  67. package/dist/esm/classes/utils/fetchers.js +6 -3
  68. package/dist/esm/index.d.ts +21 -22
  69. package/dist/esm/index.js +16 -17
  70. package/dist/esm/logger/package-version.d.ts +1 -1
  71. package/dist/esm/logger/package-version.js +1 -1
  72. package/dist/esm/providers/FallthroughProvider.js +3 -3
  73. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  74. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +142 -0
  75. package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
  76. package/dist/esm/providers/test/rpc-urls.js +7 -4
  77. package/dist/esm/providers/utils/chains-info.d.ts +5 -448
  78. package/dist/esm/providers/utils/chains-info.js +13 -1344
  79. package/dist/esm/shared/validate-type.d.ts +1 -1
  80. package/dist/esm/types/Block.types.d.ts +3 -3
  81. package/dist/esm/types/Contract.types.d.ts +4 -4
  82. package/dist/esm/types/Transaction.types.d.ts +5 -5
  83. package/dist/esm/utils/bytes.d.ts +4 -4
  84. package/package.json +23 -51
  85. package/readme.md +15 -38
  86. package/dist/cjs/classes/test/Contract/crv.test.js +0 -690
  87. package/dist/cjs/classes/test/Contract/ens.test.js +0 -217
  88. package/dist/cjs/classes/test/Contract/fei.test.js +0 -224
  89. package/dist/cjs/classes/test/Contract/foo.test.js +0 -33
  90. package/dist/cjs/classes/test/Contract/uni.test.js +0 -387
  91. package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +0 -228
  92. package/dist/cjs/providers/test/get-transaction-count.test.js +0 -276
  93. package/dist/cjs/providers/test/json-rpc-provider/call.test.js +0 -436
  94. package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +0 -288
  95. package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +0 -261
  96. package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +0 -159
  97. package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +0 -477
  98. package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +0 -311
  99. package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +0 -212
  100. package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +0 -164
  101. package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
  102. package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +0 -274
  103. package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +0 -301
  104. package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +0 -307
  105. package/dist/cjs/providers/test/test-alchemy-provider.test.js +0 -151
  106. package/dist/cjs/shared/tiny-big/helpers.test.js +0 -29
  107. package/dist/cjs/shared/tiny-big/tiny-big.test.js +0 -34
  108. package/dist/cjs/utils/tests/bytes/arrayify.test.js +0 -40
  109. package/dist/cjs/utils/tests/bytes/concat.test.js +0 -15
  110. package/dist/cjs/utils/tests/bytes/hex-concat.test.js +0 -63
  111. package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +0 -49
  112. package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +0 -52
  113. package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +0 -58
  114. package/dist/cjs/utils/tests/bytes/hex-value.test.js +0 -85
  115. package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +0 -62
  116. package/dist/cjs/utils/tests/bytes/hexlify.test.js +0 -62
  117. package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +0 -69
  118. package/dist/cjs/utils/tests/bytes/is-bytes.test.js +0 -33
  119. package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +0 -88
  120. package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +0 -57
  121. package/dist/cjs/utils/tests/bytes/zero-pad.test.js +0 -80
  122. package/dist/cjs/utils/tests/compute-address.test.js +0 -27
  123. package/dist/cjs/utils/tests/compute-public-key.test.js +0 -15
  124. package/dist/cjs/utils/tests/ether-to-gwei.test.js +0 -26
  125. package/dist/cjs/utils/tests/ether-to-wei.test.js +0 -44
  126. package/dist/cjs/utils/tests/gwei-to-ether.test.js +0 -28
  127. package/dist/cjs/utils/tests/hash-message.test.js +0 -21
  128. package/dist/cjs/utils/tests/is-address.test.js +0 -55
  129. package/dist/cjs/utils/tests/keccak256.test.js +0 -97
  130. package/dist/cjs/utils/tests/solidity-keccak256.test.js +0 -310
  131. package/dist/cjs/utils/tests/split-signature.test.js +0 -25
  132. package/dist/cjs/utils/tests/to-checksum-address.test.js +0 -42
  133. package/dist/cjs/utils/tests/to-utf8-bytes.test.js +0 -14
  134. package/dist/cjs/utils/tests/wei-to-ether.test.js +0 -51
@@ -1,92 +1,36 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _arrayWithHoles(arr) {
7
- if (Array.isArray(arr)) return arr;
8
- }
9
- function _classCallCheck(instance, Constructor) {
10
- if (!(instance instanceof Constructor)) {
11
- throw new TypeError("Cannot call a class as a function");
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ const package_version_1 = require("./package-version");
5
+ class Logger {
6
+ constructor() {
7
+ this.packageVersion = package_version_1.version;
12
8
  }
13
- }
14
- function _iterableToArrayLimit(arr, i) {
15
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
16
- if (_i == null) return;
17
- var _arr = [];
18
- var _n = true;
19
- var _d = false;
20
- var _s, _e;
21
- try {
22
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
23
- _arr.push(_s.value);
24
- if (i && _arr.length === i) break;
25
- }
26
- } catch (err) {
27
- _d = true;
28
- _e = err;
29
- } finally{
30
- try {
31
- if (!_n && _i["return"] != null) _i["return"]();
32
- } finally{
33
- if (_d) throw _e;
34
- }
9
+ throwError(message, args) {
10
+ const argsLength = Object.keys(args).length;
11
+ throw new Error(`${message} (${Object.entries(args).map(([key, value], index) => `${key}=${value}${index < argsLength - 1 && ', '}`)}, version=essential-eth@${this.packageVersion})`);
35
12
  }
36
- return _arr;
37
- }
38
- function _nonIterableRest() {
39
- 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
- }
41
- function _slicedToArray(arr, i) {
42
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
43
- }
44
- function _unsupportedIterableToArray(o, minLen) {
45
- if (!o) return;
46
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
47
- var n = Object.prototype.toString.call(o).slice(8, -1);
48
- if (n === "Object" && o.constructor) n = o.constructor.name;
49
- 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);
51
- }
52
- import { version } from "./package-version";
53
- var Logger = /*#__PURE__*/ function() {
54
- "use strict";
55
- function Logger() {
56
- _classCallCheck(this, Logger);
57
- this.packageVersion = version;
13
+ throwArgumentError(message, arg, value) {
14
+ throw new Error(`${message} (argument="${arg}" value=${value}, version=essential-eth@${this.packageVersion})`);
58
15
  }
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") {
16
+ checkSafeUint53(value, message = 'value not safe') {
17
+ if (typeof value !== 'number') {
73
18
  return;
74
19
  }
75
20
  if (value < 0 || value >= 0x1fffffffffffff) {
76
21
  this.throwError(message, {
77
- operation: "checkSafeInteger",
78
- fault: "out-of-safe-range",
79
- value: value
22
+ operation: 'checkSafeInteger',
23
+ fault: 'out-of-safe-range',
24
+ value: value,
80
25
  });
81
26
  }
82
27
  if (value % 1) {
83
28
  this.throwError(message, {
84
- operation: "checkSafeInteger",
85
- fault: "non-integer",
86
- value: value
29
+ operation: 'checkSafeInteger',
30
+ fault: 'non-integer',
31
+ value: value,
87
32
  });
88
33
  }
89
- };
90
- return Logger;
91
- }();
92
- export var logger = new Logger();
34
+ }
35
+ }
36
+ exports.logger = new Logger();
@@ -1 +1 @@
1
- export declare const version = "0.9.0";
1
+ export declare const version = "0.9.1-next.1";
@@ -1,2 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
1
4
  // Generated by genversion.
2
- export var version = "0.9.0";
5
+ exports.version = '0.9.1-next.1';
@@ -1,84 +1,11 @@
1
- function _assertThisInitialized(self) {
2
- if (self === void 0) {
3
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlchemyProvider = void 0;
4
+ const JsonRpcProvider_1 = require("./JsonRpcProvider");
5
+ class AlchemyProvider extends JsonRpcProvider_1.JsonRpcProvider {
6
+ constructor(apiKey, network = 'mainnet') {
7
+ const alchemyUrl = `https://eth-${network}.alchemyapi.io/v2/${apiKey}`;
8
+ super(alchemyUrl);
4
9
  }
5
- return self;
6
10
  }
7
- function _classCallCheck(instance, Constructor) {
8
- if (!(instance instanceof Constructor)) {
9
- throw new TypeError("Cannot call a class as a function");
10
- }
11
- }
12
- function _getPrototypeOf(o) {
13
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
14
- return o.__proto__ || Object.getPrototypeOf(o);
15
- };
16
- return _getPrototypeOf(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) _setPrototypeOf(subClass, superClass);
30
- }
31
- function _possibleConstructorReturn(self, call) {
32
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
33
- return call;
34
- }
35
- return _assertThisInitialized(self);
36
- }
37
- function _setPrototypeOf(o, p) {
38
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
39
- o.__proto__ = p;
40
- return o;
41
- };
42
- return _setPrototypeOf(o, p);
43
- }
44
- var _typeof = function(obj) {
45
- "@swc/helpers - typeof";
46
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
47
- };
48
- function _isNativeReflectConstruct() {
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 _createSuper(Derived) {
60
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
61
- return function _createSuperInternal() {
62
- var Super = _getPrototypeOf(Derived), result;
63
- if (hasNativeReflectConstruct) {
64
- var NewTarget = _getPrototypeOf(this).constructor;
65
- result = Reflect.construct(Super, arguments, NewTarget);
66
- } else {
67
- result = Super.apply(this, arguments);
68
- }
69
- return _possibleConstructorReturn(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 = _createSuper(AlchemyProvider);
77
- function AlchemyProvider(apiKey) {
78
- var network = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "mainnet";
79
- _classCallCheck(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);
11
+ exports.AlchemyProvider = AlchemyProvider;