Adding more functions for retrieving onchain data to the EthereumService #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Core Ethereum Blockchain Data Retrieval Functions
This pull request introduces several new functions, each designed to retrieve specific blockchain information, and utilizes a structured request format.
Key Implemented Features:
EthereumNodeRequestStructure:node_url: String(Target Ethereum node)block_number: Option<u64>(Optional block number, used byget_block,get_block_transactions, andget_account_balance)transaction_hash: String(Used byget_transaction)account_address: String(Used byget_account_balance)block_numberisOption<u64>, allowing flexibility for functions likeget_account_balanceto default to the latest block if no number is provided.Service Functions Added:
get_block():request.block_number.request.block_number.unwrap(), assuming a block number will always be provided for this call.)get_transaction():request.transaction_hash.H256.get_block_transactions():request.block_number.provider.get_block_with_txs()to retrieve full transaction objects..take(10)) from the block.request.block_number.unwrap(), assuming a block number will always be provided.)get_account_balance():request.account_address.request.block_numberisSome(bn), fetches the balance at that specific block.request.block_numberisNone, fetches the balance at the latest block.ethers::utils::format_ether.ethers::types::Address.How to Test:
The implemented functionalities can be invoked via the
rmcpservice layer:get_latest_blockwith a node URL.get_blockwith a node URL and a block number.get_transactionwith a node URL and a transaction hash.get_block_transactionswith a node URL and a block number.get_account_balancewith a node URL, an account address, and optionally a block number.