difftreelog
style fix clippy warnings
in: master
26 files changed
.maintain/frame-weight-template.hbsdiffbeforeafterboth--- a/.maintain/frame-weight-template.hbs
+++ b/.maintain/frame-weight-template.hbs
@@ -14,6 +14,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -57,9 +57,5 @@
bench-nonfungible:
make _bench PALLET=nonfungible
-.PHONY: bench-evm-coder-substrate
-bench-evm-coder-substrate:
- make _bench PALLET=evm-coder-substrate
-
.PHONY: bench
-bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible bench-evm-coder-substrate
+bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible
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
@@ -226,16 +226,10 @@
}
}
fn is_value(&self) -> bool {
- match self {
- Self::Plain(v) if v == "value" => true,
- _ => false,
- }
+ matches!(self, Self::Plain(v) if v == "value")
}
fn is_caller(&self) -> bool {
- match self {
- Self::Plain(v) if v == "caller" => true,
- _ => false,
- }
+ matches!(self, Self::Plain(v) if v == "caller")
}
fn is_special(&self) -> bool {
self.is_caller() || self.is_value()
@@ -599,7 +593,7 @@
#args,
)*
)?;
- (&result).into_result()
+ (&result).to_result()
}
}
}
crates/evm-coder/src/abi.rsdiffbeforeafterboth--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -310,7 +310,7 @@
pub trait AbiWrite {
fn abi_write(&self, writer: &mut AbiWriter);
- fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {
+ fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
let mut writer = AbiWriter::new();
self.abi_write(&mut writer);
Ok(writer.into())
@@ -319,7 +319,7 @@
impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {
// this particular AbiWrite implementation should be split to another trait,
- // which only implements [`into_result`]
+ // which only implements [`to_result`]
//
// But due to lack of specialization feature in stable Rust, we can't have
// blanket impl of this trait `for T where T: AbiWrite`, so here we abusing
@@ -327,7 +327,7 @@
fn abi_write(&self, _writer: &mut AbiWriter) {
debug_assert!(false, "shouldn't be called, see comment")
}
- fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {
+ fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
match self {
Ok(v) => Ok(WithPostDispatchInfo {
post_info: v.post_info.clone(),
node/rpc/src/lib.rsdiffbeforeafterboth--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -214,7 +214,7 @@
500_usize, // max stored filters
overrides.clone(),
max_past_logs,
- block_data_cache.clone(),
+ block_data_cache,
)));
}
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -51,7 +51,7 @@
Self::new_with_gas_limit(id, u64::MAX)
}
pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {
- Ok(Self::new(id).ok_or_else(|| <Error<T>>::CollectionNotFound)?)
+ Ok(Self::new(id).ok_or(<Error<T>>::CollectionNotFound)?)
}
pub fn log(&self, log: impl evm_coder::ToLog) {
self.recorder.log(log)
@@ -453,7 +453,7 @@
collection.limits.owner_can_destroy(),
<Error<T>>::NoPermission,
);
- collection.check_is_owner(&sender)?;
+ collection.check_is_owner(sender)?;
let destroyed_collections = <DestroyedCollectionCount<T>>::get()
.0
@@ -476,7 +476,7 @@
user: &T::CrossAccountId,
allowed: bool,
) -> DispatchResult {
- collection.check_is_owner_or_admin(&sender)?;
+ collection.check_is_owner_or_admin(sender)?;
// =========
@@ -495,7 +495,7 @@
user: &T::CrossAccountId,
admin: bool,
) -> DispatchResult {
- collection.check_is_owner_or_admin(&sender)?;
+ collection.check_is_owner_or_admin(sender)?;
let was_admin = <IsAdmin<T>>::get((collection.id, user));
if was_admin == admin {
pallets/evm-contract-helpers/exp.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/exp.rs
+++ b/pallets/evm-contract-helpers/exp.rs
@@ -532,11 +532,11 @@
match c.call {
InternalCall::ContractOwner { contract_address } => {
let result = self.contract_owner(contract_address)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::SponsoringEnabled { contract_address } => {
let result = self.sponsoring_enabled(contract_address)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::ToggleSponsoring {
contract_address,
@@ -544,7 +544,7 @@
} => {
let result =
self.toggle_sponsoring(c.caller.clone(), contract_address, enabled)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::SetSponsoringRateLimit {
contract_address,
@@ -555,22 +555,22 @@
contract_address,
rate_limit,
)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::GetSponsoringRateLimit { contract_address } => {
let result = self.get_sponsoring_rate_limit(contract_address)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::Allowed {
contract_address,
user,
} => {
let result = self.allowed(contract_address, user)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::AllowlistEnabled { contract_address } => {
let result = self.allowlist_enabled(contract_address)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::ToggleAllowlist {
contract_address,
@@ -578,7 +578,7 @@
} => {
let result =
self.toggle_allowlist(c.caller.clone(), contract_address, enabled)?;
- (&result).into_result()
+ (&result).to_result()
}
InternalCall::ToggleAllowed {
contract_address,
@@ -587,7 +587,7 @@
} => {
let result =
self.toggle_allowed(c.caller.clone(), contract_address, user, allowed)?;
- (&result).into_result()
+ (&result).to_result()
}
_ => ::core::panicking::panic("internal error: entered unreachable code"),
}
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth1use core::marker::PhantomData;2use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};3use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};4use pallet_evm::{5 ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput, PrecompileResult,6 PrecompileFailure,7};8use sp_core::H160;9use crate::{10 AllowlistEnabled, Config, Owner, Pallet, SelfSponsoring, SponsorBasket, SponsoringRateLimit,11};12use frame_support::traits::Get;13use up_sponsorship::SponsorshipHandler;14use sp_std::{convert::TryInto, vec::Vec};1516struct ContractHelpers<T: Config>(SubstrateRecorder<T>);17impl<T: Config> WithRecorder<T> for ContractHelpers<T> {18 fn recorder(&self) -> &SubstrateRecorder<T> {19 &self.020 }2122 fn into_recorder(self) -> SubstrateRecorder<T> {23 self.024 }25}2627#[solidity_interface(name = "ContractHelpers")]28impl<T: Config> ContractHelpers<T> {29 fn contract_owner(&self, contract_address: address) -> Result<address> {30 Ok(<Owner<T>>::get(contract_address))31 }3233 fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {34 Ok(<SelfSponsoring<T>>::get(contract_address))35 }3637 fn toggle_sponsoring(38 &mut self,39 caller: caller,40 contract_address: address,41 enabled: bool,42 ) -> Result<void> {43 <Pallet<T>>::ensure_owner(contract_address, caller)?;44 <Pallet<T>>::toggle_sponsoring(contract_address, enabled);45 Ok(())46 }4748 fn set_sponsoring_rate_limit(49 &mut self,50 caller: caller,51 contract_address: address,52 rate_limit: uint32,53 ) -> Result<void> {54 <Pallet<T>>::ensure_owner(contract_address, caller)?;55 <Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());56 Ok(())57 }5859 fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {60 Ok(<SponsoringRateLimit<T>>::get(contract_address)61 .try_into()62 .map_err(|_| "rate limit > u32::MAX")?)63 }6465 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {66 self.0.consume_sload()?;67 Ok(<Pallet<T>>::allowed(contract_address, user)68 || !<AllowlistEnabled<T>>::get(contract_address))69 }7071 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {72 Ok(<AllowlistEnabled<T>>::get(contract_address))73 }7475 fn toggle_allowlist(76 &mut self,77 caller: caller,78 contract_address: address,79 enabled: bool,80 ) -> Result<void> {81 <Pallet<T>>::ensure_owner(contract_address, caller)?;82 <Pallet<T>>::toggle_allowlist(contract_address, enabled);83 Ok(())84 }8586 fn toggle_allowed(87 &mut self,88 caller: caller,89 contract_address: address,90 user: address,91 allowed: bool,92 ) -> Result<void> {93 <Pallet<T>>::ensure_owner(contract_address, caller)?;94 <Pallet<T>>::toggle_allowed(contract_address, user, allowed);95 Ok(())96 }97}9899pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);100impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T> {101 fn is_reserved(contract: &sp_core::H160) -> bool {102 contract == &T::ContractAddress::get()103 }104105 fn is_used(contract: &sp_core::H160) -> bool {106 contract == &T::ContractAddress::get()107 }108109 fn call(110 source: &sp_core::H160,111 target: &sp_core::H160,112 gas_left: u64,113 input: &[u8],114 value: sp_core::U256,115 ) -> Option<PrecompileResult> {116 // TODO: Extract to another OnMethodCall handler117 if <AllowlistEnabled<T>>::get(target) && !<Pallet<T>>::allowed(*target, *source) {118 return Some(Err(PrecompileFailure::Revert {119 exit_status: ExitRevert::Reverted,120 cost: 0,121 output: {122 let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));123 writer.string("Target contract is allowlisted");124 writer.finish()125 },126 }));127 }128129 if target != &T::ContractAddress::get() {130 return None;131 }132133 let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(*target, gas_left));134 pallet_evm_coder_substrate::call(*source, helpers, value, input)135 }136137 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {138 (contract == &T::ContractAddress::get())139 .then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())140 }141}142143pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);144impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {145 fn on_create(owner: H160, contract: H160) {146 <Owner<T>>::insert(contract, owner);147 }148}149150pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);151impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for HelpersContractSponsoring<T> {152 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {153 if !<SelfSponsoring<T>>::get(&call.0) {154 return None;155 }156 if !<Pallet<T>>::allowed(call.0, *who) {157 return None;158 }159 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;160161 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {162 let limit = <SponsoringRateLimit<T>>::get(&call.0);163164 let timeout = last_tx_block + limit.into();165 if block_number < timeout {166 return None;167 }168 }169170 <SponsorBasket<T>>::insert(&call.0, who, block_number);171172 Some(call.0)173 }174}175176generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);177generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);1use core::marker::PhantomData;2use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};3use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};4use pallet_evm::{ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure};5use sp_core::H160;6use crate::{7 AllowlistEnabled, Config, Owner, Pallet, SelfSponsoring, SponsorBasket, SponsoringRateLimit,8};9use frame_support::traits::Get;10use up_sponsorship::SponsorshipHandler;11use sp_std::{convert::TryInto, vec::Vec};1213struct ContractHelpers<T: Config>(SubstrateRecorder<T>);14impl<T: Config> WithRecorder<T> for ContractHelpers<T> {15 fn recorder(&self) -> &SubstrateRecorder<T> {16 &self.017 }1819 fn into_recorder(self) -> SubstrateRecorder<T> {20 self.021 }22}2324#[solidity_interface(name = "ContractHelpers")]25impl<T: Config> ContractHelpers<T> {26 fn contract_owner(&self, contract_address: address) -> Result<address> {27 Ok(<Owner<T>>::get(contract_address))28 }2930 fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {31 Ok(<SelfSponsoring<T>>::get(contract_address))32 }3334 fn toggle_sponsoring(35 &mut self,36 caller: caller,37 contract_address: address,38 enabled: bool,39 ) -> Result<void> {40 <Pallet<T>>::ensure_owner(contract_address, caller)?;41 <Pallet<T>>::toggle_sponsoring(contract_address, enabled);42 Ok(())43 }4445 fn set_sponsoring_rate_limit(46 &mut self,47 caller: caller,48 contract_address: address,49 rate_limit: uint32,50 ) -> Result<void> {51 <Pallet<T>>::ensure_owner(contract_address, caller)?;52 <Pallet<T>>::set_sponsoring_rate_limit(contract_address, rate_limit.into());53 Ok(())54 }5556 fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {57 Ok(<SponsoringRateLimit<T>>::get(contract_address)58 .try_into()59 .map_err(|_| "rate limit > u32::MAX")?)60 }6162 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {63 self.0.consume_sload()?;64 Ok(<Pallet<T>>::allowed(contract_address, user)65 || !<AllowlistEnabled<T>>::get(contract_address))66 }6768 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {69 Ok(<AllowlistEnabled<T>>::get(contract_address))70 }7172 fn toggle_allowlist(73 &mut self,74 caller: caller,75 contract_address: address,76 enabled: bool,77 ) -> Result<void> {78 <Pallet<T>>::ensure_owner(contract_address, caller)?;79 <Pallet<T>>::toggle_allowlist(contract_address, enabled);80 Ok(())81 }8283 fn toggle_allowed(84 &mut self,85 caller: caller,86 contract_address: address,87 user: address,88 allowed: bool,89 ) -> Result<void> {90 <Pallet<T>>::ensure_owner(contract_address, caller)?;91 <Pallet<T>>::toggle_allowed(contract_address, user, allowed);92 Ok(())93 }94}9596pub struct HelpersOnMethodCall<T: Config>(PhantomData<*const T>);97impl<T: Config> OnMethodCall<T> for HelpersOnMethodCall<T> {98 fn is_reserved(contract: &sp_core::H160) -> bool {99 contract == &T::ContractAddress::get()100 }101102 fn is_used(contract: &sp_core::H160) -> bool {103 contract == &T::ContractAddress::get()104 }105106 fn call(107 source: &sp_core::H160,108 target: &sp_core::H160,109 gas_left: u64,110 input: &[u8],111 value: sp_core::U256,112 ) -> Option<PrecompileResult> {113 // TODO: Extract to another OnMethodCall handler114 if <AllowlistEnabled<T>>::get(target) && !<Pallet<T>>::allowed(*target, *source) {115 return Some(Err(PrecompileFailure::Revert {116 exit_status: ExitRevert::Reverted,117 cost: 0,118 output: {119 let mut writer = AbiWriter::new_call(evm_coder::fn_selector!(Error(string)));120 writer.string("Target contract is allowlisted");121 writer.finish()122 },123 }));124 }125126 if target != &T::ContractAddress::get() {127 return None;128 }129130 let helpers = ContractHelpers::<T>(SubstrateRecorder::<T>::new(*target, gas_left));131 pallet_evm_coder_substrate::call(*source, helpers, value, input)132 }133134 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {135 (contract == &T::ContractAddress::get())136 .then(|| include_bytes!("./stubs/ContractHelpers.raw").to_vec())137 }138}139140pub struct HelpersOnCreate<T: Config>(PhantomData<*const T>);141impl<T: Config> OnCreate<T> for HelpersOnCreate<T> {142 fn on_create(owner: H160, contract: H160) {143 <Owner<T>>::insert(contract, owner);144 }145}146147pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);148impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for HelpersContractSponsoring<T> {149 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {150 if !<SelfSponsoring<T>>::get(&call.0) {151 return None;152 }153 if !<Pallet<T>>::allowed(call.0, *who) {154 return None;155 }156 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;157158 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {159 let limit = <SponsoringRateLimit<T>>::get(&call.0);160161 let timeout = last_tx_block + limit;162 if block_number < timeout {163 return None;164 }165 }166167 <SponsorBasket<T>>::insert(&call.0, who, block_number);168169 Some(call.0)170 }171}172173generate_stubgen!(contract_helpers_impl, ContractHelpersCall<()>, true);174generate_stubgen!(contract_helpers_iface, ContractHelpersCall<()>, false);pallets/evm-migration/src/weights.rsdiffbeforeafterboth--- a/pallets/evm-migration/src/weights.rs
+++ b/pallets/evm-migration/src/weights.rs
@@ -25,6 +25,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
pallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -128,7 +128,7 @@
let sponsor = frame_support::storage::with_transaction(|| {
TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(
&who,
- &(target.clone(), input.clone()),
+ &(*target, input.clone()),
))
})?;
let sponsor = T::EvmAddressMapping::into_account_id(sponsor);
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -116,7 +116,7 @@
);
with_weight(
- <Pallet<T>>::transfer(&self, &from, &to, amount),
+ <Pallet<T>>::transfer(self, &from, &to, amount),
<CommonWeights<T>>::transfer(),
)
}
@@ -134,7 +134,7 @@
);
with_weight(
- <Pallet<T>>::set_allowance(&self, &sender, &spender, amount),
+ <Pallet<T>>::set_allowance(self, &sender, &spender, amount),
<CommonWeights<T>>::approve(),
)
}
@@ -153,7 +153,7 @@
);
with_weight(
- <Pallet<T>>::transfer_from(&self, &sender, &from, &to, amount),
+ <Pallet<T>>::transfer_from(self, &sender, &from, &to, amount),
<CommonWeights<T>>::transfer_from(),
)
}
@@ -171,7 +171,7 @@
);
with_weight(
- <Pallet<T>>::burn_from(&self, &sender, &from, amount),
+ <Pallet<T>>::burn_from(self, &sender, &from, amount),
<CommonWeights<T>>::burn_from(),
)
}
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -6,7 +6,6 @@
use sp_core::{H160, U256};
use sp_std::vec::Vec;
use pallet_common::account::CrossAccountId;
-use pallet_common::erc::PrecompileOutput;
use pallet_evm_coder_substrate::{call, dispatch_to_evm};
use crate::{
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -303,8 +303,8 @@
amount: u128,
) -> DispatchResult {
if collection.access == AccessMode::AllowList {
- collection.check_allowlist(&owner)?;
- collection.check_allowlist(&spender)?;
+ collection.check_allowlist(owner)?;
+ collection.check_allowlist(spender)?;
}
if <Balance<T>>::get((collection.id, owner)) < amount {
pallets/fungible/src/weights.rsdiffbeforeafterboth--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -25,6 +25,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
@@ -32,11 +33,11 @@
/// Weight functions needed for pallet_fungible.
pub trait WeightInfo {
fn create_item() -> Weight;
- fn burn_from() -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
+ fn burn_from() -> Weight;
}
/// Weights for pallet_fungible using the Substrate node and recommended hardware.
pallets/nft/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nft/src/benchmarking.rs
+++ b/pallets/nft/src/benchmarking.rs
@@ -158,6 +158,7 @@
sponsored_data_size: Some(0),
token_limit: Some(1),
sponsor_transfer_timeout: Some(0),
+ sponsor_approve_timeout: None,
owner_can_destroy: Some(true),
owner_can_transfer: Some(true),
sponsored_data_rate_limit: None,
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -195,7 +195,7 @@
// Create new collection
let new_collection = Collection {
- owner: who.clone(),
+ owner: who,
name: collection_name,
mode: mode.clone(),
mint_mode: false,
pallets/nft/src/weights.rsdiffbeforeafterboth--- a/pallets/nft/src/weights.rs
+++ b/pallets/nft/src/weights.rs
@@ -25,6 +25,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -100,7 +100,7 @@
ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
if amount == 1 {
with_weight(
- <Pallet<T>>::burn(&self, &sender, token),
+ <Pallet<T>>::burn(self, &sender, token),
<CommonWeights<T>>::burn_item(),
)
} else {
@@ -118,7 +118,7 @@
ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
if amount == 1 {
with_weight(
- <Pallet<T>>::transfer(&self, &from, &to, token),
+ <Pallet<T>>::transfer(self, &from, &to, token),
<CommonWeights<T>>::transfer(),
)
} else {
@@ -137,9 +137,9 @@
with_weight(
if amount == 1 {
- <Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))
+ <Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))
} else {
- <Pallet<T>>::set_allowance(&self, &sender, token, None)
+ <Pallet<T>>::set_allowance(self, &sender, token, None)
},
<CommonWeights<T>>::approve(),
)
@@ -157,7 +157,7 @@
if amount == 1 {
with_weight(
- <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),
+ <Pallet<T>>::transfer_from(self, &sender, &from, &to, token),
<CommonWeights<T>>::transfer_from(),
)
} else {
@@ -176,7 +176,7 @@
if amount == 1 {
with_weight(
- <Pallet<T>>::burn_from(&self, &sender, &from, token),
+ <Pallet<T>>::burn_from(self, &sender, &from, token),
<CommonWeights<T>>::burn_from(),
)
} else {
@@ -192,7 +192,7 @@
) -> DispatchResultWithPostInfo {
let len = data.len();
with_weight(
- <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),
+ <Pallet<T>>::set_variable_metadata(self, &sender, token, data),
<CommonWeights<T>>::set_variable_metadata(len as u32),
)
}
@@ -218,12 +218,12 @@
}
fn const_metadata(&self, token: TokenId) -> Vec<u8> {
<TokenData<T>>::get((self.id, token))
- .map(|t| t.const_data.clone())
+ .map(|t| t.const_data)
.unwrap_or_default()
}
fn variable_metadata(&self, token: TokenId) -> Vec<u8> {
<TokenData<T>>::get((self.id, token))
- .map(|t| t.variable_data.clone())
+ .map(|t| t.variable_data)
.unwrap_or_default()
}
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -13,7 +13,6 @@
erc::{CommonEvmHandler, PrecompileResult},
};
use pallet_evm_coder_substrate::call;
-use pallet_common::erc::PrecompileOutput;
use crate::{
AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -169,8 +169,8 @@
sender: &T::CrossAccountId,
token: TokenId,
) -> DispatchResult {
- let token_data = <TokenData<T>>::get((collection.id, token))
- .ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
+ let token_data =
+ <TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
ensure!(
&token_data.owner == sender
|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),
@@ -197,7 +197,7 @@
collection.id,
token,
sender.clone(),
- old_spender.clone(),
+ old_spender,
0,
));
}
@@ -213,7 +213,7 @@
token_data.owner,
1,
));
- return Ok(());
+ Ok(())
}
pub fn transfer(
@@ -227,8 +227,8 @@
<CommonError<T>>::TransferNotAllowed
);
- let token_data = <TokenData<T>>::get((collection.id, token))
- .ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
+ let token_data =
+ <TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
ensure!(
&token_data.owner == from
|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),
@@ -399,7 +399,7 @@
collection.id,
token,
sender.clone(),
- old_owner.clone(),
+ old_owner,
0,
));
}
@@ -429,7 +429,7 @@
collection.id,
token,
sender.clone(),
- old_spender.clone(),
+ old_spender,
0,
));
}
@@ -443,9 +443,9 @@
spender: Option<&T::CrossAccountId>,
) -> DispatchResult {
if collection.access == AccessMode::AllowList {
- collection.check_allowlist(&sender)?;
+ collection.check_allowlist(sender)?;
if let Some(spender) = spender {
- collection.check_allowlist(&spender)?;
+ collection.check_allowlist(spender)?;
}
}
@@ -491,7 +491,7 @@
// =========
- Self::transfer(collection, &from, to, token)?;
+ Self::transfer(collection, from, to, token)?;
// Allowance is reset in [`transfer`]
Ok(())
}
@@ -519,7 +519,7 @@
// =========
- Self::burn(collection, &from, token)
+ Self::burn(collection, from, token)
}
pub fn set_variable_metadata(
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -25,6 +25,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
@@ -33,11 +34,11 @@
pub trait WeightInfo {
fn create_item() -> Weight;
fn create_multiple_items(b: u32, ) -> Weight;
- fn burn_from() -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
+ fn burn_from() -> Weight;
fn set_variable_metadata(b: u32, ) -> Weight;
}
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -135,7 +135,7 @@
amount: u128,
) -> DispatchResultWithPostInfo {
with_weight(
- <Pallet<T>>::transfer(&self, &from, &to, token, amount),
+ <Pallet<T>>::transfer(self, &from, &to, token, amount),
<CommonWeights<T>>::transfer(),
)
}
@@ -148,7 +148,7 @@
amount: u128,
) -> DispatchResultWithPostInfo {
with_weight(
- <Pallet<T>>::set_allowance(&self, &sender, &spender, token, amount),
+ <Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),
<CommonWeights<T>>::approve(),
)
}
@@ -162,7 +162,7 @@
amount: u128,
) -> DispatchResultWithPostInfo {
with_weight(
- <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token, amount),
+ <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount),
<CommonWeights<T>>::transfer_from(),
)
}
@@ -175,7 +175,7 @@
amount: u128,
) -> DispatchResultWithPostInfo {
with_weight(
- <Pallet<T>>::burn_from(&self, &sender, &from, token, amount),
+ <Pallet<T>>::burn_from(self, &sender, &from, token, amount),
<CommonWeights<T>>::burn_from(),
)
}
@@ -188,7 +188,7 @@
) -> DispatchResultWithPostInfo {
let len = data.len();
with_weight(
- <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),
+ <Pallet<T>>::set_variable_metadata(self, &sender, token, data),
<CommonWeights<T>>::set_variable_metadata(len as u32),
)
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -189,7 +189,7 @@
<Balance<T>>::remove_prefix((collection.id, token_id), None);
<Allowance<T>>::remove_prefix((collection.id, token_id), None);
// TODO: ERC721 transfer event
- return Ok(());
+ Ok(())
}
pub fn burn(
@@ -367,8 +367,8 @@
collection.check_allowlist(sender)?;
for item in data.iter() {
- for (user, _) in &item.users {
- collection.check_allowlist(&user)?;
+ for user in item.users.keys() {
+ collection.check_allowlist(user)?;
}
}
}
@@ -409,7 +409,7 @@
let mut balances = BTreeMap::new();
for data in &data {
- for (owner, _) in &data.users {
+ for owner in data.users.keys() {
let balance = balances
.entry(owner)
.or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));
@@ -483,8 +483,8 @@
amount: u128,
) -> DispatchResult {
if collection.access == AccessMode::AllowList {
- collection.check_allowlist(&sender)?;
- collection.check_allowlist(&spender)?;
+ collection.check_allowlist(sender)?;
+ collection.check_allowlist(spender)?;
}
<PalletCommon<T>>::ensure_correct_receiver(spender)?;
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -25,6 +25,7 @@
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
@@ -33,7 +34,6 @@
pub trait WeightInfo {
fn create_item() -> Weight;
fn create_multiple_items(b: u32, ) -> Weight;
- fn burn_from() -> Weight;
fn burn_item_partial() -> Weight;
fn burn_item_fully() -> Weight;
fn transfer_normal() -> Weight;
@@ -45,6 +45,7 @@
fn transfer_from_creating() -> Weight;
fn transfer_from_removing() -> Weight;
fn transfer_from_creating_removing() -> Weight;
+ fn burn_from() -> Weight;
fn set_variable_metadata(b: u32, ) -> Weight;
}
primitives/nft/src/lib.rsdiffbeforeafterboth--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -327,8 +327,7 @@
D: ser::Serializer,
V: Serialize,
{
- let vec: &Vec<_> = &value;
- vec.serialize(serializer)
+ (value as &Vec<_>).serialize(serializer)
}
pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -1177,6 +1177,7 @@
EVM::account_storages(address, H256::from_slice(&tmp[..]))
}
+ #[allow(clippy::redundant_closure)]
fn call(
from: H160,
to: H160,
@@ -1207,6 +1208,7 @@
).map_err(|err| err.into())
}
+ #[allow(clippy::redundant_closure)]
fn create(
from: H160,
data: Vec<u8>,