Skip to content

Commit

Permalink
chore: getHashOfCurrentCode
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielMartinezRodriguez committed Jan 23, 2024
1 parent abbf4d7 commit f64d785
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions precompiles/upgrade-runtime-controller/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H256> {
handle.record_cost(RuntimeHelper::<Runtime>::db_read_gas_cost())?;

let hash = pallet_upgrade_runtime_proposal::Pallet::<Runtime>::get_current_code_hash();

match hash {
Some(hash) => Ok(hash.into()),
None => Ok(H256::default()),
}
}
}

0 comments on commit f64d785

Please sign in to comment.