mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make return for debug_codeByHash optional (#14572)
This commit is contained in:
@ -198,7 +198,11 @@ pub trait DebugApi {
|
|||||||
/// Returns the code associated with a given hash at the specified block ID.
|
/// Returns the code associated with a given hash at the specified block ID.
|
||||||
/// If no block ID is provided, it defaults to the latest block.
|
/// If no block ID is provided, it defaults to the latest block.
|
||||||
#[method(name = "codeByHash")]
|
#[method(name = "codeByHash")]
|
||||||
async fn debug_code_by_hash(&self, hash: B256, block_id: Option<BlockId>) -> RpcResult<Bytes>;
|
async fn debug_code_by_hash(
|
||||||
|
&self,
|
||||||
|
hash: B256,
|
||||||
|
block_id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Bytes>>;
|
||||||
|
|
||||||
/// Turns on CPU profiling for the given duration and writes profile data to disk.
|
/// Turns on CPU profiling for the given duration and writes profile data to disk.
|
||||||
#[method(name = "cpuProfile")]
|
#[method(name = "cpuProfile")]
|
||||||
|
|||||||
@ -654,21 +654,20 @@ where
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the code associated with a given hash at the specified block ID.
|
/// Returns the code associated with a given hash at the specified block ID. If no code is
|
||||||
/// If no block ID is provided, it defaults to the latest block.
|
/// found, it returns None. If no block ID is provided, it defaults to the latest block.
|
||||||
pub async fn debug_code_by_hash(
|
pub async fn debug_code_by_hash(
|
||||||
&self,
|
&self,
|
||||||
hash: B256,
|
hash: B256,
|
||||||
block_id: Option<BlockId>,
|
block_id: Option<BlockId>,
|
||||||
) -> Result<Bytes, Eth::Error> {
|
) -> Result<Option<Bytes>, Eth::Error> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.provider()
|
.provider()
|
||||||
.state_by_block_id(block_id.unwrap_or_default())
|
.state_by_block_id(block_id.unwrap_or_default())
|
||||||
.map_err(Eth::Error::from_eth_err)?
|
.map_err(Eth::Error::from_eth_err)?
|
||||||
.bytecode_by_hash(&hash)
|
.bytecode_by_hash(&hash)
|
||||||
.map_err(Eth::Error::from_eth_err)?
|
.map_err(Eth::Error::from_eth_err)?
|
||||||
.unwrap_or_default()
|
.map(|b| b.original_bytes()))
|
||||||
.original_bytes())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the configured transaction with the environment on the given database.
|
/// Executes the configured transaction with the environment on the given database.
|
||||||
@ -1051,7 +1050,11 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn debug_code_by_hash(&self, hash: B256, block_id: Option<BlockId>) -> RpcResult<Bytes> {
|
async fn debug_code_by_hash(
|
||||||
|
&self,
|
||||||
|
hash: B256,
|
||||||
|
block_id: Option<BlockId>,
|
||||||
|
) -> RpcResult<Option<Bytes>> {
|
||||||
Self::debug_code_by_hash(self, hash, block_id).await.map_err(Into::into)
|
Self::debug_code_by_hash(self, hash, block_id).await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user