Skip to content

Commit

Permalink
Accept block hashes for eth_getCode
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Apr 17, 2024
1 parent ea7e8c6 commit d9ba4ff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/api/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ impl<T: Transport> Eth<T> {
}

/// Get code under given address
pub fn code(&self, address: Address, block: Option<BlockNumber>) -> CallFuture<Bytes, T::Out> {
pub fn code(&self, address: Address, block: Option<BlockId>) -> CallFuture<Bytes, T::Out> {
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]))
}
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit d9ba4ff

Please sign in to comment.