1use casper_types::{ContractHash, ContractPackageHash};
2use casperlabs_contract_utils::{get_key, set_key};
3use casper_types::Key;
4
5pub const SELF_CONTRACT_HASH: &str = "self_contract_hash";
6pub const CONTRACT_PACKAGE_HASH: &str = "contract_package_hash";
7
8
9pub fn zero_address() -> Key {
10 Key::from_formatted_str(
11 "hash-0000000000000000000000000000000000000000000000000000000000000000".into(),
12 )
13 .unwrap()
14}
15
16
17pub fn set_contract_hash(contract_hash: ContractHash) {
18 set_key(SELF_CONTRACT_HASH, contract_hash);
19}
20
21pub fn get_contract_hash() -> ContractHash {
22 get_key(SELF_CONTRACT_HASH).unwrap_or_default()
23}
24
25pub fn set_package_hash(package_hash: ContractPackageHash) {
26 set_key(CONTRACT_PACKAGE_HASH, package_hash);
27}
28
29pub fn get_package_hash() -> ContractPackageHash {
30 get_key(CONTRACT_PACKAGE_HASH).unwrap_or_default()
31}