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.rsdiffbeforeafterboth1// This file is part of Substrate.23// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.4// SPDX-License-Identifier: Apache-2.056// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.1718use crate::{19 chain_spec,20 cli::{Cli, RelayChainCli, Subcommand},21 service::{new_partial, ParachainRuntimeExecutor},22};23use codec::Encode;24use cumulus_primitives_core::ParaId;25use cumulus_client_service::genesis::generate_genesis_block;26use log::info;27use nft_runtime::Block;28use polkadot_parachain::primitives::AccountIdConversion;29use sc_cli::{30 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,31 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,32};33use sc_service::{34 config::{BasePath, PrometheusConfig},35};36use sp_core::hexdisplay::HexDisplay;37use sp_runtime::traits::Block as BlockT;38use std::{io::Write, net::SocketAddr};3940fn load_spec(41 id: &str,42 para_id: ParaId,43) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {44 Ok(match id {45 "dev" => Box::new(chain_spec::development_config(para_id)),46 "" | "local" => Box::new(chain_spec::local_testnet_config(para_id)),47 path => Box::new(chain_spec::ChainSpec::from_json_file(48 std::path::PathBuf::from(path),49 )?),50 })51}5253impl SubstrateCli for Cli {54 fn impl_name() -> String {55 "Parachain Collator Template".into()56 }5758 fn impl_version() -> String {59 env!("SUBSTRATE_CLI_IMPL_VERSION").into()60 }6162 fn description() -> String {63 format!(64 "Parachain Collator Template\n\nThe command-line arguments provided first will be \65 passed to the parachain node, while the arguments provided after -- will be passed \66 to the relaychain node.\n\n\67 {} [parachain-args] -- [relaychain-args]",68 Self::executable_name()69 )70 }7172 fn author() -> String {73 env!("CARGO_PKG_AUTHORS").into()74 }7576 fn support_url() -> String {77 "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into()78 }7980 fn copyright_start_year() -> i32 {81 201782 }8384 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {85 load_spec(id, self.run.parachain_id.unwrap_or(200).into())86 }8788 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {89 &nft_runtime::VERSION90 }91}9293impl SubstrateCli for RelayChainCli {94 fn impl_name() -> String {95 "Parachain Collator Template".into()96 }9798 fn impl_version() -> String {99 env!("SUBSTRATE_CLI_IMPL_VERSION").into()100 }101102 fn description() -> String {103 "Parachain Collator Template\n\nThe command-line arguments provided first will be \104 passed to the parachain node, while the arguments provided after -- will be passed \105 to the relaychain node.\n\n\106 parachain-collator [parachain-args] -- [relaychain-args]"107 .into()108 }109110 fn author() -> String {111 env!("CARGO_PKG_AUTHORS").into()112 }113114 fn support_url() -> String {115 "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into()116 }117118 fn copyright_start_year() -> i32 {119 2017120 }121122 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {123 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name().to_string()].iter())124 .load_spec(id)125 }126127 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {128 polkadot_cli::Cli::native_runtime_version(chain_spec)129 }130}131132fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {133 let mut storage = chain_spec.build_storage()?;134135 storage136 .top137 .remove(sp_core::storage::well_known_keys::CODE)138 .ok_or_else(|| "Could not find wasm file in genesis state!".into())139}140141macro_rules! construct_async_run {142 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{143 let runner = $cli.create_runner($cmd)?;144 runner.async_run(|$config| {145 let $components = new_partial::<146 _147 >(148 &$config,149 crate::service::parachain_build_import_queue,150 )?;151 let task_manager = $components.task_manager;152 { $( $code )* }.map(|v| (v, task_manager))153 })154 }}155}156157/// Parse command line arguments into service configuration.158pub fn run() -> Result<()> {159 let cli = Cli::from_args();160161 match &cli.subcommand {162 Some(Subcommand::BuildSpec(cmd)) => {163 let runner = cli.create_runner(cmd)?;164 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))165 }166 Some(Subcommand::CheckBlock(cmd)) => {167 construct_async_run!(|components, cli, cmd, config| {168 Ok(cmd.run(components.client, components.import_queue))169 })170 }171 Some(Subcommand::ExportBlocks(cmd)) => {172 construct_async_run!(|components, cli, cmd, config| {173 Ok(cmd.run(components.client, config.database))174 })175 }176 Some(Subcommand::ExportState(cmd)) => {177 construct_async_run!(|components, cli, cmd, config| {178 Ok(cmd.run(components.client, config.chain_spec))179 })180 }181 Some(Subcommand::ImportBlocks(cmd)) => {182 construct_async_run!(|components, cli, cmd, config| {183 Ok(cmd.run(components.client, components.import_queue))184 })185 }186 Some(Subcommand::PurgeChain(cmd)) => {187 let runner = cli.create_runner(cmd)?;188189 runner.sync_run(|config| {190 let polkadot_cli = RelayChainCli::new(191 &config,192 [RelayChainCli::executable_name().to_string()]193 .iter()194 .chain(cli.relaychain_args.iter()),195 );196197 let polkadot_config = SubstrateCli::create_configuration(198 &polkadot_cli,199 &polkadot_cli,200 config.task_executor.clone(),201 )202 .map_err(|err| format!("Relay chain argument error: {}", err))?;203204 cmd.run(config, polkadot_config)205 })206 }207 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {208 Ok(cmd.run(components.client, components.backend))209 }),210 Some(Subcommand::ExportGenesisState(params)) => {211 let mut builder = sc_cli::LoggerBuilder::new("");212 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");213 let _ = builder.init();214215 let block: Block = generate_genesis_block(&load_spec(216 ¶ms.chain.clone().unwrap_or_default(),217 params.parachain_id.unwrap_or(200).into(),218 )?)?;219 let raw_header = block.header().encode();220 let output_buf = if params.raw {221 raw_header222 } else {223 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()224 };225226 if let Some(output) = ¶ms.output {227 std::fs::write(output, output_buf)?;228 } else {229 std::io::stdout().write_all(&output_buf)?;230 }231232 Ok(())233 }234 Some(Subcommand::ExportGenesisWasm(params)) => {235 let mut builder = sc_cli::LoggerBuilder::new("");236 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");237 let _ = builder.init();238239 let raw_wasm_blob =240 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;241 let output_buf = if params.raw {242 raw_wasm_blob243 } else {244 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()245 };246247 if let Some(output) = ¶ms.output {248 std::fs::write(output, output_buf)?;249 } else {250 std::io::stdout().write_all(&output_buf)?;251 }252253 Ok(())254 }255 Some(Subcommand::Benchmark(cmd)) => {256 if cfg!(feature = "runtime-benchmarks") {257 let runner = cli.create_runner(cmd)?;258259 runner.sync_run(|config| cmd.run::<Block, ParachainRuntimeExecutor>(config))260 } else {261 Err("Benchmarking wasn't enabled when building the node. \262 You can enable it with `--features runtime-benchmarks`."263 .into())264 }265 }266 None => {267 let runner = cli.create_runner(&cli.run.normalize())?;268269 runner.run_node_until_exit(|config| async move {270 // TODO271 let key = sp_core::Pair::generate().0;272273 let para_id =274 chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id);275276 let polkadot_cli = RelayChainCli::new(277 &config,278 [RelayChainCli::executable_name().to_string()]279 .iter()280 .chain(cli.relaychain_args.iter()),281 );282283 let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(200));284285 let parachain_account =286 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);287288 let block: Block =289 generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;290 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));291292 let task_executor = config.task_executor.clone();293 let polkadot_config =294 SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)295 .map_err(|err| format!("Relay chain argument error: {}", err))?;296297 info!("Parachain id: {:?}", id);298 info!("Parachain Account: {}", parachain_account);299 info!("Parachain genesis state: {}", genesis_state);300 info!(301 "Is collating: {}",302 if config.role.is_authority() {303 "yes"304 } else {305 "no"306 }307 );308309 crate::service::start_node(config, key, polkadot_config, id)310 .await311 .map(|r| r.0)312 .map_err(Into::into)313 })314 }315 }316}317318impl DefaultConfigurationValues for RelayChainCli {319 fn p2p_listen_port() -> u16 {320 30334321 }322323 fn rpc_ws_listen_port() -> u16 {324 9945325 }326327 fn rpc_http_listen_port() -> u16 {328 9934329 }330331 fn prometheus_listen_port() -> u16 {332 9616333 }334}335336impl CliConfiguration<Self> for RelayChainCli {337 fn shared_params(&self) -> &SharedParams {338 self.base.base.shared_params()339 }340341 fn import_params(&self) -> Option<&ImportParams> {342 self.base.base.import_params()343 }344345 fn network_params(&self) -> Option<&NetworkParams> {346 self.base.base.network_params()347 }348349 fn keystore_params(&self) -> Option<&KeystoreParams> {350 self.base.base.keystore_params()351 }352353 fn base_path(&self) -> Result<Option<BasePath>> {354 Ok(self355 .shared_params()356 .base_path()357 .or_else(|| self.base_path.clone().map(Into::into)))358 }359360 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {361 self.base.base.rpc_http(default_listen_port)362 }363364 fn rpc_ipc(&self) -> Result<Option<String>> {365 self.base.base.rpc_ipc()366 }367368 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {369 self.base.base.rpc_ws(default_listen_port)370 }371372 fn prometheus_config(&self, default_listen_port: u16) -> Result<Option<PrometheusConfig>> {373 self.base.base.prometheus_config(default_listen_port)374 }375376 fn init<C: SubstrateCli>(&self) -> Result<()> {377 unreachable!("PolkadotCli is never initialized; qed");378 }379380 fn chain_id(&self, is_dev: bool) -> Result<String> {381 let chain_id = self.base.base.chain_id(is_dev)?;382383 Ok(if chain_id.is_empty() {384 self.chain_id.clone().unwrap_or_default()385 } else {386 chain_id387 })388 }389390 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {391 self.base.base.role(is_dev)392 }393394 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {395 self.base.base.transaction_pool()396 }397398 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {399 self.base.base.state_cache_child_ratio()400 }401402 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {403 self.base.base.rpc_methods()404 }405406 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {407 self.base.base.rpc_ws_max_connections()408 }409410 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {411 self.base.base.rpc_cors(is_dev)412 }413414 fn telemetry_external_transport(&self) -> Result<Option<sc_service::config::ExtTransport>> {415 self.base.base.telemetry_external_transport()416 }417418 fn default_heap_pages(&self) -> Result<Option<u64>> {419 self.base.base.default_heap_pages()420 }421422 fn force_authoring(&self) -> Result<bool> {423 self.base.base.force_authoring()424 }425426 fn disable_grandpa(&self) -> Result<bool> {427 self.base.base.disable_grandpa()428 }429430 fn max_runtime_instances(&self) -> Result<Option<usize>> {431 self.base.base.max_runtime_instances()432 }433434 fn announce_block(&self) -> Result<bool> {435 self.base.base.announce_block()436 }437438 fn telemetry_endpoints(439 &self,440 chain_spec: &Box<dyn ChainSpec>,441 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {442 self.base.base.telemetry_endpoints(chain_spec)443 }444}1// This file is part of Substrate.23// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.4// SPDX-License-Identifier: Apache-2.056// Licensed under the Apache License, Version 2.0 (the "License");7// you may not use this file except in compliance with the License.8// You may obtain a copy of the License at9//10// http://www.apache.org/licenses/LICENSE-2.011//12// Unless required by applicable law or agreed to in writing, software13// distributed under the License is distributed on an "AS IS" BASIS,14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15// See the License for the specific language governing permissions and16// limitations under the License.1718use crate::{19 chain_spec,20 cli::{Cli, RelayChainCli, Subcommand},21 service::{new_partial, ParachainRuntimeExecutor},22};23use codec::Encode;24use cumulus_primitives_core::ParaId;25use cumulus_client_service::genesis::generate_genesis_block;26use log::info;27use nft_runtime::Block;28use polkadot_parachain::primitives::AccountIdConversion;29use sc_cli::{30 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,31 NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,32};33use sc_service::{34 config::{BasePath, PrometheusConfig},35};36use sp_core::hexdisplay::HexDisplay;37use sp_runtime::traits::Block as BlockT;38use std::{io::Write, net::SocketAddr};3940fn load_spec(41 id: &str,42 para_id: ParaId,43) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {44 Ok(match id {45 "dev" => Box::new(chain_spec::development_config(para_id)),46 "" | "local" => Box::new(chain_spec::local_testnet_config(para_id)),47 path => Box::new(chain_spec::ChainSpec::from_json_file(48 std::path::PathBuf::from(path),49 )?),50 })51}5253impl SubstrateCli for Cli {54 fn impl_name() -> String {55 "Parachain Collator Template".into()56 }5758 fn impl_version() -> String {59 env!("SUBSTRATE_CLI_IMPL_VERSION").into()60 }6162 fn description() -> String {63 format!(64 "Parachain Collator Template\n\nThe command-line arguments provided first will be \65 passed to the parachain node, while the arguments provided after -- will be passed \66 to the relaychain node.\n\n\67 {} [parachain-args] -- [relaychain-args]",68 Self::executable_name()69 )70 }7172 fn author() -> String {73 env!("CARGO_PKG_AUTHORS").into()74 }7576 fn support_url() -> String {77 "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into()78 }7980 fn copyright_start_year() -> i32 {81 201782 }8384 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {85 load_spec(id, self.run.parachain_id.unwrap_or(200).into())86 }8788 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {89 &nft_runtime::VERSION90 }91}9293impl SubstrateCli for RelayChainCli {94 fn impl_name() -> String {95 "Parachain Collator Template".into()96 }9798 fn impl_version() -> String {99 env!("SUBSTRATE_CLI_IMPL_VERSION").into()100 }101102 fn description() -> String {103 "Parachain Collator Template\n\nThe command-line arguments provided first will be \104 passed to the parachain node, while the arguments provided after -- will be passed \105 to the relaychain node.\n\n\106 parachain-collator [parachain-args] -- [relaychain-args]"107 .into()108 }109110 fn author() -> String {111 env!("CARGO_PKG_AUTHORS").into()112 }113114 fn support_url() -> String {115 "https://github.com/substrate-developer-hub/substrate-parachain-template/issues/new".into()116 }117118 fn copyright_start_year() -> i32 {119 2017120 }121122 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {123 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)124 }125126 fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {127 polkadot_cli::Cli::native_runtime_version(chain_spec)128 }129}130131#[allow(clippy::borrowed_box)]132fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {133 let mut storage = chain_spec.build_storage()?;134135 storage136 .top137 .remove(sp_core::storage::well_known_keys::CODE)138 .ok_or_else(|| "Could not find wasm file in genesis state!".into())139}140141macro_rules! construct_async_run {142 (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{143 let runner = $cli.create_runner($cmd)?;144 runner.async_run(|$config| {145 let $components = new_partial::<146 _147 >(148 &$config,149 crate::service::parachain_build_import_queue,150 )?;151 let task_manager = $components.task_manager;152 { $( $code )* }.map(|v| (v, task_manager))153 })154 }}155}156157/// Parse command line arguments into service configuration.158pub fn run() -> Result<()> {159 let cli = Cli::from_args();160161 match &cli.subcommand {162 Some(Subcommand::BuildSpec(cmd)) => {163 let runner = cli.create_runner(cmd)?;164 runner.sync_run(|config| cmd.run(config.chain_spec, config.network))165 }166 Some(Subcommand::CheckBlock(cmd)) => {167 construct_async_run!(|components, cli, cmd, config| {168 Ok(cmd.run(components.client, components.import_queue))169 })170 }171 Some(Subcommand::ExportBlocks(cmd)) => {172 construct_async_run!(|components, cli, cmd, config| {173 Ok(cmd.run(components.client, config.database))174 })175 }176 Some(Subcommand::ExportState(cmd)) => {177 construct_async_run!(|components, cli, cmd, config| {178 Ok(cmd.run(components.client, config.chain_spec))179 })180 }181 Some(Subcommand::ImportBlocks(cmd)) => {182 construct_async_run!(|components, cli, cmd, config| {183 Ok(cmd.run(components.client, components.import_queue))184 })185 }186 Some(Subcommand::PurgeChain(cmd)) => {187 let runner = cli.create_runner(cmd)?;188189 runner.sync_run(|config| {190 let polkadot_cli = RelayChainCli::new(191 &config,192 [RelayChainCli::executable_name()]193 .iter()194 .chain(cli.relaychain_args.iter()),195 );196197 let polkadot_config = SubstrateCli::create_configuration(198 &polkadot_cli,199 &polkadot_cli,200 config.task_executor.clone(),201 )202 .map_err(|err| format!("Relay chain argument error: {}", err))?;203204 cmd.run(config, polkadot_config)205 })206 }207 Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {208 Ok(cmd.run(components.client, components.backend))209 }),210 Some(Subcommand::ExportGenesisState(params)) => {211 let mut builder = sc_cli::LoggerBuilder::new("");212 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");213 let _ = builder.init();214215 let block: Block = generate_genesis_block(&load_spec(216 ¶ms.chain.clone().unwrap_or_default(),217 params.parachain_id.unwrap_or(200).into(),218 )?)?;219 let raw_header = block.header().encode();220 let output_buf = if params.raw {221 raw_header222 } else {223 format!("0x{:?}", HexDisplay::from(&block.header().encode())).into_bytes()224 };225226 if let Some(output) = ¶ms.output {227 std::fs::write(output, output_buf)?;228 } else {229 std::io::stdout().write_all(&output_buf)?;230 }231232 Ok(())233 }234 Some(Subcommand::ExportGenesisWasm(params)) => {235 let mut builder = sc_cli::LoggerBuilder::new("");236 builder.with_profiling(sc_tracing::TracingReceiver::Log, "");237 let _ = builder.init();238239 let raw_wasm_blob =240 extract_genesis_wasm(&cli.load_spec(¶ms.chain.clone().unwrap_or_default())?)?;241 let output_buf = if params.raw {242 raw_wasm_blob243 } else {244 format!("0x{:?}", HexDisplay::from(&raw_wasm_blob)).into_bytes()245 };246247 if let Some(output) = ¶ms.output {248 std::fs::write(output, output_buf)?;249 } else {250 std::io::stdout().write_all(&output_buf)?;251 }252253 Ok(())254 }255 Some(Subcommand::Benchmark(cmd)) => {256 if cfg!(feature = "runtime-benchmarks") {257 let runner = cli.create_runner(cmd)?;258259 runner.sync_run(|config| cmd.run::<Block, ParachainRuntimeExecutor>(config))260 } else {261 Err("Benchmarking wasn't enabled when building the node. \262 You can enable it with `--features runtime-benchmarks`."263 .into())264 }265 }266 None => {267 let runner = cli.create_runner(&cli.run.normalize())?;268269 runner.run_node_until_exit(|config| async move {270 // TODO271 let key = sp_core::Pair::generate().0;272273 let para_id =274 chain_spec::Extensions::try_get(&*config.chain_spec).map(|e| e.para_id);275276 let polkadot_cli = RelayChainCli::new(277 &config,278 [RelayChainCli::executable_name()]279 .iter()280 .chain(cli.relaychain_args.iter()),281 );282283 let id = ParaId::from(cli.run.parachain_id.or(para_id).unwrap_or(200));284285 let parachain_account =286 AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);287288 let block: Block =289 generate_genesis_block(&config.chain_spec).map_err(|e| format!("{:?}", e))?;290 let genesis_state = format!("0x{:?}", HexDisplay::from(&block.header().encode()));291292 let task_executor = config.task_executor.clone();293 let polkadot_config =294 SubstrateCli::create_configuration(&polkadot_cli, &polkadot_cli, task_executor)295 .map_err(|err| format!("Relay chain argument error: {}", err))?;296297 info!("Parachain id: {:?}", id);298 info!("Parachain Account: {}", parachain_account);299 info!("Parachain genesis state: {}", genesis_state);300 info!(301 "Is collating: {}",302 if config.role.is_authority() {303 "yes"304 } else {305 "no"306 }307 );308309 crate::service::start_node(config, key, polkadot_config, id)310 .await311 .map(|r| r.0)312 .map_err(Into::into)313 })314 }315 }316}317318impl DefaultConfigurationValues for RelayChainCli {319 fn p2p_listen_port() -> u16 {320 30334321 }322323 fn rpc_ws_listen_port() -> u16 {324 9945325 }326327 fn rpc_http_listen_port() -> u16 {328 9934329 }330331 fn prometheus_listen_port() -> u16 {332 9616333 }334}335336impl CliConfiguration<Self> for RelayChainCli {337 fn shared_params(&self) -> &SharedParams {338 self.base.base.shared_params()339 }340341 fn import_params(&self) -> Option<&ImportParams> {342 self.base.base.import_params()343 }344345 fn network_params(&self) -> Option<&NetworkParams> {346 self.base.base.network_params()347 }348349 fn keystore_params(&self) -> Option<&KeystoreParams> {350 self.base.base.keystore_params()351 }352353 fn base_path(&self) -> Result<Option<BasePath>> {354 Ok(self355 .shared_params()356 .base_path()357 .or_else(|| self.base_path.clone().map(Into::into)))358 }359360 fn rpc_http(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {361 self.base.base.rpc_http(default_listen_port)362 }363364 fn rpc_ipc(&self) -> Result<Option<String>> {365 self.base.base.rpc_ipc()366 }367368 fn rpc_ws(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {369 self.base.base.rpc_ws(default_listen_port)370 }371372 fn prometheus_config(&self, default_listen_port: u16) -> Result<Option<PrometheusConfig>> {373 self.base.base.prometheus_config(default_listen_port)374 }375376 fn init<C: SubstrateCli>(&self) -> Result<()> {377 unreachable!("PolkadotCli is never initialized; qed");378 }379380 fn chain_id(&self, is_dev: bool) -> Result<String> {381 let chain_id = self.base.base.chain_id(is_dev)?;382383 Ok(if chain_id.is_empty() {384 self.chain_id.clone().unwrap_or_default()385 } else {386 chain_id387 })388 }389390 fn role(&self, is_dev: bool) -> Result<sc_service::Role> {391 self.base.base.role(is_dev)392 }393394 fn transaction_pool(&self) -> Result<sc_service::config::TransactionPoolOptions> {395 self.base.base.transaction_pool()396 }397398 fn state_cache_child_ratio(&self) -> Result<Option<usize>> {399 self.base.base.state_cache_child_ratio()400 }401402 fn rpc_methods(&self) -> Result<sc_service::config::RpcMethods> {403 self.base.base.rpc_methods()404 }405406 fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {407 self.base.base.rpc_ws_max_connections()408 }409410 fn rpc_cors(&self, is_dev: bool) -> Result<Option<Vec<String>>> {411 self.base.base.rpc_cors(is_dev)412 }413414 fn telemetry_external_transport(&self) -> Result<Option<sc_service::config::ExtTransport>> {415 self.base.base.telemetry_external_transport()416 }417418 fn default_heap_pages(&self) -> Result<Option<u64>> {419 self.base.base.default_heap_pages()420 }421422 fn force_authoring(&self) -> Result<bool> {423 self.base.base.force_authoring()424 }425426 fn disable_grandpa(&self) -> Result<bool> {427 self.base.base.disable_grandpa()428 }429430 fn max_runtime_instances(&self) -> Result<Option<usize>> {431 self.base.base.max_runtime_instances()432 }433434 fn announce_block(&self) -> Result<bool> {435 self.base.base.announce_block()436 }437438 fn telemetry_endpoints(439 &self,440 chain_spec: &Box<dyn ChainSpec>,441 ) -> Result<Option<sc_telemetry::TelemetryEndpoints>> {442 self.base.base.telemetry_endpoints(chain_spec)443 }444}node/cli/src/service.rsdiffbeforeafterboth--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -141,7 +141,7 @@
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(
- &config,
+ config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
)?;
let client = Arc::new(client);
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,
}