Skip to content

Commit

Permalink
panic on invalid environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Aug 29, 2024
1 parent 6d40a23 commit 8ffd8a9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions substrate/frame/metadata-hash-extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ enum MetadataHash {
const RUNTIME_METADATA: Option<[u8; 32]> = if let Some(hex) = option_env!("RUNTIME_METADATA_HASH") {
match const_hex::const_decode_to_array(hex.as_bytes()) {
Ok(hex) => Some(hex),
Err(_) => None,
Err(_) => panic!("Invalid RUNTIME_METADATA_HASH environment variable: it must be a 32 \
bytes value in hexadecimal: e.g. 0x1234567890abcdef1234567890ABCDEF. Upper case or \
lower case, 0x prefix is optional."),
}
} else {
None
Expand Down Expand Up @@ -160,13 +162,16 @@ impl<T: Config + Send + Sync> TransactionExtensionBase for CheckMetadataHash<T>

Ok(signed)
}
fn weight() -> Weight {
Weight::default()
}
}
impl<T: Config + Send + Sync> TransactionExtension<T::RuntimeCall> for CheckMetadataHash<T> {
type Val = ();
type Pre = ();

fn weight(&self, _: &T::RuntimeCall) -> Weight {
// The weight is the weight of implicit, it consists of a few match operation, it is
// negligible.
Weight::zero()
}

impl_tx_ext_default!(T::RuntimeCall; validate prepare);
}

0 comments on commit 8ffd8a9

Please sign in to comment.