difftreelog
ci fix clippy warnings
in: master
13 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5996,34 +5996,34 @@
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
-source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
+ "serde",
+ "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
+ "substrate-test-utils",
+ "up-sponsorship",
]
[[package]]
name = "pallet-scheduler"
version = "3.0.0"
+source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"parity-scale-codec 2.1.3",
- "serde",
- "sp-core",
"sp-io",
"sp-runtime",
"sp-std",
- "substrate-test-utils",
- "up-sponsorship",
]
[[package]]
crates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterboth--- a/crates/evm-coder-macros/src/solidity_interface.rs
+++ b/crates/evm-coder-macros/src/solidity_interface.rs
@@ -264,7 +264,7 @@
ReturnType::Type(_, ty) => ty,
_ => return Err(syn::Error::new(value.sig.output.span(), "interface method should return Result<value>\nif there is no value to return - specify void (which is alias to unit)")),
};
- let result = parse_result_ok(&result)?;
+ let result = parse_result_ok(result)?;
let camel_name = info
.rename_selector
@@ -285,8 +285,8 @@
Ok(Self {
name: ident.clone(),
camel_name,
- pascal_name: snake_ident_to_pascal(&ident),
- screaming_name: snake_ident_to_screaming(&ident),
+ pascal_name: snake_ident_to_pascal(ident),
+ screaming_name: snake_ident_to_screaming(ident),
selector_str,
selector,
args,
@@ -433,7 +433,7 @@
found_error = true;
}
}
- TraitItem::Method(method) => methods.push(Method::try_from(&method)?),
+ TraitItem::Method(method) => methods.push(Method::try_from(method)?),
_ => {}
}
}
crates/evm-coder-macros/src/to_log.rsdiffbeforeafterboth--- a/crates/evm-coder-macros/src/to_log.rs
+++ b/crates/evm-coder-macros/src/to_log.rs
@@ -41,7 +41,7 @@
impl Event {
fn try_from(variant: &Variant) -> syn::Result<Self> {
let name = &variant.ident;
- let name_screaming = snake_ident_to_screaming(&name);
+ let name_screaming = snake_ident_to_screaming(name);
let named = match &variant.fields {
Fields::Named(named) => named,
@@ -54,7 +54,7 @@
};
let mut fields = Vec::new();
for field in &named.named {
- fields.push(EventField::try_from(&field)?);
+ fields.push(EventField::try_from(field)?);
}
let mut selector_str = format!("{}(", name);
for (i, arg) in fields.iter().enumerate() {
crates/evm-coder/src/abi.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -104,7 +104,7 @@
fn subresult(&mut self) -> Result<AbiReader<'i>> {
let offset = self.read_usize()?;
Ok(AbiReader {
- buf: &self.buf,
+ buf: self.buf,
offset: offset + self.offset,
})
}
@@ -252,7 +252,7 @@
impl_abi_writeable!(&str, string);
impl AbiWrite for &string {
fn abi_write(&self, writer: &mut AbiWriter) {
- writer.string(&self)
+ writer.string(self)
}
}
node/cli/src/cli.rsdiffbeforeafterboth--- a/node/cli/src/cli.rs
+++ b/node/cli/src/cli.rs
@@ -1,6 +1,4 @@
use crate::chain_spec;
-use cumulus_client_cli;
-use sc_cli;
use std::path::PathBuf;
use structopt::StructOpt;
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -120,8 +120,7 @@
}
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
- polkadot_cli::Cli::from_iter([RelayChainCli::executable_name().to_string()].iter())
- .load_spec(id)
+ polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
}
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
@@ -129,6 +128,7 @@
}
}
+#[allow(clippy::borrowed_box)]
fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {
let mut storage = chain_spec.build_storage()?;
@@ -189,7 +189,7 @@
runner.sync_run(|config| {
let polkadot_cli = RelayChainCli::new(
&config,
- [RelayChainCli::executable_name().to_string()]
+ [RelayChainCli::executable_name()]
.iter()
.chain(cli.relaychain_args.iter()),
);
@@ -275,7 +275,7 @@
let polkadot_cli = RelayChainCli::new(
&config,
- [RelayChainCli::executable_name().to_string()]
+ [RelayChainCli::executable_name()]
.iter()
.chain(cli.relaychain_args.iter()),
);
node/cli/src/service.rsdiffbeforeafterboth1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.23//4// This file is subject to the terms and conditions defined in5// file 'LICENSE', which is part of this source code package.6//78// std9use std::sync::Arc;10use std::sync::Mutex;11use std::collections::BTreeMap;12use std::collections::HashMap;1314// Local Runtime Types15use nft_runtime::RuntimeApi;1617// Cumulus Imports18use cumulus_client_consensus_aura::{build_aura_consensus, BuildAuraConsensusParams, SlotProportion};19use cumulus_client_consensus_common::ParachainConsensus;20use cumulus_client_network::build_block_announce_validator;21use cumulus_client_service::{22 prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,23};24use cumulus_primitives_core::ParaId;2526// Polkadot Imports27use polkadot_primitives::v1::CollatorPair;2829// Substrate Imports30use sc_client_api::ExecutorProvider;31pub use sc_executor::NativeExecutor;32use sc_executor::native_executor_instance;33use sc_network::NetworkService;34use sc_service::{BasePath, Configuration, PartialComponents, Role, TaskManager};35use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};36use sp_consensus::SlotData;37use sp_keystore::SyncCryptoStorePtr;38use sp_runtime::traits::BlakeTwo256;39use substrate_prometheus_endpoint::Registry;4041// Frontier Imports42use fc_rpc_core::types::FilterPool;43use fc_rpc_core::types::PendingTransactions;4445// Runtime type overrides46type BlockNumber = u32;47type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;48pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;49type Hash = sp_core::H256;5051// Native executor instance.52native_executor_instance!(53 pub ParachainRuntimeExecutor,54 nft_runtime::api::dispatch,55 nft_runtime::native_version,56 frame_benchmarking::benchmarking::HostFunctions,57);5859pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {60 let config_dir = config61 .base_path62 .as_ref()63 .map(|base_path| base_path.config_dir(config.chain_spec.id()))64 .unwrap_or_else(|| {65 BasePath::from_project("", "", "nft").config_dir(config.chain_spec.id())66 });67 let database_dir = config_dir.join("frontier").join("db");6869 Ok(Arc::new(fc_db::Backend::<Block>::new(70 &fc_db::DatabaseSettings {71 source: fc_db::DatabaseSettingsSrc::RocksDb {72 path: database_dir,73 cache_size: 0,74 },75 },76 )?))77}7879type Executor = ParachainRuntimeExecutor;8081type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;82type FullBackend = sc_service::TFullBackend<Block>;83type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;8485/// Starts a `ServiceBuilder` for a full service.86///87/// Use this macro if you don't actually need the full service, but just the builder in order to88/// be able to perform chain operations.89#[allow(clippy::type_complexity)]90pub fn new_partial<BIQ>(91 config: &Configuration,92 build_import_queue: BIQ,93) -> Result<94 PartialComponents<95 FullClient,96 FullBackend,97 FullSelectChain,98 sp_consensus::DefaultImportQueue<Block, FullClient>,99 sc_transaction_pool::FullPool<Block, FullClient>,100 (101 Option<Telemetry>,102 PendingTransactions,103 Option<FilterPool>,104 Arc<fc_db::Backend<Block>>,105 Option<TelemetryWorkerHandle>,106 ),107 >,108 sc_service::Error,109>110where111 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,112 Executor: sc_executor::NativeExecutionDispatch + 'static,113 BIQ: FnOnce(114 Arc<FullClient>,115 &Configuration,116 Option<TelemetryHandle>,117 &TaskManager,118 ) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,119{120 let _telemetry = config121 .telemetry_endpoints122 .clone()123 .filter(|x| !x.is_empty())124 .map(|endpoints| -> Result<_, sc_telemetry::Error> {125 let worker = TelemetryWorker::new(16)?;126 let telemetry = worker.handle().new_telemetry(endpoints);127 Ok((worker, telemetry))128 })129 .transpose()?;130131 let telemetry = config132 .telemetry_endpoints133 .clone()134 .filter(|x| !x.is_empty())135 .map(|endpoints| -> Result<_, sc_telemetry::Error> {136 let worker = TelemetryWorker::new(16)?;137 let telemetry = worker.handle().new_telemetry(endpoints);138 Ok((worker, telemetry))139 })140 .transpose()?;141142 let (client, backend, keystore_container, task_manager) =143 sc_service::new_full_parts::<Block, RuntimeApi, Executor>(144 &config,145 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),146 )?;147 let client = Arc::new(client);148149 let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());150151 let telemetry = telemetry.map(|(worker, telemetry)| {152 task_manager.spawn_handle().spawn("telemetry", worker.run());153 telemetry154 });155156 let select_chain = sc_consensus::LongestChain::new(backend.clone());157158 let transaction_pool = sc_transaction_pool::BasicPool::new_full(159 config.transaction_pool.clone(),160 config.role.is_authority().into(),161 config.prometheus_registry(),162 task_manager.spawn_handle(),163 client.clone(),164 );165166 let pending_transactions: PendingTransactions = Some(Arc::new(Mutex::new(HashMap::new())));167168 let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));169170 let frontier_backend = open_frontier_backend(config)?;171172 let import_queue = build_import_queue(173 client.clone(),174 config,175 telemetry.as_ref().map(|telemetry| telemetry.handle()),176 &task_manager,177 )?;178179 let params = PartialComponents {180 backend,181 client,182 import_queue,183 keystore_container,184 task_manager,185 transaction_pool,186 select_chain,187 other: (188 telemetry,189 pending_transactions,190 filter_pool,191 frontier_backend,192 telemetry_worker_handle,193 ),194 };195196 Ok(params)197}198199/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.200///201/// This is the actual implementation that is abstract over the executor and the runtime api.202#[sc_tracing::logging::prefix_logs_with("Parachain")]203async fn start_node_impl<BIQ, BIC>(204 parachain_config: Configuration,205 collator_key: CollatorPair,206 polkadot_config: Configuration,207 id: ParaId,208 build_import_queue: BIQ,209 build_consensus: BIC,210) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)>211where212 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,213 Executor: sc_executor::NativeExecutionDispatch + 'static,214 BIQ: FnOnce(215 Arc<FullClient>,216 &Configuration,217 Option<TelemetryHandle>,218 &TaskManager,219 ) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,220 BIC: FnOnce(221 Arc<FullClient>,222 Option<&Registry>,223 Option<TelemetryHandle>,224 &TaskManager,225 &polkadot_service::NewFull<polkadot_service::Client>,226 Arc<sc_transaction_pool::FullPool<Block, FullClient>>,227 Arc<NetworkService<Block, Hash>>,228 SyncCryptoStorePtr,229 bool,230 ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,231{232 if matches!(parachain_config.role, Role::Light) {233 return Err("Light client not supported!".into());234 }235236 let parachain_config = prepare_node_config(parachain_config);237238 let params = new_partial::<BIQ>(¶chain_config, build_import_queue)?;239 let (240 mut telemetry,241 pending_transactions,242 filter_pool,243 frontier_backend,244 telemetry_worker_handle,245 ) = params.other;246247 let relay_chain_full_node = cumulus_client_service::build_polkadot_full_node(248 polkadot_config,249 collator_key.clone(),250 telemetry_worker_handle,251 )252 .map_err(|e| match e {253 polkadot_service::Error::Sub(x) => x,254 s => format!("{}", s).into(),255 })?;256257 let client = params.client.clone();258 let backend = params.backend.clone();259 let block_announce_validator = build_block_announce_validator(260 relay_chain_full_node.client.clone(),261 id,262 Box::new(relay_chain_full_node.network.clone()),263 relay_chain_full_node.backend.clone(),264 );265266 let force_authoring = parachain_config.force_authoring;267 let validator = parachain_config.role.is_authority();268 let prometheus_registry = parachain_config.prometheus_registry().cloned();269 let transaction_pool = params.transaction_pool.clone();270 let mut task_manager = params.task_manager;271 let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);272 let (network, network_status_sinks, system_rpc_tx, start_network) =273 sc_service::build_network(sc_service::BuildNetworkParams {274 config: ¶chain_config,275 client: client.clone(),276 transaction_pool: transaction_pool.clone(),277 spawn_handle: task_manager.spawn_handle(),278 import_queue: import_queue.clone(),279 on_demand: None,280 block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),281 })?;282283 let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());284 let rpc_client = client.clone();285 let rpc_pool = transaction_pool.clone();286 let select_chain = params.select_chain.clone();287 let is_authority = parachain_config.role.clone().is_authority();288 let rpc_network = network.clone();289 let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {290 let full_deps = nft_rpc::FullDeps {291 backend: frontier_backend.clone(),292 deny_unsafe,293 client: rpc_client.clone(),294 pool: rpc_pool.clone(),295 // TODO: Unhardcode296 enable_dev_signer: false,297 filter_pool: filter_pool.clone(),298 network: rpc_network.clone(),299 pending_transactions: pending_transactions.clone(),300 select_chain: select_chain.clone(),301 is_authority,302 // TODO: Unhardcode303 max_past_logs: 10000,304 };305306 nft_rpc::create_full::<_, _, _, RuntimeApi, _>(full_deps, subscription_executor.clone())307 });308309 sc_service::spawn_tasks(sc_service::SpawnTasksParams {310 on_demand: None,311 remote_blockchain: None,312 rpc_extensions_builder,313 client: client.clone(),314 transaction_pool: transaction_pool.clone(),315 task_manager: &mut task_manager,316 config: parachain_config,317 keystore: params.keystore_container.sync_keystore(),318 backend: backend.clone(),319 network: network.clone(),320 network_status_sinks,321 system_rpc_tx,322 telemetry: telemetry.as_mut(),323 })?;324325 let announce_block = {326 let network = network.clone();327 Arc::new(move |hash, data| network.announce_block(hash, data))328 };329330 if validator {331 let parachain_consensus = build_consensus(332 client.clone(),333 prometheus_registry.as_ref(),334 telemetry.as_ref().map(|t| t.handle()),335 &task_manager,336 &relay_chain_full_node,337 transaction_pool,338 network,339 params.keystore_container.sync_keystore(),340 force_authoring,341 )?;342343 let spawner = task_manager.spawn_handle();344345 let params = StartCollatorParams {346 para_id: id,347 block_status: client.clone(),348 announce_block,349 client: client.clone(),350 task_manager: &mut task_manager,351 collator_key,352 relay_chain_full_node,353 spawner,354 parachain_consensus,355 import_queue,356 };357358 start_collator(params).await?;359 } else {360 let params = StartFullNodeParams {361 client: client.clone(),362 announce_block,363 task_manager: &mut task_manager,364 para_id: id,365 relay_chain_full_node,366 };367368 start_full_node(params)?;369 }370371 start_network.start_network();372373 Ok((task_manager, client))374}375376/// Build the import queue for the the parachain runtime.377pub fn parachain_build_import_queue(378 client: Arc<FullClient>,379 config: &Configuration,380 telemetry: Option<TelemetryHandle>,381 task_manager: &TaskManager,382) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error> {383 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;384385 cumulus_client_consensus_aura::import_queue::<386 sp_consensus_aura::sr25519::AuthorityPair,387 _,388 _,389 _,390 _,391 _,392 _,393 >(cumulus_client_consensus_aura::ImportQueueParams {394 block_import: client.clone(),395 client: client.clone(),396 create_inherent_data_providers: move |_, _| async move {397 let time = sp_timestamp::InherentDataProvider::from_system_time();398399 let slot =400 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(401 *time,402 slot_duration.slot_duration(),403 );404405 Ok((time, slot))406 },407 registry: config.prometheus_registry(),408 can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),409 spawner: &task_manager.spawn_essential_handle(),410 telemetry,411 })412 .map_err(Into::into)413}414415/// Start a normal parachain node.416pub async fn start_node(417 parachain_config: Configuration,418 collator_key: CollatorPair,419 polkadot_config: Configuration,420 id: ParaId,421) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)> {422 start_node_impl::<_, _>(423 parachain_config,424 collator_key,425 polkadot_config,426 id,427 parachain_build_import_queue,428 |client,429 prometheus_registry,430 telemetry,431 task_manager,432 relay_chain_node,433 transaction_pool,434 sync_oracle,435 keystore,436 force_authoring| {437 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;438439 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(440 task_manager.spawn_handle(),441 client.clone(),442 transaction_pool,443 prometheus_registry,444 telemetry.clone(),445 );446447 let relay_chain_backend = relay_chain_node.backend.clone();448 let relay_chain_client = relay_chain_node.client.clone();449 Ok(build_aura_consensus::<450 sp_consensus_aura::sr25519::AuthorityPair,451 _,452 _,453 _,454 _,455 _,456 _,457 _,458 _,459 _,460 >(BuildAuraConsensusParams {461 proposer_factory,462 create_inherent_data_providers: move |_, (relay_parent, validation_data)| {463 let parachain_inherent =464 cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(465 relay_parent,466 &relay_chain_client,467 &*relay_chain_backend,468 &validation_data,469 id,470 );471 async move {472 let time = sp_timestamp::InherentDataProvider::from_system_time();473474 let slot =475 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(476 *time,477 slot_duration.slot_duration(),478 );479480 let parachain_inherent = parachain_inherent.ok_or_else(|| {481 Box::<dyn std::error::Error + Send + Sync>::from(482 "Failed to create parachain inherent",483 )484 })?;485 Ok((time, slot, parachain_inherent))486 }487 },488 block_import: client.clone(),489 relay_chain_client: relay_chain_node.client.clone(),490 relay_chain_backend: relay_chain_node.backend.clone(),491 para_client: client,492 backoff_authoring_blocks: Option::<()>::None,493 sync_oracle,494 keystore,495 force_authoring,496 slot_duration,497 // We got around 500ms for proposing498 block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),499 telemetry,500 }))501 },502 )503 .await504}1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.23//4// This file is subject to the terms and conditions defined in5// file 'LICENSE', which is part of this source code package.6//78// std9use std::sync::Arc;10use std::sync::Mutex;11use std::collections::BTreeMap;12use std::collections::HashMap;1314// Local Runtime Types15use nft_runtime::RuntimeApi;1617// Cumulus Imports18use cumulus_client_consensus_aura::{build_aura_consensus, BuildAuraConsensusParams, SlotProportion};19use cumulus_client_consensus_common::ParachainConsensus;20use cumulus_client_network::build_block_announce_validator;21use cumulus_client_service::{22 prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,23};24use cumulus_primitives_core::ParaId;2526// Polkadot Imports27use polkadot_primitives::v1::CollatorPair;2829// Substrate Imports30use sc_client_api::ExecutorProvider;31pub use sc_executor::NativeExecutor;32use sc_executor::native_executor_instance;33use sc_network::NetworkService;34use sc_service::{BasePath, Configuration, PartialComponents, Role, TaskManager};35use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};36use sp_consensus::SlotData;37use sp_keystore::SyncCryptoStorePtr;38use sp_runtime::traits::BlakeTwo256;39use substrate_prometheus_endpoint::Registry;4041// Frontier Imports42use fc_rpc_core::types::FilterPool;43use fc_rpc_core::types::PendingTransactions;4445// Runtime type overrides46type BlockNumber = u32;47type Header = sp_runtime::generic::Header<BlockNumber, sp_runtime::traits::BlakeTwo256>;48pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;49type Hash = sp_core::H256;5051// Native executor instance.52native_executor_instance!(53 pub ParachainRuntimeExecutor,54 nft_runtime::api::dispatch,55 nft_runtime::native_version,56 frame_benchmarking::benchmarking::HostFunctions,57);5859pub fn open_frontier_backend(config: &Configuration) -> Result<Arc<fc_db::Backend<Block>>, String> {60 let config_dir = config61 .base_path62 .as_ref()63 .map(|base_path| base_path.config_dir(config.chain_spec.id()))64 .unwrap_or_else(|| {65 BasePath::from_project("", "", "nft").config_dir(config.chain_spec.id())66 });67 let database_dir = config_dir.join("frontier").join("db");6869 Ok(Arc::new(fc_db::Backend::<Block>::new(70 &fc_db::DatabaseSettings {71 source: fc_db::DatabaseSettingsSrc::RocksDb {72 path: database_dir,73 cache_size: 0,74 },75 },76 )?))77}7879type Executor = ParachainRuntimeExecutor;8081type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;82type FullBackend = sc_service::TFullBackend<Block>;83type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;8485/// Starts a `ServiceBuilder` for a full service.86///87/// Use this macro if you don't actually need the full service, but just the builder in order to88/// be able to perform chain operations.89#[allow(clippy::type_complexity)]90pub fn new_partial<BIQ>(91 config: &Configuration,92 build_import_queue: BIQ,93) -> Result<94 PartialComponents<95 FullClient,96 FullBackend,97 FullSelectChain,98 sp_consensus::DefaultImportQueue<Block, FullClient>,99 sc_transaction_pool::FullPool<Block, FullClient>,100 (101 Option<Telemetry>,102 PendingTransactions,103 Option<FilterPool>,104 Arc<fc_db::Backend<Block>>,105 Option<TelemetryWorkerHandle>,106 ),107 >,108 sc_service::Error,109>110where111 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,112 Executor: sc_executor::NativeExecutionDispatch + 'static,113 BIQ: FnOnce(114 Arc<FullClient>,115 &Configuration,116 Option<TelemetryHandle>,117 &TaskManager,118 ) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,119{120 let _telemetry = config121 .telemetry_endpoints122 .clone()123 .filter(|x| !x.is_empty())124 .map(|endpoints| -> Result<_, sc_telemetry::Error> {125 let worker = TelemetryWorker::new(16)?;126 let telemetry = worker.handle().new_telemetry(endpoints);127 Ok((worker, telemetry))128 })129 .transpose()?;130131 let telemetry = config132 .telemetry_endpoints133 .clone()134 .filter(|x| !x.is_empty())135 .map(|endpoints| -> Result<_, sc_telemetry::Error> {136 let worker = TelemetryWorker::new(16)?;137 let telemetry = worker.handle().new_telemetry(endpoints);138 Ok((worker, telemetry))139 })140 .transpose()?;141142 let (client, backend, keystore_container, task_manager) =143 sc_service::new_full_parts::<Block, RuntimeApi, Executor>(144 config,145 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),146 )?;147 let client = Arc::new(client);148149 let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle());150151 let telemetry = telemetry.map(|(worker, telemetry)| {152 task_manager.spawn_handle().spawn("telemetry", worker.run());153 telemetry154 });155156 let select_chain = sc_consensus::LongestChain::new(backend.clone());157158 let transaction_pool = sc_transaction_pool::BasicPool::new_full(159 config.transaction_pool.clone(),160 config.role.is_authority().into(),161 config.prometheus_registry(),162 task_manager.spawn_handle(),163 client.clone(),164 );165166 let pending_transactions: PendingTransactions = Some(Arc::new(Mutex::new(HashMap::new())));167168 let filter_pool: Option<FilterPool> = Some(Arc::new(Mutex::new(BTreeMap::new())));169170 let frontier_backend = open_frontier_backend(config)?;171172 let import_queue = build_import_queue(173 client.clone(),174 config,175 telemetry.as_ref().map(|telemetry| telemetry.handle()),176 &task_manager,177 )?;178179 let params = PartialComponents {180 backend,181 client,182 import_queue,183 keystore_container,184 task_manager,185 transaction_pool,186 select_chain,187 other: (188 telemetry,189 pending_transactions,190 filter_pool,191 frontier_backend,192 telemetry_worker_handle,193 ),194 };195196 Ok(params)197}198199/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.200///201/// This is the actual implementation that is abstract over the executor and the runtime api.202#[sc_tracing::logging::prefix_logs_with("Parachain")]203async fn start_node_impl<BIQ, BIC>(204 parachain_config: Configuration,205 collator_key: CollatorPair,206 polkadot_config: Configuration,207 id: ParaId,208 build_import_queue: BIQ,209 build_consensus: BIC,210) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)>211where212 sc_client_api::StateBackendFor<FullBackend, Block>: sp_api::StateBackend<BlakeTwo256>,213 Executor: sc_executor::NativeExecutionDispatch + 'static,214 BIQ: FnOnce(215 Arc<FullClient>,216 &Configuration,217 Option<TelemetryHandle>,218 &TaskManager,219 ) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error>,220 BIC: FnOnce(221 Arc<FullClient>,222 Option<&Registry>,223 Option<TelemetryHandle>,224 &TaskManager,225 &polkadot_service::NewFull<polkadot_service::Client>,226 Arc<sc_transaction_pool::FullPool<Block, FullClient>>,227 Arc<NetworkService<Block, Hash>>,228 SyncCryptoStorePtr,229 bool,230 ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,231{232 if matches!(parachain_config.role, Role::Light) {233 return Err("Light client not supported!".into());234 }235236 let parachain_config = prepare_node_config(parachain_config);237238 let params = new_partial::<BIQ>(¶chain_config, build_import_queue)?;239 let (240 mut telemetry,241 pending_transactions,242 filter_pool,243 frontier_backend,244 telemetry_worker_handle,245 ) = params.other;246247 let relay_chain_full_node = cumulus_client_service::build_polkadot_full_node(248 polkadot_config,249 collator_key.clone(),250 telemetry_worker_handle,251 )252 .map_err(|e| match e {253 polkadot_service::Error::Sub(x) => x,254 s => format!("{}", s).into(),255 })?;256257 let client = params.client.clone();258 let backend = params.backend.clone();259 let block_announce_validator = build_block_announce_validator(260 relay_chain_full_node.client.clone(),261 id,262 Box::new(relay_chain_full_node.network.clone()),263 relay_chain_full_node.backend.clone(),264 );265266 let force_authoring = parachain_config.force_authoring;267 let validator = parachain_config.role.is_authority();268 let prometheus_registry = parachain_config.prometheus_registry().cloned();269 let transaction_pool = params.transaction_pool.clone();270 let mut task_manager = params.task_manager;271 let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue);272 let (network, network_status_sinks, system_rpc_tx, start_network) =273 sc_service::build_network(sc_service::BuildNetworkParams {274 config: ¶chain_config,275 client: client.clone(),276 transaction_pool: transaction_pool.clone(),277 spawn_handle: task_manager.spawn_handle(),278 import_queue: import_queue.clone(),279 on_demand: None,280 block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),281 })?;282283 let subscription_executor = sc_rpc::SubscriptionTaskExecutor::new(task_manager.spawn_handle());284 let rpc_client = client.clone();285 let rpc_pool = transaction_pool.clone();286 let select_chain = params.select_chain.clone();287 let is_authority = parachain_config.role.clone().is_authority();288 let rpc_network = network.clone();289 let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {290 let full_deps = nft_rpc::FullDeps {291 backend: frontier_backend.clone(),292 deny_unsafe,293 client: rpc_client.clone(),294 pool: rpc_pool.clone(),295 // TODO: Unhardcode296 enable_dev_signer: false,297 filter_pool: filter_pool.clone(),298 network: rpc_network.clone(),299 pending_transactions: pending_transactions.clone(),300 select_chain: select_chain.clone(),301 is_authority,302 // TODO: Unhardcode303 max_past_logs: 10000,304 };305306 nft_rpc::create_full::<_, _, _, RuntimeApi, _>(full_deps, subscription_executor.clone())307 });308309 sc_service::spawn_tasks(sc_service::SpawnTasksParams {310 on_demand: None,311 remote_blockchain: None,312 rpc_extensions_builder,313 client: client.clone(),314 transaction_pool: transaction_pool.clone(),315 task_manager: &mut task_manager,316 config: parachain_config,317 keystore: params.keystore_container.sync_keystore(),318 backend: backend.clone(),319 network: network.clone(),320 network_status_sinks,321 system_rpc_tx,322 telemetry: telemetry.as_mut(),323 })?;324325 let announce_block = {326 let network = network.clone();327 Arc::new(move |hash, data| network.announce_block(hash, data))328 };329330 if validator {331 let parachain_consensus = build_consensus(332 client.clone(),333 prometheus_registry.as_ref(),334 telemetry.as_ref().map(|t| t.handle()),335 &task_manager,336 &relay_chain_full_node,337 transaction_pool,338 network,339 params.keystore_container.sync_keystore(),340 force_authoring,341 )?;342343 let spawner = task_manager.spawn_handle();344345 let params = StartCollatorParams {346 para_id: id,347 block_status: client.clone(),348 announce_block,349 client: client.clone(),350 task_manager: &mut task_manager,351 collator_key,352 relay_chain_full_node,353 spawner,354 parachain_consensus,355 import_queue,356 };357358 start_collator(params).await?;359 } else {360 let params = StartFullNodeParams {361 client: client.clone(),362 announce_block,363 task_manager: &mut task_manager,364 para_id: id,365 relay_chain_full_node,366 };367368 start_full_node(params)?;369 }370371 start_network.start_network();372373 Ok((task_manager, client))374}375376/// Build the import queue for the the parachain runtime.377pub fn parachain_build_import_queue(378 client: Arc<FullClient>,379 config: &Configuration,380 telemetry: Option<TelemetryHandle>,381 task_manager: &TaskManager,382) -> Result<sp_consensus::DefaultImportQueue<Block, FullClient>, sc_service::Error> {383 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;384385 cumulus_client_consensus_aura::import_queue::<386 sp_consensus_aura::sr25519::AuthorityPair,387 _,388 _,389 _,390 _,391 _,392 _,393 >(cumulus_client_consensus_aura::ImportQueueParams {394 block_import: client.clone(),395 client: client.clone(),396 create_inherent_data_providers: move |_, _| async move {397 let time = sp_timestamp::InherentDataProvider::from_system_time();398399 let slot =400 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(401 *time,402 slot_duration.slot_duration(),403 );404405 Ok((time, slot))406 },407 registry: config.prometheus_registry(),408 can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),409 spawner: &task_manager.spawn_essential_handle(),410 telemetry,411 })412 .map_err(Into::into)413}414415/// Start a normal parachain node.416pub async fn start_node(417 parachain_config: Configuration,418 collator_key: CollatorPair,419 polkadot_config: Configuration,420 id: ParaId,421) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)> {422 start_node_impl::<_, _>(423 parachain_config,424 collator_key,425 polkadot_config,426 id,427 parachain_build_import_queue,428 |client,429 prometheus_registry,430 telemetry,431 task_manager,432 relay_chain_node,433 transaction_pool,434 sync_oracle,435 keystore,436 force_authoring| {437 let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;438439 let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(440 task_manager.spawn_handle(),441 client.clone(),442 transaction_pool,443 prometheus_registry,444 telemetry.clone(),445 );446447 let relay_chain_backend = relay_chain_node.backend.clone();448 let relay_chain_client = relay_chain_node.client.clone();449 Ok(build_aura_consensus::<450 sp_consensus_aura::sr25519::AuthorityPair,451 _,452 _,453 _,454 _,455 _,456 _,457 _,458 _,459 _,460 >(BuildAuraConsensusParams {461 proposer_factory,462 create_inherent_data_providers: move |_, (relay_parent, validation_data)| {463 let parachain_inherent =464 cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(465 relay_parent,466 &relay_chain_client,467 &*relay_chain_backend,468 &validation_data,469 id,470 );471 async move {472 let time = sp_timestamp::InherentDataProvider::from_system_time();473474 let slot =475 sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(476 *time,477 slot_duration.slot_duration(),478 );479480 let parachain_inherent = parachain_inherent.ok_or_else(|| {481 Box::<dyn std::error::Error + Send + Sync>::from(482 "Failed to create parachain inherent",483 )484 })?;485 Ok((time, slot, parachain_inherent))486 }487 },488 block_import: client.clone(),489 relay_chain_client: relay_chain_node.client.clone(),490 relay_chain_backend: relay_chain_node.backend.clone(),491 para_client: client,492 backoff_authoring_blocks: Option::<()>::None,493 sync_oracle,494 keystore,495 force_authoring,496 slot_duration,497 // We got around 500ms for proposing498 block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),499 telemetry,500 }))501 },502 )503 .await504}pallets/contract-helpers/src/lib.rsdiffbeforeafterboth--- a/pallets/contract-helpers/src/lib.rs
+++ b/pallets/contract-helpers/src/lib.rs
@@ -213,7 +213,7 @@
Ok(Some((who.clone(), *code_hash, salt.clone())))
}
Some(pallet_contracts::Call::instantiate_with_code(_, _, code, _, salt)) => {
- let code_hash = &T::Hashing::hash(&code);
+ let code_hash = &T::Hashing::hash(code);
Ok(Some((who.clone(), *code_hash, salt.clone())))
}
_ => Ok(None),
pallets/nft/src/eth/erc_impl.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/erc_impl.rs
+++ b/pallets/nft/src/eth/erc_impl.rs
@@ -114,7 +114,7 @@
let to = T::CrossAccountId::from_eth(to);
let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;
- <Module<T>>::transfer_from_internal(&caller, &from, &to, &self, token_id, 1)
+ <Module<T>>::transfer_from_internal(&caller, &from, &to, self, token_id, 1)
.map_err(|_| "transferFrom error")?;
Ok(())
}
@@ -130,7 +130,7 @@
let approved = T::CrossAccountId::from_eth(approved);
let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;
- <Module<T>>::approve_internal(&caller, &approved, &self, token_id, 1)
+ <Module<T>>::approve_internal(&caller, &approved, self, token_id, 1)
.map_err(|_| "approve internal")?;
Ok(())
}
@@ -176,7 +176,7 @@
let to = T::CrossAccountId::from_eth(to);
let token_id = token_id.try_into().map_err(|_| "amount overflow")?;
- <Module<T>>::transfer_internal(&caller, &to, &self, token_id, 1)
+ <Module<T>>::transfer_internal(&caller, &to, self, token_id, 1)
.map_err(|_| "transfer error")?;
Ok(())
}
@@ -226,7 +226,7 @@
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- <Module<T>>::transfer_internal(&caller, &to, &self, 1, amount)
+ <Module<T>>::transfer_internal(&caller, &to, self, 1, amount)
.map_err(|_| "transfer error")?;
Ok(true)
}
@@ -242,7 +242,7 @@
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- <Module<T>>::transfer_from_internal(&caller, &from, &to, &self, 1, amount)
+ <Module<T>>::transfer_from_internal(&caller, &from, &to, self, 1, amount)
.map_err(|_| "transferFrom error")?;
Ok(true)
}
@@ -251,7 +251,7 @@
let spender = T::CrossAccountId::from_eth(spender);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- <Module<T>>::approve_internal(&caller, &spender, &self, 1, amount)
+ <Module<T>>::approve_internal(&caller, &spender, self, 1, amount)
.map_err(|_| "approve internal")?;
Ok(true)
}
pallets/nft/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/mod.rs
+++ b/pallets/nft/src/eth/mod.rs
@@ -108,7 +108,7 @@
.unwrap_or(false)
}
fn get_code(target: &H160) -> Option<Vec<u8>> {
- map_eth_to_id(&target)
+ map_eth_to_id(target)
.and_then(<CollectionById<T>>::get)
.map(|collection| {
match collection.mode {
@@ -127,7 +127,7 @@
input: &[u8],
value: U256,
) -> Option<PrecompileOutput> {
- let mut collection = map_eth_to_id(&target)
+ let mut collection = map_eth_to_id(target)
.and_then(|id| <CollectionHandle<T>>::get_with_gas_limit(id, gas_limit))?;
let (method_id, input) = AbiReader::new_call(input).unwrap();
let result = call_internal(&mut collection, *source, method_id, input, value);
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/sponsoring.rs
+++ b/pallets/nft/src/eth/sponsoring.rs
@@ -132,10 +132,10 @@
) -> Result<Self::LiquidityInfo, pallet_evm::Error<T>> {
let mut who_pays_fee = *who;
if let WithdrawReason::Call { target, input } = &reason {
- if let Some(collection_id) = crate::eth::map_eth_to_id(&target) {
+ if let Some(collection_id) = crate::eth::map_eth_to_id(target) {
if let Some(collection) = <CollectionById<T>>::get(collection_id) {
if let Some(sponsor) = collection.sponsorship.sponsor() {
- if try_sponsor(who, collection_id, &collection, &input).is_ok() {
+ if try_sponsor(who, collection_id, &collection, input).is_ok() {
who_pays_fee =
T::EvmBackwardsAddressMapping::from_account_id(sponsor.clone());
}
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1232,7 +1232,7 @@
) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let mut target_collection = Self::get_collection(collection_id)?;
- Self::check_owner_permissions(&target_collection, &sender.as_sub())?;
+ Self::check_owner_permissions(&target_collection, sender.as_sub())?;
let old_limits = &target_collection.limits;
let chain_limits = ChainLimit::get();
@@ -1267,9 +1267,9 @@
owner: &T::CrossAccountId,
data: CreateItemData,
) -> DispatchResult {
- Self::can_create_items_in_collection(&collection, &sender, &owner, 1)?;
- Self::validate_create_item_args(&collection, &data)?;
- Self::create_item_no_validation(&collection, owner, data)?;
+ Self::can_create_items_in_collection(collection, sender, owner, 1)?;
+ Self::validate_create_item_args(collection, &data)?;
+ Self::create_item_no_validation(collection, owner, data)?;
Ok(())
}
@@ -1283,18 +1283,18 @@
) -> DispatchResult {
target_collection.consume_gas(2000000)?;
// Limits check
- Self::is_correct_transfer(target_collection, &recipient)?;
+ Self::is_correct_transfer(target_collection, recipient)?;
// Transfer permissions check
ensure!(
- Self::is_item_owner(&sender, target_collection, item_id)
- || Self::is_owner_or_admin_permissions(target_collection, &sender),
+ Self::is_item_owner(sender, target_collection, item_id)
+ || Self::is_owner_or_admin_permissions(target_collection, sender),
Error::<T>::NoPermission
);
if target_collection.access == AccessMode::WhiteList {
- Self::check_white_list(target_collection, &sender)?;
- Self::check_white_list(target_collection, &recipient)?;
+ Self::check_white_list(target_collection, sender)?;
+ Self::check_white_list(target_collection, recipient)?;
}
match target_collection.mode {
@@ -1305,7 +1305,7 @@
recipient.clone(),
)?,
CollectionMode::Fungible(_) => {
- Self::transfer_fungible(target_collection, value, &sender, &recipient)?
+ Self::transfer_fungible(target_collection, value, sender, recipient)?
}
CollectionMode::ReFungible => Self::transfer_refungible(
target_collection,
@@ -1336,23 +1336,23 @@
amount: u128,
) -> DispatchResult {
collection.consume_gas(2000000)?;
- Self::token_exists(&collection, item_id)?;
+ Self::token_exists(collection, item_id)?;
// Transfer permissions check
let bypasses_limits = collection.limits.owner_can_transfer
- && Self::is_owner_or_admin_permissions(&collection, &sender);
+ && Self::is_owner_or_admin_permissions(collection, sender);
let allowance_limit = if bypasses_limits {
None
- } else if let Some(amount) = Self::owned_amount(&sender, &collection, item_id) {
+ } else if let Some(amount) = Self::owned_amount(sender, collection, item_id) {
Some(amount)
} else {
fail!(Error::<T>::NoPermission);
};
if collection.access == AccessMode::WhiteList {
- Self::check_white_list(&collection, &sender)?;
- Self::check_white_list(&collection, &spender)?;
+ Self::check_white_list(collection, sender)?;
+ Self::check_white_list(collection, spender)?;
}
let allowance: u128 = amount
@@ -1412,19 +1412,19 @@
<Allowances<T>>::get(collection.id, (item_id, from.as_sub(), sender.as_sub()));
// Limits check
- Self::is_correct_transfer(&collection, &recipient)?;
+ Self::is_correct_transfer(collection, recipient)?;
// Transfer permissions check
ensure!(
approval >= amount
|| (collection.limits.owner_can_transfer
- && Self::is_owner_or_admin_permissions(&collection, &sender)),
+ && Self::is_owner_or_admin_permissions(collection, sender)),
Error::<T>::NoPermission
);
if collection.access == AccessMode::WhiteList {
- Self::check_white_list(&collection, &sender)?;
- Self::check_white_list(&collection, &recipient)?;
+ Self::check_white_list(collection, sender)?;
+ Self::check_white_list(collection, recipient)?;
}
// Reduce approval by transferred amount or remove if remaining approval drops to 0
@@ -1441,13 +1441,13 @@
match collection.mode {
CollectionMode::NFT => {
- Self::transfer_nft(&collection, item_id, from.clone(), recipient.clone())?
+ Self::transfer_nft(collection, item_id, from.clone(), recipient.clone())?
}
CollectionMode::Fungible(_) => {
- Self::transfer_fungible(&collection, amount, &from, &recipient)?
+ Self::transfer_fungible(collection, amount, from, recipient)?
}
CollectionMode::ReFungible => Self::transfer_refungible(
- &collection,
+ collection,
item_id,
amount,
from.clone(),
@@ -1473,7 +1473,7 @@
item_id: TokenId,
data: Vec<u8>,
) -> DispatchResult {
- Self::token_exists(&collection, item_id)?;
+ Self::token_exists(collection, item_id)?;
ensure!(
ChainLimit::get().custom_data_limit >= data.len() as u32,
@@ -1482,15 +1482,15 @@
// Modify permissions check
ensure!(
- Self::is_item_owner(&sender, &collection, item_id)
- || Self::is_owner_or_admin_permissions(&collection, &sender),
+ Self::is_item_owner(sender, collection, item_id)
+ || Self::is_owner_or_admin_permissions(collection, sender),
Error::<T>::NoPermission
);
match collection.mode {
- CollectionMode::NFT => Self::set_nft_variable_data(&collection, item_id, data)?,
+ CollectionMode::NFT => Self::set_nft_variable_data(collection, item_id, data)?,
CollectionMode::ReFungible => {
- Self::set_re_fungible_variable_data(&collection, item_id, data)?
+ Self::set_re_fungible_variable_data(collection, item_id, data)?
}
CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),
_ => fail!(Error::<T>::UnexpectedCollectionType),
@@ -1505,18 +1505,13 @@
owner: &T::CrossAccountId,
items_data: Vec<CreateItemData>,
) -> DispatchResult {
- Self::can_create_items_in_collection(
- &collection,
- &sender,
- &owner,
- items_data.len() as u32,
- )?;
+ Self::can_create_items_in_collection(collection, sender, owner, items_data.len() as u32)?;
for data in &items_data {
- Self::validate_create_item_args(&collection, data)?;
+ Self::validate_create_item_args(collection, data)?;
}
for data in &items_data {
- Self::create_item_no_validation(&collection, owner, data.clone())?;
+ Self::create_item_no_validation(collection, owner, data.clone())?;
}
Ok(())
@@ -1529,22 +1524,20 @@
value: u128,
) -> DispatchResult {
ensure!(
- Self::is_item_owner(&sender, &collection, item_id)
+ Self::is_item_owner(sender, collection, item_id)
|| (collection.limits.owner_can_transfer
- && Self::is_owner_or_admin_permissions(&collection, &sender)),
+ && Self::is_owner_or_admin_permissions(collection, sender)),
Error::<T>::NoPermission
);
if collection.access == AccessMode::WhiteList {
- Self::check_white_list(&collection, &sender)?;
+ Self::check_white_list(collection, sender)?;
}
match collection.mode {
- CollectionMode::NFT => Self::burn_nft_item(&collection, item_id)?,
- CollectionMode::Fungible(_) => Self::burn_fungible_item(&sender, &collection, value)?,
- CollectionMode::ReFungible => {
- Self::burn_refungible_item(&collection, item_id, &sender)?
- }
+ CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,
+ CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,
+ CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,
_ => (),
};
@@ -1557,7 +1550,7 @@
address: &T::CrossAccountId,
whitelisted: bool,
) -> DispatchResult {
- Self::check_owner_or_admin_permissions(&collection, &sender)?;
+ Self::check_owner_or_admin_permissions(collection, sender)?;
if whitelisted {
<WhiteList<T>>::insert(collection.id, address.as_sub(), true);
@@ -1610,7 +1603,7 @@
Error::<T>::AccountTokenLimitExceeded
);
- if !Self::is_owner_or_admin_permissions(collection, &sender) {
+ if !Self::is_owner_or_admin_permissions(collection, sender) {
ensure!(collection.mint_mode, Error::<T>::PublicMintingNotAllowed);
Self::check_white_list(collection, owner)?;
Self::check_white_list(collection, sender)?;
@@ -1691,7 +1684,7 @@
Self::add_nft_item(collection, item)?;
}
CreateItemData::Fungible(data) => {
- Self::add_fungible_item(collection, &owner, data.value)?;
+ Self::add_fungible_item(collection, owner, data.value)?;
}
CreateItemData::ReFungible(data) => {
let owner_list = vec![Ownership {
@@ -1934,7 +1927,7 @@
subject: &T::CrossAccountId,
) -> bool {
*subject.as_sub() == collection.owner
- || <AdminList<T>>::get(collection.id).contains(&subject)
+ || <AdminList<T>>::get(collection.id).contains(subject)
}
fn check_owner_or_admin_permissions(
@@ -1979,7 +1972,7 @@
) -> bool {
match target_collection.mode {
CollectionMode::Fungible(_) => true,
- _ => Self::owned_amount(&subject, target_collection, item_id).is_some(),
+ _ => Self::owned_amount(subject, target_collection, item_id).is_some(),
}
}
pallets/nft/src/sponsorship.rsdiffbeforeafterboth--- a/pallets/nft/src/sponsorship.rs
+++ b/pallets/nft/src/sponsorship.rs
@@ -179,14 +179,14 @@
{
fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {
match IsSubType::<Call<T>>::is_sub_type(call)? {
- Call::create_item(collection_id, _owner, _properties) => {
- Self::withdraw_create_item(who, collection_id, &_properties)
+ Call::create_item(collection_id, _owner, properties) => {
+ Self::withdraw_create_item(who, collection_id, properties)
}
Call::transfer(_new_owner, collection_id, item_id, _value) => {
Self::withdraw_transfer(who, collection_id, item_id)
}
Call::set_variable_meta_data(collection_id, item_id, data) => {
- Self::withdraw_set_variable_meta_data(collection_id, item_id, &data)
+ Self::withdraw_set_variable_meta_data(collection_id, item_id, data)
}
_ => None,
}