essential-eth 0.9.1 → 0.9.2-beta.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 (205) hide show
  1. package/dist/essential-eth.esm.mjs +2 -0
  2. package/dist/essential-eth.esm.mjs.map +1 -0
  3. package/dist/essential-eth.js +2 -0
  4. package/dist/essential-eth.js.map +1 -0
  5. package/dist/essential-eth.modern.mjs +2 -0
  6. package/dist/essential-eth.modern.mjs.map +1 -0
  7. package/dist/essential-eth.umd.js +2 -0
  8. package/dist/essential-eth.umd.js.map +1 -0
  9. package/dist/logger/package-version.d.ts +1 -0
  10. package/package.json +12 -13
  11. package/readme.md +1 -1
  12. package/dist/cjs/classes/Contract.js +0 -138
  13. package/dist/cjs/classes/test/Contract/crv-abi.js +0 -488
  14. package/dist/cjs/classes/test/Contract/ens-abi.js +0 -453
  15. package/dist/cjs/classes/test/Contract/fei-abi.js +0 -526
  16. package/dist/cjs/classes/test/Contract/foo-abi.js +0 -42
  17. package/dist/cjs/classes/test/Contract/uniswap-abi.js +0 -121
  18. package/dist/cjs/classes/utils/clean-block.js +0 -160
  19. package/dist/cjs/classes/utils/clean-log.js +0 -37
  20. package/dist/cjs/classes/utils/clean-transaction-receipt.js +0 -51
  21. package/dist/cjs/classes/utils/clean-transaction.js +0 -52
  22. package/dist/cjs/classes/utils/encode-decode-transaction.js +0 -177
  23. package/dist/cjs/classes/utils/fetchers.js +0 -94
  24. package/dist/cjs/classes/utils/hex-to-decimal.js +0 -24
  25. package/dist/cjs/classes/utils/prepare-transaction.js +0 -45
  26. package/dist/cjs/index.js +0 -56
  27. package/dist/cjs/index.umd.js +0 -2
  28. package/dist/cjs/index.umd.js.map +0 -1
  29. package/dist/cjs/logger/logger.js +0 -36
  30. package/dist/cjs/logger/package-version.d.ts +0 -1
  31. package/dist/cjs/logger/package-version.js +0 -5
  32. package/dist/cjs/providers/AlchemyProvider.js +0 -11
  33. package/dist/cjs/providers/BaseProvider.js +0 -549
  34. package/dist/cjs/providers/FallthroughProvider.js +0 -73
  35. package/dist/cjs/providers/JsonRpcProvider.js +0 -46
  36. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +0 -152
  37. package/dist/cjs/providers/test/mock-of.js +0 -12
  38. package/dist/cjs/providers/test/rpc-urls.js +0 -25
  39. package/dist/cjs/providers/utils/chains-info.js +0 -71
  40. package/dist/cjs/shared/tiny-big/helpers.js +0 -97
  41. package/dist/cjs/shared/tiny-big/tiny-big.js +0 -101
  42. package/dist/cjs/shared/validate-type.js +0 -9
  43. package/dist/cjs/types/Block.types.js +0 -2
  44. package/dist/cjs/types/Contract.types.js +0 -2
  45. package/dist/cjs/types/FeeData.types.js +0 -2
  46. package/dist/cjs/types/Filter.types.js +0 -2
  47. package/dist/cjs/types/Network.types.js +0 -2
  48. package/dist/cjs/types/Transaction.types.js +0 -2
  49. package/dist/cjs/utils/bytes.js +0 -711
  50. package/dist/cjs/utils/compute-address.js +0 -34
  51. package/dist/cjs/utils/compute-public-key.js +0 -26
  52. package/dist/cjs/utils/ether-to-gwei.js +0 -35
  53. package/dist/cjs/utils/ether-to-wei.js +0 -35
  54. package/dist/cjs/utils/gwei-to-ether.js +0 -35
  55. package/dist/cjs/utils/hash-message.js +0 -30
  56. package/dist/cjs/utils/is-address.js +0 -39
  57. package/dist/cjs/utils/keccak256.js +0 -31
  58. package/dist/cjs/utils/solidity-keccak256.js +0 -138
  59. package/dist/cjs/utils/split-signature.js +0 -163
  60. package/dist/cjs/utils/to-checksum-address.js +0 -46
  61. package/dist/cjs/utils/to-utf8-bytes.js +0 -21
  62. package/dist/cjs/utils/wei-to-ether.js +0 -45
  63. package/dist/esm/classes/Contract.d.ts +0 -11
  64. package/dist/esm/classes/Contract.js +0 -61
  65. package/dist/esm/classes/test/Contract/crv-abi.d.ts +0 -2
  66. package/dist/esm/classes/test/Contract/crv-abi.js +0 -470
  67. package/dist/esm/classes/test/Contract/ens-abi.d.ts +0 -2
  68. package/dist/esm/classes/test/Contract/ens-abi.js +0 -435
  69. package/dist/esm/classes/test/Contract/fei-abi.d.ts +0 -2
  70. package/dist/esm/classes/test/Contract/fei-abi.js +0 -521
  71. package/dist/esm/classes/test/Contract/foo-abi.d.ts +0 -2
  72. package/dist/esm/classes/test/Contract/foo-abi.js +0 -33
  73. package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
  74. package/dist/esm/classes/test/Contract/uniswap-abi.js +0 -116
  75. package/dist/esm/classes/utils/clean-block.d.ts +0 -2
  76. package/dist/esm/classes/utils/clean-block.js +0 -35
  77. package/dist/esm/classes/utils/clean-log.d.ts +0 -2
  78. package/dist/esm/classes/utils/clean-log.js +0 -26
  79. package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +0 -2
  80. package/dist/esm/classes/utils/clean-transaction-receipt.js +0 -35
  81. package/dist/esm/classes/utils/clean-transaction.d.ts +0 -2
  82. package/dist/esm/classes/utils/clean-transaction.js +0 -34
  83. package/dist/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
  84. package/dist/esm/classes/utils/encode-decode-transaction.js +0 -134
  85. package/dist/esm/classes/utils/fetchers.d.ts +0 -15
  86. package/dist/esm/classes/utils/fetchers.js +0 -46
  87. package/dist/esm/classes/utils/hex-to-decimal.d.ts +0 -1
  88. package/dist/esm/classes/utils/hex-to-decimal.js +0 -3
  89. package/dist/esm/classes/utils/prepare-transaction.d.ts +0 -2
  90. package/dist/esm/classes/utils/prepare-transaction.js +0 -34
  91. package/dist/esm/index.d.ts +0 -25
  92. package/dist/esm/index.js +0 -20
  93. package/dist/esm/logger/logger.d.ts +0 -11
  94. package/dist/esm/logger/logger.js +0 -33
  95. package/dist/esm/logger/package-version.d.ts +0 -1
  96. package/dist/esm/logger/package-version.js +0 -1
  97. package/dist/esm/providers/AlchemyProvider.d.ts +0 -4
  98. package/dist/esm/providers/AlchemyProvider.js +0 -7
  99. package/dist/esm/providers/BaseProvider.d.ts +0 -26
  100. package/dist/esm/providers/BaseProvider.js +0 -172
  101. package/dist/esm/providers/FallthroughProvider.d.ts +0 -11
  102. package/dist/esm/providers/FallthroughProvider.js +0 -49
  103. package/dist/esm/providers/JsonRpcProvider.d.ts +0 -7
  104. package/dist/esm/providers/JsonRpcProvider.js +0 -15
  105. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
  106. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +0 -142
  107. package/dist/esm/providers/test/mock-of.d.ts +0 -2
  108. package/dist/esm/providers/test/mock-of.js +0 -1
  109. package/dist/esm/providers/test/rpc-urls.d.ts +0 -12
  110. package/dist/esm/providers/test/rpc-urls.js +0 -19
  111. package/dist/esm/providers/utils/chains-info.d.ts +0 -24
  112. package/dist/esm/providers/utils/chains-info.js +0 -67
  113. package/dist/esm/shared/tiny-big/helpers.d.ts +0 -1
  114. package/dist/esm/shared/tiny-big/helpers.js +0 -58
  115. package/dist/esm/shared/tiny-big/tiny-big.d.ts +0 -10
  116. package/dist/esm/shared/tiny-big/tiny-big.js +0 -45
  117. package/dist/esm/shared/validate-type.d.ts +0 -3
  118. package/dist/esm/shared/validate-type.js +0 -5
  119. package/dist/esm/types/Block.types.d.ts +0 -40
  120. package/dist/esm/types/Block.types.js +0 -1
  121. package/dist/esm/types/Contract.types.d.ts +0 -24
  122. package/dist/esm/types/Contract.types.js +0 -1
  123. package/dist/esm/types/FeeData.types.d.ts +0 -7
  124. package/dist/esm/types/FeeData.types.js +0 -1
  125. package/dist/esm/types/Filter.types.d.ts +0 -12
  126. package/dist/esm/types/Filter.types.js +0 -1
  127. package/dist/esm/types/Network.types.d.ts +0 -5
  128. package/dist/esm/types/Network.types.js +0 -1
  129. package/dist/esm/types/Transaction.types.d.ts +0 -113
  130. package/dist/esm/types/Transaction.types.js +0 -1
  131. package/dist/esm/utils/bytes.d.ts +0 -40
  132. package/dist/esm/utils/bytes.js +0 -245
  133. package/dist/esm/utils/compute-address.d.ts +0 -1
  134. package/dist/esm/utils/compute-address.js +0 -12
  135. package/dist/esm/utils/compute-public-key.d.ts +0 -2
  136. package/dist/esm/utils/compute-public-key.js +0 -6
  137. package/dist/esm/utils/ether-to-gwei.d.ts +0 -3
  138. package/dist/esm/utils/ether-to-gwei.js +0 -7
  139. package/dist/esm/utils/ether-to-wei.d.ts +0 -3
  140. package/dist/esm/utils/ether-to-wei.js +0 -7
  141. package/dist/esm/utils/gwei-to-ether.d.ts +0 -3
  142. package/dist/esm/utils/gwei-to-ether.js +0 -7
  143. package/dist/esm/utils/hash-message.d.ts +0 -2
  144. package/dist/esm/utils/hash-message.js +0 -14
  145. package/dist/esm/utils/is-address.d.ts +0 -1
  146. package/dist/esm/utils/is-address.js +0 -12
  147. package/dist/esm/utils/keccak256.d.ts +0 -2
  148. package/dist/esm/utils/keccak256.js +0 -13
  149. package/dist/esm/utils/solidity-keccak256.d.ts +0 -2
  150. package/dist/esm/utils/solidity-keccak256.js +0 -85
  151. package/dist/esm/utils/split-signature.d.ts +0 -2
  152. package/dist/esm/utils/split-signature.js +0 -126
  153. package/dist/esm/utils/to-checksum-address.d.ts +0 -1
  154. package/dist/esm/utils/to-checksum-address.js +0 -25
  155. package/dist/esm/utils/to-utf8-bytes.d.ts +0 -1
  156. package/dist/esm/utils/to-utf8-bytes.js +0 -3
  157. package/dist/esm/utils/wei-to-ether.d.ts +0 -3
  158. package/dist/esm/utils/wei-to-ether.js +0 -16
  159. /package/dist/{cjs/classes → classes}/Contract.d.ts +0 -0
  160. /package/dist/{cjs/classes → classes}/test/Contract/crv-abi.d.ts +0 -0
  161. /package/dist/{cjs/classes → classes}/test/Contract/ens-abi.d.ts +0 -0
  162. /package/dist/{cjs/classes → classes}/test/Contract/fei-abi.d.ts +0 -0
  163. /package/dist/{cjs/classes → classes}/test/Contract/foo-abi.d.ts +0 -0
  164. /package/dist/{cjs/classes → classes}/test/Contract/uniswap-abi.d.ts +0 -0
  165. /package/dist/{cjs/classes → classes}/utils/clean-block.d.ts +0 -0
  166. /package/dist/{cjs/classes → classes}/utils/clean-log.d.ts +0 -0
  167. /package/dist/{cjs/classes → classes}/utils/clean-transaction-receipt.d.ts +0 -0
  168. /package/dist/{cjs/classes → classes}/utils/clean-transaction.d.ts +0 -0
  169. /package/dist/{cjs/classes → classes}/utils/encode-decode-transaction.d.ts +0 -0
  170. /package/dist/{cjs/classes → classes}/utils/fetchers.d.ts +0 -0
  171. /package/dist/{cjs/classes → classes}/utils/hex-to-decimal.d.ts +0 -0
  172. /package/dist/{cjs/classes → classes}/utils/prepare-transaction.d.ts +0 -0
  173. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  174. /package/dist/{cjs/logger → logger}/logger.d.ts +0 -0
  175. /package/dist/{cjs/providers → providers}/AlchemyProvider.d.ts +0 -0
  176. /package/dist/{cjs/providers → providers}/BaseProvider.d.ts +0 -0
  177. /package/dist/{cjs/providers → providers}/FallthroughProvider.d.ts +0 -0
  178. /package/dist/{cjs/providers → providers}/JsonRpcProvider.d.ts +0 -0
  179. /package/dist/{cjs/providers → providers}/test/json-rpc-provider/get-logs/mocks.d.ts +0 -0
  180. /package/dist/{cjs/providers → providers}/test/mock-of.d.ts +0 -0
  181. /package/dist/{cjs/providers → providers}/test/rpc-urls.d.ts +0 -0
  182. /package/dist/{cjs/providers → providers}/utils/chains-info.d.ts +0 -0
  183. /package/dist/{cjs/shared → shared}/tiny-big/helpers.d.ts +0 -0
  184. /package/dist/{cjs/shared → shared}/tiny-big/tiny-big.d.ts +0 -0
  185. /package/dist/{cjs/shared → shared}/validate-type.d.ts +0 -0
  186. /package/dist/{cjs/types → types}/Block.types.d.ts +0 -0
  187. /package/dist/{cjs/types → types}/Contract.types.d.ts +0 -0
  188. /package/dist/{cjs/types → types}/FeeData.types.d.ts +0 -0
  189. /package/dist/{cjs/types → types}/Filter.types.d.ts +0 -0
  190. /package/dist/{cjs/types → types}/Network.types.d.ts +0 -0
  191. /package/dist/{cjs/types → types}/Transaction.types.d.ts +0 -0
  192. /package/dist/{cjs/utils → utils}/bytes.d.ts +0 -0
  193. /package/dist/{cjs/utils → utils}/compute-address.d.ts +0 -0
  194. /package/dist/{cjs/utils → utils}/compute-public-key.d.ts +0 -0
  195. /package/dist/{cjs/utils → utils}/ether-to-gwei.d.ts +0 -0
  196. /package/dist/{cjs/utils → utils}/ether-to-wei.d.ts +0 -0
  197. /package/dist/{cjs/utils → utils}/gwei-to-ether.d.ts +0 -0
  198. /package/dist/{cjs/utils → utils}/hash-message.d.ts +0 -0
  199. /package/dist/{cjs/utils → utils}/is-address.d.ts +0 -0
  200. /package/dist/{cjs/utils → utils}/keccak256.d.ts +0 -0
  201. /package/dist/{cjs/utils → utils}/solidity-keccak256.d.ts +0 -0
  202. /package/dist/{cjs/utils → utils}/split-signature.d.ts +0 -0
  203. /package/dist/{cjs/utils → utils}/to-checksum-address.d.ts +0 -0
  204. /package/dist/{cjs/utils → utils}/to-utf8-bytes.d.ts +0 -0
  205. /package/dist/{cjs/utils → utils}/wei-to-ether.d.ts +0 -0
@@ -1,160 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanBlock = void 0;
4
- const tiny_big_1 = require("../../shared/tiny-big/tiny-big");
5
- const to_checksum_address_1 = require("../../utils/to-checksum-address");
6
- const clean_transaction_1 = require("./clean-transaction");
7
- const hex_to_decimal_1 = require("./hex-to-decimal");
8
- /**
9
- * Converts RPC block response to more JS-friendly format
10
- *
11
- * @param block the RPCBlock to clean
12
- * @param returnTransactionObjects whether or not to return the transactions specified in this block
13
- * @returns a cleaned block
14
- * @example
15
- * ```js
16
- * const rpcBlock = {
17
- * number: '0x40f9de',
18
- * hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
19
- * parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
20
- * sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
21
- * logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
22
- * transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
23
- * stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
24
- * receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
25
- * miner: '0x1b7a75ef070ff49e6b9491a26403d799f2099ebd',
26
- * difficulty: '0x47ede14fcbe635706e',
27
- * totalDifficulty: '0x139e1de9b8404dedc5d30959',
28
- * extraData: '0xce018c495249532d62613031656132',
29
- * size: '0xb4f',
30
- * gasLimit: '0x67c280',
31
- * gasUsed: '0x56e2d',
32
- * timestamp: '0x62648dc2',
33
- * transactions: [
34
- * '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
35
- * '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
36
- * '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
37
- * '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
38
- * '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
39
- * ],
40
- * uncles: [
41
- * '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
42
- * ],
43
- * minimumGasPrice: '0x387ee40',
44
- * bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
45
- * bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
46
- * bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
47
- * hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
48
- * paidFees: '0x1fb451615b58',
49
- * cumulativeDifficulty: '0x8fdbe015f7248cf993'
50
- * };
51
- * const returnTransactionObjects = false;
52
- *
53
- * await cleanBlock(rpcBlock, returnTransactionObjects);
54
- * // {
55
- * // number: 4258270,
56
- * // hash: '0x4cbaa942e48a91108f38e2a250f6dbaff7fffe3027f5ebf76701929eed2b2970',
57
- * // parentHash: '0xc8de1e513f74cbc5cc77e2a39e4cada6504469a5d0e87200b708319c1e9ef154',
58
- * // sha3Uncles: '0x04d250716296c9662314b37c112e5ce8b1c9ad7fd7820a39482a3688a2078f2b',
59
- * // logsBloom: '0x0000400004000000040010100200000000000000000000000000000000000000001000000001000000000000000000000004010000000000000a800000000000040000000001000400000000000000000000000000000000000002000000000000000000000004000040000000800000000001000000000000000000000000000000000000000001000000000004200000000000000000000000000124400000000000000200100020000000000000000080000000000080001000000000000000000081000000000000000000008000000020000100000000200020100800000000000000000008002000000080001000020c00000000000000200000000000',
60
- * // transactionsRoot: '0xfc79f4f620cb69861ac67ceee5e1ddf3e45da95be230d4064be234f1ee491aa5',
61
- * // stateRoot: '0xfa5ef7e368997d70670b0ea3172aabefc2dee285786ce69c7165d8d854f8b292',
62
- * // receiptsRoot: '0x7fa0679e88fef8a8f7f5865dc4e6000ddcc267b14d2904948e3b1576a18a3bbd',
63
- * // miner: '0x1b7A75Ef070Ff49E6B9491a26403D799f2099EbD',
64
- * // difficulty: Big {
65
- * // s: 1,
66
- * // e: 21,
67
- * // c: [Array],
68
- * // constructor: [Function],
69
- * // padAndChop: [Function (anonymous)]
70
- * // },
71
- * // totalDifficulty: Big {
72
- * // s: 1,
73
- * // e: 27,
74
- * // c: [Array],
75
- * // constructor: [Function],
76
- * // padAndChop: [Function (anonymous)]
77
- * // },
78
- * // extraData: '0xce018c495249532d62613031656132',
79
- * // size: Big {
80
- * // s: 1,
81
- * // e: 3,
82
- * // c: [Array],
83
- * // constructor: [Function],
84
- * // padAndChop: [Function (anonymous)]
85
- * // },
86
- * // gasLimit: Big {
87
- * // s: 1,
88
- * // e: 6,
89
- * // c: [Array],
90
- * // constructor: [Function],
91
- * // padAndChop: [Function (anonymous)]
92
- * // },
93
- * // gasUsed: Big {
94
- * // s: 1,
95
- * // e: 5,
96
- * // c: [Array],
97
- * // constructor: [Function],
98
- * // padAndChop: [Function (anonymous)]
99
- * // },
100
- * // timestamp: Big {
101
- * // s: 1,
102
- * // e: 9,
103
- * // c: [Array],
104
- * // constructor: [Function],
105
- * // padAndChop: [Function (anonymous)]
106
- * // },
107
- * // transactions: [
108
- * // '0xd53800afc69e55cc7a64b927803b46a5b4c5ddccbaafb6b32fe0ec883739b825',
109
- * // '0x4b8b07f35a1f911a80a0ffeebe3d3c41cd393b4d5e1ce0a408026705913d6760',
110
- * // '0xa50eac0ea8005cb1e4b95be4e64c24035d9c41adb164c49477c3169870f02fb1',
111
- * // '0x413e5293786f8b63e73adf0b74ab56067da4b564d01936b88b138d48cc414a42',
112
- * // '0xd4e4969365d144b0b987632dca36ba9e272254bdc687245987a57666d6afa148'
113
- * // ],
114
- * // uncles: [
115
- * // '0x36cd3869fd17a285b984dea8b705d34096e1fbdfe48df69ae530fbe921ba83fa'
116
- * // ],
117
- * // minimumGasPrice: '0x387ee40',
118
- * // bitcoinMergedMiningHeader: '0x0040502d717ae205da048b0ffb8e110603564d8677ca8bd3a54601000000000000000000e722e86bfebcae00bffb46c663fa0241b63a27f0c98fa710e421d5cc1afa2448d08d6462d9f809172f5e30aa',
119
- * // bitcoinMergedMiningCoinbaseTransaction: '0x00000000000001003f8757a906f0159f882f0968788a2e396b7bf8090e1b926fb2bb46789ac32d55082aca4e0800000000000000002b6a2952534b424c4f434b3a831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de00000000',
120
- * // bitcoinMergedMiningMerkleProof: '0xb53111a4e11bc19bf90268485d1b957d908ebc6a4cd9862aca3fc6ed3dcf3240b14c316de8521369d55dbfeb2b0116bcc10f40e999c4885e1bd2a08691bdea1c43862d590390a227a379d5677b958f1a23eecc16ac590ad675b8a4cea0c10da3ef597acb9ca1fe0a21fc408f09e0c7169d83aca8ddd636d8cc155f922e1d36c74b7cc11e9ee98dd1bf2100a55d59630c65da3db1575d58f165c5753c1779df90efcff9017b73cc32f4c87178bd0eae6a6dd0357047be70d6c4af17fcef097e80a9f1751447f4eee3831fc79f2d894934694149bcb99840a525f5128215eca6b54642af452ee7568a9281f40560afffd35725df31b98155d7813dea12e42f2a8052c7d98bcf62c9cdc66c40fb12b729b685a31aec4970ea5316640691ae5eb616808656a2bde4e9f5920ff178bf9d1f84e96a0d0bd048a3a8ca0d60970d02aacf7ecfb6e7feaec5c4a764873531cfd630e9430840cfe8b88154da25d6b94b706fe678d0efc1ecafed5a1f539e34552bea65622513b663e17e121f3c4548942584',
121
- * // hashForMergedMining: '0x831a30935da1bd1e8631942fc7fa78f7a7b11d51ca39a1684d91a81f0040f9de',
122
- * // paidFees: '0x1fb451615b58',
123
- * // cumulativeDifficulty: '0x8fdbe015f7248cf993'
124
- * // }
125
- */
126
- function cleanBlock(block, returnTransactionObjects) {
127
- const cleanedBlock = Object.assign({}, block);
128
- Object.keys(block).forEach((key) => {
129
- // pending blocks have null instead of a difficulty
130
- // pending blocks have null instead of a miner address
131
- if (!block[key])
132
- return;
133
- switch (key) {
134
- case 'difficulty':
135
- case 'totalDifficulty':
136
- case 'gasLimit':
137
- case 'gasUsed':
138
- case 'size':
139
- case 'timestamp':
140
- case 'baseFeePerGas':
141
- cleanedBlock[key] = (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(block[key]));
142
- break;
143
- case 'number':
144
- cleanedBlock[key] = Number((0, hex_to_decimal_1.hexToDecimal)(block[key]));
145
- break;
146
- case 'miner':
147
- cleanedBlock[key] = (0, to_checksum_address_1.toChecksumAddress)(block[key]);
148
- break;
149
- }
150
- });
151
- // for all full transactions
152
- if (returnTransactionObjects) {
153
- const txns = block.transactions;
154
- txns.forEach((transaction, index) => {
155
- cleanedBlock.transactions[index] = (0, clean_transaction_1.cleanTransaction)(transaction);
156
- });
157
- }
158
- return cleanedBlock;
159
- }
160
- exports.cleanBlock = cleanBlock;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanLog = void 0;
4
- const to_checksum_address_1 = require("../../utils/to-checksum-address");
5
- const hex_to_decimal_1 = require("./hex-to-decimal");
6
- /**
7
- * Converts RPC log receipt response to more JS-friendly format
8
- *
9
- * @param log the log to clean
10
- * @param receiptLog if the log is part of a transaction receipt. Used to remove certain keys from log
11
- * @example
12
- */
13
- function cleanLog(log, receiptLog) {
14
- const cleanedLog = Object.assign({}, log);
15
- Object.keys(log).forEach((key) => {
16
- switch (key) {
17
- case 'address':
18
- cleanedLog[key] = (0, to_checksum_address_1.toChecksumAddress)(log[key]);
19
- break;
20
- case 'blockNumber':
21
- case 'logIndex':
22
- case 'transactionIndex':
23
- cleanedLog[key] = Number((0, hex_to_decimal_1.hexToDecimal)(log[key]));
24
- break;
25
- case 'removed':
26
- if (receiptLog) {
27
- delete cleanedLog[key];
28
- }
29
- else if (log[key] == null) {
30
- cleanedLog[key] === false;
31
- }
32
- break;
33
- }
34
- });
35
- return cleanedLog;
36
- }
37
- exports.cleanLog = cleanLog;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanTransactionReceipt = void 0;
4
- const tiny_big_1 = require("../../shared/tiny-big/tiny-big");
5
- const to_checksum_address_1 = require("../../utils/to-checksum-address");
6
- const clean_log_1 = require("./clean-log");
7
- const clean_transaction_1 = require("./clean-transaction");
8
- const hex_to_decimal_1 = require("./hex-to-decimal");
9
- /**
10
- * Converts RPC transaction receipt response to more JS-friendly format
11
- *
12
- * @param transactionReceipt the transaction receipt to clean
13
- * @returns a cleaned transaction receipt
14
- * @example
15
- * ```javascript
16
- * const RPCTransactionReceipt = { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', contractAddress: null, cumulativeGasUsed: '0x37a2b9', effectiveGasPrice: '0x62df1c62c', from: '0x642824fab1d0141073ed74326332950bec4701e3', gasUsed: '0x1a325', logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: '0x1', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: '0x29', type: '0x2' }
17
- * cleanTransactionReceipt(RPCTransactionReceipt);
18
- * // { blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, contractAddress: null, cumulativeGasUsed: Big { s: 1, e: 6, c: [ 3, 6, 4, 6, 1, 3, 7 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, effectiveGasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gasUsed: Big { s: 1, e: 5, c: [ 1, 0, 7, 3, 0, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, logs: [ { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 84, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074d' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 85, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074e' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 86, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x000000000000000000000000000000000000000000000000000000000000074f' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 87, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000750' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 88, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000751' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 89, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000752' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 90, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000753' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 91, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000754' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 92, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000755' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 }, { address: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, data: '0x', logIndex: 93, topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000642824fab1d0141073ed74326332950bec4701e3', '0x0000000000000000000000000000000000000000000000000000000000000756' ], transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41 } ], logsBloom: '0x20000080004000000000000400000000000001000000000400000000000000000000000000000000000000000008000000000000000000000000000000004000000000000008000000000008000000010080000014000004000000000000000000100000020800000000000000001800000080000000002000000010000000000000000000000200000200000000002000000000000400000000000000000000000000000000000000000040000000000000000100000000000000000000040002100002000000000000080000000000000100000002000000040000001220000000000000000000000000000000000000000000000000000000000000004000', status: 1, to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionHash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', transactionIndex: 41, type: 2, byzantium: true, confirmations: 40 }
19
- * ```
20
- */
21
- function cleanTransactionReceipt(transactionReceipt) {
22
- const cleanedTransaction = (0, clean_transaction_1.cleanTransaction)(transactionReceipt);
23
- const cleanedTransactionReceipt = Object.assign({}, cleanedTransaction);
24
- Object.keys(transactionReceipt).forEach((key) => {
25
- if (!transactionReceipt[key])
26
- return;
27
- switch (key) {
28
- case 'status':
29
- cleanedTransactionReceipt[key] = Number((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
30
- break;
31
- case 'contractAddress':
32
- if (transactionReceipt[key]) {
33
- cleanedTransactionReceipt[key] = (0, to_checksum_address_1.toChecksumAddress)(transactionReceipt[key]);
34
- }
35
- break;
36
- case 'cumulativeGasUsed':
37
- case 'effectiveGasPrice':
38
- case 'gasUsed':
39
- cleanedTransactionReceipt[key] = (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transactionReceipt[key]));
40
- break;
41
- case 'logs':
42
- transactionReceipt[key].forEach((log, index) => {
43
- cleanedTransactionReceipt[key][index] = (0, clean_log_1.cleanLog)(log, true);
44
- });
45
- }
46
- });
47
- cleanedTransactionReceipt.byzantium =
48
- cleanedTransactionReceipt.blockNumber >= 4370000;
49
- return cleanedTransactionReceipt;
50
- }
51
- exports.cleanTransactionReceipt = cleanTransactionReceipt;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanTransaction = void 0;
4
- const tiny_big_1 = require("../../shared/tiny-big/tiny-big");
5
- const to_checksum_address_1 = require("../../utils/to-checksum-address");
6
- const hex_to_decimal_1 = require("./hex-to-decimal");
7
- /**
8
- * Converts RPC transaction response to more JS-friendly format
9
- *
10
- * @param transaction the transaction to clean
11
- * @returns a cleaned transaction
12
- * @example
13
- * ```javascript
14
- * const RPCTransaction = { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: '0xe28f62', chainId: '0x1', from: '0x642824fab1d0141073ed74326332950bec4701e3', gas: '0x274b7', gasPrice: '0x62df1c62c', hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: '0x98808e3f0', maxPriorityFeePerGas: '0x3b9aca00', nonce: '0x42', r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84f80ea01e26b7c11bdd241970982c7eeab6ddcc', transactionIndex: '0x29', type: '0x2', v: '0x1', value: '0x470de4df820000' }
15
- * cleanTransaction(RPCTransaction);
16
- * // { accessList: [], blockHash: '0x03ddc6a835462f750fcaf5ab511d8c48121b0813e3e80de84d7adc3ef192b7bf', blockNumber: 14847842, chainId: 1, from: '0x642824FaB1D0141073ed74326332950bEc4701e3', gas: Big { s: 1, e: 5, c: [ 1, 6, 0, 9, 5, 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, gasPrice: Big { s: 1, e: 10, c: [ 2, 6, 5, 4, 0, 6, 2, 3, 4, 0, 4 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, hash: '0xd0befcb9d10a89aba2d488534811bf5c62a889e2499d23cdd83c2a2200cde873', input: '0xa0712d68000000000000000000000000000000000000000000000000000000000000000a', maxFeePerGas: Big { s: 1, e: 10, c: [ 4, 0, 9, 3, 6, 9, 8, 9, 6, 8 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, maxPriorityFeePerGas: Big { s: 1, e: 9, c: [ 1 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, nonce: 66, r: '0x304682f8b22006dd1347c3722f6e43a5ad8e3a1ae51939cc0d6f07981602f5c0', s: '0x207ad110eb5c014cb628814b92396785fabfbe74542293300eeadf156f50f105', to: '0x84F80EA01e26B7C11bdd241970982C7EEAb6DdcC', transactionIndex: 41, type: 2, v: 1, value: Big { s: 1, e: 16, c: [ 2 ], constructor: { [λ: Big] DP: 20, RM: 1, NE: -7, PE: 21, strict: false, roundDown: 0, roundHalfUp: 1, roundHalfEven: 2, roundUp: 3, Big: [Circular], default: [Circular] }, padAndChop: [λ] }, confirmations: 53 }
17
- * ```
18
- */
19
- function cleanTransaction(transaction) {
20
- const cleanedTransaction = Object.assign({}, transaction);
21
- Object.keys(transaction).forEach((key) => {
22
- // pending blocks have null instead of a difficulty
23
- // pending blocks have null instead of a miner address
24
- if (!transaction[key])
25
- return;
26
- switch (key) {
27
- case 'blockNumber':
28
- case 'chainId':
29
- case 'transactionIndex':
30
- case 'type':
31
- case 'v':
32
- cleanedTransaction[key] = Number((0, hex_to_decimal_1.hexToDecimal)(transaction[key]));
33
- break;
34
- case 'from':
35
- case 'to':
36
- if (transaction[key]) {
37
- cleanedTransaction[key] = (0, to_checksum_address_1.toChecksumAddress)(transaction[key]);
38
- }
39
- break;
40
- case 'value':
41
- case 'gas':
42
- case 'gasPrice':
43
- case 'maxFeePerGas':
44
- case 'maxPriorityFeePerGas':
45
- case 'nonce':
46
- cleanedTransaction[key] = (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(transaction[key]));
47
- break;
48
- }
49
- });
50
- return cleanedTransaction;
51
- }
52
- exports.cleanTransaction = cleanTransaction;
@@ -1,177 +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 tiny_big_1 = require("../../shared/tiny-big/tiny-big");
6
- const to_checksum_address_1 = require("../../utils/to-checksum-address");
7
- const hex_to_decimal_1 = require("./hex-to-decimal");
8
- exports.hexFalse = '0'.repeat(64);
9
- const hexTrue = '0'.repeat(63) + '1';
10
- /**
11
- * @param hex
12
- * @example
13
- */
14
- function hexToUtf8(hex) {
15
- let str = '';
16
- let i = 0;
17
- const l = hex.length;
18
- if (hex.substring(0, 2) === '0x') {
19
- i = 2;
20
- }
21
- for (; i < l; i += 2) {
22
- const code = parseInt(hex.substr(i, 2), 16);
23
- if (code === 0)
24
- continue; // Skip null bytes
25
- str += String.fromCharCode(code);
26
- }
27
- try {
28
- return decodeURIComponent(escape(str)); // Convert UTF-8 to Unicode
29
- }
30
- catch (e) {
31
- return str; // Return original string if conversion fails
32
- }
33
- }
34
- /**
35
- * Expands an integer type to use a default of 256 bits. Used for consistency; not required in Solidity
36
- *
37
- * @see https://ethereum.stackexchange.com/questions/43241/why-write-uint256-instead-of-uint-if-theyre-the-same-thing
38
- * @param type the type to explicitly define as 256 bits
39
- * @returns the integer type expanded to explicitly be 256 bits when possible
40
- * @example
41
- * ```javascript
42
- * expandType('uint[]');
43
- * // 'uint256[]'
44
- * ```
45
- */
46
- function expandType(type) {
47
- // https://docs.soliditylang.org/en/v0.8.7/types.html#integers
48
- if (type === 'uint[]') {
49
- return 'uint256[]';
50
- }
51
- else if (type === 'int[]') {
52
- return 'int256[]';
53
- }
54
- return type;
55
- }
56
- /**
57
- *
58
- * @param jsonABIArgument
59
- * @param args
60
- * @example
61
- */
62
- function encodeData(jsonABIArgument, args) {
63
- const hash = new sha3_1.Keccak(256);
64
- /* first 4 bytes will create the data parameter */
65
- const functionString = `${jsonABIArgument.name}(${jsonABIArgument.inputs.map((input) => expandType(input.type))})`;
66
- // encoding learnt from https://ethereum.stackexchange.com/questions/3514/how-to-call-a-contract-method-using-the-eth-call-json-rpc-api
67
- const functionHash = hash.update(functionString).digest('hex');
68
- // no arrays
69
- const jsonABIInputsLength = jsonABIArgument.inputs.length;
70
- let shouldValidateInputLength = true;
71
- // inputs contains 1 or more arrays
72
- if (jsonABIArgument.inputs.find((input) => input.type.includes('['))) {
73
- shouldValidateInputLength = false;
74
- }
75
- if (shouldValidateInputLength && args.length !== jsonABIInputsLength) {
76
- throw new Error(`args inputs of "${args.length}" does not match expected length of "${jsonABIArgument.inputs.length}"`);
77
- }
78
- const argsWithTypes = (jsonABIArgument.inputs || []).reduce((acc, input, i) => {
79
- var _a;
80
- if (input.type.includes('[')) {
81
- // strip array and length like "[2]" from type
82
- const basicType = (_a = /([^[]*)\[.*$/g.exec(input.type)) === null || _a === void 0 ? void 0 : _a[1];
83
- args.forEach((arg) => {
84
- acc = acc.concat([[arg, basicType]]);
85
- });
86
- return acc;
87
- }
88
- else {
89
- return acc.concat([[args[i], input.type]]);
90
- }
91
- }, []);
92
- const encodedArgs = argsWithTypes.map(([arg, inputType]) => {
93
- let rawArg = arg;
94
- switch (inputType) {
95
- case 'bool':
96
- return arg ? hexTrue : exports.hexFalse;
97
- case 'address':
98
- // remove leading "0x"
99
- rawArg = arg.replace(/^0x/g, '').toLowerCase();
100
- break;
101
- default:
102
- if (inputType.startsWith('bytes')) {
103
- // encode each character to hex
104
- const argEncoded = rawArg
105
- .split('')
106
- .map((character) => character.charCodeAt(0).toString(16))
107
- .join('');
108
- const paddedEncodedArg = argEncoded.padEnd(64, '0');
109
- return paddedEncodedArg;
110
- }
111
- else if (inputType === 'uint256') {
112
- const argEncoded = BigInt(arg).toString(16);
113
- const paddedEncodedArg = argEncoded.padStart(64, '0');
114
- return paddedEncodedArg;
115
- }
116
- else if (inputType.startsWith('uint')) {
117
- break;
118
- }
119
- else {
120
- throw new Error(`essential-eth does not yet support "${inputType}" inputs. Make a PR today!"`);
121
- }
122
- }
123
- const argEncoded = rawArg.toString(16);
124
- const paddedEncodedArg = argEncoded.padStart(64, '0');
125
- return paddedEncodedArg;
126
- });
127
- const functionEncoded = functionHash.slice(0, 8);
128
- const data = `0x${functionEncoded}${encodedArgs.join('')}`;
129
- return data;
130
- }
131
- exports.encodeData = encodeData;
132
- /**
133
- * @internal
134
- * @param jsonABIArgument
135
- * @param nodeResponse
136
- * @example
137
- */
138
- function decodeRPCResponse(jsonABIArgument, nodeResponse) {
139
- var _a;
140
- const rawOutputs = jsonABIArgument.outputs;
141
- const slicedResponse = nodeResponse.slice(2);
142
- if (((_a = jsonABIArgument === null || jsonABIArgument === void 0 ? void 0 : jsonABIArgument.outputs) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
143
- jsonABIArgument.outputs[0].type === 'string') {
144
- const [hexOffset, responseData] = [
145
- slicedResponse.slice(0, 64),
146
- slicedResponse.slice(64),
147
- ];
148
- const decimalOffset = Number((0, hex_to_decimal_1.hexToDecimal)(`0x${hexOffset}`));
149
- const hexLength = responseData.slice(0, decimalOffset * 2);
150
- const decimalLength = Number((0, hex_to_decimal_1.hexToDecimal)(`0x${hexLength}`));
151
- const hexToDecode = responseData.slice(decimalOffset * 2, decimalOffset * 2 + decimalLength * 2);
152
- return hexToUtf8(hexToDecode);
153
- }
154
- // chunk response every 64 characters
155
- const encodedOutputs = slicedResponse.match(/.{1,64}/g);
156
- const outputs = (encodedOutputs || []).map((output, i) => {
157
- const outputType = (rawOutputs || [])[i].type;
158
- switch (outputType) {
159
- case 'bool':
160
- return output === hexTrue;
161
- case 'address':
162
- /* address types have 24 leading zeroes to remove */
163
- return (0, to_checksum_address_1.toChecksumAddress)(`0x${output.slice(24)}`);
164
- case 'uint256':
165
- case 'uint120':
166
- return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(`0x${output}`));
167
- case 'bytes32':
168
- return `0x${output}`;
169
- case 'uint8':
170
- return Number((0, hex_to_decimal_1.hexToDecimal)(`0x${output}`));
171
- default:
172
- throw new Error(`essential-eth does not yet support "${outputType}" outputs. Make a PR today!"`);
173
- }
174
- });
175
- return outputs.length === 1 ? outputs[0] : outputs;
176
- }
177
- exports.decodeRPCResponse = decodeRPCResponse;
@@ -1,94 +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 = exports.buildFetchInit = void 0;
16
- const isomorphic_unfetch_1 = __importDefault(require("isomorphic-unfetch"));
17
- /**
18
- * Forms the init field for http fetching
19
- *
20
- * @param body
21
- * @internal
22
- */
23
- function buildFetchInit(body) {
24
- return {
25
- method: 'POST',
26
- headers: {
27
- 'Content-Type': 'application/json',
28
- },
29
- body: JSON.stringify(body),
30
- };
31
- }
32
- exports.buildFetchInit = buildFetchInit;
33
- /**
34
- * Makes a post request with the specified JSON data, normally to the a Ethereum JSON RPC API endpoint
35
- *
36
- * @internal
37
- * @param url the URL to send the request to
38
- * @param body JSON POST body
39
- * @returns the JSON response from the server
40
- * @example
41
- * ```javascript
42
- * post('https://free-eth-node.com/api/eth', { jsonrpc: '2.0', id: 1, method: 'eth_gasPrice', params: [] });
43
- * // '0x66fa8dbfd'
44
- *
45
- * post('https://free-eth-node.com/api/eth', { jsonrpc: '2.0', id: 1, method: 'eth_getBalance', params: [ '0x4a986a6dCA6dbf99bC3d17F8D71aFb0d60e740f8', 'latest' ] });
46
- * // '0x312faeb995df61d4'
47
- * ```
48
- */
49
- function post(url, body) {
50
- return (0, isomorphic_unfetch_1.default)(url, buildFetchInit(body))
51
- .then((r) => __awaiter(this, void 0, void 0, function* () {
52
- const t = yield r.text();
53
- try {
54
- return JSON.parse(t);
55
- }
56
- catch (_a) {
57
- throw new Error(`Invalid JSON RPC response: "${t}"`);
58
- }
59
- }))
60
- .then((response) => {
61
- const result = response === null || response === void 0 ? void 0 : response.result;
62
- if (!result) {
63
- throw new Error(`Invalid JSON RPC response: ${JSON.stringify(response)}`);
64
- }
65
- return response.result;
66
- });
67
- }
68
- exports.post = post;
69
- /**
70
- * Prepares data to be sent using the {@link post} function. Data is prepared per the {@link https://en.wikipedia.org/wiki/JSON-RPC#Examples JSON RPC v2 spec}
71
- *
72
- * @internal
73
- * @param method the RPC method to be invoked
74
- * @param params the parameters to be passed to the defined method
75
- * @returns a POST method body matching the {@link https://en.wikipedia.org/wiki/JSON-RPC#Examples JSON RPC v2 spec}
76
- * @example
77
- * ```javascript
78
- * buildRPCPostBody('eth_gasPrice', []);
79
- * // { jsonrpc: '2.0', id: 1, method: 'eth_gasPrice', params: [] }
80
- *
81
- * buildRPCPostBody('eth_getBalance', ['0x407d73d8a49eeb85d32cf465507dd71d507100c1', 'latest']);
82
- * // { jsonrpc: '2.0', id: 1, method: 'eth_getBalance', params: [ '0x4a986a6dCA6dbf99bC3d17F8D71aFb0d60e740f8', 'latest' ] }
83
- * ```
84
- */
85
- function buildRPCPostBody(method, params) {
86
- return {
87
- jsonrpc: '2.0',
88
- // TODO: Increment ID will be needed when websocket support is added
89
- id: 1,
90
- method,
91
- params,
92
- };
93
- }
94
- exports.buildRPCPostBody = buildRPCPostBody;
@@ -1,24 +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
- * @param hex the hex string to be converted to decimal
9
- * @returns a decimal value equivalent to the hex string given
10
- * @example
11
- * ```javascript
12
- * hexToDecimal('0x34');
13
- * // 52
14
- * ```
15
- * @example
16
- * ```javascript
17
- * hexToDecimal('0x628608');
18
- * // 6456840
19
- * ```
20
- */
21
- function hexToDecimal(hex) {
22
- return BigInt(hex).toString();
23
- }
24
- exports.hexToDecimal = hexToDecimal;