diff --git a/src/evm-canister-client/src/client.rs b/src/evm-canister-client/src/client.rs index 49f10a8a..8e9b2eb6 100644 --- a/src/evm-canister-client/src/client.rs +++ b/src/evm-canister-client/src/client.rs @@ -11,8 +11,8 @@ use did::transaction::StorableExecutionResult; use did::unsafe_blocks::ValidateUnsafeBlockArgs; use did::{ Block, BlockConfirmationData, BlockConfirmationResult, BlockConfirmationStrategy, BlockNumber, - BlockchainBlockInfo, BlockchainStorageLimits, Bytes, EstimateGasRequest, EvmStats, H160, H256, - Transaction, TransactionReceipt, U64, U256, + BlockchainBlockInfo, BlockchainStorageLimits, Bytes, EstimateGasRequest, EvmStats, FeeHistory, + H160, H256, Transaction, TransactionReceipt, U64, U256, }; use ic_canister_client::{CanisterClient, CanisterClientResult}; pub use ic_log::writer::{Log, Logs}; @@ -317,6 +317,55 @@ impl EvmCanisterClient { .await } + /// Returns the maximum priority fee per gas that should be paid by a transaction + /// to be included in the next block. + /// + /// It uses a default gas ratio threshold of 75% to determine if a block is nearly empty. + /// + /// Returns error variant only if there's no block data available. + /// + /// See . + pub async fn eth_max_priority_fee_per_gas(&self) -> CanisterClientResult> { + self.client.query("eth_max_priority_fee_per_gas", ()).await + } + + /// Reports the fee history, for the given amount of blocks, up until the + /// newest block provided. + /// + /// # JSON RPC + /// + /// This method can also be called through PRC method [`eth_feeHistory`](evm_core::rpc::EthRpc::eth_fee_history). + /// + /// # Ethereum spec + /// + /// See . + pub async fn eth_fee_history( + &self, + block_count: u64, + newest_block: BlockNumber, + reward_percentiles: Option>, + ) -> CanisterClientResult> { + self.client + .query( + "eth_fee_history", + (block_count, newest_block, reward_percentiles), + ) + .await + } + + /// Returns an estimate of the current price per gas in wei. + /// + /// # JSON RPC + /// + /// This method can also be called by [`eth_gasPrice`](evm_core::rpc::EthRpc::eth_gas_price) JSON RPC method. + /// + /// # Ethereum spec + /// + /// See . + pub async fn eth_gas_price(&self) -> CanisterClientResult> { + self.client.query("eth_gas_price", ()).await + } + /// Execute a call on the EVM without modifying the state /// See [eth_call](https://eth.wiki/json-rpc/API#eth_call) /// @@ -431,6 +480,12 @@ impl EvmCanisterClient { self.client.query("get_evm_global_state", ()).await } + /// Returns the max pool size. This is the maximum amount of transactions + /// that can be in the pool. + pub async fn get_max_tx_pool_size(&self) -> CanisterClientResult { + self.client.query("get_max_tx_pool_size", ()).await + } + /// Sets the global state of the EVM. pub async fn admin_set_evm_global_state( &self, @@ -493,6 +548,16 @@ impl EvmCanisterClient { .await } + /// Sets the coinbase address. + pub async fn admin_set_coinbase(&self, coinbase: H160) -> CanisterClientResult> { + self.client.update("admin_set_coinbase", (coinbase,)).await + } + + /// Removes all transactions from the transaction pool. + pub async fn admin_clear_pool(&self) -> CanisterClientResult> { + self.client.update("admin_clear_pool", ()).await + } + /// Returns whether unsafe blocks are enabled pub async fn is_unsafe_blocks_enabled(&self) -> CanisterClientResult { self.client.query("is_unsafe_blocks_enabled", ()).await