diff --git a/precompiles/upgrade-runtime-controller/src/lib.rs b/precompiles/upgrade-runtime-controller/src/lib.rs index 78f1f264..d55bb681 100644 --- a/precompiles/upgrade-runtime-controller/src/lib.rs +++ b/precompiles/upgrade-runtime-controller/src/lib.rs @@ -329,4 +329,17 @@ where None => Ok(H256::default()), } } + + #[precompile::public("getHashOfCurrentCode()")] + #[precompile::view] + fn get_hash_of_current_code(handle: &mut impl PrecompileHandle) -> EvmResult { + handle.record_cost(RuntimeHelper::::db_read_gas_cost())?; + + let hash = pallet_upgrade_runtime_proposal::Pallet::::get_current_code_hash(); + + match hash { + Some(hash) => Ok(hash.into()), + None => Ok(H256::default()), + } + } }