mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
contracts: Refactor the runtime API in order to simplify node integration (#7409)
* contracts: Make use of existing type aliases for runtime API types * contracts: Refactor the contracts call runtime API * review: Fix comment typo Co-authored-by: Andrew Jones <ascjones@gmail.com> * Update frame/contracts/common/src/lib.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Update frame/contracts/common/src/lib.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Update frame/contracts/common/src/lib.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Update frame/contracts/common/src/lib.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Update frame/contracts/common/src/lib.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> * Update lib.rs * review: Group crate imports Co-authored-by: Andrew Jones <ascjones@gmail.com> Co-authored-by: Addie Wagenknecht <addie@nortd.com> Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bd450c24ff
commit
a5ec7e5c4e
@@ -19,7 +19,7 @@
|
||||
|
||||
use crate::{CodeHash, Schedule, Trait};
|
||||
use crate::wasm::env_def::FunctionImplProvider;
|
||||
use crate::exec::{Ext, ExecResult};
|
||||
use crate::exec::Ext;
|
||||
use crate::gas::GasMeter;
|
||||
|
||||
use sp_std::prelude::*;
|
||||
@@ -34,6 +34,7 @@ mod runtime;
|
||||
|
||||
use self::runtime::{to_execution_result, Runtime};
|
||||
use self::code_cache::load as load_code;
|
||||
use pallet_contracts_primitives::ExecResult;
|
||||
|
||||
pub use self::code_cache::save as save_code;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -155,7 +156,7 @@ mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
use sp_core::H256;
|
||||
use crate::exec::{Ext, StorageKey, ExecReturnValue, ReturnFlags, ExecError, ErrorOrigin};
|
||||
use crate::exec::{Ext, StorageKey};
|
||||
use crate::gas::{Gas, GasMeter};
|
||||
use crate::tests::{Test, Call};
|
||||
use crate::wasm::prepare::prepare_contract;
|
||||
@@ -163,6 +164,7 @@ mod tests {
|
||||
use hex_literal::hex;
|
||||
use sp_runtime::DispatchError;
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags, ExecError, ErrorOrigin};
|
||||
|
||||
const GAS_LIMIT: Gas = 10_000_000_000;
|
||||
|
||||
@@ -1361,7 +1363,7 @@ mod tests {
|
||||
|
||||
;; size of our buffer is 128 bytes
|
||||
(data (i32.const 160) "\80")
|
||||
|
||||
|
||||
(func $assert (param i32)
|
||||
(block $ok
|
||||
(br_if $ok
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
//! Environment definition of the wasm smart-contract runtime.
|
||||
|
||||
use crate::{HostFnWeights, Schedule, Trait, CodeHash, BalanceOf, Error};
|
||||
use crate::exec::{
|
||||
Ext, ExecResult, ExecReturnValue, StorageKey, TopicOf, ReturnFlags, ExecError
|
||||
use crate::{
|
||||
HostFnWeights, Schedule, Trait, CodeHash, BalanceOf, Error,
|
||||
exec::{Ext, StorageKey, TopicOf},
|
||||
gas::{Gas, GasMeter, Token, GasMeterResult},
|
||||
wasm::env_def::ConvertibleToWasm,
|
||||
};
|
||||
use crate::gas::{Gas, GasMeter, Token, GasMeterResult};
|
||||
use crate::wasm::env_def::ConvertibleToWasm;
|
||||
use sp_sandbox;
|
||||
use parity_wasm::elements::ValueType;
|
||||
use frame_system;
|
||||
@@ -35,6 +35,7 @@ use sp_io::hashing::{
|
||||
blake2_128,
|
||||
sha2_256,
|
||||
};
|
||||
use pallet_contracts_primitives::{ExecResult, ExecReturnValue, ReturnFlags, ExecError};
|
||||
|
||||
/// Every error that can be returned to a contract when it calls any of the host functions.
|
||||
#[repr(u32)]
|
||||
@@ -499,7 +500,7 @@ fn err_into_return_code<T: Trait>(from: DispatchError) -> Result<ReturnCode, Dis
|
||||
|
||||
/// Fallible conversion of a `ExecResult` to `ReturnCode`.
|
||||
fn exec_into_return_code<T: Trait>(from: ExecResult) -> Result<ReturnCode, DispatchError> {
|
||||
use crate::exec::ErrorOrigin::Callee;
|
||||
use pallet_contracts_primitives::ErrorOrigin::Callee;
|
||||
|
||||
let ExecError { error, origin } = match from {
|
||||
Ok(retval) => return Ok(retval.into()),
|
||||
|
||||
Reference in New Issue
Block a user