@@ -39,6 +39,7 @@ import {
3939 Transaction ,
4040 TransactionCall ,
4141 TransactionWithLocalWalletIndex ,
42+ Web3EthExecutionAPI ,
4243} from 'web3-types' ;
4344import { Web3Context , Web3PromiEvent } from 'web3-core' ;
4445import {
@@ -52,8 +53,14 @@ import {
5253} from 'web3-utils' ;
5354import { isBlockTag , isBytes , isNullish , isString } from 'web3-validator' ;
5455import { TransactionError , TransactionRevertError } from 'web3-errors' ;
56+ import { ethRpcMethods } from 'web3-rpc-methods' ;
57+ import {
58+ formatTransaction ,
59+ getTransactionGasPricing ,
60+ getTransactionFromAttr ,
61+ } from 'web3-eth-transaction-utils' ;
62+
5563import { SignatureError , TransactionSendTimeoutError } from './errors' ;
56- import * as rpcMethods from './rpc_methods' ;
5764import {
5865 accountSchema ,
5966 blockSchema ,
@@ -69,14 +76,8 @@ import {
6976 SendTransactionOptions ,
7077} from './types' ;
7178// eslint-disable-next-line import/no-cycle
72- import { getTransactionFromAttr } from './utils/transaction_builder' ;
73- import { formatTransaction } from './utils/format_transaction' ;
74- // eslint-disable-next-line import/no-cycle
75- import { getTransactionGasPricing } from './utils/get_transaction_gas_pricing' ;
76- // eslint-disable-next-line import/no-cycle
7779import { waitForTransactionReceipt } from './utils/wait_for_transaction_receipt' ;
7880import { watchTransactionForConfirmations } from './utils/watch_transaction_for_confirmations' ;
79- import { Web3EthExecutionAPI } from './web3_eth_execution_api' ;
8081import { NUMBER_DATA_FORMAT } from './constants' ;
8182import { decodeSignedTransaction } from './utils/decode_signed_transaction' ;
8283
@@ -91,7 +92,7 @@ import { decodeSignedTransaction } from './utils/decode_signed_transaction';
9192 * ```
9293 */
9394export const getProtocolVersion = async ( web3Context : Web3Context < EthExecutionAPI > ) =>
94- rpcMethods . getProtocolVersion ( web3Context . requestManager ) ;
95+ ethRpcMethods . getProtocolVersion ( web3Context . requestManager ) ;
9596
9697// TODO Add returnFormat parameter
9798/**
@@ -112,7 +113,7 @@ export const getProtocolVersion = async (web3Context: Web3Context<EthExecutionAP
112113 * ```
113114 */
114115export const isSyncing = async ( web3Context : Web3Context < EthExecutionAPI > ) =>
115- rpcMethods . getSyncing ( web3Context . requestManager ) ;
116+ ethRpcMethods . getSyncing ( web3Context . requestManager ) ;
116117
117118// TODO consider adding returnFormat parameter (to format address as bytes)
118119/**
@@ -125,7 +126,7 @@ export const isSyncing = async (web3Context: Web3Context<EthExecutionAPI>) =>
125126 * ```
126127 */
127128export const getCoinbase = async ( web3Context : Web3Context < EthExecutionAPI > ) =>
128- rpcMethods . getCoinbase ( web3Context . requestManager ) ;
129+ ethRpcMethods . getCoinbase ( web3Context . requestManager ) ;
129130
130131/**
131132 * Checks whether the node is mining or not.
@@ -139,7 +140,7 @@ export const getCoinbase = async (web3Context: Web3Context<EthExecutionAPI>) =>
139140 * ```
140141 */
141142export const isMining = async ( web3Context : Web3Context < EthExecutionAPI > ) =>
142- rpcMethods . getMining ( web3Context . requestManager ) ;
143+ ethRpcMethods . getMining ( web3Context . requestManager ) ;
143144
144145/**
145146 * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
@@ -158,7 +159,7 @@ export async function getHashRate<ReturnFormat extends DataFormat>(
158159 web3Context : Web3Context < EthExecutionAPI > ,
159160 returnFormat : ReturnFormat ,
160161) {
161- const response = await rpcMethods . getHashRate ( web3Context . requestManager ) ;
162+ const response = await ethRpcMethods . getHashRate ( web3Context . requestManager ) ;
162163
163164 return format ( { eth : 'uint' } , response as Numbers , returnFormat ) ;
164165}
@@ -180,23 +181,21 @@ export async function getGasPrice<ReturnFormat extends DataFormat>(
180181 web3Context : Web3Context < EthExecutionAPI > ,
181182 returnFormat : ReturnFormat ,
182183) {
183- const response = await rpcMethods . getGasPrice ( web3Context . requestManager ) ;
184+ const response = await ethRpcMethods . getGasPrice ( web3Context . requestManager ) ;
184185
185186 return format ( { eth : 'uint' } , response as Numbers , returnFormat ) ;
186187}
187188
188189/**
189- * @returns A list of accounts the node controls (addresses are checksummed).
190- *
191- * ```ts
192- * web3.eth.getAccounts().then(console.log);
193- * > ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"]
194- * ```
195- */
196- export async function getAccounts (
197- web3Context : Web3Context < EthExecutionAPI >
198- ) {
199- const response = await rpcMethods . getAccounts ( web3Context . requestManager ) ;
190+ * @returns A list of accounts the node controls (addresses are checksummed).
191+ *
192+ * ```ts
193+ * web3.eth.getAccounts().then(console.log);
194+ * > ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"]
195+ * ```
196+ */
197+ export async function getAccounts ( web3Context : Web3Context < EthExecutionAPI > ) {
198+ const response = await ethRpcMethods . getAccounts ( web3Context . requestManager ) ;
200199 return response . map ( address => toChecksumAddress ( address ) ) ;
201200}
202201
@@ -217,7 +216,7 @@ export async function getBlockNumber<ReturnFormat extends DataFormat>(
217216 web3Context : Web3Context < EthExecutionAPI > ,
218217 returnFormat : ReturnFormat ,
219218) {
220- const response = await rpcMethods . getBlockNumber ( web3Context . requestManager ) ;
219+ const response = await ethRpcMethods . getBlockNumber ( web3Context . requestManager ) ;
221220
222221 return format ( { eth : 'uint' } , response as Numbers , returnFormat ) ;
223222}
@@ -248,7 +247,7 @@ export async function getBalance<ReturnFormat extends DataFormat>(
248247 const blockNumberFormatted = isBlockTag ( blockNumber as string )
249248 ? ( blockNumber as BlockTag )
250249 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
251- const response = await rpcMethods . getBalance (
250+ const response = await ethRpcMethods . getBalance (
252251 web3Context . requestManager ,
253252 address ,
254253 blockNumberFormatted ,
@@ -290,7 +289,7 @@ export async function getStorageAt<ReturnFormat extends DataFormat>(
290289 const blockNumberFormatted = isBlockTag ( blockNumber as string )
291290 ? ( blockNumber as BlockTag )
292291 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
293- const response = await rpcMethods . getStorageAt (
292+ const response = await ethRpcMethods . getStorageAt (
294293 web3Context . requestManager ,
295294 address ,
296295 storageSlotFormatted ,
@@ -329,7 +328,7 @@ export async function getCode<ReturnFormat extends DataFormat>(
329328 const blockNumberFormatted = isBlockTag ( blockNumber as string )
330329 ? ( blockNumber as BlockTag )
331330 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
332- const response = await rpcMethods . getCode (
331+ const response = await ethRpcMethods . getCode (
333332 web3Context . requestManager ,
334333 address ,
335334 blockNumberFormatted ,
@@ -411,7 +410,7 @@ export async function getBlock<ReturnFormat extends DataFormat>(
411410 let response ;
412411 if ( isBytes ( block ) ) {
413412 const blockHashFormatted = format ( { eth : 'bytes32' } , block , ETH_DATA_FORMAT ) ;
414- response = await rpcMethods . getBlockByHash (
413+ response = await ethRpcMethods . getBlockByHash (
415414 web3Context . requestManager ,
416415 blockHashFormatted as HexString ,
417416 hydrated ,
@@ -420,7 +419,7 @@ export async function getBlock<ReturnFormat extends DataFormat>(
420419 const blockNumberFormatted = isBlockTag ( block as string )
421420 ? ( block as BlockTag )
422421 : format ( { eth : 'uint' } , block as Numbers , ETH_DATA_FORMAT ) ;
423- response = await rpcMethods . getBlockByNumber (
422+ response = await ethRpcMethods . getBlockByNumber (
424423 web3Context . requestManager ,
425424 blockNumberFormatted ,
426425 hydrated ,
@@ -455,15 +454,15 @@ export async function getBlockTransactionCount<ReturnFormat extends DataFormat>(
455454 let response ;
456455 if ( isBytes ( block ) ) {
457456 const blockHashFormatted = format ( { eth : 'bytes32' } , block , ETH_DATA_FORMAT ) ;
458- response = await rpcMethods . getBlockTransactionCountByHash (
457+ response = await ethRpcMethods . getBlockTransactionCountByHash (
459458 web3Context . requestManager ,
460459 blockHashFormatted as HexString ,
461460 ) ;
462461 } else {
463462 const blockNumberFormatted = isBlockTag ( block as string )
464463 ? ( block as BlockTag )
465464 : format ( { eth : 'uint' } , block as Numbers , ETH_DATA_FORMAT ) ;
466- response = await rpcMethods . getBlockTransactionCountByNumber (
465+ response = await ethRpcMethods . getBlockTransactionCountByNumber (
467466 web3Context . requestManager ,
468467 blockNumberFormatted ,
469468 ) ;
@@ -497,15 +496,15 @@ export async function getBlockUncleCount<ReturnFormat extends DataFormat>(
497496 let response ;
498497 if ( isBytes ( block ) ) {
499498 const blockHashFormatted = format ( { eth : 'bytes32' } , block , ETH_DATA_FORMAT ) ;
500- response = await rpcMethods . getUncleCountByBlockHash (
499+ response = await ethRpcMethods . getUncleCountByBlockHash (
501500 web3Context . requestManager ,
502501 blockHashFormatted as HexString ,
503502 ) ;
504503 } else {
505504 const blockNumberFormatted = isBlockTag ( block as string )
506505 ? ( block as BlockTag )
507506 : format ( { eth : 'uint' } , block as Numbers , ETH_DATA_FORMAT ) ;
508- response = await rpcMethods . getUncleCountByBlockNumber (
507+ response = await ethRpcMethods . getUncleCountByBlockNumber (
509508 web3Context . requestManager ,
510509 blockNumberFormatted ,
511510 ) ;
@@ -588,7 +587,7 @@ export async function getUncle<ReturnFormat extends DataFormat>(
588587 let response ;
589588 if ( isBytes ( block ) ) {
590589 const blockHashFormatted = format ( { eth : 'bytes32' } , block , ETH_DATA_FORMAT ) ;
591- response = await rpcMethods . getUncleByBlockHashAndIndex (
590+ response = await ethRpcMethods . getUncleByBlockHashAndIndex (
592591 web3Context . requestManager ,
593592 blockHashFormatted as HexString ,
594593 uncleIndexFormatted ,
@@ -597,7 +596,7 @@ export async function getUncle<ReturnFormat extends DataFormat>(
597596 const blockNumberFormatted = isBlockTag ( block as string )
598597 ? ( block as BlockTag )
599598 : format ( { eth : 'uint' } , block as Numbers , ETH_DATA_FORMAT ) ;
600- response = await rpcMethods . getUncleByBlockNumberAndIndex (
599+ response = await ethRpcMethods . getUncleByBlockNumberAndIndex (
601600 web3Context . requestManager ,
602601 blockNumberFormatted ,
603602 uncleIndexFormatted ,
@@ -666,7 +665,7 @@ export async function getTransaction<ReturnFormat extends DataFormat>(
666665 transactionHash ,
667666 DEFAULT_RETURN_FORMAT ,
668667 ) ;
669- const response = await rpcMethods . getTransactionByHash (
668+ const response = await ethRpcMethods . getTransactionByHash (
670669 web3Context . requestManager ,
671670 transactionHashFormatted ,
672671 ) ;
@@ -763,7 +762,7 @@ export async function getPendingTransactions<ReturnFormat extends DataFormat>(
763762 web3Context : Web3Context < EthExecutionAPI > ,
764763 returnFormat : ReturnFormat ,
765764) {
766- const response = await rpcMethods . getPendingTransactions ( web3Context . requestManager ) ;
765+ const response = await ethRpcMethods . getPendingTransactions ( web3Context . requestManager ) ;
767766
768767 return response . map ( transaction =>
769768 formatTransaction ( transaction as unknown as Transaction , returnFormat ) ,
@@ -832,7 +831,7 @@ export async function getTransactionFromBlock<ReturnFormat extends DataFormat>(
832831 let response ;
833832 if ( isBytes ( block ) ) {
834833 const blockHashFormatted = format ( { eth : 'bytes32' } , block , ETH_DATA_FORMAT ) ;
835- response = await rpcMethods . getTransactionByBlockHashAndIndex (
834+ response = await ethRpcMethods . getTransactionByBlockHashAndIndex (
836835 web3Context . requestManager ,
837836 blockHashFormatted as HexString ,
838837 transactionIndexFormatted ,
@@ -841,7 +840,7 @@ export async function getTransactionFromBlock<ReturnFormat extends DataFormat>(
841840 const blockNumberFormatted = isBlockTag ( block as string )
842841 ? ( block as BlockTag )
843842 : format ( { eth : 'uint' } , block as Numbers , ETH_DATA_FORMAT ) ;
844- response = await rpcMethods . getTransactionByBlockNumberAndIndex (
843+ response = await ethRpcMethods . getTransactionByBlockNumberAndIndex (
845844 web3Context . requestManager ,
846845 blockNumberFormatted ,
847846 transactionIndexFormatted ,
@@ -908,7 +907,7 @@ export async function getTransactionReceipt<ReturnFormat extends DataFormat>(
908907 transactionHash ,
909908 DEFAULT_RETURN_FORMAT ,
910909 ) ;
911- const response = await rpcMethods . getTransactionReceipt (
910+ const response = await ethRpcMethods . getTransactionReceipt (
912911 web3Context . requestManager ,
913912 transactionHashFormatted ,
914913 ) ;
@@ -950,7 +949,7 @@ export async function getTransactionCount<ReturnFormat extends DataFormat>(
950949 const blockNumberFormatted = isBlockTag ( blockNumber as string )
951950 ? ( blockNumber as BlockTag )
952951 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
953- const response = await rpcMethods . getTransactionCount (
952+ const response = await ethRpcMethods . getTransactionCount (
954953 web3Context . requestManager ,
955954 address ,
956955 blockNumberFormatted ,
@@ -1132,7 +1131,7 @@ export function sendTransaction<
11321131 ) ;
11331132
11341133 transactionHash = await waitWithTimeout (
1135- rpcMethods . sendRawTransaction (
1134+ ethRpcMethods . sendRawTransaction (
11361135 web3Context . requestManager ,
11371136 signedTransaction . rawTransaction ,
11381137 ) ,
@@ -1144,7 +1143,7 @@ export function sendTransaction<
11441143 ) ;
11451144 } else {
11461145 transactionHash = await waitWithTimeout (
1147- rpcMethods . sendTransaction (
1146+ ethRpcMethods . sendTransaction (
11481147 web3Context . requestManager ,
11491148 transactionFormatted as Partial < TransactionWithSenderAPI > ,
11501149 ) ,
@@ -1352,7 +1351,7 @@ export function sendSignedTransaction<
13521351 // await getRevertReason(web3Context, transaction, returnFormat);
13531352 // }
13541353
1355- const transactionHash = await rpcMethods . sendRawTransaction (
1354+ const transactionHash = await ethRpcMethods . sendRawTransaction (
13561355 web3Context . requestManager ,
13571356 signedTransactionFormattedHex ,
13581357 ) ;
@@ -1480,7 +1479,7 @@ export async function sign<ReturnFormat extends DataFormat>(
14801479 ) ;
14811480 }
14821481
1483- const response = await rpcMethods . sign (
1482+ const response = await ethRpcMethods . sign (
14841483 web3Context . requestManager ,
14851484 addressOrIndex ,
14861485 messageFormatted ,
@@ -1545,7 +1544,7 @@ export async function signTransaction<ReturnFormat extends DataFormat>(
15451544 transaction : Transaction ,
15461545 returnFormat : ReturnFormat ,
15471546) {
1548- const response = await rpcMethods . signTransaction (
1547+ const response = await ethRpcMethods . signTransaction (
15491548 web3Context . requestManager ,
15501549 formatTransaction ( transaction , ETH_DATA_FORMAT ) ,
15511550 ) ;
@@ -1585,7 +1584,7 @@ export async function call<ReturnFormat extends DataFormat>(
15851584 ? ( blockNumber as BlockTag )
15861585 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
15871586
1588- const response = await rpcMethods . call (
1587+ const response = await ethRpcMethods . call (
15891588 web3Context . requestManager ,
15901589 formatTransaction ( transaction , ETH_DATA_FORMAT ) ,
15911590 blockNumberFormatted ,
@@ -1634,7 +1633,7 @@ export async function estimateGas<ReturnFormat extends DataFormat>(
16341633 ? ( blockNumber as BlockTag )
16351634 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
16361635
1637- const response = await rpcMethods . estimateGas (
1636+ const response = await ethRpcMethods . estimateGas (
16381637 web3Context . requestManager ,
16391638 transactionFormatted ,
16401639 blockNumberFormatted ,
@@ -1694,7 +1693,7 @@ export async function getLogs<ReturnFormat extends DataFormat>(
16941693 filter : Filter ,
16951694 returnFormat : ReturnFormat ,
16961695) {
1697- const response = await rpcMethods . getLogs ( web3Context . requestManager , filter ) ;
1696+ const response = await ethRpcMethods . getLogs ( web3Context . requestManager , filter ) ;
16981697
16991698 const result = response . map ( res => {
17001699 if ( typeof res === 'string' ) {
@@ -1724,7 +1723,7 @@ export async function getChainId<ReturnFormat extends DataFormat>(
17241723 web3Context : Web3Context < EthExecutionAPI > ,
17251724 returnFormat : ReturnFormat ,
17261725) {
1727- const response = await rpcMethods . getChainId ( web3Context . requestManager ) ;
1726+ const response = await ethRpcMethods . getChainId ( web3Context . requestManager ) ;
17281727
17291728 return format (
17301729 { eth : 'uint' } ,
@@ -1822,7 +1821,7 @@ export async function getProof<ReturnFormat extends DataFormat>(
18221821 ? ( blockNumber as BlockTag )
18231822 : format ( { eth : 'uint' } , blockNumber as Numbers , ETH_DATA_FORMAT ) ;
18241823
1825- const response = await rpcMethods . getProof (
1824+ const response = await ethRpcMethods . getProof (
18261825 web3Context . requestManager ,
18271826 address ,
18281827 storageKeysFormatted ,
@@ -1918,7 +1917,7 @@ export async function getFeeHistory<ReturnFormat extends DataFormat>(
19181917 NUMBER_DATA_FORMAT ,
19191918 ) ;
19201919
1921- const response = await rpcMethods . getFeeHistory (
1920+ const response = await ethRpcMethods . getFeeHistory (
19221921 web3Context . requestManager ,
19231922 blockCountFormatted ,
19241923 newestBlockFormatted ,
0 commit comments