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,284 +0,0 @@
1
- import { TinyBig } from '../shared/tiny-big/tiny-big';
2
- import { BlockResponse, BlockTag } from '../types/Block.types';
3
- import { Network } from '../types/Network.types';
4
- import { TransactionReceipt, TransactionResponse } from '../types/Transaction.types';
5
- export declare abstract class BaseProvider {
6
- /**
7
- * ignore
8
- */
9
- abstract selectRpcUrl(): string;
10
- abstract post(body: Record<string, unknown>): Promise<any>;
11
- /**
12
- * @ignore
13
- */
14
- readonly _rpcUrls: string[];
15
- /**
16
- * @ignore
17
- */
18
- protected _post: (body: Record<string, unknown>) => Promise<any>;
19
- /**
20
- * @param rpcUrl The URL to your Eth node. Consider POKT or Infura
21
- */
22
- constructor(rpcUrls: string[]);
23
- /**
24
- * Returns the network this provider is connected to
25
- */
26
- getNetwork(): Promise<Network>;
27
- /**
28
- * Gets the number of the most recently mined block on the network the provider is connected to
29
- *
30
- * * Identical to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber)
31
- * * Identical to [`web3.eth.getBlockNumber`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getblocknumber)
32
- *
33
- * @returns the number of the most recently mined block
34
- * @example
35
- * ```js
36
- * await provider.getBlockNumber();
37
- * // 1053312
38
- * ```
39
- */
40
- getBlockNumber(): Promise<number>;
41
- /**
42
- * * Similar to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction), some information not included
43
- *
44
- * @returns information about one transaction
45
- * @example
46
- * ```js
47
- * await provider.getTransaction('0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789');
48
- * {
49
- * accessList: [],
50
- * blockHash: '0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d',
51
- * blockNumber: 14578286,
52
- * chainId: 1,
53
- * from: '0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4',
54
- * gas: Big {
55
- * s: 1,
56
- * e: 5,
57
- * c: [ 1, 1, 2, 1, 6, 3 ],
58
- * constructor: <ref *1> [Function: Big] {
59
- * DP: 20,
60
- * RM: 1,
61
- * NE: -7,
62
- * PE: 21,
63
- * strict: false,
64
- * roundDown: 0,
65
- * roundHalfUp: 1,
66
- * roundHalfEven: 2,
67
- * roundUp: 3,
68
- * Big: [Circular *1],
69
- * default: [Circular *1]
70
- * }
71
- * },
72
- * gasPrice: Big {
73
- * s: 1,
74
- * e: 10,
75
- * c: [
76
- * 4, 8, 5, 9, 2,
77
- * 4, 2, 6, 8, 5,
78
- * 8
79
- * ],
80
- * constructor: <ref *1> [Function: Big] {
81
- * DP: 20,
82
- * RM: 1,
83
- * NE: -7,
84
- * PE: 21,
85
- * strict: false,
86
- * roundDown: 0,
87
- * roundHalfUp: 1,
88
- * roundHalfEven: 2,
89
- * roundUp: 3,
90
- * Big: [Circular *1],
91
- * default: [Circular *1]
92
- * }
93
- * },
94
- * hash: '0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789',
95
- * input: '0x83259f170000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009e99ad11a214fd016b19dc3648678c5944859ae292b21c24ca94f857836c4596f1950c82dd0c23dd621af4763edc2f66466e63c5df9de0c1107b1cd16bf460fe93e43fd308e3444bc79c3d88a4cb961dc8367ab6ad048867afc76d193bca99cf3a068864ed4a7df1dbf1d4c52238eced3e5e05644b4040fc2b3ccb8557b0e99fff6131305a0ea2b8061b90bd418db5bbdd2e92129f52d93f90531465e309c4caec5b85285822b6196398d36f16f511811b61bbda6461e80e29210cd303118bdcee8df6fa0505ffbe8642094fd2ba4dd458496fe3b459ac880bbf71877c713e969ccf5ed7efab8a84ebc07e3939901371ca427e1192e455a8f35a6a1d7ad09e1475dd1758b36fa631dab5d70e99316b23c4c43094188d360cd9c3457355904e07c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000162074a7047f',
96
- * maxFeePerGas: Big {
97
- * s: 1,
98
- * e: 10,
99
- * c: [
100
- * 6, 7, 6, 8, 1,
101
- * 2, 6, 1, 6, 1,
102
- * 8
103
- * ],
104
- * constructor: <ref *1> [Function: Big] {
105
- * DP: 20,
106
- * RM: 1,
107
- * NE: -7,
108
- * PE: 21,
109
- * strict: false,
110
- * roundDown: 0,
111
- * roundHalfUp: 1,
112
- * roundHalfEven: 2,
113
- * roundUp: 3,
114
- * Big: [Circular *1],
115
- * default: [Circular *1]
116
- * }
117
- * },
118
- * maxPriorityFeePerGas: Big {
119
- * s: 1,
120
- * e: 9,
121
- * c: [ 1, 5 ],
122
- * constructor: <ref *1> [Function: Big] {
123
- * DP: 20,
124
- * RM: 1,
125
- * NE: -7,
126
- * PE: 21,
127
- * strict: false,
128
- * roundDown: 0,
129
- * roundHalfUp: 1,
130
- * roundHalfEven: 2,
131
- * roundUp: 3,
132
- * Big: [Circular *1],
133
- * default: [Circular *1]
134
- * }
135
- * },
136
- * nonce: 129,
137
- * r: '0x59a7c15b12c18cd68d6c440963d959bff3e73831ffc938e75ecad07f7ee43fbc',
138
- * s: '0x1ebaf05f0d9273b16c2a7748b150a79d22533a8cd74552611cbe620fee3dcf1c',
139
- * to: '0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B',
140
- * transactionIndex: 29,
141
- * type: 2,
142
- * v: 0,
143
- * value: Big {
144
- * s: 1,
145
- * e: 0,
146
- * c: [ 0 ],
147
- * constructor: <ref *1> [Function: Big] {
148
- * DP: 20,
149
- * RM: 1,
150
- * NE: -7,
151
- * PE: 21,
152
- * strict: false,
153
- * roundDown: 0,
154
- * roundHalfUp: 1,
155
- * roundHalfEven: 2,
156
- * roundUp: 3,
157
- * Big: [Circular *1],
158
- * default: [Circular *1]
159
- * }
160
- * },
161
- * confirmations: 1210
162
- * }
163
- * ```
164
- */
165
- getTransaction(transactionHash: string): Promise<TransactionResponse>;
166
- /**
167
- * Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by `getTransaction()`
168
- *
169
- * * Similar to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt), some information not included
170
- *
171
- * @param transactionHash the hash of the transaction to get information about
172
- *
173
- */
174
- getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
175
- /**
176
- * Returns the transaction count from genesis up to specified blockTag
177
- *
178
- * * Same as `ethers.provider.getTransactionCount`
179
- * * Same as `web3.eth.getTransactionCount`
180
- *
181
- * @example
182
- * ```js
183
- * const address = '0x71660c4005ba85c37ccec55d0c4493e66fe775d3';
184
- * await provider
185
- * .getTransactionCount(address, 'latest')
186
- * // 1060000
187
- * ```
188
- *
189
- * @example
190
- * ```js
191
- * await provider
192
- * .getTransactionCount(address)
193
- * // 1053312
194
- * ```
195
- *
196
- * @example
197
- * ```js
198
- * await provider
199
- * .getTransactionCount(address, 14649390)
200
- * // 1053312
201
- * ```
202
- */
203
- getTransactionCount(address: string, blockTag?: BlockTag): Promise<number>;
204
- /**
205
- * Gets information about a certain block.
206
- * Same as `web3.eth.getBlock` and `ethers.providers.getBlock`
207
- *
208
- * @param timeFrame The number, hash, or text-based description ('latest', 'earliest', or 'pending') of the block to collect information on.
209
- *
210
- * @param returnTransactionObjects Whether to also return data about the transactions on the block.
211
- *
212
- * @returns A BlockResponse object with information about the specified block
213
- *
214
- * @example
215
- * ```js
216
- * await provider.getBlock(14645431);
217
- * ```
218
- *
219
- * @example
220
- * ```js
221
- * await provider.getBlock('0x3e5cea9c2be7e0ab4b0aa04c24dafddc37571db2d2d345caf7f88b3366ece0cf');
222
- * ```
223
- *
224
- * @example
225
- * ```js
226
- * await provider.getBlock('latest');
227
- * {
228
- * number: 4232826,
229
- * hash: '0x93211a1cd17e154b183565ec685254a03f844a8e34824a46ce1bdd6753dcb669',
230
- * parentHash: '0x1b32bfcba1bb2a57f56e166a3bb06875a1978992999dfc8828397b4c1526f472',
231
- * sha3Uncles: '0x0fb399c67bb5a071ec8a22549223215ab76b7d4009941c9c37aa3c3936010463',
232
- * logsBloom: '0x00000000000000000000101000000000020000000000000000000000000000000000400000010000000000000000000000000000010000000008800000000800000000200000000000000000000000000000000000000000000002000000000000000000000000000040000000000040000000000000000000000000000000000000000000000001000000000004000000000010000000000000000020000000000000000200100020000000000000000080000000000080001000000000000000000001040000000000000000008000000020010100000000200000100000000000000000000000002000000080000000020400000000002000200000000000',
233
- * transactionsRoot: '0xc43b3f13e1fe810e34d3a26ffe465b72c7063a5c70a02de2c78e91e4d10bd9fb',
234
- * stateRoot: '0x04d7bc816537ea7ef3a16e76c9879d29f34f99d4154273c2e98e012a31bad745',
235
- * receiptsRoot: '0x89c6f781ceac0bd49c4d9aa9115df4a5d4dd0e0220ff7668012f15bc04222c6b',
236
- * miner: '0x31fe561eb2c628cD32Ec52573D7c4b7E4C278Bfa',
237
- * difficulty: '1300907486001755331049',
238
- * totalDifficulty: '5989929395521171616186006183',
239
- * extraData: '0xce018c495249532d62613031656132',
240
- * size: 5416,
241
- * gasLimit: 6800000,
242
- * gasUsed: 202955,
243
- * timestamp: 1649884910,
244
- * transactions: [
245
- * '0x6b34a59c7b9aead24fa6dad782f8a3ad84ed4a23ee09bcbf0bcf880840fbbe20',
246
- * '0x9a3851ca24d5336c6a0d48aba2c4b4769d7a672c9b01729c5eb9924efd1b19a7',
247
- * '0xc3ed3d198b62f2f3427ebfa3bbd0fcada4e3c0c189e4464e7eeceb403c75981e'
248
- * ],
249
- * uncles: [
250
- * '0x0c567c054e98153f10d651fbbc018891c1dd9d62a9ffd998e87678803e95b6ed',
251
- * '0xb7d69389dbfb057c6fcb4bc0582d46a2ba01170703f0dadf8cd1462b83e88753',
252
- * '0xd5f74ccd0ad4c58b3161e8c2c507c264231e5f28925061b809c02e5e4bb6db28'
253
- * ],
254
- * minimumGasPrice: '0x387ee40',
255
- * bitcoinMergedMiningHeader: '0x04000020e8567ed3d2480e15a1dd1b4335e4732ae343c037e4fd03000000000000000000ed10a8340d163d3e813bdd430f902f4e5a56828dc62313b2e23797c0be6b8516eb3e576297d8091735884f42',
256
- * bitcoinMergedMiningCoinbaseTransaction: '0x0000000000000140e910128fda7bac502dc5e0573bbaf12de8e2524f70c22f7bd160dedcb19a2521002b6a2952534b424c4f434b3ae493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967aace6a7d9',
257
- * bitcoinMergedMiningMerkleProof: '0xdf63a3d7eb6fbcfb301311faa46e9a15b0408bb1a04e284daee86c273c1dfd65ede23f3170f806e9e0f4cef7ba6b56aa37470d9c23f96ec8e43d08b58645919c5e10bcb892897a731f8f9ce79c72dc0e390896bcd6c67bb38c0bdb72982b6cf05519968d76673572c3f3ef3a08b0ddb464863f1788f7cdbaad3fe44a8a8af576d430ac282fe28852c16df198ca96cc5f71a50695912efe1a836e8442be69e31b6d6f973da2818bce9a3a1c2d9be0671aee9a7776e398d6a03d1e178e20d84646004a3d03c0501334e629d9146aa6a01316dcbaa289df6e6c5e3090cadaddff22699cfc7ff09512fc0d65c5062f17c98561ce3c9510de210d9d654cf99f8d756ff37c9fa21e7122ee8cadb923341690845d572921425f2bd7e044558b7e07983ac4df28928028b0c13c3624dc7a965af8091b0cecc845bf7da5308c03b2c97d607f6706a599f802025894435f1d76ea4e67cc2fc4e1559f1206f559a24633de0f',
258
- * hashForMergedMining: '0xe493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967a',
259
- * paidFees: '0xc0744dcb7a0',
260
- * cumulativeDifficulty: '0x1190930db285269e582'
261
- * }
262
- *```
263
- */
264
- getBlock(timeFrame?: BlockTag, returnTransactionObjects?: boolean): Promise<BlockResponse>;
265
- /**
266
- * Returns the current gas price in wei as TinyBig
267
- * Same as `ethers.provider.getGasPrice`
268
- */
269
- getGasPrice(): Promise<TinyBig>;
270
- /**
271
- * Returns the balance of the account in wei as TinyBig
272
- * * Same as [`ethers.provider.getBalance`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBalance)
273
- * * Same as `web3.eth.getBalance`
274
- *
275
- * @example
276
- * ```js
277
- * await provider
278
- * .getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8')
279
- * .then((balance) => console.log(balance.toString()));
280
- * // "28798127851528138"
281
- * ```
282
- */
283
- getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>;
284
- }
@@ -1,380 +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.BaseProvider = void 0;
16
- const clean_block_1 = require("../classes/utils/clean-block");
17
- const clean_transaction_1 = require("../classes/utils/clean-transaction");
18
- const clean_transaction_receipt_1 = require("../classes/utils/clean-transaction-receipt");
19
- const fetchers_1 = require("../classes/utils/fetchers");
20
- const hex_to_decimal_1 = require("../classes/utils/hex-to-decimal");
21
- const tiny_big_1 = require("../shared/tiny-big/tiny-big");
22
- const chains_info_1 = __importDefault(require("./utils/chains-info"));
23
- class BaseProvider {
24
- /**
25
- * @param rpcUrl The URL to your Eth node. Consider POKT or Infura
26
- */
27
- constructor(rpcUrls) {
28
- /**
29
- * @ignore
30
- */
31
- this._rpcUrls = [];
32
- /**
33
- * @ignore
34
- */
35
- this._post = (body) => (0, fetchers_1.post)(this.selectRpcUrl(), body);
36
- this._rpcUrls = rpcUrls;
37
- }
38
- /**
39
- * Returns the network this provider is connected to
40
- */
41
- getNetwork() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const hexChainId = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_chainId', [])));
44
- const chainId = (0, hex_to_decimal_1.hexToDecimal)(hexChainId);
45
- const info = chains_info_1.default[chainId];
46
- return {
47
- chainId: Number(chainId),
48
- name: info[0] || 'unknown',
49
- ensAddress: info[1] || null, // only send ensAddress if it exists
50
- };
51
- });
52
- }
53
- /**
54
- * Gets the number of the most recently mined block on the network the provider is connected to
55
- *
56
- * * Identical to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber)
57
- * * Identical to [`web3.eth.getBlockNumber`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getblocknumber)
58
- *
59
- * @returns the number of the most recently mined block
60
- * @example
61
- * ```js
62
- * await provider.getBlockNumber();
63
- * // 1053312
64
- * ```
65
- */
66
- getBlockNumber() {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const currentBlockNumber = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_blockNumber', [])));
69
- return Number((0, hex_to_decimal_1.hexToDecimal)(currentBlockNumber));
70
- });
71
- }
72
- /**
73
- * * Similar to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction), some information not included
74
- *
75
- * @returns information about one transaction
76
- * @example
77
- * ```js
78
- * await provider.getTransaction('0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789');
79
- * {
80
- * accessList: [],
81
- * blockHash: '0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d',
82
- * blockNumber: 14578286,
83
- * chainId: 1,
84
- * from: '0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4',
85
- * gas: Big {
86
- * s: 1,
87
- * e: 5,
88
- * c: [ 1, 1, 2, 1, 6, 3 ],
89
- * constructor: <ref *1> [Function: Big] {
90
- * DP: 20,
91
- * RM: 1,
92
- * NE: -7,
93
- * PE: 21,
94
- * strict: false,
95
- * roundDown: 0,
96
- * roundHalfUp: 1,
97
- * roundHalfEven: 2,
98
- * roundUp: 3,
99
- * Big: [Circular *1],
100
- * default: [Circular *1]
101
- * }
102
- * },
103
- * gasPrice: Big {
104
- * s: 1,
105
- * e: 10,
106
- * c: [
107
- * 4, 8, 5, 9, 2,
108
- * 4, 2, 6, 8, 5,
109
- * 8
110
- * ],
111
- * constructor: <ref *1> [Function: Big] {
112
- * DP: 20,
113
- * RM: 1,
114
- * NE: -7,
115
- * PE: 21,
116
- * strict: false,
117
- * roundDown: 0,
118
- * roundHalfUp: 1,
119
- * roundHalfEven: 2,
120
- * roundUp: 3,
121
- * Big: [Circular *1],
122
- * default: [Circular *1]
123
- * }
124
- * },
125
- * hash: '0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789',
126
- * input: '0x83259f170000000000000000000000000000000000000000000000000000000000000080000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009e99ad11a214fd016b19dc3648678c5944859ae292b21c24ca94f857836c4596f1950c82dd0c23dd621af4763edc2f66466e63c5df9de0c1107b1cd16bf460fe93e43fd308e3444bc79c3d88a4cb961dc8367ab6ad048867afc76d193bca99cf3a068864ed4a7df1dbf1d4c52238eced3e5e05644b4040fc2b3ccb8557b0e99fff6131305a0ea2b8061b90bd418db5bbdd2e92129f52d93f90531465e309c4caec5b85285822b6196398d36f16f511811b61bbda6461e80e29210cd303118bdcee8df6fa0505ffbe8642094fd2ba4dd458496fe3b459ac880bbf71877c713e969ccf5ed7efab8a84ebc07e3939901371ca427e1192e455a8f35a6a1d7ad09e1475dd1758b36fa631dab5d70e99316b23c4c43094188d360cd9c3457355904e07c00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000162074a7047f',
127
- * maxFeePerGas: Big {
128
- * s: 1,
129
- * e: 10,
130
- * c: [
131
- * 6, 7, 6, 8, 1,
132
- * 2, 6, 1, 6, 1,
133
- * 8
134
- * ],
135
- * constructor: <ref *1> [Function: Big] {
136
- * DP: 20,
137
- * RM: 1,
138
- * NE: -7,
139
- * PE: 21,
140
- * strict: false,
141
- * roundDown: 0,
142
- * roundHalfUp: 1,
143
- * roundHalfEven: 2,
144
- * roundUp: 3,
145
- * Big: [Circular *1],
146
- * default: [Circular *1]
147
- * }
148
- * },
149
- * maxPriorityFeePerGas: Big {
150
- * s: 1,
151
- * e: 9,
152
- * c: [ 1, 5 ],
153
- * constructor: <ref *1> [Function: Big] {
154
- * DP: 20,
155
- * RM: 1,
156
- * NE: -7,
157
- * PE: 21,
158
- * strict: false,
159
- * roundDown: 0,
160
- * roundHalfUp: 1,
161
- * roundHalfEven: 2,
162
- * roundUp: 3,
163
- * Big: [Circular *1],
164
- * default: [Circular *1]
165
- * }
166
- * },
167
- * nonce: 129,
168
- * r: '0x59a7c15b12c18cd68d6c440963d959bff3e73831ffc938e75ecad07f7ee43fbc',
169
- * s: '0x1ebaf05f0d9273b16c2a7748b150a79d22533a8cd74552611cbe620fee3dcf1c',
170
- * to: '0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B',
171
- * transactionIndex: 29,
172
- * type: 2,
173
- * v: 0,
174
- * value: Big {
175
- * s: 1,
176
- * e: 0,
177
- * c: [ 0 ],
178
- * constructor: <ref *1> [Function: Big] {
179
- * DP: 20,
180
- * RM: 1,
181
- * NE: -7,
182
- * PE: 21,
183
- * strict: false,
184
- * roundDown: 0,
185
- * roundHalfUp: 1,
186
- * roundHalfEven: 2,
187
- * roundUp: 3,
188
- * Big: [Circular *1],
189
- * default: [Circular *1]
190
- * }
191
- * },
192
- * confirmations: 1210
193
- * }
194
- * ```
195
- */
196
- getTransaction(transactionHash) {
197
- return __awaiter(this, void 0, void 0, function* () {
198
- const [rpcTransaction, blockNumber] = yield Promise.all([
199
- this.post((0, fetchers_1.buildRPCPostBody)('eth_getTransactionByHash', [transactionHash])),
200
- this.getBlock('latest'),
201
- ]);
202
- const cleanedTransaction = (0, clean_transaction_1.cleanTransaction)(rpcTransaction);
203
- // https://ethereum.stackexchange.com/questions/2881/how-to-get-the-transaction-confirmations-using-the-json-rpc
204
- cleanedTransaction.confirmations =
205
- blockNumber.number - cleanedTransaction.blockNumber + 1;
206
- return cleanedTransaction;
207
- });
208
- }
209
- /**
210
- * Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by `getTransaction()`
211
- *
212
- * * Similar to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt), some information not included
213
- *
214
- * @param transactionHash the hash of the transaction to get information about
215
- *
216
- */
217
- getTransactionReceipt(transactionHash) {
218
- return __awaiter(this, void 0, void 0, function* () {
219
- const [rpcTransaction, blockNumber] = yield Promise.all([
220
- this.post((0, fetchers_1.buildRPCPostBody)('eth_getTransactionReceipt', [transactionHash])),
221
- this.getBlock('latest'),
222
- ]);
223
- const cleanedTransactionReceipt = (0, clean_transaction_receipt_1.cleanTransactionReceipt)(rpcTransaction);
224
- cleanedTransactionReceipt.confirmations =
225
- blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
226
- return cleanedTransactionReceipt;
227
- });
228
- }
229
- /**
230
- * Returns the transaction count from genesis up to specified blockTag
231
- *
232
- * * Same as `ethers.provider.getTransactionCount`
233
- * * Same as `web3.eth.getTransactionCount`
234
- *
235
- * @example
236
- * ```js
237
- * const address = '0x71660c4005ba85c37ccec55d0c4493e66fe775d3';
238
- * await provider
239
- * .getTransactionCount(address, 'latest')
240
- * // 1060000
241
- * ```
242
- *
243
- * @example
244
- * ```js
245
- * await provider
246
- * .getTransactionCount(address)
247
- * // 1053312
248
- * ```
249
- *
250
- * @example
251
- * ```js
252
- * await provider
253
- * .getTransactionCount(address, 14649390)
254
- * // 1053312
255
- * ```
256
- */
257
- getTransactionCount(address, blockTag = 'latest') {
258
- return __awaiter(this, void 0, void 0, function* () {
259
- if (typeof blockTag === 'number') {
260
- blockTag = `0x${blockTag.toString(16)}`;
261
- }
262
- const transactionCount = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_getTransactionCount', [address, blockTag])));
263
- return Number((0, hex_to_decimal_1.hexToDecimal)(transactionCount));
264
- });
265
- }
266
- /**
267
- * Gets information about a certain block.
268
- * Same as `web3.eth.getBlock` and `ethers.providers.getBlock`
269
- *
270
- * @param timeFrame The number, hash, or text-based description ('latest', 'earliest', or 'pending') of the block to collect information on.
271
- *
272
- * @param returnTransactionObjects Whether to also return data about the transactions on the block.
273
- *
274
- * @returns A BlockResponse object with information about the specified block
275
- *
276
- * @example
277
- * ```js
278
- * await provider.getBlock(14645431);
279
- * ```
280
- *
281
- * @example
282
- * ```js
283
- * await provider.getBlock('0x3e5cea9c2be7e0ab4b0aa04c24dafddc37571db2d2d345caf7f88b3366ece0cf');
284
- * ```
285
- *
286
- * @example
287
- * ```js
288
- * await provider.getBlock('latest');
289
- * {
290
- * number: 4232826,
291
- * hash: '0x93211a1cd17e154b183565ec685254a03f844a8e34824a46ce1bdd6753dcb669',
292
- * parentHash: '0x1b32bfcba1bb2a57f56e166a3bb06875a1978992999dfc8828397b4c1526f472',
293
- * sha3Uncles: '0x0fb399c67bb5a071ec8a22549223215ab76b7d4009941c9c37aa3c3936010463',
294
- * logsBloom: '0x00000000000000000000101000000000020000000000000000000000000000000000400000010000000000000000000000000000010000000008800000000800000000200000000000000000000000000000000000000000000002000000000000000000000000000040000000000040000000000000000000000000000000000000000000000001000000000004000000000010000000000000000020000000000000000200100020000000000000000080000000000080001000000000000000000001040000000000000000008000000020010100000000200000100000000000000000000000002000000080000000020400000000002000200000000000',
295
- * transactionsRoot: '0xc43b3f13e1fe810e34d3a26ffe465b72c7063a5c70a02de2c78e91e4d10bd9fb',
296
- * stateRoot: '0x04d7bc816537ea7ef3a16e76c9879d29f34f99d4154273c2e98e012a31bad745',
297
- * receiptsRoot: '0x89c6f781ceac0bd49c4d9aa9115df4a5d4dd0e0220ff7668012f15bc04222c6b',
298
- * miner: '0x31fe561eb2c628cD32Ec52573D7c4b7E4C278Bfa',
299
- * difficulty: '1300907486001755331049',
300
- * totalDifficulty: '5989929395521171616186006183',
301
- * extraData: '0xce018c495249532d62613031656132',
302
- * size: 5416,
303
- * gasLimit: 6800000,
304
- * gasUsed: 202955,
305
- * timestamp: 1649884910,
306
- * transactions: [
307
- * '0x6b34a59c7b9aead24fa6dad782f8a3ad84ed4a23ee09bcbf0bcf880840fbbe20',
308
- * '0x9a3851ca24d5336c6a0d48aba2c4b4769d7a672c9b01729c5eb9924efd1b19a7',
309
- * '0xc3ed3d198b62f2f3427ebfa3bbd0fcada4e3c0c189e4464e7eeceb403c75981e'
310
- * ],
311
- * uncles: [
312
- * '0x0c567c054e98153f10d651fbbc018891c1dd9d62a9ffd998e87678803e95b6ed',
313
- * '0xb7d69389dbfb057c6fcb4bc0582d46a2ba01170703f0dadf8cd1462b83e88753',
314
- * '0xd5f74ccd0ad4c58b3161e8c2c507c264231e5f28925061b809c02e5e4bb6db28'
315
- * ],
316
- * minimumGasPrice: '0x387ee40',
317
- * bitcoinMergedMiningHeader: '0x04000020e8567ed3d2480e15a1dd1b4335e4732ae343c037e4fd03000000000000000000ed10a8340d163d3e813bdd430f902f4e5a56828dc62313b2e23797c0be6b8516eb3e576297d8091735884f42',
318
- * bitcoinMergedMiningCoinbaseTransaction: '0x0000000000000140e910128fda7bac502dc5e0573bbaf12de8e2524f70c22f7bd160dedcb19a2521002b6a2952534b424c4f434b3ae493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967aace6a7d9',
319
- * bitcoinMergedMiningMerkleProof: '0xdf63a3d7eb6fbcfb301311faa46e9a15b0408bb1a04e284daee86c273c1dfd65ede23f3170f806e9e0f4cef7ba6b56aa37470d9c23f96ec8e43d08b58645919c5e10bcb892897a731f8f9ce79c72dc0e390896bcd6c67bb38c0bdb72982b6cf05519968d76673572c3f3ef3a08b0ddb464863f1788f7cdbaad3fe44a8a8af576d430ac282fe28852c16df198ca96cc5f71a50695912efe1a836e8442be69e31b6d6f973da2818bce9a3a1c2d9be0671aee9a7776e398d6a03d1e178e20d84646004a3d03c0501334e629d9146aa6a01316dcbaa289df6e6c5e3090cadaddff22699cfc7ff09512fc0d65c5062f17c98561ce3c9510de210d9d654cf99f8d756ff37c9fa21e7122ee8cadb923341690845d572921425f2bd7e044558b7e07983ac4df28928028b0c13c3624dc7a965af8091b0cecc845bf7da5308c03b2c97d607f6706a599f802025894435f1d76ea4e67cc2fc4e1559f1206f559a24633de0f',
320
- * hashForMergedMining: '0xe493303f597fa368c0ccc4f8aceabf1c315bb7c9a07605c073a89f260040967a',
321
- * paidFees: '0xc0744dcb7a0',
322
- * cumulativeDifficulty: '0x1190930db285269e582'
323
- * }
324
- *```
325
- */
326
- getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- let rpcTimeFrame;
329
- let type = 'Number';
330
- if (typeof timeFrame === 'number') {
331
- // exact block numbers require hex string format
332
- rpcTimeFrame = `0x${timeFrame.toString(16)}`;
333
- }
334
- else if (timeFrame.startsWith('0x')) {
335
- rpcTimeFrame = timeFrame;
336
- // use endpoint that accepts string
337
- type = 'Hash';
338
- }
339
- else {
340
- // "latest", "earliest", "pending", or hex string require no manipulation
341
- rpcTimeFrame = timeFrame;
342
- }
343
- const rpcBlock = (yield this.post((0, fetchers_1.buildRPCPostBody)(`eth_getBlockBy${type}`, [
344
- rpcTimeFrame,
345
- returnTransactionObjects,
346
- ])));
347
- return (0, clean_block_1.cleanBlock)(rpcBlock, returnTransactionObjects);
348
- });
349
- }
350
- /**
351
- * Returns the current gas price in wei as TinyBig
352
- * Same as `ethers.provider.getGasPrice`
353
- */
354
- getGasPrice() {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- const hexGasPrice = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_gasPrice', [])));
357
- return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(hexGasPrice));
358
- });
359
- }
360
- /**
361
- * Returns the balance of the account in wei as TinyBig
362
- * * Same as [`ethers.provider.getBalance`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBalance)
363
- * * Same as `web3.eth.getBalance`
364
- *
365
- * @example
366
- * ```js
367
- * await provider
368
- * .getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8')
369
- * .then((balance) => console.log(balance.toString()));
370
- * // "28798127851528138"
371
- * ```
372
- */
373
- getBalance(address, blockTag = 'latest') {
374
- return __awaiter(this, void 0, void 0, function* () {
375
- const hexBalance = (yield this.post((0, fetchers_1.buildRPCPostBody)('eth_getBalance', [address, blockTag])));
376
- return (0, tiny_big_1.tinyBig)((0, hex_to_decimal_1.hexToDecimal)(hexBalance));
377
- });
378
- }
379
- }
380
- exports.BaseProvider = BaseProvider;
@@ -1,24 +0,0 @@
1
- import { BaseProvider } from './BaseProvider';
2
- export interface ConstructorOptions {
3
- timeoutDuration?: number;
4
- }
5
- /**
6
- * @beta
7
- * A JSON RPC Provider which moves to the next URL when one fails.
8
- */
9
- export declare class FallthroughProvider extends BaseProvider {
10
- /**
11
- * @ignore
12
- */
13
- private rpcUrlCounter;
14
- private readonly timeoutDuration;
15
- /**
16
- * @ignore
17
- */
18
- selectRpcUrl(): string;
19
- constructor(rpcUrls: string[], options?: ConstructorOptions);
20
- /**
21
- * @ignore
22
- */
23
- post: (body: Record<string, unknown>) => Promise<any>;
24
- }