mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 10:57:56 +00:00
Register ReadRuntimeVersionExt (#3045)
* Register ReadRuntimeVersionExt * Update Substrate This includes the fix of compilation for macOS platforms.
This commit is contained in:
@@ -64,6 +64,7 @@ pub fn execute(
|
||||
let mut extensions = sp_externalities::Extensions::new();
|
||||
|
||||
extensions.register(sp_core::traits::TaskExecutorExt::new(spawner));
|
||||
extensions.register(sp_core::traits::ReadRuntimeVersionExt::new(ReadRuntimeVersion));
|
||||
|
||||
let mut ext = ValidationExternalities(extensions);
|
||||
|
||||
@@ -244,3 +245,26 @@ impl sp_core::traits::SpawnNamed for TaskExecutor {
|
||||
self.0.spawn_ok(future);
|
||||
}
|
||||
}
|
||||
|
||||
struct ReadRuntimeVersion;
|
||||
|
||||
impl sp_core::traits::ReadRuntimeVersion for ReadRuntimeVersion {
|
||||
fn read_runtime_version(
|
||||
&self,
|
||||
wasm_code: &[u8],
|
||||
_ext: &mut dyn sp_externalities::Externalities,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
let blob = RuntimeBlob::uncompress_if_needed(wasm_code)
|
||||
.map_err(|e| format!("Failed to read the PVF runtime blob: {:?}", e))?;
|
||||
|
||||
match sc_executor::read_embedded_version(&blob)
|
||||
.map_err(|e| format!("Failed to read the static section from the PVF blob: {:?}", e))?
|
||||
{
|
||||
Some(version) => {
|
||||
use parity_scale_codec::Encode;
|
||||
Ok(version.encode())
|
||||
},
|
||||
None => Err(format!("runtime version section is not found")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user