Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove unused imports #81

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
82 changes: 2 additions & 80 deletions node/client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
pub use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Header, Index, Signature};
use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider};
pub use sc_executor::NativeElseWasmExecutor;
use sp_api::{CallApiAt, Encode, NumberFor, ProvideRuntimeApi};
use sp_api::{CallApiAt, NumberFor, ProvideRuntimeApi};
use sp_blockchain::{HeaderBackend, HeaderMetadata};
use sp_consensus::BlockStatus;
use sp_core::Pair;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{
generic::{BlockId, SignedBlock},
traits::{BlakeTwo256, Block as BlockT},
Justifications, OpaqueExtrinsic,
Justifications,
};
use sp_storage::{ChildInfo, StorageData, StorageKey};
use std::sync::Arc;
Expand Down Expand Up @@ -446,82 +444,6 @@ impl sp_blockchain::HeaderBackend<Block> for Client {
}
}

macro_rules! with_signed_payload {
{
$self:ident,
{
$extra:ident,
$client:ident,
$raw_payload:ident
},
{
$( $setup:tt )*
},
(
$period:expr,
$current_block:expr,
$nonce:expr,
$tip:expr,
$call:expr,
$genesis:expr
),
{
$( $usage:tt )*
}
} => {
match $self {
#[cfg(feature = "cere")]
Self::Cere($client) => {
use cere_runtime as runtime;

$( $setup )*

let $extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckMortality::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
$period,
$current_block,
)),
frame_system::CheckNonce::<runtime::Runtime>::from($nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from($tip),
);

let $raw_payload = runtime::SignedPayload::from_raw(
$call.clone(),
$extra.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
$genesis.clone(),
$genesis,
(),
(),
(),
),
);

$( $usage )*
},
#[cfg(feature = "cere-dev")]
Self::CereDev($client) => {
use cere_dev_runtime as runtime;

$( $setup )*

signed_payload!($extra, $raw_payload,
($period, $current_block, $nonce, $tip, $call, $genesis));

$( $usage )*
},
}
}
}

#[allow(unused_macros)]
macro_rules! signed_payload {
(
Expand Down
15 changes: 3 additions & 12 deletions pallets/chainbridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,18 @@
use codec::{Decode, Encode, EncodeLike};
use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::{
ClassifyDispatch, DispatchClass, DispatchResult, GetDispatchInfo, Pays, PaysFee, WeighData,
Weight,
},
dispatch::{DispatchResult, GetDispatchInfo, Pays, Weight},
ensure,
traits::{EnsureOrigin, Get},
PalletId, Parameter,
};
use frame_system::{self as system, ensure_root, ensure_signed};
use sp_core::U256;
use sp_runtime::{
traits::{
AccountIdConversion, Bounded, DispatchInfoOf, Dispatchable, SaturatedConversion,
SignedExtension,
},
transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
},
traits::{AccountIdConversion, Dispatchable},
RuntimeDebug,
};
use sp_std::{marker::PhantomData, prelude::*};
use sp_std::prelude::*;

mod mock;
mod tests;
Expand Down
6 changes: 3 additions & 3 deletions pallets/chainbridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
use super::*;

use frame_support::{
assert_ok, ord_parameter_types, parameter_types, traits::Everything, weights::Weight, PalletId,
assert_ok, ord_parameter_types, parameter_types, traits::Everything, weights::Weight,
};
use frame_system::{self as system};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{AccountIdConversion, BlakeTwo256, Block as BlockT, IdentityLookup},
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup},
Perbill,
};

Expand Down Expand Up @@ -146,7 +146,7 @@ pub fn new_test_ext_initialized(
// include the most recent event, but do not have to include every past event.
pub fn assert_events(mut expected: Vec<RuntimeEvent>) {
let mut actual: Vec<RuntimeEvent> =
system::Module::<Test>::events().iter().map(|e| e.event.clone()).collect();
system::Pallet::<Test>::events().iter().map(|e| e.event.clone()).collect();

expected.reverse();

Expand Down
1 change: 0 additions & 1 deletion pallets/chainbridge/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::{
};
use crate::mock::new_test_ext_initialized;
use frame_support::{assert_noop, assert_ok};
use frame_system::Origin;

#[test]
fn derive_ids() {
Expand Down
3 changes: 1 addition & 2 deletions pallets/ddc-metrics-offchain-worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ extern crate alloc;
use alloc::string::String;
use core::fmt::Debug;
use frame_support::weights::Weight;
use scale_info::{Type, TypeInfo};
use sp_runtime::offchain::storage::StorageRetrievalError;
use scale_info::TypeInfo;

pub const BLOCK_INTERVAL: u32 = 100; // TODO: Change to 1200 later [1h]. Now - 200 [10 minutes] for testing purposes.

Expand Down
3 changes: 1 addition & 2 deletions pallets/ddc-metrics-offchain-worker/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use frame_support::traits::{Currency, OffchainWorker};
use frame_system::Config as FSC;
use pallet_contracts::{self as contracts, Config as CC};
use sp_core::offchain::{
testing, OffchainDbExt, OffchainWorkerExt, Timestamp as OCWTimestamp, TransactionPoolExt,
};
Expand Down Expand Up @@ -285,7 +284,7 @@ fn should_run_contract() {
let contract_id = deploy_contract();
let call_data = DdcMetricsOffchainWorker::encode_get_current_period_ms();

pallet_contracts::Module::<T>::call(
pallet_contracts::Pallet::<T>::call(
RuntimeOrigin::signed(alice.clone()),
contract_id.clone(),
0,
Expand Down
3 changes: 0 additions & 3 deletions pallets/ddc-metrics-offchain-worker/src/tests/test_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use crate::{self as pallet_ddc_metrics_offchain_worker, *};

use codec::{Decode, Encode};
use frame_support::{
parameter_types,
traits::{ConstU32, Currency, Everything, Get, Nothing},
Expand All @@ -30,8 +29,6 @@ pub type Moment = u64;
// -- Implement a contracts runtime for testing --

// Macro hack: Give names to the pallets.
use frame_system as system;
use pallet_balances as balances;
use pallet_contracts as contracts;

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand Down
1 change: 0 additions & 1 deletion pallets/ddc/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate as pallet_cere_ddc;
use crate::Module;
use frame_support::{construct_runtime, parameter_types, traits::Everything};
use frame_system as system;
use sp_core::H256;
Expand Down
12 changes: 2 additions & 10 deletions pallets/erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,16 @@
use pallet_chainbridge as bridge;
use pallet_erc721 as erc721;

use codec::{Decode, Encode};
use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::DispatchResult,
ensure,
traits::{Currency, EnsureOrigin, ExistenceRequirement::AllowDeath, Get},
weights::{ClassifyDispatch, DispatchClass, Pays, PaysFee, WeighData, Weight},
};
use frame_system::{self as system, ensure_root, ensure_signed};
use frame_system::{self as system, ensure_signed};
use sp_arithmetic::traits::SaturatedConversion;
use sp_core::U256;
use sp_runtime::{
traits::{Bounded, DispatchInfoOf, SignedExtension, UniqueSaturatedInto},
transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
},
};
use sp_std::{marker::PhantomData, prelude::*};
use sp_std::prelude::*;

type ResourceId = bridge::ResourceId;

Expand Down
15 changes: 3 additions & 12 deletions pallets/erc721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@

use codec::{Decode, Encode};
use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::{ClassifyDispatch, DispatchClass, DispatchResult, Pays, PaysFee, WeighData},
ensure,
decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure,
traits::Get,
weights::Weight,
};
use frame_system::{self as system, ensure_root, ensure_signed};
use sp_core::U256;
use sp_runtime::{
traits::{Bounded, DispatchInfoOf, SaturatedConversion, SignedExtension},
transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
},
RuntimeDebug,
};
use sp_std::{marker::PhantomData, prelude::*};
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;

mod mock;
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion pallets/erc721/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use frame_system::{self as system};
use sp_core::{hashing::blake2_128, H256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Block as BlockT, IdentityLookup},
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, Perbill,
};

Expand Down
1 change: 0 additions & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use jsonrpsee::RpcModule;
use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index};
use sc_client_api::AuxStore;
use sc_consensus_babe::{BabeConfiguration, Epoch};
use sc_consensus_babe_rpc::Babe;
use sc_consensus_epochs::SharedEpochChanges;
use sc_finality_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
Expand Down
5 changes: 4 additions & 1 deletion runtime/cere-dev/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ mod multiplier_tests {
System, TargetBlockFullness, TransactionPayment,
};
use cere_dev_runtime_constants::{currency::*, time::*};
use frame_support::weights::{DispatchClass, Weight, WeightToFee as WeightToFeeT};
use frame_support::{
dispatch::DispatchClass,
weights::{Weight, WeightToFee as WeightToFeeT},
};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
use sp_runtime::{
assert_eq_error_rate,
Expand Down
9 changes: 3 additions & 6 deletions runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]

use cere_runtime_common::{BalanceToU256, U256ToBalance};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_election_provider_support::{
onchain, BalancingConfig, ExtendedBalance, SequentialPhragmen, VoteWeight,
};
use frame_election_provider_support::{onchain, BalancingConfig, SequentialPhragmen, VoteWeight};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
pallet_prelude::Get,
parameter_types,
traits::{
Expand All @@ -38,7 +36,7 @@ use frame_support::{
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, IdentityFee, Weight,
ConstantMultiplier, IdentityFee, Weight,
},
PalletId, RuntimeDebug,
};
Expand All @@ -50,7 +48,6 @@ pub use node_primitives::{AccountId, Signature};
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
pub use pallet_cere_ddc;
pub use pallet_chainbridge;
use pallet_contracts::weights::WeightInfo;
pub use pallet_ddc_accounts;
pub use pallet_ddc_metrics_offchain_worker;
pub use pallet_ddc_staking;
Expand Down
5 changes: 4 additions & 1 deletion runtime/cere/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ mod multiplier_tests {
System, TargetBlockFullness, TransactionPayment,
};
use cere_runtime_constants::{currency::*, time::*};
use frame_support::weights::{DispatchClass, Weight, WeightToFee as WeightToFeeT};
use frame_support::{
dispatch::DispatchClass,
weights::{Weight, WeightToFee as WeightToFeeT},
};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
use sp_runtime::{
assert_eq_error_rate,
Expand Down
9 changes: 3 additions & 6 deletions runtime/cere/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]

use cere_runtime_common::{BalanceToU256, U256ToBalance};
use codec::{Decode, Encode, MaxEncodedLen};
use frame_election_provider_support::{
onchain, BalancingConfig, ExtendedBalance, SequentialPhragmen, VoteWeight,
};
use frame_election_provider_support::{onchain, BalancingConfig, SequentialPhragmen, VoteWeight};
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
pallet_prelude::Get,
parameter_types,
traits::{
Expand All @@ -38,7 +36,7 @@ use frame_support::{
},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
ConstantMultiplier, DispatchClass, IdentityFee, Weight,
ConstantMultiplier, IdentityFee, Weight,
},
PalletId, RuntimeDebug,
};
Expand All @@ -50,7 +48,6 @@ pub use node_primitives::{AccountId, Signature};
use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment};
pub use pallet_cere_ddc;
pub use pallet_chainbridge;
use pallet_contracts::weights::WeightInfo;
pub use pallet_ddc_metrics_offchain_worker;
use pallet_election_provider_multi_phase::SolutionAccuracyOf;
use pallet_grandpa::{
Expand Down
Loading