mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 17:31:03 +00:00
Rename pallet trait Trait to Config (#7599)
* rename Trait to Config * add test asserting using Trait is still valid. * fix ui tests
This commit is contained in:
committed by
GitHub
parent
dd3c84c362
commit
1cbfc9257f
@@ -18,7 +18,7 @@
|
||||
//!
|
||||
//! The Contract module provides functionality for the runtime to deploy and execute WebAssembly smart-contracts.
|
||||
//!
|
||||
//! - [`contract::Trait`](./trait.Trait.html)
|
||||
//! - [`contract::Config`](./trait.Config.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//!
|
||||
//! ## Overview
|
||||
@@ -126,18 +126,18 @@ use pallet_contracts_primitives::{
|
||||
};
|
||||
use frame_support::weights::Weight;
|
||||
|
||||
pub type CodeHash<T> = <T as frame_system::Trait>::Hash;
|
||||
pub type CodeHash<T> = <T as frame_system::Config>::Hash;
|
||||
pub type TrieId = Vec<u8>;
|
||||
|
||||
/// Information for managing an account and its sub trie abstraction.
|
||||
/// This is the required info to cache for an account
|
||||
#[derive(Encode, Decode, RuntimeDebug)]
|
||||
pub enum ContractInfo<T: Trait> {
|
||||
pub enum ContractInfo<T: Config> {
|
||||
Alive(AliveContractInfo<T>),
|
||||
Tombstone(TombstoneContractInfo<T>),
|
||||
}
|
||||
|
||||
impl<T: Trait> ContractInfo<T> {
|
||||
impl<T: Config> ContractInfo<T> {
|
||||
/// If contract is alive then return some alive info
|
||||
pub fn get_alive(self) -> Option<AliveContractInfo<T>> {
|
||||
if let ContractInfo::Alive(alive) = self {
|
||||
@@ -190,7 +190,7 @@ impl<T: Trait> ContractInfo<T> {
|
||||
}
|
||||
|
||||
pub type AliveContractInfo<T> =
|
||||
RawAliveContractInfo<CodeHash<T>, BalanceOf<T>, <T as frame_system::Trait>::BlockNumber>;
|
||||
RawAliveContractInfo<CodeHash<T>, BalanceOf<T>, <T as frame_system::Config>::BlockNumber>;
|
||||
|
||||
/// Information for managing an account and its sub trie abstraction.
|
||||
/// This is the required info to cache for an account.
|
||||
@@ -230,7 +230,7 @@ pub(crate) fn child_trie_info(trie_id: &[u8]) -> ChildInfo {
|
||||
}
|
||||
|
||||
pub type TombstoneContractInfo<T> =
|
||||
RawTombstoneContractInfo<<T as frame_system::Trait>::Hash, <T as frame_system::Trait>::Hashing>;
|
||||
RawTombstoneContractInfo<<T as frame_system::Config>::Hash, <T as frame_system::Config>::Hashing>;
|
||||
|
||||
#[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct RawTombstoneContractInfo<H, Hasher>(H, PhantomData<Hasher>);
|
||||
@@ -250,18 +250,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> From<AliveContractInfo<T>> for ContractInfo<T> {
|
||||
impl<T: Config> From<AliveContractInfo<T>> for ContractInfo<T> {
|
||||
fn from(alive_info: AliveContractInfo<T>) -> Self {
|
||||
Self::Alive(alive_info)
|
||||
}
|
||||
}
|
||||
|
||||
pub type BalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
|
||||
pub type NegativeImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait: frame_system::Trait {
|
||||
pub trait Config: frame_system::Config {
|
||||
type Time: Time;
|
||||
type Randomness: Randomness<Self::Hash>;
|
||||
|
||||
@@ -269,7 +269,7 @@ pub trait Trait: frame_system::Trait {
|
||||
type Currency: Currency<Self::AccountId>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Handler for rent payments.
|
||||
type RentPayment: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
@@ -323,7 +323,7 @@ pub trait Trait: frame_system::Trait {
|
||||
|
||||
decl_error! {
|
||||
/// Error for the contracts module.
|
||||
pub enum Error for Module<T: Trait>
|
||||
pub enum Error for Module<T: Config>
|
||||
where
|
||||
T::AccountId: UncheckedFrom<T::Hash>,
|
||||
T::AccountId: AsRef<[u8]>,
|
||||
@@ -383,7 +383,7 @@ decl_error! {
|
||||
|
||||
decl_module! {
|
||||
/// Contracts module.
|
||||
pub struct Module<T: Trait> for enum Call
|
||||
pub struct Module<T: Config> for enum Call
|
||||
where
|
||||
origin: T::Origin,
|
||||
T::AccountId: UncheckedFrom<T::Hash>,
|
||||
@@ -564,7 +564,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Public APIs provided by the contracts module.
|
||||
impl<T: Trait> Module<T>
|
||||
impl<T: Config> Module<T>
|
||||
where
|
||||
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
|
||||
{
|
||||
@@ -638,7 +638,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> Module<T>
|
||||
impl<T: Config> Module<T>
|
||||
where
|
||||
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
|
||||
{
|
||||
@@ -647,7 +647,7 @@ where
|
||||
gas_meter: &mut GasMeter<T>,
|
||||
func: impl FnOnce(&mut ExecutionContext<T, WasmVm<T>, WasmLoader<T>>, &mut GasMeter<T>) -> ExecResult,
|
||||
) -> ExecResult {
|
||||
let cfg = Config::preload();
|
||||
let cfg = ConfigCache::preload();
|
||||
let vm = WasmVm::new(&cfg.schedule);
|
||||
let loader = WasmLoader::new(&cfg.schedule);
|
||||
let mut ctx = ExecutionContext::top_level(origin, &cfg, &vm, &loader);
|
||||
@@ -659,8 +659,8 @@ decl_event! {
|
||||
pub enum Event<T>
|
||||
where
|
||||
Balance = BalanceOf<T>,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash
|
||||
<T as frame_system::Config>::AccountId,
|
||||
<T as frame_system::Config>::Hash
|
||||
{
|
||||
/// Contract deployed by address at the specified address. \[owner, contract\]
|
||||
Instantiated(AccountId, AccountId),
|
||||
@@ -699,7 +699,7 @@ decl_event! {
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Contracts
|
||||
trait Store for Module<T: Config> as Contracts
|
||||
where
|
||||
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>
|
||||
{
|
||||
@@ -722,7 +722,7 @@ decl_storage! {
|
||||
///
|
||||
/// We assume that these values can't be changed in the
|
||||
/// course of transaction execution.
|
||||
pub struct Config<T: Trait> {
|
||||
pub struct ConfigCache<T: Config> {
|
||||
pub schedule: Schedule<T>,
|
||||
pub existential_deposit: BalanceOf<T>,
|
||||
pub tombstone_deposit: BalanceOf<T>,
|
||||
@@ -730,12 +730,12 @@ pub struct Config<T: Trait> {
|
||||
pub max_value_size: u32,
|
||||
}
|
||||
|
||||
impl<T: Trait> Config<T>
|
||||
impl<T: Config> ConfigCache<T>
|
||||
where
|
||||
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>
|
||||
{
|
||||
fn preload() -> Config<T> {
|
||||
Config {
|
||||
fn preload() -> ConfigCache<T> {
|
||||
ConfigCache {
|
||||
schedule: <Module<T>>::current_schedule(),
|
||||
existential_deposit: T::Currency::minimum_balance(),
|
||||
tombstone_deposit: T::TombstoneDeposit::get(),
|
||||
|
||||
Reference in New Issue
Block a user