Skip to content

Commit 934c5a5

Browse files
valeriikharkinshawntabrizibkchr4meta5gnunicorn
committed
Make Pallet ModuleId and LockIdentifier Configurable (#5695)
* transition treasury to configurable moduleids * make election module id configurable * convert runtime and pallet to accept module id config elections-phragmen * add ModuleId to evm pallet * change society pallet to configurable module id * delete commented out module_id * delete commented out code and merge in upstream master * try and convert 4 whitespace to tab * fix remaining space to tab conversions * trivial cleaning * delete comment from elections-phragrems tests * trivial * Update frame/elections-phragmen/src/lib.rs * add docs for elections and elections phragmen * make has_lock test get moduleid dynamically * Apply suggestions from code review Co-Authored-By: Amar Singh <[email protected]> * make sure get is imported to evm Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Amar Singh <[email protected]> Co-authored-by: Benjamin Kampmann <[email protected]>
1 parent 17a5473 commit 934c5a5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub use crate::backend::{Account, Log, Vicinity, Backend};
2626
use sp_std::{vec::Vec, marker::PhantomData};
2727
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
2828
use frame_support::weights::{Weight, MINIMUM_WEIGHT, DispatchClass, FunctionOf, Pays};
29-
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement};
29+
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement, Get};
3030
use frame_system::{self as system, ensure_signed};
3131
use sp_runtime::ModuleId;
3232
use sp_core::{U256, H256, H160, Hasher};
@@ -38,8 +38,6 @@ use evm::{ExitReason, ExitSucceed, ExitError, Config};
3838
use evm::executor::StackExecutor;
3939
use evm::backend::ApplyBackend;
4040

41-
const MODULE_ID: ModuleId = ModuleId(*b"py/ethvm");
42-
4341
/// Type alias for currency balance.
4442
pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
4543

@@ -119,6 +117,8 @@ static ISTANBUL_CONFIG: Config = Config::istanbul();
119117

120118
/// EVM module trait
121119
pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
120+
/// The EVM's module id
121+
type ModuleId: Get<ModuleId>;
122122
/// Calculator for current gas price.
123123
type FeeCalculator: FeeCalculator;
124124
/// Convert account ID to H160;
@@ -188,6 +188,8 @@ decl_module! {
188188
type Error = Error<T>;
189189

190190
fn deposit_event() = default;
191+
192+
const ModuleId: ModuleId = T::ModuleId::get();
191193

192194
/// Deposit balance from currency/balances module into EVM.
193195
#[weight = MINIMUM_WEIGHT]
@@ -361,7 +363,7 @@ impl<T: Trait> Module<T> {
361363
/// This actually does computation. If you need to keep using it, then make sure you cache the
362364
/// value and only call this once.
363365
pub fn account_id() -> T::AccountId {
364-
MODULE_ID.into_account()
366+
T::ModuleId::get().into_account()
365367
}
366368

367369
/// Check whether an account is empty.

0 commit comments

Comments
 (0)