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,172 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { cleanBlock } from '../classes/utils/clean-block';
11
- import { cleanLog } from '../classes/utils/clean-log';
12
- import { cleanTransaction } from '../classes/utils/clean-transaction';
13
- import { cleanTransactionReceipt } from '../classes/utils/clean-transaction-receipt';
14
- import { buildRPCPostBody, post } from '../classes/utils/fetchers';
15
- import { hexToDecimal } from '../classes/utils/hex-to-decimal';
16
- import { prepareTransaction } from '../classes/utils/prepare-transaction';
17
- import { logger } from '../logger/logger';
18
- import { tinyBig } from '../shared/tiny-big/tiny-big';
19
- import chainsInfo from './utils/chains-info';
20
- function prepBlockTag(blockTag) {
21
- return typeof blockTag === 'number'
22
- ? tinyBig(blockTag).toHexString()
23
- : blockTag;
24
- }
25
- export class BaseProvider {
26
- constructor(rpcUrls) {
27
- this._rpcUrls = [];
28
- this._post = (body) => post(this.selectRpcUrl(), body);
29
- this._rpcUrls = rpcUrls;
30
- }
31
- getNetwork() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const hexChainId = (yield this.post(buildRPCPostBody('eth_chainId', [])));
34
- const chainId = hexToDecimal(hexChainId);
35
- const info = chainsInfo[chainId];
36
- return {
37
- chainId: Number(chainId),
38
- name: info[0] || 'unknown',
39
- ensAddress: info[1] || null,
40
- };
41
- });
42
- }
43
- getBlockNumber() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const currentBlockNumber = (yield this.post(buildRPCPostBody('eth_blockNumber', [])));
46
- return Number(hexToDecimal(currentBlockNumber));
47
- });
48
- }
49
- getTransaction(transactionHash) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const [rpcTransaction, blockNumber] = yield Promise.all([
52
- this.post(buildRPCPostBody('eth_getTransactionByHash', [transactionHash])),
53
- this.getBlock('latest'),
54
- ]);
55
- const cleanedTransaction = cleanTransaction(rpcTransaction);
56
- cleanedTransaction.confirmations =
57
- blockNumber.number - cleanedTransaction.blockNumber + 1;
58
- return cleanedTransaction;
59
- });
60
- }
61
- getTransactionReceipt(transactionHash) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const [rpcTransaction, blockNumber] = yield Promise.all([
64
- this.post(buildRPCPostBody('eth_getTransactionReceipt', [transactionHash])),
65
- this.getBlock('latest'),
66
- ]);
67
- const cleanedTransactionReceipt = cleanTransactionReceipt(rpcTransaction);
68
- cleanedTransactionReceipt.confirmations =
69
- blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
70
- return cleanedTransactionReceipt;
71
- });
72
- }
73
- getTransactionCount(address, blockTag = 'latest') {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- blockTag = prepBlockTag(blockTag);
76
- const transactionCount = (yield this.post(buildRPCPostBody('eth_getTransactionCount', [address, blockTag])));
77
- return Number(hexToDecimal(transactionCount));
78
- });
79
- }
80
- getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- let type = 'Number';
83
- if (typeof timeFrame === 'string' && timeFrame.length === 66) {
84
- type = 'Hash';
85
- }
86
- else {
87
- timeFrame = prepBlockTag(timeFrame);
88
- }
89
- const rpcBlock = (yield this.post(buildRPCPostBody(`eth_getBlockBy${type}`, [
90
- timeFrame,
91
- returnTransactionObjects,
92
- ])));
93
- return cleanBlock(rpcBlock, returnTransactionObjects);
94
- });
95
- }
96
- getGasPrice() {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const hexGasPrice = (yield this.post(buildRPCPostBody('eth_gasPrice', [])));
99
- return tinyBig(hexToDecimal(hexGasPrice));
100
- });
101
- }
102
- getBalance(address, blockTag = 'latest') {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- blockTag = prepBlockTag(blockTag);
105
- const hexBalance = (yield this.post(buildRPCPostBody('eth_getBalance', [address, blockTag])));
106
- return tinyBig(hexToDecimal(hexBalance));
107
- });
108
- }
109
- getCode(address, blockTag = 'latest') {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- blockTag = prepBlockTag(blockTag);
112
- const contractCode = (yield this.post(buildRPCPostBody('eth_getCode', [address, blockTag])));
113
- return contractCode;
114
- });
115
- }
116
- estimateGas(transaction) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- const rpcTransaction = prepareTransaction(transaction);
119
- const gasUsed = (yield this.post(buildRPCPostBody('eth_estimateGas', [rpcTransaction])));
120
- return tinyBig(hexToDecimal(gasUsed));
121
- });
122
- }
123
- getFeeData() {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const [block, gasPrice] = yield Promise.all([
126
- this.getBlock('latest'),
127
- this.getGasPrice(),
128
- ]);
129
- let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
130
- if (block && block.baseFeePerGas) {
131
- lastBaseFeePerGas = block.baseFeePerGas;
132
- maxPriorityFeePerGas = tinyBig('1500000000');
133
- maxFeePerGas = tinyBig(block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas));
134
- }
135
- return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
136
- });
137
- }
138
- getLogs(filter) {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- const filterByRange = filter;
141
- if (filterByRange.fromBlock)
142
- filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
143
- if (filterByRange.toBlock)
144
- filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
145
- const rpcLogs = (yield this.post(buildRPCPostBody('eth_getLogs', [filter])));
146
- const logs = rpcLogs.map((log) => cleanLog(log, false));
147
- return logs;
148
- });
149
- }
150
- call(transaction, blockTag = 'latest') {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- if (transaction.gasPrice &&
153
- (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
154
- logger.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")', {
155
- gasPrice: transaction.gasPrice,
156
- maxFeePerGas: transaction.maxFeePerGas,
157
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
158
- });
159
- }
160
- if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
161
- logger.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"', {
162
- maxFeePerGas: transaction.maxFeePerGas,
163
- maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
164
- });
165
- }
166
- blockTag = prepBlockTag(blockTag);
167
- const rpcTransaction = prepareTransaction(transaction);
168
- const transactionRes = (yield this.post(buildRPCPostBody('eth_call', [rpcTransaction, blockTag])));
169
- return transactionRes;
170
- });
171
- }
172
- }
@@ -1,11 +0,0 @@
1
- import { BaseProvider } from './BaseProvider';
2
- export interface ConstructorOptions {
3
- timeoutDuration?: number;
4
- }
5
- export declare class FallthroughProvider extends BaseProvider {
6
- private rpcUrlCounter;
7
- private readonly timeoutDuration;
8
- selectRpcUrl(): string;
9
- constructor(rpcUrls: string[], options?: ConstructorOptions);
10
- post: (body: Record<string, unknown>) => Promise<any>;
11
- }
@@ -1,49 +0,0 @@
1
- import { logger } from '../logger/logger';
2
- import { BaseProvider } from './BaseProvider';
3
- const promiseTimeout = (prom, time) => new Promise((resolve, reject) => {
4
- const timeout = setTimeout(() => reject(new Error('Promise timed out')), time);
5
- prom
6
- .then((result) => {
7
- clearTimeout(timeout);
8
- resolve(result);
9
- })
10
- .catch((error) => {
11
- clearTimeout(timeout);
12
- reject(error);
13
- });
14
- });
15
- const DEFAULT_TIMEOUT_DURATION = 8000;
16
- export class FallthroughProvider extends BaseProvider {
17
- selectRpcUrl() {
18
- return this._rpcUrls[this.rpcUrlCounter];
19
- }
20
- constructor(rpcUrls, options = {}) {
21
- if (!Array.isArray(rpcUrls)) {
22
- logger.throwError('Array required', { rpcUrls });
23
- }
24
- if (rpcUrls.length <= 1) {
25
- logger.throwError('More than one rpcUrl is required', { rpcUrls });
26
- }
27
- super(rpcUrls);
28
- this.rpcUrlCounter = 0;
29
- this.post = (body) => {
30
- const genesisCount = this.rpcUrlCounter;
31
- const recursivePostRetry = () => {
32
- const genesisRpcUrl = this.selectRpcUrl();
33
- const res = promiseTimeout(this._post(body), this.timeoutDuration).catch((e) => {
34
- if (genesisRpcUrl === this.selectRpcUrl()) {
35
- this.rpcUrlCounter =
36
- (this.rpcUrlCounter + 1) % this._rpcUrls.length;
37
- }
38
- if (this.rpcUrlCounter === genesisCount) {
39
- throw e;
40
- }
41
- return recursivePostRetry();
42
- });
43
- return res;
44
- };
45
- return recursivePostRetry();
46
- };
47
- this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
48
- }
49
- }
@@ -1,7 +0,0 @@
1
- import { BaseProvider } from './BaseProvider';
2
- export declare class JsonRpcProvider extends BaseProvider {
3
- selectRpcUrl(): string;
4
- post(body: Record<string, unknown>): Promise<any>;
5
- constructor(rpcUrl?: string);
6
- }
7
- export declare function jsonRpcProvider(rpcUrl?: string): JsonRpcProvider;
@@ -1,15 +0,0 @@
1
- import { BaseProvider } from './BaseProvider';
2
- export class JsonRpcProvider extends BaseProvider {
3
- selectRpcUrl() {
4
- return this._rpcUrls[0];
5
- }
6
- post(body) {
7
- return this._post(body);
8
- }
9
- constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
10
- super([rpcUrl]);
11
- }
12
- }
13
- export function jsonRpcProvider(rpcUrl) {
14
- return new JsonRpcProvider(rpcUrl);
15
- }
@@ -1,14 +0,0 @@
1
- import type { Filter } from '../../../../types/Filter.types';
2
- import type { RPCLog } from '../../../../types/Transaction.types';
3
- export declare const STRONGBLOCK_ADDRESS = "0xfbddadd80fe7bda00b901fbaf73803f2238ae655";
4
- export declare const filterAddressFromTo: Filter;
5
- export declare const RARELAND_ADDRESS = "0x596a0f276ee432d8a28441e55737ff55cf30d0f7";
6
- export declare const filterAddressTopics: Filter;
7
- export declare const WETH_ADDRESS = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
8
- export declare const filterAll: Filter;
9
- export declare const mockfilterAddressFromToLogs: RPCLog[];
10
- export declare const mockfilterAddressTopicsLogs: RPCLog[];
11
- export declare const mockfilterAllLogs: RPCLog[];
12
- export declare const mockRpcAddressFromToResponse: string;
13
- export declare const mockRpcAddressTopicsResponse: string;
14
- export declare const mockRpcAllResponse: string;
@@ -1,142 +0,0 @@
1
- export const STRONGBLOCK_ADDRESS = '0xfbddadd80fe7bda00b901fbaf73803f2238ae655';
2
- export const filterAddressFromTo = {
3
- address: STRONGBLOCK_ADDRESS,
4
- fromBlock: '0xE1F8F1',
5
- toBlock: '0xE1F8F1',
6
- };
7
- export const RARELAND_ADDRESS = '0x596a0f276ee432d8a28441e55737ff55cf30d0f7';
8
- export const filterAddressTopics = {
9
- address: RARELAND_ADDRESS,
10
- topics: [
11
- '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
12
- ],
13
- };
14
- export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
15
- export const filterAll = {
16
- address: WETH_ADDRESS,
17
- topics: [
18
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
19
- '0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
20
- ],
21
- fromBlock: 14825027,
22
- toBlock: 14825039,
23
- };
24
- export const mockfilterAddressFromToLogs = [
25
- {
26
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
27
- topics: [
28
- '0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
29
- '0x00000000000000000000000028c2e3e17f8c61a9b7515f7bb1e1347846588b82',
30
- ],
31
- data: '0x0000000000000000000000000000000000000000000000001dbaed81bf64db6d',
32
- blockNumber: '0xe1f8f1',
33
- transactionHash: '0x5dec3a55b87edac0af5c4a9afdd015bb04303fdf86525dd1cc4e7aa7653b6301',
34
- transactionIndex: '0x29',
35
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
36
- logIndex: '0x88',
37
- removed: false,
38
- },
39
- {
40
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
41
- topics: [
42
- '0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
43
- '0x000000000000000000000000c3b80d78bb52fd734c4f730dad5e190ba4ecb830',
44
- ],
45
- data: '0x0000000000000000000000000000000000000000000000001c277de315af8924',
46
- blockNumber: '0xe1f8f1',
47
- transactionHash: '0xae04b63efd57852e34bdc84e257bb413f9f942288f63a131d4b7071c8ee0b896',
48
- transactionIndex: '0x2f',
49
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
50
- logIndex: '0x95',
51
- removed: false,
52
- },
53
- {
54
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
55
- topics: [
56
- '0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
57
- '0x000000000000000000000000f1a192063f0a2b2be0cbcb2978b13e95e7f35f6b',
58
- ],
59
- data: '0x00000000000000000000000000000000000000000000000018ecfa70ea275b6d',
60
- blockNumber: '0xe1f8f1',
61
- transactionHash: '0xbdba7260507b4ca24757809ac9a23e5225e80a491475ccf89a04c1894a693c77',
62
- transactionIndex: '0x30',
63
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
64
- logIndex: '0x97',
65
- removed: false,
66
- },
67
- {
68
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
69
- topics: [
70
- '0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
71
- '0x000000000000000000000000c78dc12c9b04858d57a108ae948020344895e910',
72
- ],
73
- data: '0x0000000000000000000000000000000000000000000000000da5142efe16e492',
74
- blockNumber: '0xe1f8f1',
75
- transactionHash: '0xdcf29bd8a44ec89a3b53488dd60b76bd7f1c532db76f88e166f3de1ab216537e',
76
- transactionIndex: '0x31',
77
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
78
- logIndex: '0x99',
79
- removed: false,
80
- },
81
- {
82
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
83
- topics: [
84
- '0xd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a',
85
- '0x000000000000000000000000aaf5c3760f4a77bdf23974f98d69f9ccfd778aea',
86
- ],
87
- data: '0x0000000000000000000000000000000000000000000000001086ed3d87034000',
88
- blockNumber: '0xe1f8f1',
89
- transactionHash: '0x56130c6e8fdafd0e08411b21ce984eeb56dc61d99a91f03efc7edde748d7ad81',
90
- transactionIndex: '0x35',
91
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
92
- logIndex: '0xac',
93
- removed: false,
94
- },
95
- {
96
- address: '0xfbddadd80fe7bda00b901fbaf73803f2238ae655',
97
- topics: [
98
- '0x39b0a0620bb668047ab7248973ddfd93d53dff1d4952bd2d56bbf5934edc1fd0',
99
- '0x0000000000000000000000001753de22132990dd5ab35f13a5951431c8ba08ea',
100
- ],
101
- data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000e3203b',
102
- blockNumber: '0xe1f8f1',
103
- transactionHash: '0xf5a77d85296cc670d577d3c9a76b1fa18be77239a4cb4c05493530866d60c36f',
104
- transactionIndex: '0x3a',
105
- blockHash: '0x343ead2d84a53b054bc191fe00807d59b40094bb0cbc49b3ba550169b046d4b8',
106
- logIndex: '0xb5',
107
- removed: false,
108
- },
109
- ];
110
- export const mockfilterAddressTopicsLogs = [];
111
- export const mockfilterAllLogs = [
112
- {
113
- address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
114
- topics: [
115
- '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
116
- '0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
117
- '0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45',
118
- ],
119
- data: '0x000000000000000000000000000000000000000000000000005f862ee352a38a',
120
- blockNumber: '0xe23645',
121
- transactionHash: '0xbd49031be16f8fd1775f4e0fe79b408ffd8ae9c65b2827ee47e3238e3f51f4c0',
122
- transactionIndex: '0xe2',
123
- blockHash: '0x8e0dfac2f704851960f866c8708b3bef2f66c0fee0329cf25ff0261b264ca6bc',
124
- logIndex: '0x180',
125
- removed: false,
126
- },
127
- ];
128
- export const mockRpcAddressFromToResponse = JSON.stringify({
129
- jsonrpc: '2.0',
130
- id: 1,
131
- result: mockfilterAddressFromToLogs,
132
- });
133
- export const mockRpcAddressTopicsResponse = JSON.stringify({
134
- jsonrpc: '2.0',
135
- id: 1,
136
- result: mockfilterAddressTopicsLogs,
137
- });
138
- export const mockRpcAllResponse = JSON.stringify({
139
- jsonrpc: '2.0',
140
- id: 1,
141
- result: mockfilterAllLogs,
142
- });
@@ -1,2 +0,0 @@
1
- /// <reference types="jest" />
2
- export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) => jest.Mock<FunctionReturnType, FunctionParameters>;
@@ -1 +0,0 @@
1
- export const mockOf = (fn) => fn;
@@ -1,12 +0,0 @@
1
- export declare const fakeUrls: {
2
- readonly notRPCButRealHttp: "https://httpstat.us/200";
3
- };
4
- export declare const rpcUrls: {
5
- mainnet: string;
6
- oeth: string;
7
- matic: string;
8
- gno: string;
9
- bnb: string;
10
- arb1: string;
11
- gor: string;
12
- };
@@ -1,19 +0,0 @@
1
- import z from 'zod';
2
- export const fakeUrls = {
3
- notRPCButRealHttp: 'https://httpstat.us/200',
4
- };
5
- const RPC_ORIGIN = 'https://free-eth-node.com';
6
- z.string({
7
- required_error: '"RPC_ORIGIN" required but not found',
8
- })
9
- .url('Expected url for "RPC_ORIGIN"')
10
- .parse(RPC_ORIGIN);
11
- export const rpcUrls = {
12
- mainnet: `${RPC_ORIGIN}/api/eth`,
13
- oeth: `${RPC_ORIGIN}/api/oeth`,
14
- matic: `${RPC_ORIGIN}/api/MATIC`,
15
- gno: `${RPC_ORIGIN}/api/gno`,
16
- bnb: `${RPC_ORIGIN}/api/bnb`,
17
- arb1: `${RPC_ORIGIN}/api/arb1`,
18
- gor: `${RPC_ORIGIN}/api/gor`,
19
- };
@@ -1,24 +0,0 @@
1
- declare const _default: {
2
- "1": string[];
3
- "5": string[];
4
- "10": string[];
5
- "50": string[];
6
- "56": string[];
7
- "100": string[];
8
- "137": string[];
9
- "250": string[];
10
- "324": string[];
11
- "1101": string[];
12
- "1337": string[];
13
- "7700": string[];
14
- "9001": string[];
15
- "42161": string[];
16
- "42220": string[];
17
- "43114": string[];
18
- "59140": string[];
19
- "80001": string[];
20
- "421613": string[];
21
- "534352": string[];
22
- "11155111": string[];
23
- };
24
- export default _default;
@@ -1,67 +0,0 @@
1
- export default {
2
- "1": [
3
- "eth",
4
- "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
5
- ],
6
- "5": [
7
- "gor",
8
- "0x112234455c3a32fd11230c42e7bccd4a84e02010"
9
- ],
10
- "10": [
11
- "oeth"
12
- ],
13
- "50": [
14
- "xdc"
15
- ],
16
- "56": [
17
- "bnb"
18
- ],
19
- "100": [
20
- "gno"
21
- ],
22
- "137": [
23
- "matic"
24
- ],
25
- "250": [
26
- "ftm"
27
- ],
28
- "324": [
29
- "zksync"
30
- ],
31
- "1101": [
32
- "zkevm"
33
- ],
34
- "1337": [
35
- "geth"
36
- ],
37
- "7700": [
38
- "canto"
39
- ],
40
- "9001": [
41
- "evmos"
42
- ],
43
- "42161": [
44
- "arb1"
45
- ],
46
- "42220": [
47
- "celo"
48
- ],
49
- "43114": [
50
- "avax"
51
- ],
52
- "59140": [
53
- "linea-testnet"
54
- ],
55
- "80001": [
56
- "maticmum"
57
- ],
58
- "421613": [
59
- "arb-goerli"
60
- ],
61
- "534352": [
62
- "scr"
63
- ],
64
- "11155111": [
65
- "sep"
66
- ]
67
- };
@@ -1 +0,0 @@
1
- export declare function scientificStrToDecimalStr(scientificString: string): string;
@@ -1,58 +0,0 @@
1
- function stripTrailingZeroes(numberString) {
2
- const isNegative = numberString.startsWith('-');
3
- numberString = numberString.replace('-', '');
4
- numberString = numberString.replace(/\.0*$/g, '');
5
- numberString = numberString.replace(/^0+/, '');
6
- if (numberString.includes('.')) {
7
- numberString = numberString.replace(/0+$/, '');
8
- }
9
- if (numberString.startsWith('.')) {
10
- numberString = `0${numberString}`;
11
- }
12
- return `${isNegative ? '-' : ''}${numberString}`;
13
- }
14
- export function scientificStrToDecimalStr(scientificString) {
15
- if (!scientificString.match(/e/i)) {
16
- return stripTrailingZeroes(scientificString);
17
- }
18
- let [base, power] = scientificString.split(/e/i);
19
- const isNegative = Number(base) < 0;
20
- base = base.replace('-', '');
21
- base = stripTrailingZeroes(base);
22
- const [wholeNumber, fraction = ''] = base.split('.');
23
- if (Number(power) === 0) {
24
- return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
25
- }
26
- else {
27
- const includesDecimal = base.includes('.');
28
- if (!includesDecimal) {
29
- base = `${base}.`;
30
- }
31
- base = base.replace('.', '');
32
- const baseLength = base.length;
33
- let splitPaddedNumber;
34
- if (Number(power) < 0) {
35
- if (wholeNumber.length < Math.abs(Number(power))) {
36
- base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
37
- }
38
- splitPaddedNumber = base.split('');
39
- if (wholeNumber.length < Math.abs(Number(power))) {
40
- splitPaddedNumber = ['.', ...splitPaddedNumber];
41
- }
42
- else {
43
- splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
44
- }
45
- }
46
- else {
47
- if (fraction.length < Math.abs(Number(power))) {
48
- base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
49
- }
50
- splitPaddedNumber = base.split('');
51
- if (fraction.length > Math.abs(Number(power))) {
52
- splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
53
- }
54
- }
55
- const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
56
- return `${isNegative ? '-' : ''}${toReturn}`;
57
- }
58
- }
@@ -1,10 +0,0 @@
1
- import Big from 'big.js';
2
- export declare class TinyBig extends Big {
3
- constructor(value: string | number | TinyBig | Big);
4
- toHexString(): string;
5
- toNumber(): number;
6
- toString(): string;
7
- private padAndChop;
8
- toTwos(bitCount: number): Big;
9
- }
10
- export declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
@@ -1,45 +0,0 @@
1
- import Big from 'big.js';
2
- import { hexToDecimal } from '../../classes/utils/hex-to-decimal';
3
- import { scientificStrToDecimalStr } from './helpers';
4
- export class TinyBig extends Big {
5
- constructor(value) {
6
- if (typeof value === 'string' && value.startsWith('0x')) {
7
- value = hexToDecimal(value);
8
- }
9
- super(value);
10
- this.padAndChop = (str, padChar, length) => {
11
- return (Array(length).fill(padChar).join('') + str).slice(length * -1);
12
- };
13
- }
14
- toHexString() {
15
- return `0x${BigInt(this.toString()).toString(16)}`;
16
- }
17
- toNumber() {
18
- return Number(scientificStrToDecimalStr(super.toString()));
19
- }
20
- toString() {
21
- if (this.toNumber() === 0) {
22
- return '0';
23
- }
24
- return scientificStrToDecimalStr(super.toString());
25
- }
26
- toTwos(bitCount) {
27
- let binaryStr;
28
- if (this.gte(0)) {
29
- const twosComp = this.toNumber().toString(2);
30
- binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
31
- }
32
- else {
33
- binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
34
- if (Number(binaryStr) < 0) {
35
- throw new Error('Cannot calculate twos complement');
36
- }
37
- }
38
- const binary = `0b${binaryStr}`;
39
- const decimal = Number(binary);
40
- return tinyBig(decimal);
41
- }
42
- }
43
- export function tinyBig(value) {
44
- return new TinyBig(value);
45
- }
@@ -1,3 +0,0 @@
1
- type JSPrimitiveTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
2
- export declare const validateType: (value: unknown, allowedTypes: JSPrimitiveTypes[]) => void;
3
- export {};