From 2d05121781134e65ac4dcabebfa86b33290956cd Mon Sep 17 00:00:00 2001 From: incrypto32 Date: Mon, 11 Mar 2024 13:27:54 +0530 Subject: [PATCH] Accept block hashes for eth_getCode --- src/api/eth.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/eth.rs b/src/api/eth.rs index 5c3f22ae..58a5fe9a 100644 --- a/src/api/eth.rs +++ b/src/api/eth.rs @@ -175,9 +175,9 @@ impl Eth { } /// Get code under given address - pub fn code(&self, address: Address, block: Option) -> CallFuture { + pub fn code(&self, address: Address, block: Option) -> CallFuture { let address = helpers::serialize(&address); - let block = helpers::serialize(&block.unwrap_or(BlockNumber::Latest)); + let block = helpers::serialize(&block.unwrap_or_else(|| BlockNumber::Latest.into())); CallFuture::new(self.transport.execute("eth_getCode", vec![address, block])) } @@ -697,7 +697,7 @@ mod tests { ); rpc_test! ( - Eth:code, H256::from_low_u64_be(0x123), Some(BlockNumber::Pending) + Eth:code, H256::from_low_u64_be(0x123), Some(BlockId::Number(BlockNumber::Pending)) => "eth_getCode", vec![r#""0x0000000000000000000000000000000000000123""#, r#""pending""#]; Value::String("0x0123".into()) => hex!("0123")