essential-eth 0.10.2 → 0.10.4-beta.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 (205) hide show
  1. package/dist/index.cjs +2024 -0
  2. package/dist/index.d.cts +330 -0
  3. package/dist/index.d.ts +330 -0
  4. package/dist/index.js +1952 -0
  5. package/package.json +13 -14
  6. package/readme.md +1 -1
  7. package/dist/cjs/classes/Contract.d.ts +0 -81
  8. package/dist/cjs/classes/Contract.js +0 -139
  9. package/dist/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
  10. package/dist/cjs/classes/test/Contract/crv-abi.js +0 -413
  11. package/dist/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
  12. package/dist/cjs/classes/test/Contract/ens-abi.js +0 -453
  13. package/dist/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
  14. package/dist/cjs/classes/test/Contract/fei-abi.js +0 -526
  15. package/dist/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
  16. package/dist/cjs/classes/test/Contract/foo-abi.js +0 -42
  17. package/dist/cjs/classes/test/Contract/jokerrace-abi.d.ts +0 -2
  18. package/dist/cjs/classes/test/Contract/jokerrace-abi.js +0 -22
  19. package/dist/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
  20. package/dist/cjs/classes/test/Contract/uniswap-abi.js +0 -121
  21. package/dist/cjs/classes/utils/clean-block.d.ts +0 -120
  22. package/dist/cjs/classes/utils/clean-block.js +0 -160
  23. package/dist/cjs/classes/utils/clean-log.d.ts +0 -9
  24. package/dist/cjs/classes/utils/clean-log.js +0 -39
  25. package/dist/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -14
  26. package/dist/cjs/classes/utils/clean-transaction-receipt.js +0 -53
  27. package/dist/cjs/classes/utils/clean-transaction.d.ts +0 -14
  28. package/dist/cjs/classes/utils/clean-transaction.js +0 -54
  29. package/dist/cjs/classes/utils/encode-decode-transaction.d.ts +0 -16
  30. package/dist/cjs/classes/utils/encode-decode-transaction.js +0 -186
  31. package/dist/cjs/classes/utils/fetchers.d.ts +0 -53
  32. package/dist/cjs/classes/utils/fetchers.js +0 -85
  33. package/dist/cjs/classes/utils/hex-to-decimal.d.ts +0 -18
  34. package/dist/cjs/classes/utils/hex-to-decimal.js +0 -24
  35. package/dist/cjs/classes/utils/prepare-transaction.d.ts +0 -6
  36. package/dist/cjs/classes/utils/prepare-transaction.js +0 -47
  37. package/dist/cjs/index.d.ts +0 -24
  38. package/dist/cjs/index.js +0 -58
  39. package/dist/cjs/index.umd.js +0 -2
  40. package/dist/cjs/index.umd.js.map +0 -1
  41. package/dist/cjs/logger/logger.d.ts +0 -11
  42. package/dist/cjs/logger/logger.js +0 -37
  43. package/dist/cjs/logger/package-version.d.ts +0 -1
  44. package/dist/cjs/logger/package-version.js +0 -5
  45. package/dist/cjs/package.json +0 -1
  46. package/dist/cjs/providers/AlchemyProvider.d.ts +0 -4
  47. package/dist/cjs/providers/AlchemyProvider.js +0 -11
  48. package/dist/cjs/providers/BaseProvider.d.ts +0 -374
  49. package/dist/cjs/providers/BaseProvider.js +0 -514
  50. package/dist/cjs/providers/FallthroughProvider.d.ts +0 -24
  51. package/dist/cjs/providers/FallthroughProvider.js +0 -74
  52. package/dist/cjs/providers/JsonRpcProvider.d.ts +0 -33
  53. package/dist/cjs/providers/JsonRpcProvider.js +0 -46
  54. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
  55. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +0 -152
  56. package/dist/cjs/providers/test/mock-of.d.ts +0 -8
  57. package/dist/cjs/providers/test/mock-of.js +0 -12
  58. package/dist/cjs/providers/test/rpc-urls.d.ts +0 -12
  59. package/dist/cjs/providers/test/rpc-urls.js +0 -27
  60. package/dist/cjs/providers/utils/chains-info.d.ts +0 -24
  61. package/dist/cjs/providers/utils/chains-info.js +0 -71
  62. package/dist/cjs/shared/tiny-big/helpers.d.ts +0 -17
  63. package/dist/cjs/shared/tiny-big/helpers.js +0 -97
  64. package/dist/cjs/shared/tiny-big/tiny-big.d.ts +0 -58
  65. package/dist/cjs/shared/tiny-big/tiny-big.js +0 -101
  66. package/dist/cjs/shared/validate-type.d.ts +0 -3
  67. package/dist/cjs/shared/validate-type.js +0 -9
  68. package/dist/cjs/types/Block.types.d.ts +0 -41
  69. package/dist/cjs/types/Block.types.js +0 -2
  70. package/dist/cjs/types/Contract.types.d.ts +0 -24
  71. package/dist/cjs/types/Contract.types.js +0 -2
  72. package/dist/cjs/types/FeeData.types.d.ts +0 -7
  73. package/dist/cjs/types/FeeData.types.js +0 -2
  74. package/dist/cjs/types/Filter.types.d.ts +0 -16
  75. package/dist/cjs/types/Filter.types.js +0 -2
  76. package/dist/cjs/types/Network.types.d.ts +0 -8
  77. package/dist/cjs/types/Network.types.js +0 -2
  78. package/dist/cjs/types/Transaction.types.d.ts +0 -123
  79. package/dist/cjs/types/Transaction.types.js +0 -2
  80. package/dist/cjs/utils/bytes.d.ts +0 -289
  81. package/dist/cjs/utils/bytes.js +0 -711
  82. package/dist/cjs/utils/compute-address.d.ts +0 -17
  83. package/dist/cjs/utils/compute-address.js +0 -34
  84. package/dist/cjs/utils/compute-public-key.d.ts +0 -18
  85. package/dist/cjs/utils/compute-public-key.js +0 -26
  86. package/dist/cjs/utils/ether-to-gwei.d.ts +0 -27
  87. package/dist/cjs/utils/ether-to-gwei.js +0 -35
  88. package/dist/cjs/utils/ether-to-wei.d.ts +0 -27
  89. package/dist/cjs/utils/ether-to-wei.js +0 -35
  90. package/dist/cjs/utils/gwei-to-ether.d.ts +0 -27
  91. package/dist/cjs/utils/gwei-to-ether.js +0 -35
  92. package/dist/cjs/utils/hash-message.d.ts +0 -14
  93. package/dist/cjs/utils/hash-message.js +0 -30
  94. package/dist/cjs/utils/is-address.d.ts +0 -24
  95. package/dist/cjs/utils/is-address.js +0 -39
  96. package/dist/cjs/utils/keccak256.d.ts +0 -16
  97. package/dist/cjs/utils/keccak256.js +0 -31
  98. package/dist/cjs/utils/solidity-keccak256.d.ts +0 -39
  99. package/dist/cjs/utils/solidity-keccak256.js +0 -138
  100. package/dist/cjs/utils/split-signature.d.ts +0 -24
  101. package/dist/cjs/utils/split-signature.js +0 -163
  102. package/dist/cjs/utils/to-checksum-address.d.ts +0 -17
  103. package/dist/cjs/utils/to-checksum-address.js +0 -46
  104. package/dist/cjs/utils/to-utf8-bytes.d.ts +0 -15
  105. package/dist/cjs/utils/to-utf8-bytes.js +0 -21
  106. package/dist/cjs/utils/wei-to-ether.d.ts +0 -27
  107. package/dist/cjs/utils/wei-to-ether.js +0 -45
  108. package/dist/esm/classes/Contract.d.ts +0 -11
  109. package/dist/esm/classes/Contract.js +0 -58
  110. package/dist/esm/classes/test/Contract/crv-abi.d.ts +0 -2
  111. package/dist/esm/classes/test/Contract/crv-abi.js +0 -395
  112. package/dist/esm/classes/test/Contract/ens-abi.d.ts +0 -2
  113. package/dist/esm/classes/test/Contract/ens-abi.js +0 -435
  114. package/dist/esm/classes/test/Contract/fei-abi.d.ts +0 -2
  115. package/dist/esm/classes/test/Contract/fei-abi.js +0 -521
  116. package/dist/esm/classes/test/Contract/foo-abi.d.ts +0 -2
  117. package/dist/esm/classes/test/Contract/foo-abi.js +0 -33
  118. package/dist/esm/classes/test/Contract/jokerrace-abi.d.ts +0 -2
  119. package/dist/esm/classes/test/Contract/jokerrace-abi.js +0 -18
  120. package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
  121. package/dist/esm/classes/test/Contract/uniswap-abi.js +0 -116
  122. package/dist/esm/classes/utils/clean-block.d.ts +0 -2
  123. package/dist/esm/classes/utils/clean-block.js +0 -35
  124. package/dist/esm/classes/utils/clean-log.d.ts +0 -2
  125. package/dist/esm/classes/utils/clean-log.js +0 -28
  126. package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +0 -2
  127. package/dist/esm/classes/utils/clean-transaction-receipt.js +0 -37
  128. package/dist/esm/classes/utils/clean-transaction.d.ts +0 -2
  129. package/dist/esm/classes/utils/clean-transaction.js +0 -36
  130. package/dist/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
  131. package/dist/esm/classes/utils/encode-decode-transaction.js +0 -143
  132. package/dist/esm/classes/utils/fetchers.d.ts +0 -15
  133. package/dist/esm/classes/utils/fetchers.js +0 -37
  134. package/dist/esm/classes/utils/hex-to-decimal.d.ts +0 -1
  135. package/dist/esm/classes/utils/hex-to-decimal.js +0 -3
  136. package/dist/esm/classes/utils/prepare-transaction.d.ts +0 -2
  137. package/dist/esm/classes/utils/prepare-transaction.js +0 -36
  138. package/dist/esm/index.d.ts +0 -24
  139. package/dist/esm/index.js +0 -19
  140. package/dist/esm/logger/logger.d.ts +0 -11
  141. package/dist/esm/logger/logger.js +0 -34
  142. package/dist/esm/logger/package-version.d.ts +0 -1
  143. package/dist/esm/logger/package-version.js +0 -1
  144. package/dist/esm/providers/AlchemyProvider.d.ts +0 -4
  145. package/dist/esm/providers/AlchemyProvider.js +0 -7
  146. package/dist/esm/providers/BaseProvider.d.ts +0 -26
  147. package/dist/esm/providers/BaseProvider.js +0 -137
  148. package/dist/esm/providers/FallthroughProvider.d.ts +0 -11
  149. package/dist/esm/providers/FallthroughProvider.js +0 -50
  150. package/dist/esm/providers/JsonRpcProvider.d.ts +0 -7
  151. package/dist/esm/providers/JsonRpcProvider.js +0 -15
  152. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
  153. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +0 -142
  154. package/dist/esm/providers/test/mock-of.d.ts +0 -1
  155. package/dist/esm/providers/test/mock-of.js +0 -1
  156. package/dist/esm/providers/test/rpc-urls.d.ts +0 -12
  157. package/dist/esm/providers/test/rpc-urls.js +0 -21
  158. package/dist/esm/providers/utils/chains-info.d.ts +0 -24
  159. package/dist/esm/providers/utils/chains-info.js +0 -67
  160. package/dist/esm/shared/tiny-big/helpers.d.ts +0 -1
  161. package/dist/esm/shared/tiny-big/helpers.js +0 -58
  162. package/dist/esm/shared/tiny-big/tiny-big.d.ts +0 -10
  163. package/dist/esm/shared/tiny-big/tiny-big.js +0 -45
  164. package/dist/esm/shared/validate-type.d.ts +0 -3
  165. package/dist/esm/shared/validate-type.js +0 -5
  166. package/dist/esm/types/Block.types.d.ts +0 -40
  167. package/dist/esm/types/Block.types.js +0 -1
  168. package/dist/esm/types/Contract.types.d.ts +0 -24
  169. package/dist/esm/types/Contract.types.js +0 -1
  170. package/dist/esm/types/FeeData.types.d.ts +0 -7
  171. package/dist/esm/types/FeeData.types.js +0 -1
  172. package/dist/esm/types/Filter.types.d.ts +0 -12
  173. package/dist/esm/types/Filter.types.js +0 -1
  174. package/dist/esm/types/Network.types.d.ts +0 -5
  175. package/dist/esm/types/Network.types.js +0 -1
  176. package/dist/esm/types/Transaction.types.d.ts +0 -113
  177. package/dist/esm/types/Transaction.types.js +0 -1
  178. package/dist/esm/utils/bytes.d.ts +0 -40
  179. package/dist/esm/utils/bytes.js +0 -245
  180. package/dist/esm/utils/compute-address.d.ts +0 -1
  181. package/dist/esm/utils/compute-address.js +0 -12
  182. package/dist/esm/utils/compute-public-key.d.ts +0 -2
  183. package/dist/esm/utils/compute-public-key.js +0 -6
  184. package/dist/esm/utils/ether-to-gwei.d.ts +0 -3
  185. package/dist/esm/utils/ether-to-gwei.js +0 -7
  186. package/dist/esm/utils/ether-to-wei.d.ts +0 -3
  187. package/dist/esm/utils/ether-to-wei.js +0 -7
  188. package/dist/esm/utils/gwei-to-ether.d.ts +0 -3
  189. package/dist/esm/utils/gwei-to-ether.js +0 -7
  190. package/dist/esm/utils/hash-message.d.ts +0 -2
  191. package/dist/esm/utils/hash-message.js +0 -14
  192. package/dist/esm/utils/is-address.d.ts +0 -1
  193. package/dist/esm/utils/is-address.js +0 -12
  194. package/dist/esm/utils/keccak256.d.ts +0 -2
  195. package/dist/esm/utils/keccak256.js +0 -13
  196. package/dist/esm/utils/solidity-keccak256.d.ts +0 -2
  197. package/dist/esm/utils/solidity-keccak256.js +0 -85
  198. package/dist/esm/utils/split-signature.d.ts +0 -2
  199. package/dist/esm/utils/split-signature.js +0 -126
  200. package/dist/esm/utils/to-checksum-address.d.ts +0 -1
  201. package/dist/esm/utils/to-checksum-address.js +0 -25
  202. package/dist/esm/utils/to-utf8-bytes.d.ts +0 -1
  203. package/dist/esm/utils/to-utf8-bytes.js +0 -3
  204. package/dist/esm/utils/wei-to-ether.d.ts +0 -3
  205. package/dist/esm/utils/wei-to-ether.js +0 -16
@@ -1,41 +0,0 @@
1
- import type { TinyBig } from './../shared/tiny-big/tiny-big';
2
- import type { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
3
- type Modify<T, R> = Omit<T, keyof R> & R;
4
- export type BlockResponse = Modify<RPCBlock, {
5
- baseFeePerGas: TinyBig;
6
- difficulty: TinyBig;
7
- gasLimit: TinyBig;
8
- gasUsed: TinyBig;
9
- nonce: TinyBig;
10
- number: number;
11
- size: TinyBig;
12
- timestamp: TinyBig;
13
- totalDifficulty: TinyBig;
14
- transactions: Array<string | BlockTransactionResponse>;
15
- }>;
16
- /** Exact response from backend */
17
- export interface RPCBlock {
18
- baseFeePerGas: string;
19
- difficulty: string;
20
- extraData: string;
21
- gasLimit: string;
22
- gasUsed: string;
23
- hash: string;
24
- logsBloom: string;
25
- miner: string;
26
- mixHash: string;
27
- nonce: string;
28
- number: string;
29
- parentHash: string;
30
- receiptsRoot: string;
31
- sha3Uncles: string;
32
- size: string;
33
- stateRoot: string;
34
- timestamp: string;
35
- totalDifficulty: string;
36
- transactions: Array<string | RPCTransaction>;
37
- transactionsRoot: string;
38
- uncles: Array<string>;
39
- }
40
- export type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
41
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +0,0 @@
1
- export type ContractTypes = 'bool' | 'bytes1' | 'bytes2' | 'bytes3' | 'bytes4' | 'bytes5' | 'bytes6' | 'bytes7' | 'bytes8' | 'bytes9' | 'bytes10' | 'bytes11' | 'bytes12' | 'bytes13' | 'bytes14' | 'bytes15' | 'bytes16' | 'bytes17' | 'bytes18' | 'bytes19' | 'bytes20' | 'bytes21' | 'bytes22' | 'bytes23' | 'bytes24' | 'bytes25' | 'bytes26' | 'bytes27' | 'bytes28' | 'bytes29' | 'bytes30' | 'bytes31' | 'bytes32' | 'bytes32[]' | 'address' | 'address payable' | 'address[4]' | 'address[100]' | 'uint256' | 'uint256[100]' | 'uint8' | 'uint32' | string;
2
- export type ContractInterface = JSONABI;
3
- export type ContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
4
- export interface JSONABIArgument {
5
- anonymous?: false;
6
- inputs: {
7
- internalType?: ContractTypes | string;
8
- name: string;
9
- type: ContractTypes;
10
- indexed?: boolean;
11
- }[];
12
- name?: string;
13
- outputs?: {
14
- internalType?: ContractTypes | string;
15
- name: string;
16
- type: ContractTypes;
17
- }[];
18
- stateMutability?: 'view' | 'nonpayable' | string;
19
- type: 'function' | 'event' | 'constructor' | 'error' | 'fallback';
20
- gas?: number;
21
- constant?: boolean;
22
- payable?: boolean;
23
- }
24
- export type JSONABI = JSONABIArgument[];
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import type { TinyBig } from '../shared/tiny-big/tiny-big';
2
- export interface FeeData {
3
- gasPrice: TinyBig;
4
- lastBaseFeePerGas: TinyBig | null;
5
- maxFeePerGas: TinyBig | null;
6
- maxPriorityFeePerGas: TinyBig | null;
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- import type { BlockTag } from './Block.types';
2
- export interface EventFilter {
3
- address?: string;
4
- topics?: Array<string | Array<string> | null>;
5
- }
6
- /**
7
- * @param fromBlock block as starting point for range, inclusive
8
- * @param toBlock block as ending point for range, inclusive
9
- */
10
- export interface Filter extends EventFilter {
11
- fromBlock?: BlockTag;
12
- toBlock?: BlockTag;
13
- }
14
- export interface FilterByBlockHash extends EventFilter {
15
- blockHash?: string;
16
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- /**
2
- * A trimmed version of https://chainid.network/chains.json
3
- */
4
- export interface Network {
5
- chainId: number;
6
- ensAddress: string | null;
7
- name: string;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,123 +0,0 @@
1
- import type Big from 'big.js';
2
- import type { TinyBig } from '../shared/tiny-big/tiny-big';
3
- import type { BytesLike } from './../utils/bytes';
4
- type Modify<T, R> = Omit<T, keyof R> & R;
5
- export interface RPCTransaction extends RPCBlockTransaction {
6
- maxFeePerGas: string;
7
- maxPriorityFeePerGas: string;
8
- }
9
- export type TransactionResponse = Modify<RPCTransaction, {
10
- blockNumber: number;
11
- chainId: number;
12
- gas: TinyBig;
13
- gasLimit: TinyBig;
14
- gasPrice: TinyBig;
15
- nonce: TinyBig;
16
- transactionIndex: number;
17
- type: number;
18
- v: number;
19
- value: TinyBig;
20
- } & {
21
- maxFeePerGas: TinyBig;
22
- maxPriorityFeePerGas: TinyBig;
23
- confirmations: number;
24
- }>;
25
- /**
26
- * Type that contains information from the receipt of a transaction
27
- *
28
- * * Similar to [`Type TransactionReceipt on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-TransactionReceipt)
29
- */
30
- export type TransactionReceipt = Modify<RPCTransactionReceipt, {
31
- blockNumber: number;
32
- cumulativeGasUsed: TinyBig;
33
- effectiveGasPrice: TinyBig;
34
- gasUsed: TinyBig;
35
- logs: Array<Log>;
36
- status: number;
37
- transactionIndex: number;
38
- type: number;
39
- } & {
40
- byzantium: boolean;
41
- confirmations: number;
42
- }>;
43
- export interface RPCTransactionRequest {
44
- from?: string;
45
- to: string;
46
- gas?: string;
47
- gasPrice?: string;
48
- value?: string;
49
- data?: BytesLike;
50
- nonce?: string;
51
- maxPriorityFeePerGas?: string;
52
- maxFeePerGas?: string;
53
- }
54
- export interface TransactionRequest {
55
- to?: string;
56
- from?: string;
57
- nonce?: TinyBig | string | Big | number;
58
- gas?: TinyBig | number | Big | string;
59
- gasPrice?: TinyBig | Big | string | number;
60
- data?: BytesLike;
61
- value?: TinyBig | string | Big | number;
62
- chainId?: number;
63
- type?: number;
64
- maxPriorityFeePerGas?: TinyBig | string | Big | number;
65
- maxFeePerGas?: TinyBig | string | Big | number;
66
- }
67
- /**
68
- * Type for the logs that are included in transaction receipts
69
- * Similar to [`Type Log on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-Log)
70
- */
71
- export type Log = Modify<RPCLog, {
72
- blockNumber: number;
73
- logIndex: number;
74
- transactionIndex: number;
75
- }>;
76
- export type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
77
- /** What JSONRPC responds with in getBlock transaction array */
78
- export interface RPCBlockTransaction {
79
- blockHash: string;
80
- blockNumber: string;
81
- chainId: string;
82
- from: string;
83
- gas: string;
84
- gasPrice: string;
85
- hash: string;
86
- input: string;
87
- nonce: string;
88
- r: string;
89
- s: string;
90
- to: string;
91
- transactionIndex: string;
92
- type: string;
93
- v: string;
94
- value: string;
95
- }
96
- export interface RPCTransactionReceipt {
97
- blockHash: string;
98
- blockNumber: string;
99
- contractAddress: string;
100
- cumulativeGasUsed: string;
101
- effectiveGasPrice: string;
102
- from: string;
103
- gasUsed: string;
104
- logs: Array<RPCLog>;
105
- logsBloom: string;
106
- status: string;
107
- to: string;
108
- transactionHash: string;
109
- transactionIndex: string;
110
- type: string;
111
- }
112
- export interface RPCLog {
113
- address: string;
114
- blockHash: string;
115
- blockNumber: string;
116
- data: string;
117
- logIndex: string;
118
- removed?: boolean;
119
- topics: Array<string>;
120
- transactionHash: string;
121
- transactionIndex: string;
122
- }
123
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,289 +0,0 @@
1
- export type Bytes = ArrayLike<number>;
2
- /**
3
- * @example
4
- * [1,2,3]
5
- * @example
6
- * 0x123
7
- * @example
8
- * '0x123'
9
- */
10
- export type BytesLike = Bytes | string;
11
- export type BytesLikeWithNumber = BytesLike | number;
12
- export interface DataOptions {
13
- allowMissingPrefix?: boolean;
14
- hexPad?: 'left' | 'right' | null;
15
- }
16
- export interface Hexable {
17
- toHexString(): string;
18
- }
19
- export type SignatureLike = {
20
- r: string;
21
- s?: string;
22
- _vs?: string;
23
- recoveryParam?: number;
24
- v?: number;
25
- } | BytesLike;
26
- export interface Signature {
27
- r: string;
28
- s: string;
29
- _vs: string;
30
- recoveryParam: number;
31
- v: number;
32
- yParityAndS: string;
33
- compact: string;
34
- }
35
- /**
36
- * Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
37
- * Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
38
- *
39
- * @param value the value to check whether or not it matches BytesLike
40
- * @returns whether or not the value matches BytesLike
41
- * @example
42
- * ```javascript
43
- * isBytesLike([1,2,3]);
44
- * // true
45
- * ```
46
- * @example
47
- * ```javascript
48
- * isBytesLike(false);
49
- * // false
50
- * ```
51
- * @example
52
- * ```javascript
53
- * isBytesLike(new Uint8Array(1));
54
- * // true
55
- * ```
56
- */
57
- export declare function isBytesLike(value: any): value is BytesLike;
58
- /**
59
- * Returns true if and only if value is a valid [Bytes](#bytes)
60
- * Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
61
- *
62
- * @param value the value to check whether or not it matches Bytes
63
- * @returns whether or not the value matches Bytes
64
- * @example
65
- * ```javascript
66
- * isBytes([1,2,3]);
67
- * // true
68
- * ```
69
- * @example
70
- * ```javascript
71
- * isBytes(false);
72
- * // false
73
- * ```
74
- * @example
75
- * ```javascript
76
- * isBytes(new Uint8Array(1));
77
- * // true
78
- * ```
79
- */
80
- export declare function isBytes(value: any): value is Bytes;
81
- /**
82
- * Converts DataHexStringOrArrayish to a Uint8Array
83
- * Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
84
- *
85
- * @param value the value to convert to a Uint8Array
86
- * @param options options to use when converting the value to a Uint8Array
87
- * @returns the value represented as a Uint8Array
88
- * @example
89
- * ```javascript
90
- * arrayify(1);
91
- * // Uint8Array(1) [ 1 ]
92
- * ```
93
- * @example
94
- * ```javascript
95
- * arrayify(0x1234);
96
- * // Uint8Array(2) [ 18, 52 ]
97
- * ```
98
- * @example
99
- * ```javascript
100
- * arrayify('0x1', { hexPad: 'right' });
101
- * // Uint8Array(1) [ 16 ]
102
- * ```
103
- */
104
- export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
105
- /**
106
- * Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
107
- * Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
108
- *
109
- * @param arrayOfBytesLike the array of {@link BytesLike} to concatenate together
110
- * @returns a concatenated Uint8Array
111
- * @example
112
- * ```javascript
113
- * concat([0, 1]);
114
- * // Uint8Array(2) [ 0, 1 ]
115
- * ```
116
- */
117
- export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
118
- /**
119
- * Strips leading zeros from a BytesLike object
120
- *
121
- * @param value the value to strip leading zeros from
122
- * @returns value without leading zeroes, expressed as a Uint8Array
123
- * @example
124
- * ```javascript
125
- * stripZeros('0x00002834');
126
- * // Uint8Array { [Iterator] 0: 40, 1: 52 }
127
- * // Equivalent to '0x2834'
128
- * ```
129
- */
130
- export declare function stripZeros(value: BytesLike): Uint8Array;
131
- /**
132
- * Pads the beginning of a {@link BytesLike} with zeros so it's the specified length as a Uint8Array
133
- *
134
- * @param value the value to pad
135
- * @param length the desired length of the value
136
- * @returns the value padded with zeros to the specified length
137
- * @example
138
- * ```javascript
139
- * zeroPad('0x039284');
140
- * // Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
141
- * // Equivalent to 0x000000039284
142
- * ```
143
- * @example
144
- * ```javascript
145
- * zeroPad([39, 25, 103, 45], 5);
146
- * // Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }
147
- * ```
148
- */
149
- export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
150
- /**
151
- * Returns true if and only if object is a valid hex string.
152
- * If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
153
- * Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
154
- *
155
- * @param value the value to check whether or not it's a hex string
156
- * @param length a length of bytes that the value should be equal to
157
- * @returns whether the value is a valid hex string (and optionally, whether it matches the length specified)
158
- * @example
159
- * ```javascript
160
- * isHexString('0x4924');
161
- * // true
162
- * ```
163
- * @example
164
- * ```javascript
165
- * isHexString('0x4924', 4);
166
- * // false
167
- * // length of 4 in bytes would mean a hex string with 8 characters
168
- * ```
169
- */
170
- export declare function isHexString(value: any, length?: number): boolean;
171
- /**
172
- * Converts a value into a hex string
173
- *
174
- * @param value the value to convert
175
- * @param options options to use when converting the value to a hex string
176
- * @returns the value represented as a hex string
177
- * @example
178
- * ```javascript
179
- * hexlify(4);
180
- * // '0x04'
181
- * ```
182
- * @example
183
- * ```javascript
184
- * hexlify(14);
185
- * // '0x0e'
186
- * ```
187
- */
188
- export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
189
- /**
190
- * Gets the length of data represented as a hex string
191
- *
192
- * @param data the data to check the length of
193
- * @returns the length of the data
194
- * @example
195
- * ```javascript
196
- * hexDataLength([2, 4, 0, 1]);
197
- * // 4
198
- * ```
199
- * @example
200
- * ```javascript
201
- * hexDataLength('0x3925');
202
- * // 2
203
- * ```
204
- */
205
- export declare function hexDataLength(data: BytesLike): number | null;
206
- /**
207
- * Slices a {@link BytesLike} to extract a certain part of the input
208
- *
209
- * @param data the data to slice from
210
- * @param offset the index to start extraction at
211
- * @param endOffset the index to end extraction at
212
- * @returns the extracted data as a hex string
213
- * @example
214
- * ```javascript
215
- * hexDataSlice([20, 6, 48], 0, 2);
216
- * // '0x1406'
217
- * ```
218
- */
219
- export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
220
- /**
221
- * Concatenates values together into one hex string
222
- *
223
- * @param items the items to concatenate together
224
- * @returns a single hex string including all of the items to be concatenated
225
- * @example
226
- * ```javascript
227
- * hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
228
- * // '0x020400010929343947'
229
- * ```
230
- */
231
- export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
232
- /**
233
- * Converts a number of different types into a hex string
234
- *
235
- * @param value the value to convert into a hex string
236
- * @returns the value represented as a hex string
237
- * @example
238
- * ```javascript
239
- * hexValue(39);
240
- * // '0x27'
241
- * ```
242
- * @example
243
- * ```javascript
244
- * hexValue([9, 4, 19, 4]);
245
- * // '0x9041304'
246
- * ```
247
- */
248
- export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
249
- /**
250
- * Strips the leading zeros from a value and returns it as a hex string
251
- *
252
- * @param value the value to strip zeros from
253
- * @returns a hex string representation of the value, without leading zeros
254
- * @example
255
- * ```javascript
256
- * hexStripZeros([0,0,0,48]);
257
- * // '0x30'
258
- * ```
259
- */
260
- export declare function hexStripZeros(value: BytesLike): string;
261
- /**
262
- * Returns a hex string padded to a specified length of bytes.
263
- *
264
- * Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
265
- *
266
- * Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
267
- *
268
- * @param value A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
269
- * @param length The final length in bytes
270
- * @returns A hex string padded to the specified length
271
- * @throws If the value is not a hex string or number
272
- * @throws If the value is longer than the length
273
- * @example
274
- * ```javascript
275
- * hexZeroPad('0x60', 2);
276
- * // '0x0060'
277
- * ```
278
- * @example
279
- * ```javascript
280
- * hexZeroPad(0x60, 3);
281
- * // '0x000060'
282
- * ```
283
- * @example
284
- * ```javascript
285
- * hexZeroPad('12345', 1);
286
- * // Throws
287
- * ```
288
- */
289
- export declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;