Skip to content

Commit

Permalink
use const-hex
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Aug 15, 2024
1 parent eea48de commit 19923a1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 147 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ codec = { version = "3.6.12", default-features = false, package = "parity-scale-
collectives-westend-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/parachains/collectives/collectives-westend" }
collectives-westend-runtime = { path = "cumulus/parachains/runtimes/collectives/collectives-westend" }
color-eyre = { version = "0.6.1", default-features = false }
const-hex = { version = "1.10.0", default-features = false }
color-print = { version = "0.3.4" }
colored = { version = "2.0.4" }
comfy-table = { version = "7.1.0", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/metadata-hash-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
docify = { workspace = true }
const-hex = { workspace = true }

[dev-dependencies]
substrate-wasm-builder = { features = ["metadata-hash"], workspace = true, default-features = true }
Expand All @@ -36,4 +37,5 @@ std = [
"log/std",
"scale-info/std",
"sp-runtime/std",
"const-hex/std",
]
11 changes: 7 additions & 4 deletions substrate/frame/metadata-hash-extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ use sp_runtime::{

#[cfg(test)]
mod tests;
mod utils;

/// The mode of [`CheckMetadataHash`].
#[derive(Decode, Encode, PartialEq, Debug, TypeInfo, Clone, Copy, Eq)]
Expand All @@ -69,9 +68,13 @@ enum MetadataHash {
Custom([u8; 32]),
}

const RUNTIME_METADATA: Option<[u8; 32]> = match option_env!("RUNTIME_METADATA_HASH") {
Some(hex) => utils::hex_str_to_32_bytes(hex),
None => None,
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,
}
} else {
None
};

impl MetadataHash {
Expand Down
143 changes: 0 additions & 143 deletions substrate/frame/metadata-hash-extension/src/utils.rs

This file was deleted.

0 comments on commit 19923a1

Please sign in to comment.