From faf278baf9c2c39df58060164b977969605033bd Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Thu, 5 Sep 2024 00:22:52 +0300 Subject: [PATCH] fix lint issue --- runtime/src/precompiles/mod.rs | 2 +- runtime/src/precompiles/staking.rs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/runtime/src/precompiles/mod.rs b/runtime/src/precompiles/mod.rs index f1902ff8d..e1ef8439a 100644 --- a/runtime/src/precompiles/mod.rs +++ b/runtime/src/precompiles/mod.rs @@ -66,7 +66,7 @@ where a if a == hash(1025) => Some(ECRecoverPublicKey::execute(handle)), a if a == hash(BALANCE_TRANSFER_INDEX) => { Some(BalanceTransferPrecompile::execute(handle)) - }, + } a if a == hash(STAKING_PRECOMPILE_INDEX) => { Some(StakingPrecompile::execute(handle)) // Add this line } diff --git a/runtime/src/precompiles/staking.rs b/runtime/src/precompiles/staking.rs index 9d30e8435..51f7609a1 100644 --- a/runtime/src/precompiles/staking.rs +++ b/runtime/src/precompiles/staking.rs @@ -1,14 +1,14 @@ +use crate::precompiles::{bytes_to_account_id, get_method_id, get_slice}; use frame_system::RawOrigin; +use pallet_evm::{AddressMapping, HashedAddressMapping}; use pallet_evm::{ ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, }; -use pallet_evm::{HashedAddressMapping,AddressMapping}; use sp_core::U256; use sp_runtime::traits::BlakeTwo256; use sp_runtime::traits::Dispatchable; use sp_runtime::AccountId32; use sp_std::vec; -use crate::precompiles::{bytes_to_account_id, get_method_id, get_slice}; use crate::{Runtime, RuntimeCall}; pub const STAKING_PRECOMPILE_INDEX: u64 = 2049; @@ -22,11 +22,15 @@ impl StakingPrecompile { let method_input = txdata[4..].to_vec(); // Avoiding borrowing conflicts match method_id { - id if id == get_method_id("addStake(bytes32)") => Self::add_stake(handle, &method_input), - id if id == get_method_id("removeStake(bytes32,uint64)") => Self::remove_stake(handle, &method_input), + id if id == get_method_id("addStake(bytes32)") => { + Self::add_stake(handle, &method_input) + } + id if id == get_method_id("removeStake(bytes32,uint64)") => { + Self::remove_stake(handle, &method_input) + } _ => Err(PrecompileFailure::Error { exit_status: ExitError::InvalidRange, - }) + }), } } @@ -63,7 +67,10 @@ impl StakingPrecompile { } fn dispatch(handle: &mut impl PrecompileHandle, call: RuntimeCall) -> PrecompileResult { - let account_id = as AddressMapping>::into_account_id(handle.context().caller); + let account_id = + as AddressMapping>::into_account_id( + handle.context().caller, + ); let result = call.dispatch(RawOrigin::Signed(account_id).into()); match &result { Ok(post_info) => log::info!("Dispatch succeeded. Post info: {:?}", post_info),