Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 4eef09b

Browse files
juanbonofannyguthmann
authored andcommitted
Fix SIR RPC get compiled class hash (#1032)
* update version * fix get_compiled_hash * cargo clippy
1 parent b8640a0 commit 4eef09b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

rpc_state_reader/src/rpc_state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ impl RpcState {
284284
"params": params,
285285
"id": 1
286286
});
287-
Self::deserialize_call(self.rpc_call_no_deserialize(&payload)?.into_json().unwrap())
287+
let response = self.rpc_call_no_deserialize(&payload)?.into_json().unwrap();
288+
Self::deserialize_call(response)
288289
}
289290

290291
fn rpc_call_no_deserialize(

rpc_state_reader/tests/sir_tests.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl StateReader for RpcStateReader {
6666
let nonce = self.0.get_nonce_at(&address);
6767
Ok(Felt252::from_bytes_be(nonce.bytes()))
6868
}
69+
6970
fn get_storage_at(&self, storage_entry: &StorageEntry) -> Result<Felt252, StateError> {
7071
let (contract_address, key) = storage_entry;
7172
let address = ContractAddress(
@@ -78,12 +79,9 @@ impl StateReader for RpcStateReader {
7879
let value = self.0.get_storage_at(&address, &key);
7980
Ok(Felt252::from_bytes_be(value.bytes()))
8081
}
82+
8183
fn get_compiled_class_hash(&self, class_hash: &ClassHash) -> Result<[u8; 32], StateError> {
82-
let address =
83-
ContractAddress(PatriciaKey::try_from(StarkHash::new(*class_hash).unwrap()).unwrap());
84-
let mut bytes = [0u8; 32];
85-
bytes.copy_from_slice(self.0.get_class_hash_at(&address).0.bytes());
86-
Ok(bytes)
84+
Ok(*class_hash)
8785
}
8886
}
8987

@@ -298,6 +296,12 @@ fn starknet_in_rust_test_case_tx(hash: &str, block_number: u64, chain: RpcChain)
298296
}
299297
}
300298

299+
#[test_case(
300+
"0x05b4665a81d89d00e529d2e298fce6606750c4f67faf43aafc893c0fc0f9d425",
301+
RpcChain::MainNet,
302+
222090,
303+
4
304+
)]
301305
#[test_case(
302306
"0x01e91fa12be4424264c8cad29f481a67d5d8e23f7abf94add734d64b91c90021",
303307
RpcChain::MainNet,

0 commit comments

Comments
 (0)