mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 03:27:58 +00:00
Don't panic if parameter can not be converted between node and native runtime (#1659)
* Don't panic if parameter can not be converted between node and native runtime * FIxes after merge * Use correct copyright year
This commit is contained in:
@@ -23,8 +23,10 @@
|
||||
use state_machine;
|
||||
use serializer;
|
||||
use wasmi;
|
||||
use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed,
|
||||
impl_extract_backtrace, impl_error_chain_kind};
|
||||
use error_chain::{
|
||||
error_chain, error_chain_processing, impl_error_chain_processed,
|
||||
impl_extract_backtrace, impl_error_chain_kind
|
||||
};
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::borrow::BorrowMut;
|
||||
use std::cell::{RefMut, RefCell};
|
||||
use std::{borrow::BorrowMut, result, cell::{RefMut, RefCell}};
|
||||
use crate::error::{Error, ErrorKind, Result};
|
||||
use state_machine::{CodeExecutor, Externalities};
|
||||
use crate::wasm_executor::WasmExecutor;
|
||||
@@ -109,7 +108,7 @@ fn safe_call<F, U>(f: F) -> Result<U>
|
||||
///
|
||||
/// If the inner closure panics, it will be caught and return an error.
|
||||
pub fn with_native_environment<F, U>(ext: &mut Externalities<Blake2Hasher>, f: F) -> Result<U>
|
||||
where F: UnwindSafe + FnOnce() -> U
|
||||
where F: UnwindSafe + FnOnce() -> U
|
||||
{
|
||||
::runtime_io::with_externalities(ext, move || safe_call(f))
|
||||
}
|
||||
@@ -186,7 +185,7 @@ impl<D: NativeExecutionDispatch> CodeExecutor<Blake2Hasher> for NativeExecutor<D
|
||||
<
|
||||
E: Externalities<Blake2Hasher>,
|
||||
R:Decode + Encode + PartialEq,
|
||||
NC: FnOnce() -> R + UnwindSafe
|
||||
NC: FnOnce() -> result::Result<R, &'static str> + UnwindSafe
|
||||
>(
|
||||
&self,
|
||||
ext: &mut E,
|
||||
@@ -242,7 +241,8 @@ impl<D: NativeExecutionDispatch> CodeExecutor<Blake2Hasher> for NativeExecutor<D
|
||||
.map_or_else(||"<None>".into(), |v| format!("{}", v))
|
||||
);
|
||||
(
|
||||
with_native_environment(ext, move || (call)()).map(NativeOrEncoded::Native),
|
||||
with_native_environment(ext, move || (call)())
|
||||
.and_then(|r| r.map(NativeOrEncoded::Native).map_err(Into::into)),
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user