bp_header_chain/
storage_keys.rs1pub const PALLET_OPERATING_MODE_VALUE_NAME: &str = "PalletOperatingMode";
21pub const BEST_FINALIZED_VALUE_NAME: &str = "BestFinalized";
23pub const CURRENT_AUTHORITY_SET_VALUE_NAME: &str = "CurrentAuthoritySet";
25
26use sp_core::storage::StorageKey;
27
28pub fn pallet_operating_mode_key(pallet_prefix: &str) -> StorageKey {
30 StorageKey(
31 bp_runtime::storage_value_final_key(
32 pallet_prefix.as_bytes(),
33 PALLET_OPERATING_MODE_VALUE_NAME.as_bytes(),
34 )
35 .to_vec(),
36 )
37}
38
39pub fn current_authority_set_key(pallet_prefix: &str) -> StorageKey {
41 StorageKey(
42 bp_runtime::storage_value_final_key(
43 pallet_prefix.as_bytes(),
44 CURRENT_AUTHORITY_SET_VALUE_NAME.as_bytes(),
45 )
46 .to_vec(),
47 )
48}
49
50pub fn best_finalized_key(pallet_prefix: &str) -> StorageKey {
52 StorageKey(
53 bp_runtime::storage_value_final_key(
54 pallet_prefix.as_bytes(),
55 BEST_FINALIZED_VALUE_NAME.as_bytes(),
56 )
57 .to_vec(),
58 )
59}
60
61#[cfg(test)]
62mod tests {
63 use super::*;
64 use hex_literal::hex;
65
66 #[test]
67 fn pallet_operating_mode_key_computed_properly() {
68 let storage_key = pallet_operating_mode_key("BridgeGrandpa").0;
71 assert_eq!(
72 storage_key,
73 hex!("0b06f475eddb98cf933a12262e0388de0f4cf0917788d791142ff6c1f216e7b3").to_vec(),
74 "Unexpected storage key: {}",
75 hex::encode(&storage_key),
76 );
77 }
78
79 #[test]
80 fn current_authority_set_key_computed_properly() {
81 let storage_key = current_authority_set_key("BridgeGrandpa").0;
84 assert_eq!(
85 storage_key,
86 hex!("0b06f475eddb98cf933a12262e0388de24a7b8b5717ea33346fa595a66ccbcb0").to_vec(),
87 "Unexpected storage key: {}",
88 hex::encode(&storage_key),
89 );
90 }
91
92 #[test]
93 fn best_finalized_key_computed_properly() {
94 let storage_key = best_finalized_key("BridgeGrandpa").0;
97 assert_eq!(
98 storage_key,
99 hex!("0b06f475eddb98cf933a12262e0388dea4ebafdd473c549fdb24c5c991c5591c").to_vec(),
100 "Unexpected storage key: {}",
101 hex::encode(&storage_key),
102 );
103 }
104}