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,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scientificStrToDecimalStr = void 0;
1
4
  /**
2
5
  * Strips both leading and trailing zeroes from a number string
3
6
  *
@@ -8,78 +11,21 @@
8
11
  * stripTrailingZeros('0005280');
9
12
  * // '5280'
10
13
  * ```
11
- */ function _arrayLikeToArray(arr, len) {
12
- if (len == null || len > arr.length) len = arr.length;
13
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
14
- return arr2;
15
- }
16
- function _arrayWithHoles(arr) {
17
- if (Array.isArray(arr)) return arr;
18
- }
19
- function _arrayWithoutHoles(arr) {
20
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
21
- }
22
- function _iterableToArray(iter) {
23
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
24
- }
25
- function _iterableToArrayLimit(arr, i) {
26
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
27
- if (_i == null) return;
28
- var _arr = [];
29
- var _n = true;
30
- var _d = false;
31
- var _s, _e;
32
- try {
33
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
34
- _arr.push(_s.value);
35
- if (i && _arr.length === i) break;
36
- }
37
- } catch (err) {
38
- _d = true;
39
- _e = err;
40
- } finally{
41
- try {
42
- if (!_n && _i["return"] != null) _i["return"]();
43
- } finally{
44
- if (_d) throw _e;
45
- }
46
- }
47
- return _arr;
48
- }
49
- function _nonIterableRest() {
50
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
- }
52
- function _nonIterableSpread() {
53
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
- }
55
- function _slicedToArray(arr, i) {
56
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
57
- }
58
- function _toConsumableArray(arr) {
59
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
60
- }
61
- function _unsupportedIterableToArray(o, minLen) {
62
- if (!o) return;
63
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
64
- var n = Object.prototype.toString.call(o).slice(8, -1);
65
- if (n === "Object" && o.constructor) n = o.constructor.name;
66
- if (n === "Map" || n === "Set") return Array.from(n);
67
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
68
- }
14
+ */
69
15
  function stripTrailingZeroes(numberString) {
70
- var isNegative = numberString.startsWith("-");
71
- numberString = numberString.replace("-", "");
72
- numberString = numberString.replace(/\.0*$/g, "" /* for numbers like "1.0" -> "1" */ );
73
- numberString = numberString.replace(/^0+/, "");
16
+ const isNegative = numberString.startsWith('-');
17
+ numberString = numberString.replace('-', '');
18
+ numberString = numberString.replace(/\.0*$/g, '' /* for numbers like "1.0" -> "1" */);
19
+ numberString = numberString.replace(/^0+/, '');
74
20
  // for numbers like "1.10" -> "1.1"
75
- if (numberString.includes(".")) {
76
- numberString = numberString.replace(/0+$/, "");
21
+ if (numberString.includes('.')) {
22
+ numberString = numberString.replace(/0+$/, '');
77
23
  }
78
- if (numberString.startsWith(".")) {
24
+ if (numberString.startsWith('.')) {
79
25
  // so that ".1" returns as "0.1"
80
- numberString = "0".concat(numberString);
26
+ numberString = `0${numberString}`;
81
27
  }
82
- return "".concat(isNegative ? "-" : "").concat(numberString);
28
+ return `${isNegative ? '-' : ''}${numberString}`;
83
29
  }
84
30
  /**
85
31
  * Converts a string in scientific notation formatting to string in decimal format
@@ -96,53 +42,56 @@ function stripTrailingZeroes(numberString) {
96
42
  * scientificStrToDecimalStr('2.3e+5');
97
43
  * // '230000'
98
44
  * ```
99
- */ export function scientificStrToDecimalStr(scientificString) {
45
+ */
46
+ function scientificStrToDecimalStr(scientificString) {
100
47
  // Does not contain "e" nor "E"
101
- if (!scientificString.match(/e/i /* lowercase and uppercase E */ )) {
48
+ if (!scientificString.match(/e/i /* lowercase and uppercase E */)) {
102
49
  return stripTrailingZeroes(scientificString);
103
50
  }
104
51
  // eslint-disable-next-line prefer-const
105
- var _scientificString_split = _slicedToArray(scientificString.split(/e/i /* lowercase and uppercase E */ ), 2), base = _scientificString_split[0], power = _scientificString_split[1];
52
+ let [base, power] = scientificString.split(/e/i /* lowercase and uppercase E */);
106
53
  // remove the leading "-" if negative
107
- var isNegative = Number(base) < 0;
108
- base = base.replace("-", "");
54
+ const isNegative = Number(base) < 0;
55
+ base = base.replace('-', '');
109
56
  base = stripTrailingZeroes(base);
110
- var _base_split = _slicedToArray(base.split("."), 2), wholeNumber = _base_split[0], tmp = _base_split[1], fraction /* move decimal this many places */ = tmp === void 0 ? "" : tmp;
57
+ const [wholeNumber, fraction /* move decimal this many places */ = ''] = base.split('.');
111
58
  if (Number(power) === 0) {
112
- return "".concat(isNegative ? "-" : "").concat(stripTrailingZeroes(base));
113
- } else {
114
- var includesDecimal = base.includes(".");
59
+ return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
60
+ }
61
+ else {
62
+ const includesDecimal = base.includes('.');
115
63
  if (!includesDecimal) {
116
- base = "".concat(base, ".");
64
+ base = `${base}.`;
117
65
  }
118
- base = base.replace(".", "");
119
- var baseLength = base.length;
120
- var splitPaddedNumber;
66
+ base = base.replace('.', '');
67
+ const baseLength = base.length;
68
+ let splitPaddedNumber;
121
69
  if (Number(power) < 0) {
122
70
  // move decimal left
123
71
  if (wholeNumber.length < Math.abs(Number(power))) {
124
- base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, "0");
72
+ base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
125
73
  }
126
- splitPaddedNumber = base.split("");
74
+ splitPaddedNumber = base.split('');
127
75
  if (wholeNumber.length < Math.abs(Number(power))) {
128
76
  // starts with zeroes
129
- splitPaddedNumber = [
130
- "."
131
- ].concat(_toConsumableArray(splitPaddedNumber));
132
- } else {
133
- splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, ".");
77
+ splitPaddedNumber = ['.', ...splitPaddedNumber];
134
78
  }
135
- } else {
79
+ else {
80
+ splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
81
+ }
82
+ }
83
+ else {
136
84
  // move decimal right
137
85
  if (fraction.length < Math.abs(Number(power))) {
138
- base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, "0");
86
+ base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
139
87
  }
140
- splitPaddedNumber = base.split("");
88
+ splitPaddedNumber = base.split('');
141
89
  if (fraction.length > Math.abs(Number(power))) {
142
- splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, ".");
90
+ splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
143
91
  }
144
92
  }
145
- var toReturn = stripTrailingZeroes(splitPaddedNumber.join(""));
146
- return "".concat(isNegative ? "-" : "").concat(toReturn);
93
+ const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
94
+ return `${isNegative ? '-' : ''}${toReturn}`;
147
95
  }
148
96
  }
97
+ exports.scientificStrToDecimalStr = scientificStrToDecimalStr;
@@ -1,180 +1,89 @@
1
- function _assertThisInitialized(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 _classCallCheck(instance, Constructor) {
8
- if (!(instance instanceof Constructor)) {
9
- throw new TypeError("Cannot call a class as a function");
10
- }
11
- }
12
- function _get(target, property, receiver) {
13
- if (typeof Reflect !== "undefined" && Reflect.get) {
14
- _get = Reflect.get;
15
- } else {
16
- _get = function _get(target, property, receiver) {
17
- var base = _superPropBase(target, property);
18
- if (!base) return;
19
- var desc = Object.getOwnPropertyDescriptor(base, property);
20
- if (desc.get) {
21
- return desc.get.call(receiver);
22
- }
23
- return desc.value;
24
- };
25
- }
26
- return _get(target, property, receiver || target);
27
- }
28
- function _getPrototypeOf(o) {
29
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
30
- return o.__proto__ || Object.getPrototypeOf(o);
31
- };
32
- return _getPrototypeOf(o);
33
- }
34
- function _inherits(subClass, superClass) {
35
- if (typeof superClass !== "function" && superClass !== null) {
36
- throw new TypeError("Super expression must either be null or a function");
37
- }
38
- subClass.prototype = Object.create(superClass && superClass.prototype, {
39
- constructor: {
40
- value: subClass,
41
- writable: true,
42
- configurable: true
43
- }
44
- });
45
- if (superClass) _setPrototypeOf(subClass, superClass);
46
- }
47
- function _possibleConstructorReturn(self, call) {
48
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
49
- return call;
50
- }
51
- return _assertThisInitialized(self);
52
- }
53
- function _setPrototypeOf(o, p) {
54
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
55
- o.__proto__ = p;
56
- return o;
57
- };
58
- return _setPrototypeOf(o, p);
59
- }
60
- function _superPropBase(object, property) {
61
- while(!Object.prototype.hasOwnProperty.call(object, property)){
62
- object = _getPrototypeOf(object);
63
- if (object === null) break;
64
- }
65
- return object;
66
- }
67
- var _typeof = function(obj) {
68
- "@swc/helpers - typeof";
69
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
70
4
  };
71
- function _isNativeReflectConstruct() {
72
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
73
- if (Reflect.construct.sham) return false;
74
- if (typeof Proxy === "function") return true;
75
- try {
76
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
77
- return true;
78
- } catch (e) {
79
- return false;
80
- }
81
- }
82
- function _createSuper(Derived) {
83
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
84
- return function _createSuperInternal() {
85
- var Super = _getPrototypeOf(Derived), result;
86
- if (hasNativeReflectConstruct) {
87
- var NewTarget = _getPrototypeOf(this).constructor;
88
- result = Reflect.construct(Super, arguments, NewTarget);
89
- } else {
90
- result = Super.apply(this, arguments);
91
- }
92
- return _possibleConstructorReturn(this, result);
93
- };
94
- }
95
- import Big from "big.js";
96
- import { hexToDecimal } from "../../classes/utils/hex-to-decimal";
97
- import { scientificStrToDecimalStr } from "./helpers";
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.tinyBig = exports.TinyBig = void 0;
7
+ const big_js_1 = __importDefault(require("big.js"));
8
+ const hex_to_decimal_1 = require("../../classes/utils/hex-to-decimal");
9
+ const helpers_1 = require("./helpers");
98
10
  /**
99
11
  * A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
100
12
  * This is the return type of every operation on ether, wei, etc.
101
- */ export var TinyBig = /*#__PURE__*/ function(Big) {
102
- "use strict";
103
- _inherits(TinyBig, Big);
104
- var _super = _createSuper(TinyBig);
105
- function TinyBig(value) {
106
- _classCallCheck(this, TinyBig);
107
- var _this;
108
- if (typeof value === "string" && value.startsWith("0x")) {
109
- value = hexToDecimal(value);
13
+ */
14
+ class TinyBig extends big_js_1.default {
15
+ constructor(value) {
16
+ if (typeof value === 'string' && value.startsWith('0x')) {
17
+ value = (0, hex_to_decimal_1.hexToDecimal)(value);
110
18
  }
111
- _this = _super.call(this, value);
19
+ super(value);
112
20
  /**
113
- * Eithers pads or shortens a string to a specified length
114
- *
115
- * @param str the string to pad or chop
116
- * @param padChar the character to pad the string with
117
- * @param length the desired length of the given string
118
- * @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
119
- * @example
120
- * ```javascript
121
- * padAndChop('essential-eth', 'a', 8);
122
- * // 'tial-eth'
123
- * ```
124
- * @example
125
- * ```javascript
126
- * padAndChop('essential-eth', 'A', 20);
127
- * // 'AAAAAAAessential-eth'
128
- * ```
129
- */ _this.padAndChop = function(str, padChar, length) {
130
- return (Array(length).fill(padChar).join("") + str).slice(length * -1);
21
+ * Eithers pads or shortens a string to a specified length
22
+ *
23
+ * @param str the string to pad or chop
24
+ * @param padChar the character to pad the string with
25
+ * @param length the desired length of the given string
26
+ * @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
27
+ * @example
28
+ * ```javascript
29
+ * padAndChop('essential-eth', 'a', 8);
30
+ * // 'tial-eth'
31
+ * ```
32
+ * @example
33
+ * ```javascript
34
+ * padAndChop('essential-eth', 'A', 20);
35
+ * // 'AAAAAAAessential-eth'
36
+ * ```
37
+ */
38
+ this.padAndChop = (str, padChar, length) => {
39
+ return (Array(length).fill(padChar).join('') + str).slice(length * -1);
131
40
  };
132
- return _this;
133
41
  }
134
- var _proto = TinyBig.prototype;
135
42
  /**
136
- * Used anytime you're passing in "value" to ethers or web3
137
- * For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
138
- *
139
- * @returns the TinyBig represented as a hex string
140
- * @example
141
- * ```javascript
142
- * tinyBig(293).toHexString();
143
- * // '0x125'
144
- * ```
145
- * @example
146
- * ```javascript
147
- * tinyBig(681365874).toHexString();
148
- * // '0x289cd172'
149
- */ _proto.toHexString = function toHexString() {
150
- return "0x".concat(BigInt(this.toString()).toString(16));
151
- };
152
- _proto.toNumber = function toNumber() {
153
- return Number(scientificStrToDecimalStr(_get(_getPrototypeOf(TinyBig.prototype), "toString", this).call(this)));
154
- };
155
- _proto.toString = function toString() {
43
+ * Used anytime you're passing in "value" to ethers or web3
44
+ * For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
45
+ *
46
+ * @returns the TinyBig represented as a hex string
47
+ * @example
48
+ * ```javascript
49
+ * tinyBig(293).toHexString();
50
+ * // '0x125'
51
+ * ```
52
+ * @example
53
+ * ```javascript
54
+ * tinyBig(681365874).toHexString();
55
+ * // '0x289cd172'
56
+ */
57
+ toHexString() {
58
+ return `0x${BigInt(this.toString()).toString(16)}`;
59
+ }
60
+ toNumber() {
61
+ return Number((0, helpers_1.scientificStrToDecimalStr)(super.toString()));
62
+ }
63
+ toString() {
156
64
  if (this.toNumber() === 0) {
157
- return "0";
65
+ return '0';
158
66
  }
159
- return scientificStrToDecimalStr(_get(_getPrototypeOf(TinyBig.prototype), "toString", this).call(this));
160
- };
161
- _proto.toTwos = function toTwos(bitCount) {
162
- var binaryStr;
67
+ return (0, helpers_1.scientificStrToDecimalStr)(super.toString());
68
+ }
69
+ toTwos(bitCount) {
70
+ let binaryStr;
163
71
  if (this.gte(0)) {
164
- var twosComp = this.toNumber().toString(2);
165
- binaryStr = this.padAndChop(twosComp, "0", bitCount || twosComp.length);
166
- } else {
72
+ const twosComp = this.toNumber().toString(2);
73
+ binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
74
+ }
75
+ else {
167
76
  binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
168
77
  if (Number(binaryStr) < 0) {
169
- throw new Error("Cannot calculate twos complement");
78
+ throw new Error('Cannot calculate twos complement');
170
79
  }
171
80
  }
172
- var binary = "0b".concat(binaryStr);
173
- var decimal = Number(binary);
81
+ const binary = `0b${binaryStr}`;
82
+ const decimal = Number(binary);
174
83
  return tinyBig(decimal);
175
- };
176
- return TinyBig;
177
- }(Big);
84
+ }
85
+ }
86
+ exports.TinyBig = TinyBig;
178
87
  /**
179
88
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
180
89
  *
@@ -185,6 +94,8 @@ import { scientificStrToDecimalStr } from "./helpers";
185
94
  * tinyBig(10).times(3).toNumber()
186
95
  * // 30
187
96
  * ```
188
- */ export function tinyBig(value) {
97
+ */
98
+ function tinyBig(value) {
189
99
  return new TinyBig(value);
190
100
  }
101
+ exports.tinyBig = tinyBig;
@@ -1,3 +1,3 @@
1
- declare type JSPrimitiveTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
1
+ type JSPrimitiveTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
2
2
  export declare const validateType: (value: unknown, allowedTypes: JSPrimitiveTypes[]) => void;
3
3
  export {};
@@ -1,9 +1,9 @@
1
- var _typeof = function(obj) {
2
- "@swc/helpers - typeof";
3
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
- };
5
- export var validateType = function(value, allowedTypes) {
6
- if (!allowedTypes.includes(typeof value === "undefined" ? "undefined" : _typeof(value))) {
7
- throw new Error("".concat(allowedTypes.join(" or "), " required. Received ").concat(typeof value === "undefined" ? "undefined" : _typeof(value)));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateType = void 0;
4
+ const validateType = (value, allowedTypes) => {
5
+ if (!allowedTypes.includes(typeof value)) {
6
+ throw new Error(`${allowedTypes.join(' or ')} required. Received ${typeof value}`);
8
7
  }
9
8
  };
9
+ exports.validateType = validateType;
@@ -1,7 +1,7 @@
1
1
  import type { TinyBig } from './../shared/tiny-big/tiny-big';
2
2
  import type { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
3
- declare type Modify<T, R> = Omit<T, keyof R> & R;
4
- export declare type BlockResponse = Modify<RPCBlock, {
3
+ type Modify<T, R> = Omit<T, keyof R> & R;
4
+ export type BlockResponse = Modify<RPCBlock, {
5
5
  baseFeePerGas: TinyBig;
6
6
  difficulty: TinyBig;
7
7
  gasLimit: TinyBig;
@@ -36,5 +36,5 @@ export interface RPCBlock {
36
36
  transactionsRoot: string;
37
37
  uncles: Array<string>;
38
38
  }
39
- export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
39
+ export type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
40
40
  export {};
@@ -1 +1,2 @@
1
- export { }; /* block number as hex string '0x0' */
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
- export declare type ContractTypes = 'bool' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' | 'bytes32[]' | 'address' | 'address payable' | 'address[4]' | 'address[100]' | 'uint256' | 'uint256[100]' | 'uint8' | 'uint32' | string;
2
- export declare type ContractInterface = JSONABI;
3
- export declare type ContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
1
+ export type ContractTypes = 'bool' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' | 'bytes32[]' | 'address' | 'address payable' | 'address[4]' | 'address[100]' | 'uint256' | 'uint256[100]' | 'uint8' | 'uint32' | string;
2
+ export type ContractInterface = JSONABI;
3
+ export type ContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
4
4
  export interface JSONABIArgument {
5
5
  anonymous?: false;
6
6
  inputs: {
@@ -21,4 +21,4 @@ export interface JSONABIArgument {
21
21
  constant?: boolean;
22
22
  payable?: boolean;
23
23
  }
24
- export declare type JSONABI = JSONABIArgument[];
24
+ export type JSONABI = JSONABIArgument[];
@@ -1 +1,2 @@
1
- export { };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export { };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export { };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,2 @@
1
- /**
2
- * A trimmed version of https://chainid.network/chains.json
3
- */ export { };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,12 @@
1
1
  import type Big from 'big.js';
2
2
  import type { TinyBig } from '../shared/tiny-big/tiny-big';
3
3
  import type { BytesLike } from './../utils/bytes';
4
- declare type Modify<T, R> = Omit<T, keyof R> & R;
4
+ type Modify<T, R> = Omit<T, keyof R> & R;
5
5
  export interface RPCTransaction extends RPCBlockTransaction {
6
6
  maxFeePerGas: string;
7
7
  maxPriorityFeePerGas: string;
8
8
  }
9
- export declare type TransactionResponse = Modify<RPCTransaction, {
9
+ export type TransactionResponse = Modify<RPCTransaction, {
10
10
  blockNumber: number;
11
11
  chainId: number;
12
12
  gas: TinyBig;
@@ -22,7 +22,7 @@ export declare type TransactionResponse = Modify<RPCTransaction, {
22
22
  maxPriorityFeePerGas: TinyBig;
23
23
  confirmations: number;
24
24
  }>;
25
- export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
25
+ export type TransactionReceipt = Modify<RPCTransactionReceipt, {
26
26
  blockNumber: number;
27
27
  cumulativeGasUsed: TinyBig;
28
28
  effectiveGasPrice: TinyBig;
@@ -59,12 +59,12 @@ export interface TransactionRequest {
59
59
  maxPriorityFeePerGas?: TinyBig | string | Big | number;
60
60
  maxFeePerGas?: TinyBig | string | Big | number;
61
61
  }
62
- export declare type Log = Modify<RPCLog, {
62
+ export type Log = Modify<RPCLog, {
63
63
  blockNumber: number;
64
64
  logIndex: number;
65
65
  transactionIndex: number;
66
66
  }>;
67
- export declare type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
67
+ export type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
68
68
  export interface RPCBlockTransaction {
69
69
  blockHash: string;
70
70
  blockNumber: string;
@@ -1 +1,2 @@
1
- export { };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
- export declare type Bytes = ArrayLike<number>;
2
- export declare type BytesLike = Bytes | string;
3
- export declare type BytesLikeWithNumber = BytesLike | number;
1
+ export type Bytes = ArrayLike<number>;
2
+ export type BytesLike = Bytes | string;
3
+ export type BytesLikeWithNumber = BytesLike | number;
4
4
  export interface DataOptions {
5
5
  allowMissingPrefix?: boolean;
6
6
  hexPad?: 'left' | 'right' | null;
@@ -8,7 +8,7 @@ export interface DataOptions {
8
8
  export interface Hexable {
9
9
  toHexString(): string;
10
10
  }
11
- export declare type SignatureLike = {
11
+ export type SignatureLike = {
12
12
  r: string;
13
13
  s?: string;
14
14
  _vs?: string;