essential-eth 0.5.5 → 0.5.10-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 (188) hide show
  1. package/{lib/esm → dist}/classes/Contract.d.ts +11 -11
  2. package/dist/classes/test/Contract/crv-abi.d.ts +2 -0
  3. package/dist/classes/test/Contract/ens-abi.d.ts +2 -0
  4. package/dist/classes/test/Contract/fei-abi.d.ts +2 -0
  5. package/dist/classes/test/Contract/foo-abi.d.ts +2 -0
  6. package/dist/classes/test/Contract/uniswap-abi.d.ts +2 -0
  7. package/dist/classes/utils/clean-block.d.ts +3 -0
  8. package/dist/classes/utils/clean-log.d.ts +2 -0
  9. package/{lib/esm → dist}/classes/utils/clean-transaction-receipt.d.ts +2 -2
  10. package/{lib/esm → dist}/classes/utils/clean-transaction.d.ts +2 -2
  11. package/{lib/cjs → dist}/classes/utils/encode-decode-transaction.d.ts +4 -4
  12. package/{lib/cjs → dist}/classes/utils/fetchers.d.ts +9 -9
  13. package/{lib/esm → dist}/classes/utils/hex-to-decimal.d.ts +1 -1
  14. package/dist/classes/utils/prepare-transaction.d.ts +2 -0
  15. package/{lib/cjs → dist}/index.d.ts +25 -24
  16. package/dist/index.js +2 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/index.modern.mjs +2 -0
  19. package/dist/index.modern.mjs.map +1 -0
  20. package/dist/index.module.js +2 -0
  21. package/dist/index.module.js.map +1 -0
  22. package/dist/index.umd.js +2 -0
  23. package/dist/index.umd.js.map +1 -0
  24. package/{lib/esm → dist}/logger/logger.d.ts +11 -11
  25. package/dist/logger/package-version.d.ts +1 -0
  26. package/{lib/esm → dist}/providers/BaseProvider.d.ts +24 -19
  27. package/{lib/esm → dist}/providers/FallthroughProvider.d.ts +11 -11
  28. package/{lib/esm → dist}/providers/JsonRpcProvider.d.ts +7 -7
  29. package/{lib/cjs → dist}/providers/test/rpc-urls.d.ts +11 -11
  30. package/{lib/esm → dist}/providers/utils/chains-info.d.ts +467 -412
  31. package/{lib/cjs → dist}/shared/tiny-big/helpers.d.ts +1 -1
  32. package/{lib/esm → dist}/shared/tiny-big/tiny-big.d.ts +10 -10
  33. package/{lib/cjs → dist}/shared/validate-type.d.ts +3 -3
  34. package/{lib/cjs → dist}/types/Block.types.d.ts +40 -37
  35. package/{lib/cjs → dist}/types/Contract.types.d.ts +24 -24
  36. package/dist/types/Filter.types.d.ts +12 -0
  37. package/{lib/esm → dist}/types/Network.types.d.ts +5 -5
  38. package/{lib/cjs → dist}/types/Transaction.types.d.ts +113 -96
  39. package/{lib/esm → dist}/utils/bytes.d.ts +40 -40
  40. package/{lib/esm → dist}/utils/compute-address.d.ts +1 -1
  41. package/{lib/esm → dist}/utils/compute-public-key.d.ts +2 -2
  42. package/{lib/esm → dist}/utils/ether-to-gwei.d.ts +3 -3
  43. package/dist/utils/ether-to-wei.d.ts +3 -0
  44. package/dist/utils/gwei-to-ether.d.ts +3 -0
  45. package/{lib/esm → dist}/utils/hash-message.d.ts +2 -2
  46. package/{lib/esm → dist}/utils/is-address.d.ts +1 -1
  47. package/dist/utils/keccak256.d.ts +2 -0
  48. package/{lib/esm → dist}/utils/solidity-keccak256.d.ts +2 -2
  49. package/{lib/esm → dist}/utils/split-signature.d.ts +2 -2
  50. package/{lib/esm → dist}/utils/to-checksum-address.d.ts +1 -1
  51. package/{lib/cjs → dist}/utils/to-utf8-bytes.d.ts +1 -1
  52. package/dist/utils/wei-to-ether.d.ts +3 -0
  53. package/package.json +45 -14
  54. package/readme.md +643 -291
  55. package/lib/cjs/classes/Contract.d.ts +0 -72
  56. package/lib/cjs/classes/Contract.js +0 -129
  57. package/lib/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
  58. package/lib/cjs/classes/test/Contract/crv-abi.js +0 -488
  59. package/lib/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
  60. package/lib/cjs/classes/test/Contract/ens-abi.js +0 -453
  61. package/lib/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
  62. package/lib/cjs/classes/test/Contract/fei-abi.js +0 -526
  63. package/lib/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
  64. package/lib/cjs/classes/test/Contract/foo-abi.js +0 -42
  65. package/lib/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
  66. package/lib/cjs/classes/test/Contract/uniswap-abi.js +0 -121
  67. package/lib/cjs/classes/utils/clean-block.d.ts +0 -6
  68. package/lib/cjs/classes/utils/clean-block.js +0 -47
  69. package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -5
  70. package/lib/cjs/classes/utils/clean-transaction-receipt.js +0 -55
  71. package/lib/cjs/classes/utils/clean-transaction.d.ts +0 -5
  72. package/lib/cjs/classes/utils/clean-transaction.js +0 -42
  73. package/lib/cjs/classes/utils/encode-decode-transaction.js +0 -113
  74. package/lib/cjs/classes/utils/fetchers.js +0 -51
  75. package/lib/cjs/classes/utils/hex-to-decimal.d.ts +0 -5
  76. package/lib/cjs/classes/utils/hex-to-decimal.js +0 -11
  77. package/lib/cjs/index.js +0 -54
  78. package/lib/cjs/logger/logger.d.ts +0 -11
  79. package/lib/cjs/logger/logger.js +0 -36
  80. package/lib/cjs/logger/package-version.d.ts +0 -1
  81. package/lib/cjs/logger/package-version.js +0 -5
  82. package/lib/cjs/providers/BaseProvider.d.ts +0 -284
  83. package/lib/cjs/providers/BaseProvider.js +0 -380
  84. package/lib/cjs/providers/FallthroughProvider.d.ts +0 -24
  85. package/lib/cjs/providers/FallthroughProvider.js +0 -65
  86. package/lib/cjs/providers/JsonRpcProvider.d.ts +0 -27
  87. package/lib/cjs/providers/JsonRpcProvider.js +0 -40
  88. package/lib/cjs/providers/test/rpc-urls.js +0 -14
  89. package/lib/cjs/providers/utils/chains-info.d.ts +0 -412
  90. package/lib/cjs/providers/utils/chains-info.js +0 -1237
  91. package/lib/cjs/shared/tiny-big/helpers.js +0 -71
  92. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +0 -32
  93. package/lib/cjs/shared/tiny-big/tiny-big.js +0 -71
  94. package/lib/cjs/shared/validate-type.js +0 -9
  95. package/lib/cjs/types/Block.types.js +0 -2
  96. package/lib/cjs/types/Contract.types.js +0 -2
  97. package/lib/cjs/types/Network.types.d.ts +0 -8
  98. package/lib/cjs/types/Network.types.js +0 -2
  99. package/lib/cjs/types/Transaction.types.js +0 -2
  100. package/lib/cjs/utils/bytes.d.ts +0 -172
  101. package/lib/cjs/utils/bytes.js +0 -564
  102. package/lib/cjs/utils/compute-address.d.ts +0 -8
  103. package/lib/cjs/utils/compute-address.js +0 -24
  104. package/lib/cjs/utils/compute-public-key.d.ts +0 -9
  105. package/lib/cjs/utils/compute-public-key.js +0 -17
  106. package/lib/cjs/utils/ether-to-gwei.d.ts +0 -26
  107. package/lib/cjs/utils/ether-to-gwei.js +0 -34
  108. package/lib/cjs/utils/ether-to-wei.d.ts +0 -26
  109. package/lib/cjs/utils/ether-to-wei.js +0 -34
  110. package/lib/cjs/utils/gwei-to-ether.d.ts +0 -26
  111. package/lib/cjs/utils/gwei-to-ether.js +0 -34
  112. package/lib/cjs/utils/hash-message.d.ts +0 -12
  113. package/lib/cjs/utils/hash-message.js +0 -26
  114. package/lib/cjs/utils/is-address.d.ts +0 -24
  115. package/lib/cjs/utils/is-address.js +0 -39
  116. package/lib/cjs/utils/keccak256.d.ts +0 -2
  117. package/lib/cjs/utils/keccak256.js +0 -17
  118. package/lib/cjs/utils/solidity-keccak256.d.ts +0 -29
  119. package/lib/cjs/utils/solidity-keccak256.js +0 -118
  120. package/lib/cjs/utils/split-signature.d.ts +0 -26
  121. package/lib/cjs/utils/split-signature.js +0 -165
  122. package/lib/cjs/utils/to-checksum-address.d.ts +0 -17
  123. package/lib/cjs/utils/to-checksum-address.js +0 -46
  124. package/lib/cjs/utils/to-utf8-bytes.js +0 -7
  125. package/lib/cjs/utils/wei-to-ether.d.ts +0 -26
  126. package/lib/cjs/utils/wei-to-ether.js +0 -34
  127. package/lib/esm/classes/Contract.js +0 -65
  128. package/lib/esm/classes/test/Contract/crv-abi.d.ts +0 -2
  129. package/lib/esm/classes/test/Contract/crv-abi.js +0 -470
  130. package/lib/esm/classes/test/Contract/ens-abi.d.ts +0 -2
  131. package/lib/esm/classes/test/Contract/ens-abi.js +0 -435
  132. package/lib/esm/classes/test/Contract/fei-abi.d.ts +0 -2
  133. package/lib/esm/classes/test/Contract/fei-abi.js +0 -521
  134. package/lib/esm/classes/test/Contract/foo-abi.d.ts +0 -2
  135. package/lib/esm/classes/test/Contract/foo-abi.js +0 -33
  136. package/lib/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
  137. package/lib/esm/classes/test/Contract/uniswap-abi.js +0 -116
  138. package/lib/esm/classes/utils/clean-block.d.ts +0 -3
  139. package/lib/esm/classes/utils/clean-block.js +0 -36
  140. package/lib/esm/classes/utils/clean-transaction-receipt.js +0 -48
  141. package/lib/esm/classes/utils/clean-transaction.js +0 -33
  142. package/lib/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
  143. package/lib/esm/classes/utils/encode-decode-transaction.js +0 -98
  144. package/lib/esm/classes/utils/fetchers.d.ts +0 -9
  145. package/lib/esm/classes/utils/fetchers.js +0 -43
  146. package/lib/esm/classes/utils/hex-to-decimal.js +0 -3
  147. package/lib/esm/index.d.ts +0 -24
  148. package/lib/esm/index.js +0 -20
  149. package/lib/esm/logger/logger.js +0 -33
  150. package/lib/esm/logger/package-version.d.ts +0 -1
  151. package/lib/esm/logger/package-version.js +0 -1
  152. package/lib/esm/providers/BaseProvider.js +0 -107
  153. package/lib/esm/providers/FallthroughProvider.js +0 -41
  154. package/lib/esm/providers/JsonRpcProvider.js +0 -15
  155. package/lib/esm/providers/test/rpc-urls.d.ts +0 -11
  156. package/lib/esm/providers/test/rpc-urls.js +0 -11
  157. package/lib/esm/providers/utils/chains-info.js +0 -1233
  158. package/lib/esm/shared/tiny-big/helpers.d.ts +0 -1
  159. package/lib/esm/shared/tiny-big/helpers.js +0 -58
  160. package/lib/esm/shared/tiny-big/tiny-big.js +0 -41
  161. package/lib/esm/shared/validate-type.d.ts +0 -3
  162. package/lib/esm/shared/validate-type.js +0 -5
  163. package/lib/esm/types/Block.types.d.ts +0 -36
  164. package/lib/esm/types/Block.types.js +0 -1
  165. package/lib/esm/types/Contract.types.d.ts +0 -24
  166. package/lib/esm/types/Contract.types.js +0 -1
  167. package/lib/esm/types/Network.types.js +0 -1
  168. package/lib/esm/types/Transaction.types.d.ts +0 -87
  169. package/lib/esm/types/Transaction.types.js +0 -1
  170. package/lib/esm/utils/bytes.js +0 -245
  171. package/lib/esm/utils/compute-address.js +0 -11
  172. package/lib/esm/utils/compute-public-key.js +0 -6
  173. package/lib/esm/utils/ether-to-gwei.js +0 -7
  174. package/lib/esm/utils/ether-to-wei.d.ts +0 -3
  175. package/lib/esm/utils/ether-to-wei.js +0 -7
  176. package/lib/esm/utils/gwei-to-ether.d.ts +0 -3
  177. package/lib/esm/utils/gwei-to-ether.js +0 -7
  178. package/lib/esm/utils/hash-message.js +0 -12
  179. package/lib/esm/utils/is-address.js +0 -12
  180. package/lib/esm/utils/keccak256.d.ts +0 -2
  181. package/lib/esm/utils/keccak256.js +0 -13
  182. package/lib/esm/utils/solidity-keccak256.js +0 -85
  183. package/lib/esm/utils/split-signature.js +0 -126
  184. package/lib/esm/utils/to-checksum-address.js +0 -25
  185. package/lib/esm/utils/to-utf8-bytes.d.ts +0 -1
  186. package/lib/esm/utils/to-utf8-bytes.js +0 -3
  187. package/lib/esm/utils/wei-to-ether.d.ts +0 -3
  188. package/lib/esm/utils/wei-to-ether.js +0 -7
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanBlock = void 0;
4
- const __1 = require("../..");
5
- const clean_transaction_1 = require("./clean-transaction");
6
- const hex_to_decimal_1 = require("./hex-to-decimal");
7
- /**
8
- * Converts RPC block response to more JS-friendly format
9
- */
10
- function cleanBlock(block, returnTransactionObjects) {
11
- const cleanedBlock = Object.assign({}, block);
12
- Object.keys(block).forEach((key) => {
13
- // pending blocks have null instead of a difficulty
14
- // pending blocks have null instead of a miner address
15
- if (!block[key])
16
- return;
17
- switch (key) {
18
- case 'gasLimit':
19
- case 'gasUsed':
20
- case 'number':
21
- case 'size':
22
- case 'timestamp':
23
- case 'baseFeePerGas':
24
- cleanedBlock[key] = Number((0, hex_to_decimal_1.hexToDecimal)(block[key]));
25
- break;
26
- case 'difficulty':
27
- case 'totalDifficulty':
28
- cleanedBlock[key] = (0, hex_to_decimal_1.hexToDecimal)(block[key]);
29
- break;
30
- case 'miner':
31
- if (block[key]) {
32
- cleanedBlock[key] = (0, __1.toChecksumAddress)(block[key]);
33
- }
34
- break;
35
- }
36
- });
37
- // for all full transactions
38
- if (returnTransactionObjects) {
39
- const txns = block.transactions;
40
- // could be renamed "cleanTransaction" in the future
41
- txns.forEach((transaction, index) => {
42
- cleanedBlock.transactions[index] = (0, clean_transaction_1.cleanTransaction)(transaction);
43
- });
44
- }
45
- return cleanedBlock;
46
- }
47
- exports.cleanBlock = cleanBlock;
@@ -1,5 +0,0 @@
1
- import { RPCTransactionReceipt, TransactionReceipt } from '../../types/Transaction.types';
2
- /**
3
- * Converts RPC transaction receipt response to more JS-friendly format
4
- */
5
- export declare function cleanTransactionReceipt(transactionReceipt: RPCTransactionReceipt): TransactionReceipt;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanTransactionReceipt = void 0;
4
- const __1 = require("../..");
5
- const clean_transaction_1 = require("./clean-transaction");
6
- const hex_to_decimal_1 = require("./hex-to-decimal");
7
- /**
8
- * Converts RPC transaction receipt response to more JS-friendly format
9
- */
10
- function cleanTransactionReceipt(transactionReceipt) {
11
- const cleanedTransaction = (0, clean_transaction_1.cleanTransaction)(transactionReceipt);
12
- const cleanedTransactionReceipt = Object.assign({}, cleanedTransaction);
13
- Object.keys(transactionReceipt).forEach((key) => {
14
- if (!transactionReceipt[key])
15
- return;
16
- switch (key) {
17
- case 'status':
18
- cleanedTransactionReceipt[key] = Number((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
19
- break;
20
- case 'contractAddress':
21
- if (transactionReceipt[key]) {
22
- cleanedTransactionReceipt[key] = (0, __1.toChecksumAddress)(transactionReceipt[key]);
23
- }
24
- break;
25
- case 'cumulativeGasUsed':
26
- case 'effectiveGasPrice':
27
- case 'gasUsed':
28
- cleanedTransactionReceipt[key] = (0, __1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
29
- break;
30
- case 'logs':
31
- transactionReceipt[key].forEach((log, index) => {
32
- Object.keys(log).forEach((logKey) => {
33
- switch (logKey) {
34
- case 'address':
35
- cleanedTransactionReceipt[key][index][logKey] =
36
- (0, __1.toChecksumAddress)(log[logKey]);
37
- break;
38
- case 'blockNumber':
39
- case 'logIndex':
40
- case 'transactionIndex':
41
- cleanedTransactionReceipt[key][index][logKey] = Number((0, hex_to_decimal_1.hexToDecimal)(log[logKey]));
42
- break;
43
- case 'removed':
44
- delete log[logKey];
45
- break;
46
- }
47
- });
48
- });
49
- }
50
- });
51
- cleanedTransactionReceipt.byzantium =
52
- cleanedTransactionReceipt.blockNumber >= 4370000;
53
- return cleanedTransactionReceipt;
54
- }
55
- exports.cleanTransactionReceipt = cleanTransactionReceipt;
@@ -1,5 +0,0 @@
1
- import { RPCTransaction, TransactionResponse } from '../../types/Transaction.types';
2
- /**
3
- * Converts RPC transaction response to more JS-friendly format
4
- */
5
- export declare function cleanTransaction(transaction: RPCTransaction): TransactionResponse;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanTransaction = void 0;
4
- const __1 = require("../..");
5
- const hex_to_decimal_1 = require("./hex-to-decimal");
6
- /**
7
- * Converts RPC transaction response to more JS-friendly format
8
- */
9
- function cleanTransaction(transaction) {
10
- const cleanedTransaction = Object.assign({}, transaction);
11
- Object.keys(transaction).forEach((key) => {
12
- // pending blocks have null instead of a difficulty
13
- // pending blocks have null instead of a miner address
14
- if (!transaction[key])
15
- return;
16
- switch (key) {
17
- case 'blockNumber':
18
- case 'chainId':
19
- case 'nonce':
20
- case 'transactionIndex':
21
- case 'type':
22
- case 'v':
23
- cleanedTransaction[key] = Number((0, hex_to_decimal_1.hexToDecimal)(transaction[key]));
24
- break;
25
- case 'from':
26
- case 'to':
27
- if (transaction[key]) {
28
- cleanedTransaction[key] = (0, __1.toChecksumAddress)(transaction[key]);
29
- }
30
- break;
31
- case 'value':
32
- case 'gas':
33
- case 'gasPrice':
34
- case 'maxFeePerGas':
35
- case 'maxPriorityFeePerGas':
36
- cleanedTransaction[key] = (0, __1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transaction[key]));
37
- break;
38
- }
39
- });
40
- return cleanedTransaction;
41
- }
42
- exports.cleanTransaction = cleanTransaction;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeRPCResponse = exports.encodeData = exports.hexFalse = void 0;
4
- const sha3_1 = require("sha3");
5
- const __1 = require("../..");
6
- const hex_to_decimal_1 = require("./hex-to-decimal");
7
- exports.hexFalse = '0'.repeat(64);
8
- const hexTrue = '0'.repeat(63) + '1';
9
- function expandType(type) {
10
- // https://docs.soliditylang.org/en/v0.8.7/types.html#integers
11
- if (type === 'uint[]') {
12
- return 'uint256[]';
13
- }
14
- else if (type === 'int[]') {
15
- return 'int256[]';
16
- }
17
- return type;
18
- }
19
- function encodeData(jsonABIArgument, args) {
20
- const hash = new sha3_1.Keccak(256);
21
- /* first 4 bytes will create the data parameter */
22
- const functionString = `${jsonABIArgument.name}(${jsonABIArgument.inputs.map((input) => expandType(input.type))})`;
23
- // encoding learnt from https://ethereum.stackexchange.com/questions/3514/how-to-call-a-contract-method-using-the-eth-call-json-rpc-api
24
- const functionHash = hash.update(functionString).digest('hex');
25
- // no arrays
26
- const jsonABIInputsLength = jsonABIArgument.inputs.length;
27
- let shouldValidateInputLength = true;
28
- // inputs contains 1 or more arrays
29
- if (jsonABIArgument.inputs.find((input) => input.type.includes('['))) {
30
- shouldValidateInputLength = false;
31
- }
32
- if (shouldValidateInputLength && args.length !== jsonABIInputsLength) {
33
- throw new Error(`args inputs of "${args.length}" does not match expected length of "${jsonABIArgument.inputs.length}"`);
34
- }
35
- const argsWithTypes = (jsonABIArgument.inputs || []).reduce((acc, input, i) => {
36
- var _a;
37
- if (input.type.includes('[')) {
38
- // strip array and length like "[2]" from type
39
- const basicType = (_a = /([^[]*)\[.*$/g.exec(input.type)) === null || _a === void 0 ? void 0 : _a[1];
40
- args.forEach((arg) => {
41
- acc = acc.concat([[arg, basicType]]);
42
- });
43
- return acc;
44
- }
45
- else {
46
- return acc.concat([[args[i], input.type]]);
47
- }
48
- }, []);
49
- const encodedArgs = argsWithTypes.map(([arg, inputType]) => {
50
- let rawArg = arg;
51
- switch (inputType) {
52
- case 'bool':
53
- return arg ? hexTrue : exports.hexFalse;
54
- case 'address':
55
- // remove leading "0x"
56
- rawArg = arg.replace(/^0x/g, '').toLowerCase();
57
- break;
58
- default:
59
- if (inputType.startsWith('bytes')) {
60
- // encode each character to hex
61
- const argEncoded = rawArg
62
- .split('')
63
- .map((character) => character.charCodeAt(0).toString(16))
64
- .join('');
65
- const paddedEncodedArg = argEncoded.padEnd(64, '0');
66
- return paddedEncodedArg;
67
- }
68
- else if (inputType === 'uint256') {
69
- const argEncoded = BigInt(arg).toString(16);
70
- const paddedEncodedArg = argEncoded.padStart(64, '0');
71
- return paddedEncodedArg;
72
- }
73
- else if (inputType.startsWith('uint')) {
74
- break;
75
- }
76
- else {
77
- throw new Error(`essential-eth does not yet support "${inputType}" inputs. Make a PR today!"`);
78
- }
79
- }
80
- const argEncoded = rawArg.toString(16);
81
- const paddedEncodedArg = argEncoded.padStart(64, '0');
82
- return paddedEncodedArg;
83
- });
84
- const functionEncoded = functionHash.slice(0, 8);
85
- const data = `0x${functionEncoded}${encodedArgs.join('')}`;
86
- return data;
87
- }
88
- exports.encodeData = encodeData;
89
- function decodeRPCResponse(jsonABIArgument, nodeResponse) {
90
- const rawOutputs = jsonABIArgument.outputs;
91
- // chunk response every 64 characters
92
- const encodedOutputs = nodeResponse.slice(2).match(/.{1,64}/g);
93
- const outputs = (encodedOutputs || []).map((output, i) => {
94
- const outputType = (rawOutputs || [])[i].type;
95
- switch (outputType) {
96
- case 'bool':
97
- return output === hexTrue;
98
- case 'address':
99
- /* address types have 26 leading zeroes to remove */
100
- return (0, __1.toChecksumAddress)(`0x${output.slice(24)}`);
101
- case 'uint256':
102
- return (0, __1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(`0x${output}`));
103
- case 'bytes32':
104
- return `0x${output}`;
105
- case 'uint8':
106
- return Number((0, hex_to_decimal_1.hexToDecimal)(`0x${output}`));
107
- default:
108
- throw new Error(`essential-eth does not yet support "${outputType}" outputs. Make a PR today!"`);
109
- }
110
- });
111
- return outputs.length === 1 ? outputs[0] : outputs;
112
- }
113
- exports.decodeRPCResponse = decodeRPCResponse;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildRPCPostBody = exports.post = void 0;
16
- const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
17
- function post(url, body) {
18
- return (0, isomorphic_unfetch_1.default)(url, {
19
- method: 'POST',
20
- headers: {
21
- 'Content-Type': 'application/json',
22
- },
23
- body: JSON.stringify(body),
24
- })
25
- .then((r) => __awaiter(this, void 0, void 0, function* () {
26
- const t = yield r.text();
27
- try {
28
- return JSON.parse(t);
29
- }
30
- catch (_a) {
31
- throw new Error(`Invalid JSON RPC response: "${t}"`);
32
- }
33
- }))
34
- .then((response) => {
35
- const result = response === null || response === void 0 ? void 0 : response.result;
36
- if (!result) {
37
- throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
38
- }
39
- return response.result;
40
- });
41
- }
42
- exports.post = post;
43
- function buildRPCPostBody(method, params) {
44
- return {
45
- jsonrpc: '2.0',
46
- id: 1,
47
- method,
48
- params,
49
- };
50
- }
51
- exports.buildRPCPostBody = buildRPCPostBody;
@@ -1,5 +0,0 @@
1
- /**
2
- * Converts a hexadecimal string it's decimal equivalent.
3
- * This is needed instead of parseInt because parseInt loses precision
4
- */
5
- export declare function hexToDecimal(hex: string): string;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hexToDecimal = void 0;
4
- /**
5
- * Converts a hexadecimal string it's decimal equivalent.
6
- * This is needed instead of parseInt because parseInt loses precision
7
- */
8
- function hexToDecimal(hex) {
9
- return BigInt(hex).toString();
10
- }
11
- exports.hexToDecimal = hexToDecimal;
package/lib/cjs/index.js DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BaseContract = exports.TinyBig = exports.Contract = exports.computePublicKey = exports.computeAddress = exports.toUtf8Bytes = exports.splitSignature = exports.hashMessage = exports.gweiToEther = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.FallthroughProvider = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToGwei = exports.etherToWei = void 0;
18
- const Contract_1 = require("./classes/Contract");
19
- Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return Contract_1.BaseContract; } });
20
- Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
21
- const FallthroughProvider_1 = require("./providers/FallthroughProvider");
22
- Object.defineProperty(exports, "FallthroughProvider", { enumerable: true, get: function () { return FallthroughProvider_1.FallthroughProvider; } });
23
- const JsonRpcProvider_1 = require("./providers/JsonRpcProvider");
24
- Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return JsonRpcProvider_1.JsonRpcProvider; } });
25
- Object.defineProperty(exports, "jsonRpcProvider", { enumerable: true, get: function () { return JsonRpcProvider_1.jsonRpcProvider; } });
26
- const tiny_big_1 = require("./shared/tiny-big/tiny-big");
27
- Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
28
- Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
29
- const compute_address_1 = require("./utils/compute-address");
30
- Object.defineProperty(exports, "computeAddress", { enumerable: true, get: function () { return compute_address_1.computeAddress; } });
31
- const compute_public_key_1 = require("./utils/compute-public-key");
32
- Object.defineProperty(exports, "computePublicKey", { enumerable: true, get: function () { return compute_public_key_1.computePublicKey; } });
33
- const ether_to_gwei_1 = require("./utils/ether-to-gwei");
34
- Object.defineProperty(exports, "etherToGwei", { enumerable: true, get: function () { return ether_to_gwei_1.etherToGwei; } });
35
- const ether_to_wei_1 = require("./utils/ether-to-wei");
36
- Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
37
- const gwei_to_ether_1 = require("./utils/gwei-to-ether");
38
- Object.defineProperty(exports, "gweiToEther", { enumerable: true, get: function () { return gwei_to_ether_1.gweiToEther; } });
39
- const hash_message_1 = require("./utils/hash-message");
40
- Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return hash_message_1.hashMessage; } });
41
- const is_address_1 = require("./utils/is-address");
42
- Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
43
- const split_signature_1 = require("./utils/split-signature");
44
- Object.defineProperty(exports, "splitSignature", { enumerable: true, get: function () { return split_signature_1.splitSignature; } });
45
- const to_checksum_address_1 = require("./utils/to-checksum-address");
46
- Object.defineProperty(exports, "toChecksumAddress", { enumerable: true, get: function () { return to_checksum_address_1.toChecksumAddress; } });
47
- const to_utf8_bytes_1 = require("./utils/to-utf8-bytes");
48
- Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return to_utf8_bytes_1.toUtf8Bytes; } });
49
- const wei_to_ether_1 = require("./utils/wei-to-ether");
50
- Object.defineProperty(exports, "weiToEther", { enumerable: true, get: function () { return wei_to_ether_1.weiToEther; } });
51
- __exportStar(require("./utils/bytes"), exports);
52
- __exportStar(require("./utils/hash-message"), exports);
53
- __exportStar(require("./utils/keccak256"), exports);
54
- __exportStar(require("./utils/solidity-keccak256"), exports);
@@ -1,11 +0,0 @@
1
- declare class Logger {
2
- private packageVersion;
3
- constructor();
4
- throwError(message: string, args: {
5
- [key: string]: any;
6
- }): never;
7
- throwArgumentError(message: string, arg: string, value: any): never;
8
- checkSafeUint53(value: number, message?: string): void;
9
- }
10
- export declare const logger: Logger;
11
- export {};
@@ -1,36 +0,0 @@
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;
8
- }
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})`);
12
- }
13
- throwArgumentError(message, arg, value) {
14
- throw new Error(`${message} (argument="${arg}" value=${value}, version=essential-eth@${this.packageVersion})`);
15
- }
16
- checkSafeUint53(value, message = 'value not safe') {
17
- if (typeof value !== 'number') {
18
- return;
19
- }
20
- if (value < 0 || value >= 0x1fffffffffffff) {
21
- this.throwError(message, {
22
- operation: 'checkSafeInteger',
23
- fault: 'out-of-safe-range',
24
- value: value,
25
- });
26
- }
27
- if (value % 1) {
28
- this.throwError(message, {
29
- operation: 'checkSafeInteger',
30
- fault: 'non-integer',
31
- value: value,
32
- });
33
- }
34
- }
35
- }
36
- exports.logger = new Logger();
@@ -1 +0,0 @@
1
- export declare const version = "0.5.5";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = void 0;
4
- // Generated by genversion.
5
- exports.version = '0.5.5';