From 3ff9be6d4fc9ac96a59f313d1e75a8c693b35b59 Mon Sep 17 00:00:00 2001 From: Resende <17102689+ZePedroResende@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:44:07 +0100 Subject: [PATCH] feat(rpc): ots_hasCode implementation (#3886) Co-authored-by: Miguel Palhas Co-authored-by: Matthias Seitz --- crates/rpc/rpc-builder/tests/it/http.rs | 4 +--- crates/rpc/rpc/src/otterscan.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 997bf0ef9e..09dbc52cb2 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -193,9 +193,7 @@ where let nonce = 1; let block_hash = H256::default(); - assert!(is_unimplemented( - OtterscanClient::has_code(client, address, None).await.err().unwrap() - )); + OtterscanClient::has_code(client, address, None).await.unwrap(); OtterscanClient::get_api_level(client).await.unwrap(); diff --git a/crates/rpc/rpc/src/otterscan.rs b/crates/rpc/rpc/src/otterscan.rs index da895c6936..767b3657ad 100644 --- a/crates/rpc/rpc/src/otterscan.rs +++ b/crates/rpc/rpc/src/otterscan.rs @@ -31,7 +31,7 @@ where { /// Handler for `ots_hasCode` async fn has_code(&self, address: Address, block_number: Option) -> RpcResult { - Err(internal_rpc_err("unimplemented")) + self.eth.get_code(address, block_number).await.map(|code| !code.is_empty()) } /// Handler for `ots_getApiLevel`