essential-eth 0.9.0 → 0.9.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/cjs/classes/Contract.js +66 -307
  2. package/dist/cjs/classes/test/Contract/crv-abi.js +256 -252
  3. package/dist/cjs/classes/test/Contract/ens-abi.d.ts +1 -1
  4. package/dist/cjs/classes/test/Contract/ens-abi.js +212 -497
  5. package/dist/cjs/classes/test/Contract/fei-abi.js +284 -605
  6. package/dist/cjs/classes/test/Contract/foo-abi.d.ts +1 -1
  7. package/dist/cjs/classes/test/Contract/foo-abi.js +21 -44
  8. package/dist/cjs/classes/test/Contract/uniswap-abi.js +68 -64
  9. package/dist/cjs/classes/utils/clean-block.js +30 -52
  10. package/dist/cjs/classes/utils/clean-log.js +20 -42
  11. package/dist/cjs/classes/utils/clean-transaction-receipt.js +30 -51
  12. package/dist/cjs/classes/utils/clean-transaction.js +30 -52
  13. package/dist/cjs/classes/utils/encode-decode-transaction.js +107 -148
  14. package/dist/cjs/classes/utils/fetchers.d.ts +8 -2
  15. package/dist/cjs/classes/utils/fetchers.js +52 -166
  16. package/dist/cjs/classes/utils/hex-to-decimal.js +6 -1
  17. package/dist/cjs/classes/utils/prepare-transaction.js +36 -59
  18. package/dist/cjs/index.d.ts +21 -22
  19. package/dist/cjs/index.js +56 -26
  20. package/dist/cjs/index.umd.js +1 -1
  21. package/dist/cjs/index.umd.js.map +1 -1
  22. package/dist/cjs/logger/logger.js +23 -79
  23. package/dist/cjs/logger/package-version.d.ts +1 -1
  24. package/dist/cjs/logger/package-version.js +4 -1
  25. package/dist/cjs/providers/AlchemyProvider.js +9 -82
  26. package/dist/cjs/providers/BaseProvider.js +511 -882
  27. package/dist/cjs/providers/FallthroughProvider.js +46 -123
  28. package/dist/cjs/providers/JsonRpcProvider.js +28 -93
  29. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  30. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +152 -0
  31. package/dist/cjs/providers/test/mock-of.js +6 -8
  32. package/dist/cjs/providers/test/rpc-urls.d.ts +1 -0
  33. package/dist/cjs/providers/test/rpc-urls.js +23 -14
  34. package/dist/cjs/providers/utils/chains-info.d.ts +5 -448
  35. package/dist/cjs/providers/utils/chains-info.js +16 -1345
  36. package/dist/cjs/shared/tiny-big/helpers.js +42 -93
  37. package/dist/cjs/shared/tiny-big/tiny-big.js +72 -161
  38. package/dist/cjs/shared/validate-type.d.ts +1 -1
  39. package/dist/cjs/shared/validate-type.js +7 -7
  40. package/dist/cjs/types/Block.types.d.ts +3 -3
  41. package/dist/cjs/types/Block.types.js +2 -1
  42. package/dist/cjs/types/Contract.types.d.ts +4 -4
  43. package/dist/cjs/types/Contract.types.js +2 -1
  44. package/dist/cjs/types/FeeData.types.js +2 -1
  45. package/dist/cjs/types/Filter.types.js +2 -1
  46. package/dist/cjs/types/Network.types.js +2 -3
  47. package/dist/cjs/types/Transaction.types.d.ts +5 -5
  48. package/dist/cjs/types/Transaction.types.js +2 -1
  49. package/dist/cjs/utils/bytes.d.ts +4 -4
  50. package/dist/cjs/utils/bytes.js +318 -286
  51. package/dist/cjs/utils/compute-address.js +15 -8
  52. package/dist/cjs/utils/compute-public-key.js +10 -5
  53. package/dist/cjs/utils/ether-to-gwei.js +11 -10
  54. package/dist/cjs/utils/ether-to-wei.js +11 -10
  55. package/dist/cjs/utils/gwei-to-ether.js +11 -10
  56. package/dist/cjs/utils/hash-message.js +16 -11
  57. package/dist/cjs/utils/is-address.js +12 -8
  58. package/dist/cjs/utils/keccak256.js +14 -8
  59. package/dist/cjs/utils/solidity-keccak256.js +60 -49
  60. package/dist/cjs/utils/split-signature.js +73 -55
  61. package/dist/cjs/utils/to-checksum-address.js +20 -15
  62. package/dist/cjs/utils/to-utf8-bytes.js +6 -1
  63. package/dist/cjs/utils/wei-to-ether.js +15 -13
  64. package/dist/esm/classes/test/Contract/ens-abi.d.ts +1 -1
  65. package/dist/esm/classes/test/Contract/foo-abi.d.ts +1 -1
  66. package/dist/esm/classes/utils/fetchers.d.ts +8 -2
  67. package/dist/esm/classes/utils/fetchers.js +6 -3
  68. package/dist/esm/index.d.ts +21 -22
  69. package/dist/esm/index.js +16 -17
  70. package/dist/esm/logger/package-version.d.ts +1 -1
  71. package/dist/esm/logger/package-version.js +1 -1
  72. package/dist/esm/providers/FallthroughProvider.js +3 -3
  73. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +14 -0
  74. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +142 -0
  75. package/dist/esm/providers/test/rpc-urls.d.ts +1 -0
  76. package/dist/esm/providers/test/rpc-urls.js +7 -4
  77. package/dist/esm/providers/utils/chains-info.d.ts +5 -448
  78. package/dist/esm/providers/utils/chains-info.js +13 -1344
  79. package/dist/esm/shared/validate-type.d.ts +1 -1
  80. package/dist/esm/types/Block.types.d.ts +3 -3
  81. package/dist/esm/types/Contract.types.d.ts +4 -4
  82. package/dist/esm/types/Transaction.types.d.ts +5 -5
  83. package/dist/esm/utils/bytes.d.ts +4 -4
  84. package/package.json +23 -51
  85. package/readme.md +15 -38
  86. package/dist/cjs/classes/test/Contract/crv.test.js +0 -690
  87. package/dist/cjs/classes/test/Contract/ens.test.js +0 -217
  88. package/dist/cjs/classes/test/Contract/fei.test.js +0 -224
  89. package/dist/cjs/classes/test/Contract/foo.test.js +0 -33
  90. package/dist/cjs/classes/test/Contract/uni.test.js +0 -387
  91. package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +0 -228
  92. package/dist/cjs/providers/test/get-transaction-count.test.js +0 -276
  93. package/dist/cjs/providers/test/json-rpc-provider/call.test.js +0 -436
  94. package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +0 -288
  95. package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +0 -261
  96. package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +0 -159
  97. package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +0 -477
  98. package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +0 -311
  99. package/dist/cjs/providers/test/json-rpc-provider/get-fee-data.test.js +0 -212
  100. package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +0 -164
  101. package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +0 -361
  102. package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +0 -274
  103. package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +0 -301
  104. package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +0 -307
  105. package/dist/cjs/providers/test/test-alchemy-provider.test.js +0 -151
  106. package/dist/cjs/shared/tiny-big/helpers.test.js +0 -29
  107. package/dist/cjs/shared/tiny-big/tiny-big.test.js +0 -34
  108. package/dist/cjs/utils/tests/bytes/arrayify.test.js +0 -40
  109. package/dist/cjs/utils/tests/bytes/concat.test.js +0 -15
  110. package/dist/cjs/utils/tests/bytes/hex-concat.test.js +0 -63
  111. package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +0 -49
  112. package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +0 -52
  113. package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +0 -58
  114. package/dist/cjs/utils/tests/bytes/hex-value.test.js +0 -85
  115. package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +0 -62
  116. package/dist/cjs/utils/tests/bytes/hexlify.test.js +0 -62
  117. package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +0 -69
  118. package/dist/cjs/utils/tests/bytes/is-bytes.test.js +0 -33
  119. package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +0 -88
  120. package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +0 -57
  121. package/dist/cjs/utils/tests/bytes/zero-pad.test.js +0 -80
  122. package/dist/cjs/utils/tests/compute-address.test.js +0 -27
  123. package/dist/cjs/utils/tests/compute-public-key.test.js +0 -15
  124. package/dist/cjs/utils/tests/ether-to-gwei.test.js +0 -26
  125. package/dist/cjs/utils/tests/ether-to-wei.test.js +0 -44
  126. package/dist/cjs/utils/tests/gwei-to-ether.test.js +0 -28
  127. package/dist/cjs/utils/tests/hash-message.test.js +0 -21
  128. package/dist/cjs/utils/tests/is-address.test.js +0 -55
  129. package/dist/cjs/utils/tests/keccak256.test.js +0 -97
  130. package/dist/cjs/utils/tests/solidity-keccak256.test.js +0 -310
  131. package/dist/cjs/utils/tests/split-signature.test.js +0 -25
  132. package/dist/cjs/utils/tests/to-checksum-address.test.js +0 -42
  133. package/dist/cjs/utils/tests/to-utf8-bytes.test.js +0 -14
  134. package/dist/cjs/utils/tests/wei-to-ether.test.js +0 -51
@@ -1,5 +1,8 @@
1
- import { Keccak } from "sha3";
2
- import { validateType } from "../shared/validate-type";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toChecksumAddress = void 0;
4
+ const sha3_1 = require("sha3");
5
+ const validate_type_1 = require("../shared/validate-type");
3
6
  /**
4
7
  * Returns an Ethereum address in proper mixed-case checksum.
5
8
  * Does NOT support ICAP
@@ -15,27 +18,29 @@ import { validateType } from "../shared/validate-type";
15
18
  * Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v5/api/utils/address/#utils-getAddress)
16
19
  *
17
20
  * Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#tochecksumaddress)
18
- */ export function toChecksumAddress(address) {
19
- validateType(address, [
20
- "string"
21
- ]);
21
+ */
22
+ function toChecksumAddress(address) {
23
+ (0, validate_type_1.validateType)(address, ['string']);
22
24
  if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
23
- throw new Error('Invalid Ethereum address "'.concat(address, '"'));
25
+ throw new Error(`Invalid Ethereum address "${address}"`);
24
26
  }
25
- var _address = address.toLowerCase().replace(/^0x/i, "");
26
- var keccak = new Keccak(256);
27
- var addressHash = keccak.update(_address).digest("hex").replace(/^0x/i, "");
28
- var checksumAddress = "0x";
29
- for(var i = 0; i < _address.length; i++){
27
+ const _address = address.toLowerCase().replace(/^0x/i, '');
28
+ const keccak = new sha3_1.Keccak(256);
29
+ const addressHash = keccak.update(_address).digest('hex').replace(/^0x/i, '');
30
+ let checksumAddress = '0x';
31
+ for (let i = 0; i < _address.length; i++) {
30
32
  // If ith character is 8 to f then make it uppercase
31
33
  if (parseInt(addressHash[i], 16) > 7) {
32
34
  checksumAddress += _address[i].toUpperCase();
33
- } else {
35
+ }
36
+ else {
34
37
  checksumAddress += _address[i];
35
38
  }
36
39
  }
37
- if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && checksumAddress !== address) {
38
- throw new Error('Invalid Checksum address for "'.concat(address, '"'));
40
+ if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) &&
41
+ checksumAddress !== address) {
42
+ throw new Error(`Invalid Checksum address for "${address}"`);
39
43
  }
40
44
  return checksumAddress;
41
45
  }
46
+ exports.toChecksumAddress = toChecksumAddress;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toUtf8Bytes = void 0;
1
4
  /**
2
5
  * Converts a string into a UTF-8 Byte Array
3
6
  *
@@ -11,6 +14,8 @@
11
14
  * toUtf8Bytes('ethereum');
12
15
  * // Uint8Array { [Iterator] 0: 101, 1: 116, 2: 104, 3: 101, 4: 114, 5: 101, 6: 117, 7: 109 }
13
16
  * ```
14
- */ export function toUtf8Bytes(data) {
17
+ */
18
+ function toUtf8Bytes(data) {
15
19
  return new Uint8Array(Buffer.from(data));
16
20
  }
21
+ exports.toUtf8Bytes = toUtf8Bytes;
@@ -1,5 +1,8 @@
1
- import { tinyBig } from "../shared/tiny-big/tiny-big";
2
- import { validateType } from "../shared/validate-type";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.weiToEther = void 0;
4
+ const tiny_big_1 = require("../shared/tiny-big/tiny-big");
5
+ const validate_type_1 = require("../shared/validate-type");
3
6
  /**
4
7
  * Convert from Wei to Ether
5
8
  *
@@ -23,21 +26,20 @@ import { validateType } from "../shared/validate-type";
23
26
  * weiToEther(1000000000000000000000).toNumber()
24
27
  * // 1000
25
28
  * ```
26
- */ export function weiToEther(weiQuantity) {
27
- validateType(weiQuantity, [
28
- "string",
29
- "number",
30
- "object"
31
- ]);
29
+ */
30
+ function weiToEther(weiQuantity) {
31
+ (0, validate_type_1.validateType)(weiQuantity, ['string', 'number', 'object']);
32
32
  // eslint-disable-next-line no-useless-catch
33
33
  try {
34
- var _weiQuantity = weiQuantity;
35
- if (typeof weiQuantity === "string" && weiQuantity.slice(0, 2) === "0x") {
34
+ let _weiQuantity = weiQuantity;
35
+ if (typeof weiQuantity === 'string' && weiQuantity.slice(0, 2) === '0x') {
36
36
  _weiQuantity = BigInt(weiQuantity).toString();
37
37
  }
38
- var result = tinyBig(_weiQuantity).div("1000000000000000000");
39
- return tinyBig(result);
40
- } catch (error) {
38
+ const result = (0, tiny_big_1.tinyBig)(_weiQuantity).div('1000000000000000000');
39
+ return (0, tiny_big_1.tinyBig)(result);
40
+ }
41
+ catch (error) {
41
42
  throw error;
42
43
  }
43
44
  }
45
+ exports.weiToEther = weiToEther;
@@ -1,2 +1,2 @@
1
- import type { JSONABI } from '../../..';
1
+ import type { JSONABI } from '../../../types/Contract.types';
2
2
  export declare const ensABI: JSONABI;
@@ -1,2 +1,2 @@
1
- import type { JSONABI } from '../../..';
1
+ import type { JSONABI } from '../../../types/Contract.types';
2
2
  export declare const fooABI: JSONABI;
@@ -1,9 +1,15 @@
1
+ export declare function buildFetchInit<T>(body: T): {
2
+ method: string;
3
+ headers: {
4
+ 'Content-Type': string;
5
+ };
6
+ body: string;
7
+ };
1
8
  export declare function post(url: string, body: Record<string, unknown>): Promise<any>;
2
- declare type RPCMethodName = 'eth_getBlockByNumber' | 'eth_getBlockByHash' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice' | 'eth_getBalance' | 'eth_getTransactionByHash' | 'eth_getTransactionReceipt' | 'eth_getTransactionCount' | 'eth_getCode' | 'eth_blockNumber' | 'eth_estimateGas' | 'eth_getLogs';
9
+ export type RPCMethodName = 'eth_getBlockByNumber' | 'eth_getBlockByHash' | 'eth_call' | 'eth_chainId' | 'eth_gasPrice' | 'eth_getBalance' | 'eth_getTransactionByHash' | 'eth_getTransactionReceipt' | 'eth_getTransactionCount' | 'eth_getCode' | 'eth_blockNumber' | 'eth_estimateGas' | 'eth_getLogs';
3
10
  export declare function buildRPCPostBody(method: RPCMethodName, params: unknown[]): {
4
11
  jsonrpc: string;
5
12
  id: number;
6
13
  method: RPCMethodName;
7
14
  params: unknown[];
8
15
  };
9
- export {};
@@ -8,14 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import unfetch from 'isomorphic-unfetch';
11
- export function post(url, body) {
12
- return unfetch(url, {
11
+ export function buildFetchInit(body) {
12
+ return {
13
13
  method: 'POST',
14
14
  headers: {
15
15
  'Content-Type': 'application/json',
16
16
  },
17
17
  body: JSON.stringify(body),
18
- })
18
+ };
19
+ }
20
+ export function post(url, body) {
21
+ return unfetch(url, buildFetchInit(body))
19
22
  .then((r) => __awaiter(this, void 0, void 0, function* () {
20
23
  const t = yield r.text();
21
24
  try {
@@ -1,26 +1,25 @@
1
- import { BaseContract, Contract } from './classes/Contract';
2
- import { AlchemyProvider } from './providers/AlchemyProvider';
3
- import { ConstructorOptions, FallthroughProvider } from './providers/FallthroughProvider';
4
- import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
5
- import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
- import { BlockResponse, BlockTag, RPCBlock } from './types/Block.types';
7
- import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
8
- import { Filter, FilterByBlockHash } from './types/Filter.types';
9
- import { Network } from './types/Network.types';
10
- import { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, RPCTransactionRequest, TransactionReceipt, TransactionRequest, TransactionResponse } from './types/Transaction.types';
11
- import { computeAddress } from './utils/compute-address';
12
- import { computePublicKey } from './utils/compute-public-key';
13
- import { etherToGwei } from './utils/ether-to-gwei';
14
- import { etherToWei } from './utils/ether-to-wei';
15
- import { gweiToEther } from './utils/gwei-to-ether';
16
- import { hashMessage } from './utils/hash-message';
17
- import { isAddress } from './utils/is-address';
18
- import { splitSignature } from './utils/split-signature';
19
- import { toChecksumAddress } from './utils/to-checksum-address';
20
- import { toUtf8Bytes } from './utils/to-utf8-bytes';
21
- import { weiToEther } from './utils/wei-to-ether';
1
+ export { Contract, BaseContract } from './classes/Contract';
2
+ export { AlchemyProvider } from './providers/AlchemyProvider';
3
+ export { FallthroughProvider, ConstructorOptions, } from './providers/FallthroughProvider';
4
+ export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
5
+ export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
+ export { BlockResponse, RPCBlock, BlockTag } from './types/Block.types';
7
+ export { ContractTypes, JSONABI, JSONABIArgument, } from './types/Contract.types';
8
+ export { Filter, FilterByBlockHash } from './types/Filter.types';
9
+ export { Network } from './types/Network.types';
10
+ export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse, } from './types/Transaction.types';
11
+ export { computeAddress } from './utils/compute-address';
12
+ export { computePublicKey } from './utils/compute-public-key';
13
+ export { etherToGwei } from './utils/ether-to-gwei';
14
+ export { etherToWei } from './utils/ether-to-wei';
15
+ export { gweiToEther } from './utils/gwei-to-ether';
16
+ export { hashMessage } from './utils/hash-message';
17
+ export { isAddress } from './utils/is-address';
18
+ export { splitSignature } from './utils/split-signature';
19
+ export { toChecksumAddress } from './utils/to-checksum-address';
20
+ export { toUtf8Bytes } from './utils/to-utf8-bytes';
21
+ export { weiToEther } from './utils/wei-to-ether';
22
22
  export * from './utils/bytes';
23
23
  export * from './utils/hash-message';
24
24
  export * from './utils/keccak256';
25
25
  export * from './utils/solidity-keccak256';
26
- export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, AlchemyProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, Filter, FilterByBlockHash, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
package/dist/esm/index.js CHANGED
@@ -1,21 +1,20 @@
1
- import { BaseContract, Contract } from './classes/Contract';
2
- import { AlchemyProvider } from './providers/AlchemyProvider';
3
- import { FallthroughProvider, } from './providers/FallthroughProvider';
4
- import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
5
- import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
- import { computeAddress } from './utils/compute-address';
7
- import { computePublicKey } from './utils/compute-public-key';
8
- import { etherToGwei } from './utils/ether-to-gwei';
9
- import { etherToWei } from './utils/ether-to-wei';
10
- import { gweiToEther } from './utils/gwei-to-ether';
11
- import { hashMessage } from './utils/hash-message';
12
- import { isAddress } from './utils/is-address';
13
- import { splitSignature } from './utils/split-signature';
14
- import { toChecksumAddress } from './utils/to-checksum-address';
15
- import { toUtf8Bytes } from './utils/to-utf8-bytes';
16
- import { weiToEther } from './utils/wei-to-ether';
1
+ export { Contract, BaseContract } from './classes/Contract';
2
+ export { AlchemyProvider } from './providers/AlchemyProvider';
3
+ export { FallthroughProvider, } from './providers/FallthroughProvider';
4
+ export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
5
+ export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
+ export { computeAddress } from './utils/compute-address';
7
+ export { computePublicKey } from './utils/compute-public-key';
8
+ export { etherToGwei } from './utils/ether-to-gwei';
9
+ export { etherToWei } from './utils/ether-to-wei';
10
+ export { gweiToEther } from './utils/gwei-to-ether';
11
+ export { hashMessage } from './utils/hash-message';
12
+ export { isAddress } from './utils/is-address';
13
+ export { splitSignature } from './utils/split-signature';
14
+ export { toChecksumAddress } from './utils/to-checksum-address';
15
+ export { toUtf8Bytes } from './utils/to-utf8-bytes';
16
+ export { weiToEther } from './utils/wei-to-ether';
17
17
  export * from './utils/bytes';
18
18
  export * from './utils/hash-message';
19
19
  export * from './utils/keccak256';
20
20
  export * from './utils/solidity-keccak256';
21
- export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, AlchemyProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, };
@@ -1 +1 @@
1
- export declare const version = "0.9.0";
1
+ export declare const version = "0.9.1-next.1";
@@ -1 +1 @@
1
- export const version = '0.9.0';
1
+ export const version = '0.9.1-next.1';
@@ -14,6 +14,9 @@ const promiseTimeout = (prom, time) => new Promise((resolve, reject) => {
14
14
  });
15
15
  const DEFAULT_TIMEOUT_DURATION = 8000;
16
16
  export class FallthroughProvider extends BaseProvider {
17
+ selectRpcUrl() {
18
+ return this._rpcUrls[this.rpcUrlCounter];
19
+ }
17
20
  constructor(rpcUrls, options = {}) {
18
21
  if (!Array.isArray(rpcUrls)) {
19
22
  logger.throwError('Array required', { rpcUrls });
@@ -43,7 +46,4 @@ export class FallthroughProvider extends BaseProvider {
43
46
  };
44
47
  this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
45
48
  }
46
- selectRpcUrl() {
47
- return this._rpcUrls[this.rpcUrlCounter];
48
- }
49
49
  }
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,142 @@
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
+ });
@@ -3,6 +3,7 @@ export declare const fakeUrls: {
3
3
  };
4
4
  export declare const rpcUrls: {
5
5
  mainnet: string;
6
+ oeth: string;
6
7
  matic: string;
7
8
  gno: string;
8
9
  bnb: string;
@@ -2,12 +2,15 @@ import z from 'zod';
2
2
  export const fakeUrls = {
3
3
  notRPCButRealHttp: 'https://httpstat.us/200',
4
4
  };
5
- const RPC_ORIGIN = process.env.RPC_ORIGIN;
6
- if (!z.string().url().safeParse(RPC_ORIGIN).success) {
7
- throw new Error('RPC_ORIGIN is not defined or is invalid URL');
8
- }
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);
9
11
  export const rpcUrls = {
10
12
  mainnet: `${RPC_ORIGIN}/api/eth`,
13
+ oeth: `${RPC_ORIGIN}/api/oeth`,
11
14
  matic: `${RPC_ORIGIN}/api/MATIC`,
12
15
  gno: `${RPC_ORIGIN}/api/gno`,
13
16
  bnb: `${RPC_ORIGIN}/api/bnb`,