Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion PR for add events to ContractResult #2510

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use frame_support::{
traits::{ConstBool, ConstU32, Nothing},
};
use pallet_contracts::{
weights::SubstrateWeight, Config, DefaultAddressGenerator, Frame, Schedule,
weights::SubstrateWeight, Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule,
};
pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO;

// Prints debug output of the `contracts` pallet to stdout if the node is
// started with `-lruntime::contracts=debug`.
pub const CONTRACTS_DEBUG_OUTPUT: bool = true;
pub const CONTRACTS_DEBUG_OUTPUT: DebugInfo = DebugInfo::UnsafeDebug;

parameter_types! {
pub const DepositPerItem: Balance = deposit(1, 0);
Expand Down
13 changes: 10 additions & 3 deletions parachains/runtimes/contracts/contracts-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, Si

pub type Migrations = (pallet_contracts::Migration<Runtime>,);

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
<Runtime as frame_system::Config>::Hash,
>;
Comment on lines +102 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this alias be defined in the pallet_contracts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In pallet_contracts this is generic over T https://github.com/paritytech/substrate/blob/jg/12412-contracts-return-emitted-events-for-dry-runs/frame/contracts/src/lib.rs#L151
This way we leave it open to the implementor to configure it.


/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Expand Down Expand Up @@ -532,15 +537,15 @@ impl_runtime_apis! {
}
}

impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash> for Runtime {
impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash, EventRecord> for Runtime {
fn call(
origin: AccountId,
dest: AccountId,
value: Balance,
gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult<Balance> {
) -> pallet_contracts_primitives::ContractExecResult<Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call(
origin,
Expand All @@ -550,6 +555,7 @@ impl_runtime_apis! {
storage_deposit_limit,
input_data,
contracts::CONTRACTS_DEBUG_OUTPUT,
pallet_contracts::CollectEvents::UnsafeCollect,
pallet_contracts::Determinism::Enforced,
)
}
Expand All @@ -562,7 +568,7 @@ impl_runtime_apis! {
code: pallet_contracts_primitives::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance> {
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance, EventRecord> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate(
origin,
Expand All @@ -573,6 +579,7 @@ impl_runtime_apis! {
data,
salt,
contracts::CONTRACTS_DEBUG_OUTPUT,
pallet_contracts::CollectEvents::UnsafeCollect,
)
}

Expand Down