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.rsdiffbeforeafterboth1use nft_runtime::{Hash, AccountId, CrossAccountId, Index, opaque::Block, BlockNumber, Balance};2use fc_rpc::{3 EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, StorageOverride,4};5use fc_rpc_core::types::FilterPool;6use jsonrpc_pubsub::manager::SubscriptionManager;7use pallet_ethereum::EthereumStorageSchema;8use sc_client_api::{9 backend::{AuxStore, StorageProvider},10 client::BlockchainEvents,11};12use sc_finality_grandpa::{13 FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,14};15use sc_network::NetworkService;16use sc_rpc::SubscriptionTaskExecutor;17pub use sc_rpc_api::DenyUnsafe;18use sc_transaction_pool::{ChainApi, Pool};19use sp_api::ProvideRuntimeApi;20use sp_block_builder::BlockBuilder;21use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};22use sp_consensus::SelectChain;23use sc_service::TransactionPool;24use std::{collections::BTreeMap, marker::PhantomData, sync::Arc};2526/// Public io handler for exporting into other modules27pub type IoHandler = jsonrpc_core::IoHandler<sc_rpc::Metadata>;2829/// Light client extra dependencies.30pub struct LightDeps<C, F, P> {31 /// The client instance to use.32 pub client: Arc<C>,33 /// Transaction pool instance.34 pub pool: Arc<P>,35 /// Remote access to the blockchain (async).36 pub remote_blockchain: Arc<dyn sc_client_api::light::RemoteBlockchain<Block>>,37 /// Fetcher instance.38 pub fetcher: Arc<F>,39}4041/// Extra dependencies for GRANDPA42pub struct GrandpaDeps<B> {43 /// Voting round info.44 pub shared_voter_state: SharedVoterState,45 /// Authority set info.46 pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,47 /// Receives notifications about justification events from Grandpa.48 pub justification_stream: GrandpaJustificationStream<Block>,49 /// Executor to drive the subscription manager in the Grandpa RPC handler.50 pub subscription_executor: SubscriptionTaskExecutor,51 /// Finality proof provider.52 pub finality_provider: Arc<FinalityProofProvider<B, Block>>,53}5455/// Full client dependencies.56pub struct FullDeps<C, P, SC, CA: ChainApi> {57 /// The client instance to use.58 pub client: Arc<C>,59 /// Transaction pool instance.60 pub pool: Arc<P>,61 /// Graph pool instance.62 pub graph: Arc<Pool<CA>>,63 /// The SelectChain Strategy64 pub select_chain: SC,65 /// The Node authority flag66 pub is_authority: bool,67 /// Whether to enable dev signer68 pub enable_dev_signer: bool,69 /// Network service70 pub network: Arc<NetworkService<Block, Hash>>,71 /// Whether to deny unsafe calls72 pub deny_unsafe: DenyUnsafe,73 /// EthFilterApi pool.74 pub filter_pool: Option<FilterPool>,75 /// Backend.76 pub backend: Arc<fc_db::Backend<Block>>,77 /// Maximum number of logs in a query.78 pub max_past_logs: u32,79}8081struct AccountCodes<C, B> {82 client: Arc<C>,83 _marker: PhantomData<B>,84}8586impl<C, Block> AccountCodes<C, Block>87where88 Block: sp_api::BlockT,89 C: ProvideRuntimeApi<Block>,90{91 fn new(client: Arc<C>) -> Self {92 Self {93 client,94 _marker: PhantomData,95 }96 }97}9899impl<C, Block> fc_rpc::AccountCodeProvider<Block> for AccountCodes<C, Block>100where101 Block: sp_api::BlockT,102 C: ProvideRuntimeApi<Block>,103 C::Api: up_rpc::NftApi<Block, CrossAccountId, AccountId>,104{105 fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {106 use up_rpc::NftApi;107 self.client108 .runtime_api()109 .eth_contract_code(block, account)110 .ok()111 .flatten()112 }113}114115/// Instantiate all Full RPC extensions.116pub fn create_full<C, P, SC, CA, A, B>(117 deps: FullDeps<C, P, SC, CA>,118 subscription_task_executor: SubscriptionTaskExecutor,119) -> jsonrpc_core::IoHandler<sc_rpc_api::Metadata>120where121 C: ProvideRuntimeApi<Block> + StorageProvider<Block, B> + AuxStore,122 C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,123 C: Send + Sync + 'static,124 C: BlockchainEvents<Block>,125 C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,126 C::Api: BlockBuilder<Block>,127 // C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,128 C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,129 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,130 C::Api: up_rpc::NftApi<Block, CrossAccountId, AccountId>,131 B: sc_client_api::Backend<Block> + Send + Sync + 'static,132 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,133 SC: SelectChain<Block> + 'static,134 P: TransactionPool<Block = Block> + 'static,135 CA: ChainApi<Block = Block> + 'static,136{137 use fc_rpc::{138 EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi,139 EthPubSubApiServer, EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api,140 Web3ApiServer,141 };142 use uc_rpc::{NftApi, Nft};143 // use pallet_contracts_rpc::{Contracts, ContractsApi};144 use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};145 use substrate_frame_rpc_system::{FullSystem, SystemApi};146147 let mut io = jsonrpc_core::IoHandler::default();148 let FullDeps {149 client,150 pool,151 graph,152 select_chain: _,153 enable_dev_signer,154 is_authority,155 network,156 deny_unsafe,157 filter_pool,158 backend,159 max_past_logs,160 } = deps;161162 io.extend_with(SystemApi::to_delegate(FullSystem::new(163 client.clone(),164 pool.clone(),165 deny_unsafe,166 )));167168 io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(169 client.clone(),170 )));171172 // io.extend_with(ContractsApi::to_delegate(Contracts::new(client.clone())));173174 let mut signers = Vec::new();175 if enable_dev_signer {176 signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);177 }178 let mut overrides_map = BTreeMap::new();179 overrides_map.insert(180 EthereumStorageSchema::V1,181 Box::new(SchemaV1Override::new_with_code_provider(182 client.clone(),183 Arc::new(AccountCodes::<C, Block>::new(client.clone())),184 )) as Box<dyn StorageOverride<_> + Send + Sync>,185 );186187 let overrides = Arc::new(OverrideHandle {188 schemas: overrides_map,189 fallback: Box::new(RuntimeApiStorageOverride::new(client.clone())),190 });191192 let block_data_cache = Arc::new(EthBlockDataCache::new(50, 50));193194 io.extend_with(EthApiServer::to_delegate(EthApi::new(195 client.clone(),196 pool.clone(),197 graph,198 nft_runtime::TransactionConverter,199 network.clone(),200 signers,201 overrides.clone(),202 backend.clone(),203 is_authority,204 max_past_logs,205 block_data_cache.clone(),206 )));207 io.extend_with(NftApi::to_delegate(Nft::new(client.clone())));208209 if let Some(filter_pool) = filter_pool {210 io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(211 client.clone(),212 backend,213 filter_pool,214 500_usize, // max stored filters215 overrides.clone(),216 max_past_logs,217 block_data_cache.clone(),218 )));219 }220221 io.extend_with(NetApiServer::to_delegate(NetApi::new(222 client.clone(),223 network.clone(),224 // Whether to format the `peer_count` response as Hex (default) or not.225 true,226 )));227228 io.extend_with(Web3ApiServer::to_delegate(Web3Api::new(client.clone())));229230 io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new(231 pool,232 client,233 network,234 SubscriptionManager::<HexEncodedIdProvider>::with_id_provider(235 HexEncodedIdProvider::default(),236 Arc::new(subscription_task_executor),237 ),238 overrides,239 )));240241 io242}243244/// Instantiate all Light RPC extensions.245pub fn create_light<C, P, M, F>(deps: LightDeps<C, F, P>) -> jsonrpc_core::IoHandler<M>246where247 C: sp_blockchain::HeaderBackend<Block>,248 C: Send + Sync + 'static,249 F: sc_client_api::light::Fetcher<Block> + 'static,250 P: TransactionPool + 'static,251 M: jsonrpc_core::Metadata + Default,252{253 use substrate_frame_rpc_system::{LightSystem, SystemApi};254255 let LightDeps {256 client,257 pool,258 remote_blockchain,259 fetcher,260 } = deps;261 let mut io = jsonrpc_core::IoHandler::default();262 io.extend_with(SystemApi::<Hash, AccountId, Index>::to_delegate(263 LightSystem::new(client, remote_blockchain, fetcher, pool),264 ));265266 io267}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.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -1,10 +1,7 @@
use core::marker::PhantomData;
use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use pallet_evm::{
- ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput, PrecompileResult,
- PrecompileFailure,
-};
+use pallet_evm::{ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure};
use sp_core::H160;
use crate::{
AllowlistEnabled, Config, Owner, Pallet, SelfSponsoring, SponsorBasket, SponsoringRateLimit,
@@ -161,7 +158,7 @@
if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {
let limit = <SponsoringRateLimit<T>>::get(&call.0);
- let timeout = last_tx_block + limit.into();
+ let timeout = last_tx_block + limit;
if block_number < timeout {
return None;
}
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>,