mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
Add get_global for Sandbox (#4756)
* Add `get_global` for `Sandbox` This pr adds `get_global` to retrieve a `global` variable from an instantiated sandbox wasm blob. * Bump `spec_version` * Update primitives/wasm-interface/src/lib.rs Co-Authored-By: Sergei Pepyakin <sergei@parity.io> * `get_global` -> `get_global_val` Co-authored-by: Sergei Pepyakin <s.pepyakin@gmail.com> Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub use sp_core::sandbox::{TypedValue, ReturnValue, HostError};
|
||||
pub use sp_core::sandbox::HostError;
|
||||
pub use sp_wasm_interface::{Value, ReturnValue};
|
||||
|
||||
mod imp {
|
||||
#[cfg(feature = "std")]
|
||||
@@ -75,7 +76,7 @@ impl From<Error> for HostError {
|
||||
/// supervisor in [`EnvironmentDefinitionBuilder`].
|
||||
///
|
||||
/// [`EnvironmentDefinitionBuilder`]: struct.EnvironmentDefinitionBuilder.html
|
||||
pub type HostFuncType<T> = fn(&mut T, &[TypedValue]) -> Result<ReturnValue, HostError>;
|
||||
pub type HostFuncType<T> = fn(&mut T, &[Value]) -> Result<ReturnValue, HostError>;
|
||||
|
||||
/// Reference to a sandboxed linear memory, that
|
||||
/// will be used by the guest module.
|
||||
@@ -197,9 +198,16 @@ impl<T> Instance<T> {
|
||||
pub fn invoke(
|
||||
&mut self,
|
||||
name: &str,
|
||||
args: &[TypedValue],
|
||||
args: &[Value],
|
||||
state: &mut T,
|
||||
) -> Result<ReturnValue, Error> {
|
||||
self.inner.invoke(name, args, state)
|
||||
}
|
||||
|
||||
/// Get the value from a global with the given `name`.
|
||||
///
|
||||
/// Returns `Some(_)` if the global could be found.
|
||||
pub fn get_global_val(&self, name: &str) -> Option<Value> {
|
||||
self.inner.get_global_val(name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user