diff --git a/src/api/eth.rs b/src/api/eth.rs index cdd3277f..a2db0c76 100644 --- a/src/api/eth.rs +++ b/src/api/eth.rs @@ -191,9 +191,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])) } @@ -736,7 +736,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")