mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
contracts: add events to ContractResult (#13807)
* contracts: add events to ContractResult * contracts: add encoded events to ContractResult * contracts: add generic Event to ContractResult * contracts: test bare_call events * contracts: update bare_call test name * contracts: add better comments to dry run events * contracts: fix pallet contracts primitives implementation * contracts: add EventRecord generic to ContractInstantiateResult * contracts: make event collection optional * contracts: impreved notes on `collect_events` * contracts: update benchmarking calls * contracts: change bare_call and bare_instantiate to accept enums instead of bools * contracts: add partial eq to new enums * contracts: improve comments * contracts: improve comments * contracts: fix bare_call benchmarking * contracts: fix bare call and instantiate in impl_runtime_apis * contracts: add api versioning to new ContractsApi functions * contracts: modify api versioning to new ContractsApi functions * contracts: create new contracts api trait * contracts: clean up code * contracts: remove the contract results with events * contracts: undo contracts api v3 * contracts: remove commented out code * contracts: add new test bare call result does not return events * contracts: add code review improvements * contracts: remove type imports * contracts: minor code review improvements
This commit is contained in:
@@ -29,11 +29,18 @@ use sp_runtime::{
|
||||
use sp_std::prelude::*;
|
||||
use sp_weights::Weight;
|
||||
|
||||
/// Result type of a `bare_call` or `bare_instantiate` call.
|
||||
/// Result type of a `bare_call` or `bare_instantiate` call as well as `ContractsApi::call` and
|
||||
/// `ContractsApi::instantiate`.
|
||||
///
|
||||
/// It contains the execution result together with some auxiliary information.
|
||||
///
|
||||
/// #Note
|
||||
///
|
||||
/// It has been extended to include `events` at the end of the struct while not bumping the
|
||||
/// `ContractsApi` version. Therefore when SCALE decoding a `ContractResult` its trailing data
|
||||
/// should be ignored to avoid any potential compatibility issues.
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ContractResult<R, Balance> {
|
||||
pub struct ContractResult<R, Balance, EventRecord> {
|
||||
/// How much weight was consumed during execution.
|
||||
pub gas_consumed: Weight,
|
||||
/// How much weight is required as gas limit in order to execute this call.
|
||||
@@ -71,15 +78,18 @@ pub struct ContractResult<R, Balance> {
|
||||
pub debug_message: Vec<u8>,
|
||||
/// The execution result of the wasm code.
|
||||
pub result: R,
|
||||
/// The events that were emitted during execution. It is an option as event collection is
|
||||
/// optional.
|
||||
pub events: Option<Vec<EventRecord>>,
|
||||
}
|
||||
|
||||
/// Result type of a `bare_call` call.
|
||||
pub type ContractExecResult<Balance> =
|
||||
ContractResult<Result<ExecReturnValue, DispatchError>, Balance>;
|
||||
/// Result type of a `bare_call` call as well as `ContractsApi::call`.
|
||||
pub type ContractExecResult<Balance, EventRecord> =
|
||||
ContractResult<Result<ExecReturnValue, DispatchError>, Balance, EventRecord>;
|
||||
|
||||
/// Result type of a `bare_instantiate` call.
|
||||
pub type ContractInstantiateResult<AccountId, Balance> =
|
||||
ContractResult<Result<InstantiateReturnValue<AccountId>, DispatchError>, Balance>;
|
||||
/// Result type of a `bare_instantiate` call as well as `ContractsApi::instantiate`.
|
||||
pub type ContractInstantiateResult<AccountId, Balance, EventRecord> =
|
||||
ContractResult<Result<InstantiateReturnValue<AccountId>, DispatchError>, Balance, EventRecord>;
|
||||
|
||||
/// Result type of a `bare_code_upload` call.
|
||||
pub type CodeUploadResult<CodeHash, Balance> =
|
||||
|
||||
Reference in New Issue
Block a user