git.delta.rocks / unique-network / refs/commits / ba69054f3875

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2021-11-26parent: #d1696cc.patch.diff
in: master

26 files changed

modified.maintain/frame-weight-template.hbsdiffbeforeafterboth
14#![cfg_attr(rustfmt, rustfmt_skip)]14#![cfg_attr(rustfmt, rustfmt_skip)]
15#![allow(unused_parens)]15#![allow(unused_parens)]
16#![allow(unused_imports)]16#![allow(unused_imports)]
17#![allow(clippy::unnecessary_cast)]
1718
18use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};19use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
19use sp_std::marker::PhantomData;20use sp_std::marker::PhantomData;
modifiedMakefilediffbeforeafterboth
57bench-nonfungible:57bench-nonfungible:
58 make _bench PALLET=nonfungible58 make _bench PALLET=nonfungible
59
60.PHONY: bench-evm-coder-substrate
61bench-evm-coder-substrate:
62 make _bench PALLET=evm-coder-substrate
6359
64.PHONY: bench60.PHONY: bench
65bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible bench-evm-coder-substrate61bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible
6662
modifiedcrates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterboth
226 }226 }
227 }227 }
228 fn is_value(&self) -> bool {228 fn is_value(&self) -> bool {
229 match self {229 matches!(self, Self::Plain(v) if v == "value")
230 Self::Plain(v) if v == "value" => true,
231 _ => false,
232 }
233 }230 }
234 fn is_caller(&self) -> bool {231 fn is_caller(&self) -> bool {
235 match self {232 matches!(self, Self::Plain(v) if v == "caller")
236 Self::Plain(v) if v == "caller" => true,
237 _ => false,
238 }
239 }233 }
240 fn is_special(&self) -> bool {234 fn is_special(&self) -> bool {
241 self.is_caller() || self.is_value()235 self.is_caller() || self.is_value()
599 #args,593 #args,
600 )*594 )*
601 )?;595 )?;
602 (&result).into_result()596 (&result).to_result()
603 }597 }
604 }598 }
605 }599 }
modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
310310
311pub trait AbiWrite {311pub trait AbiWrite {
312 fn abi_write(&self, writer: &mut AbiWriter);312 fn abi_write(&self, writer: &mut AbiWriter);
313 fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {313 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
314 let mut writer = AbiWriter::new();314 let mut writer = AbiWriter::new();
315 self.abi_write(&mut writer);315 self.abi_write(&mut writer);
316 Ok(writer.into())316 Ok(writer.into())
319319
320impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {320impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {
321 // this particular AbiWrite implementation should be split to another trait,321 // this particular AbiWrite implementation should be split to another trait,
322 // which only implements [`into_result`]322 // which only implements [`to_result`]
323 //323 //
324 // But due to lack of specialization feature in stable Rust, we can't have324 // But due to lack of specialization feature in stable Rust, we can't have
325 // blanket impl of this trait `for T where T: AbiWrite`, so here we abusing325 // blanket impl of this trait `for T where T: AbiWrite`, so here we abusing
326 // default trait methods for it326 // default trait methods for it
327 fn abi_write(&self, _writer: &mut AbiWriter) {327 fn abi_write(&self, _writer: &mut AbiWriter) {
328 debug_assert!(false, "shouldn't be called, see comment")328 debug_assert!(false, "shouldn't be called, see comment")
329 }329 }
330 fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {330 fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
331 match self {331 match self {
332 Ok(v) => Ok(WithPostDispatchInfo {332 Ok(v) => Ok(WithPostDispatchInfo {
333 post_info: v.post_info.clone(),333 post_info: v.post_info.clone(),
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
214 500_usize, // max stored filters214 500_usize, // max stored filters
215 overrides.clone(),215 overrides.clone(),
216 max_past_logs,216 max_past_logs,
217 block_data_cache.clone(),217 block_data_cache,
218 )));218 )));
219 }219 }
220220
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
51 Self::new_with_gas_limit(id, u64::MAX)51 Self::new_with_gas_limit(id, u64::MAX)
52 }52 }
53 pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {53 pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {
54 Ok(Self::new(id).ok_or_else(|| <Error<T>>::CollectionNotFound)?)54 Ok(Self::new(id).ok_or(<Error<T>>::CollectionNotFound)?)
55 }55 }
56 pub fn log(&self, log: impl evm_coder::ToLog) {56 pub fn log(&self, log: impl evm_coder::ToLog) {
57 self.recorder.log(log)57 self.recorder.log(log)
453 collection.limits.owner_can_destroy(),453 collection.limits.owner_can_destroy(),
454 <Error<T>>::NoPermission,454 <Error<T>>::NoPermission,
455 );455 );
456 collection.check_is_owner(&sender)?;456 collection.check_is_owner(sender)?;
457457
458 let destroyed_collections = <DestroyedCollectionCount<T>>::get()458 let destroyed_collections = <DestroyedCollectionCount<T>>::get()
459 .0459 .0
476 user: &T::CrossAccountId,476 user: &T::CrossAccountId,
477 allowed: bool,477 allowed: bool,
478 ) -> DispatchResult {478 ) -> DispatchResult {
479 collection.check_is_owner_or_admin(&sender)?;479 collection.check_is_owner_or_admin(sender)?;
480480
481 // =========481 // =========
482482
495 user: &T::CrossAccountId,495 user: &T::CrossAccountId,
496 admin: bool,496 admin: bool,
497 ) -> DispatchResult {497 ) -> DispatchResult {
498 collection.check_is_owner_or_admin(&sender)?;498 collection.check_is_owner_or_admin(sender)?;
499499
500 let was_admin = <IsAdmin<T>>::get((collection.id, user));500 let was_admin = <IsAdmin<T>>::get((collection.id, user));
501 if was_admin == admin {501 if was_admin == admin {
modifiedpallets/evm-contract-helpers/exp.rsdiffbeforeafterboth
532 match c.call {532 match c.call {
533 InternalCall::ContractOwner { contract_address } => {533 InternalCall::ContractOwner { contract_address } => {
534 let result = self.contract_owner(contract_address)?;534 let result = self.contract_owner(contract_address)?;
535 (&result).into_result()535 (&result).to_result()
536 }536 }
537 InternalCall::SponsoringEnabled { contract_address } => {537 InternalCall::SponsoringEnabled { contract_address } => {
538 let result = self.sponsoring_enabled(contract_address)?;538 let result = self.sponsoring_enabled(contract_address)?;
539 (&result).into_result()539 (&result).to_result()
540 }540 }
541 InternalCall::ToggleSponsoring {541 InternalCall::ToggleSponsoring {
542 contract_address,542 contract_address,
543 enabled,543 enabled,
544 } => {544 } => {
545 let result =545 let result =
546 self.toggle_sponsoring(c.caller.clone(), contract_address, enabled)?;546 self.toggle_sponsoring(c.caller.clone(), contract_address, enabled)?;
547 (&result).into_result()547 (&result).to_result()
548 }548 }
549 InternalCall::SetSponsoringRateLimit {549 InternalCall::SetSponsoringRateLimit {
550 contract_address,550 contract_address,
555 contract_address,555 contract_address,
556 rate_limit,556 rate_limit,
557 )?;557 )?;
558 (&result).into_result()558 (&result).to_result()
559 }559 }
560 InternalCall::GetSponsoringRateLimit { contract_address } => {560 InternalCall::GetSponsoringRateLimit { contract_address } => {
561 let result = self.get_sponsoring_rate_limit(contract_address)?;561 let result = self.get_sponsoring_rate_limit(contract_address)?;
562 (&result).into_result()562 (&result).to_result()
563 }563 }
564 InternalCall::Allowed {564 InternalCall::Allowed {
565 contract_address,565 contract_address,
566 user,566 user,
567 } => {567 } => {
568 let result = self.allowed(contract_address, user)?;568 let result = self.allowed(contract_address, user)?;
569 (&result).into_result()569 (&result).to_result()
570 }570 }
571 InternalCall::AllowlistEnabled { contract_address } => {571 InternalCall::AllowlistEnabled { contract_address } => {
572 let result = self.allowlist_enabled(contract_address)?;572 let result = self.allowlist_enabled(contract_address)?;
573 (&result).into_result()573 (&result).to_result()
574 }574 }
575 InternalCall::ToggleAllowlist {575 InternalCall::ToggleAllowlist {
576 contract_address,576 contract_address,
577 enabled,577 enabled,
578 } => {578 } => {
579 let result =579 let result =
580 self.toggle_allowlist(c.caller.clone(), contract_address, enabled)?;580 self.toggle_allowlist(c.caller.clone(), contract_address, enabled)?;
581 (&result).into_result()581 (&result).to_result()
582 }582 }
583 InternalCall::ToggleAllowed {583 InternalCall::ToggleAllowed {
584 contract_address,584 contract_address,
587 } => {587 } => {
588 let result =588 let result =
589 self.toggle_allowed(c.caller.clone(), contract_address, user, allowed)?;589 self.toggle_allowed(c.caller.clone(), contract_address, user, allowed)?;
590 (&result).into_result()590 (&result).to_result()
591 }591 }
592 _ => ::core::panicking::panic("internal error: entered unreachable code"),592 _ => ::core::panicking::panic("internal error: entered unreachable code"),
593 }593 }
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
2use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};2use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
3use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};3use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
4use pallet_evm::{4use pallet_evm::{ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure};
5 ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput, PrecompileResult,
6 PrecompileFailure,
7};
8use sp_core::H160;5use sp_core::H160;
9use crate::{6use crate::{
161 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {158 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {
162 let limit = <SponsoringRateLimit<T>>::get(&call.0);159 let limit = <SponsoringRateLimit<T>>::get(&call.0);
163160
164 let timeout = last_tx_block + limit.into();161 let timeout = last_tx_block + limit;
165 if block_number < timeout {162 if block_number < timeout {
166 return None;163 return None;
167 }164 }
modifiedpallets/evm-migration/src/weights.rsdiffbeforeafterboth
25#![cfg_attr(rustfmt, rustfmt_skip)]25#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]26#![allow(unused_parens)]
27#![allow(unused_imports)]27#![allow(unused_imports)]
28#![allow(clippy::unnecessary_cast)]
2829
29use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
30use sp_std::marker::PhantomData;31use sp_std::marker::PhantomData;
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
128 let sponsor = frame_support::storage::with_transaction(|| {128 let sponsor = frame_support::storage::with_transaction(|| {
129 TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(129 TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(
130 &who,130 &who,
131 &(target.clone(), input.clone()),131 &(*target, input.clone()),
132 ))132 ))
133 })?;133 })?;
134 let sponsor = T::EvmAddressMapping::into_account_id(sponsor);134 let sponsor = T::EvmAddressMapping::into_account_id(sponsor);
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
116 );116 );
117117
118 with_weight(118 with_weight(
119 <Pallet<T>>::transfer(&self, &from, &to, amount),119 <Pallet<T>>::transfer(self, &from, &to, amount),
120 <CommonWeights<T>>::transfer(),120 <CommonWeights<T>>::transfer(),
121 )121 )
122 }122 }
134 );134 );
135135
136 with_weight(136 with_weight(
137 <Pallet<T>>::set_allowance(&self, &sender, &spender, amount),137 <Pallet<T>>::set_allowance(self, &sender, &spender, amount),
138 <CommonWeights<T>>::approve(),138 <CommonWeights<T>>::approve(),
139 )139 )
140 }140 }
153 );153 );
154154
155 with_weight(155 with_weight(
156 <Pallet<T>>::transfer_from(&self, &sender, &from, &to, amount),156 <Pallet<T>>::transfer_from(self, &sender, &from, &to, amount),
157 <CommonWeights<T>>::transfer_from(),157 <CommonWeights<T>>::transfer_from(),
158 )158 )
159 }159 }
171 );171 );
172172
173 with_weight(173 with_weight(
174 <Pallet<T>>::burn_from(&self, &sender, &from, amount),174 <Pallet<T>>::burn_from(self, &sender, &from, amount),
175 <CommonWeights<T>>::burn_from(),175 <CommonWeights<T>>::burn_from(),
176 )176 )
177 }177 }
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
6use sp_core::{H160, U256};6use sp_core::{H160, U256};
7use sp_std::vec::Vec;7use sp_std::vec::Vec;
8use pallet_common::account::CrossAccountId;8use pallet_common::account::CrossAccountId;
9use pallet_common::erc::PrecompileOutput;
10use pallet_evm_coder_substrate::{call, dispatch_to_evm};9use pallet_evm_coder_substrate::{call, dispatch_to_evm};
1110
12use crate::{11use crate::{
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
303 amount: u128,303 amount: u128,
304 ) -> DispatchResult {304 ) -> DispatchResult {
305 if collection.access == AccessMode::AllowList {305 if collection.access == AccessMode::AllowList {
306 collection.check_allowlist(&owner)?;306 collection.check_allowlist(owner)?;
307 collection.check_allowlist(&spender)?;307 collection.check_allowlist(spender)?;
308 }308 }
309309
310 if <Balance<T>>::get((collection.id, owner)) < amount {310 if <Balance<T>>::get((collection.id, owner)) < amount {
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
25#![cfg_attr(rustfmt, rustfmt_skip)]25#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]26#![allow(unused_parens)]
27#![allow(unused_imports)]27#![allow(unused_imports)]
28#![allow(clippy::unnecessary_cast)]
2829
29use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
30use sp_std::marker::PhantomData;31use sp_std::marker::PhantomData;
3132
32/// Weight functions needed for pallet_fungible.33/// Weight functions needed for pallet_fungible.
33pub trait WeightInfo {34pub trait WeightInfo {
34 fn create_item() -> Weight;35 fn create_item() -> Weight;
35 fn burn_from() -> Weight;
36 fn burn_item() -> Weight;36 fn burn_item() -> Weight;
37 fn transfer() -> Weight;37 fn transfer() -> Weight;
38 fn approve() -> Weight;38 fn approve() -> Weight;
39 fn transfer_from() -> Weight;39 fn transfer_from() -> Weight;
40 fn burn_from() -> Weight;
40}41}
4142
42/// Weights for pallet_fungible using the Substrate node and recommended hardware.43/// Weights for pallet_fungible using the Substrate node and recommended hardware.
modifiedpallets/nft/src/benchmarking.rsdiffbeforeafterboth
158 sponsored_data_size: Some(0),158 sponsored_data_size: Some(0),
159 token_limit: Some(1),159 token_limit: Some(1),
160 sponsor_transfer_timeout: Some(0),160 sponsor_transfer_timeout: Some(0),
161 sponsor_approve_timeout: None,
161 owner_can_destroy: Some(true),162 owner_can_destroy: Some(true),
162 owner_can_transfer: Some(true),163 owner_can_transfer: Some(true),
163 sponsored_data_rate_limit: None,164 sponsored_data_rate_limit: None,
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
195195
196 // Create new collection196 // Create new collection
197 let new_collection = Collection {197 let new_collection = Collection {
198 owner: who.clone(),198 owner: who,
199 name: collection_name,199 name: collection_name,
200 mode: mode.clone(),200 mode: mode.clone(),
201 mint_mode: false,201 mint_mode: false,
modifiedpallets/nft/src/weights.rsdiffbeforeafterboth
25#![cfg_attr(rustfmt, rustfmt_skip)]25#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]26#![allow(unused_parens)]
27#![allow(unused_imports)]27#![allow(unused_imports)]
28#![allow(clippy::unnecessary_cast)]
2829
29use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
30use sp_std::marker::PhantomData;31use sp_std::marker::PhantomData;
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
100 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);100 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
101 if amount == 1 {101 if amount == 1 {
102 with_weight(102 with_weight(
103 <Pallet<T>>::burn(&self, &sender, token),103 <Pallet<T>>::burn(self, &sender, token),
104 <CommonWeights<T>>::burn_item(),104 <CommonWeights<T>>::burn_item(),
105 )105 )
106 } else {106 } else {
118 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);118 ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
119 if amount == 1 {119 if amount == 1 {
120 with_weight(120 with_weight(
121 <Pallet<T>>::transfer(&self, &from, &to, token),121 <Pallet<T>>::transfer(self, &from, &to, token),
122 <CommonWeights<T>>::transfer(),122 <CommonWeights<T>>::transfer(),
123 )123 )
124 } else {124 } else {
137137
138 with_weight(138 with_weight(
139 if amount == 1 {139 if amount == 1 {
140 <Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))140 <Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))
141 } else {141 } else {
142 <Pallet<T>>::set_allowance(&self, &sender, token, None)142 <Pallet<T>>::set_allowance(self, &sender, token, None)
143 },143 },
144 <CommonWeights<T>>::approve(),144 <CommonWeights<T>>::approve(),
145 )145 )
157157
158 if amount == 1 {158 if amount == 1 {
159 with_weight(159 with_weight(
160 <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),160 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token),
161 <CommonWeights<T>>::transfer_from(),161 <CommonWeights<T>>::transfer_from(),
162 )162 )
163 } else {163 } else {
176176
177 if amount == 1 {177 if amount == 1 {
178 with_weight(178 with_weight(
179 <Pallet<T>>::burn_from(&self, &sender, &from, token),179 <Pallet<T>>::burn_from(self, &sender, &from, token),
180 <CommonWeights<T>>::burn_from(),180 <CommonWeights<T>>::burn_from(),
181 )181 )
182 } else {182 } else {
192 ) -> DispatchResultWithPostInfo {192 ) -> DispatchResultWithPostInfo {
193 let len = data.len();193 let len = data.len();
194 with_weight(194 with_weight(
195 <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),195 <Pallet<T>>::set_variable_metadata(self, &sender, token, data),
196 <CommonWeights<T>>::set_variable_metadata(len as u32),196 <CommonWeights<T>>::set_variable_metadata(len as u32),
197 )197 )
198 }198 }
218 }218 }
219 fn const_metadata(&self, token: TokenId) -> Vec<u8> {219 fn const_metadata(&self, token: TokenId) -> Vec<u8> {
220 <TokenData<T>>::get((self.id, token))220 <TokenData<T>>::get((self.id, token))
221 .map(|t| t.const_data.clone())221 .map(|t| t.const_data)
222 .unwrap_or_default()222 .unwrap_or_default()
223 }223 }
224 fn variable_metadata(&self, token: TokenId) -> Vec<u8> {224 fn variable_metadata(&self, token: TokenId) -> Vec<u8> {
225 <TokenData<T>>::get((self.id, token))225 <TokenData<T>>::get((self.id, token))
226 .map(|t| t.variable_data.clone())226 .map(|t| t.variable_data)
227 .unwrap_or_default()227 .unwrap_or_default()
228 }228 }
229229
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
13 erc::{CommonEvmHandler, PrecompileResult},13 erc::{CommonEvmHandler, PrecompileResult},
14};14};
15use pallet_evm_coder_substrate::call;15use pallet_evm_coder_substrate::call;
16use pallet_common::erc::PrecompileOutput;
1716
18use crate::{17use crate::{
19 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,18 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
170 token: TokenId,170 token: TokenId,
171 ) -> DispatchResult {171 ) -> DispatchResult {
172 let token_data = <TokenData<T>>::get((collection.id, token))172 let token_data =
173 .ok_or_else(|| <CommonError<T>>::TokenNotFound)?;173 <TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
174 ensure!(174 ensure!(
175 &token_data.owner == sender175 &token_data.owner == sender
176 || (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),176 || (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),
197 collection.id,197 collection.id,
198 token,198 token,
199 sender.clone(),199 sender.clone(),
200 old_spender.clone(),200 old_spender,
201 0,201 0,
202 ));202 ));
203 }203 }
213 token_data.owner,213 token_data.owner,
214 1,214 1,
215 ));215 ));
216 return Ok(());216 Ok(())
217 }217 }
218218
219 pub fn transfer(219 pub fn transfer(
228 );228 );
229229
230 let token_data = <TokenData<T>>::get((collection.id, token))230 let token_data =
231 .ok_or_else(|| <CommonError<T>>::TokenNotFound)?;231 <TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
232 ensure!(232 ensure!(
233 &token_data.owner == from233 &token_data.owner == from
234 || (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),234 || (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),
399 collection.id,399 collection.id,
400 token,400 token,
401 sender.clone(),401 sender.clone(),
402 old_owner.clone(),402 old_owner,
403 0,403 0,
404 ));404 ));
405 }405 }
429 collection.id,429 collection.id,
430 token,430 token,
431 sender.clone(),431 sender.clone(),
432 old_spender.clone(),432 old_spender,
433 0,433 0,
434 ));434 ));
435 }435 }
443 spender: Option<&T::CrossAccountId>,443 spender: Option<&T::CrossAccountId>,
444 ) -> DispatchResult {444 ) -> DispatchResult {
445 if collection.access == AccessMode::AllowList {445 if collection.access == AccessMode::AllowList {
446 collection.check_allowlist(&sender)?;446 collection.check_allowlist(sender)?;
447 if let Some(spender) = spender {447 if let Some(spender) = spender {
448 collection.check_allowlist(&spender)?;448 collection.check_allowlist(spender)?;
449 }449 }
450 }450 }
451451
491491
492 // =========492 // =========
493493
494 Self::transfer(collection, &from, to, token)?;494 Self::transfer(collection, from, to, token)?;
495 // Allowance is reset in [`transfer`]495 // Allowance is reset in [`transfer`]
496 Ok(())496 Ok(())
497 }497 }
519519
520 // =========520 // =========
521521
522 Self::burn(collection, &from, token)522 Self::burn(collection, from, token)
523 }523 }
524524
525 pub fn set_variable_metadata(525 pub fn set_variable_metadata(
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
25#![cfg_attr(rustfmt, rustfmt_skip)]25#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]26#![allow(unused_parens)]
27#![allow(unused_imports)]27#![allow(unused_imports)]
28#![allow(clippy::unnecessary_cast)]
2829
29use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
30use sp_std::marker::PhantomData;31use sp_std::marker::PhantomData;
33pub trait WeightInfo {34pub trait WeightInfo {
34 fn create_item() -> Weight;35 fn create_item() -> Weight;
35 fn create_multiple_items(b: u32, ) -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;
36 fn burn_from() -> Weight;
37 fn burn_item() -> Weight;37 fn burn_item() -> Weight;
38 fn transfer() -> Weight;38 fn transfer() -> Weight;
39 fn approve() -> Weight;39 fn approve() -> Weight;
40 fn transfer_from() -> Weight;40 fn transfer_from() -> Weight;
41 fn burn_from() -> Weight;
41 fn set_variable_metadata(b: u32, ) -> Weight;42 fn set_variable_metadata(b: u32, ) -> Weight;
42}43}
4344
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
135 amount: u128,135 amount: u128,
136 ) -> DispatchResultWithPostInfo {136 ) -> DispatchResultWithPostInfo {
137 with_weight(137 with_weight(
138 <Pallet<T>>::transfer(&self, &from, &to, token, amount),138 <Pallet<T>>::transfer(self, &from, &to, token, amount),
139 <CommonWeights<T>>::transfer(),139 <CommonWeights<T>>::transfer(),
140 )140 )
141 }141 }
148 amount: u128,148 amount: u128,
149 ) -> DispatchResultWithPostInfo {149 ) -> DispatchResultWithPostInfo {
150 with_weight(150 with_weight(
151 <Pallet<T>>::set_allowance(&self, &sender, &spender, token, amount),151 <Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),
152 <CommonWeights<T>>::approve(),152 <CommonWeights<T>>::approve(),
153 )153 )
154 }154 }
162 amount: u128,162 amount: u128,
163 ) -> DispatchResultWithPostInfo {163 ) -> DispatchResultWithPostInfo {
164 with_weight(164 with_weight(
165 <Pallet<T>>::transfer_from(&self, &sender, &from, &to, token, amount),165 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount),
166 <CommonWeights<T>>::transfer_from(),166 <CommonWeights<T>>::transfer_from(),
167 )167 )
168 }168 }
175 amount: u128,175 amount: u128,
176 ) -> DispatchResultWithPostInfo {176 ) -> DispatchResultWithPostInfo {
177 with_weight(177 with_weight(
178 <Pallet<T>>::burn_from(&self, &sender, &from, token, amount),178 <Pallet<T>>::burn_from(self, &sender, &from, token, amount),
179 <CommonWeights<T>>::burn_from(),179 <CommonWeights<T>>::burn_from(),
180 )180 )
181 }181 }
188 ) -> DispatchResultWithPostInfo {188 ) -> DispatchResultWithPostInfo {
189 let len = data.len();189 let len = data.len();
190 with_weight(190 with_weight(
191 <Pallet<T>>::set_variable_metadata(&self, &sender, token, data),191 <Pallet<T>>::set_variable_metadata(self, &sender, token, data),
192 <CommonWeights<T>>::set_variable_metadata(len as u32),192 <CommonWeights<T>>::set_variable_metadata(len as u32),
193 )193 )
194 }194 }
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
189 <Balance<T>>::remove_prefix((collection.id, token_id), None);189 <Balance<T>>::remove_prefix((collection.id, token_id), None);
190 <Allowance<T>>::remove_prefix((collection.id, token_id), None);190 <Allowance<T>>::remove_prefix((collection.id, token_id), None);
191 // TODO: ERC721 transfer event191 // TODO: ERC721 transfer event
192 return Ok(());192 Ok(())
193 }193 }
194194
195 pub fn burn(195 pub fn burn(
367 collection.check_allowlist(sender)?;367 collection.check_allowlist(sender)?;
368368
369 for item in data.iter() {369 for item in data.iter() {
370 for (user, _) in &item.users {370 for user in item.users.keys() {
371 collection.check_allowlist(&user)?;371 collection.check_allowlist(user)?;
372 }372 }
373 }373 }
374 }374 }
409409
410 let mut balances = BTreeMap::new();410 let mut balances = BTreeMap::new();
411 for data in &data {411 for data in &data {
412 for (owner, _) in &data.users {412 for owner in data.users.keys() {
413 let balance = balances413 let balance = balances
414 .entry(owner)414 .entry(owner)
415 .or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));415 .or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));
483 amount: u128,483 amount: u128,
484 ) -> DispatchResult {484 ) -> DispatchResult {
485 if collection.access == AccessMode::AllowList {485 if collection.access == AccessMode::AllowList {
486 collection.check_allowlist(&sender)?;486 collection.check_allowlist(sender)?;
487 collection.check_allowlist(&spender)?;487 collection.check_allowlist(spender)?;
488 }488 }
489489
490 <PalletCommon<T>>::ensure_correct_receiver(spender)?;490 <PalletCommon<T>>::ensure_correct_receiver(spender)?;
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
25#![cfg_attr(rustfmt, rustfmt_skip)]25#![cfg_attr(rustfmt, rustfmt_skip)]
26#![allow(unused_parens)]26#![allow(unused_parens)]
27#![allow(unused_imports)]27#![allow(unused_imports)]
28#![allow(clippy::unnecessary_cast)]
2829
29use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};30use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
30use sp_std::marker::PhantomData;31use sp_std::marker::PhantomData;
33pub trait WeightInfo {34pub trait WeightInfo {
34 fn create_item() -> Weight;35 fn create_item() -> Weight;
35 fn create_multiple_items(b: u32, ) -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;
36 fn burn_from() -> Weight;
37 fn burn_item_partial() -> Weight;37 fn burn_item_partial() -> Weight;
38 fn burn_item_fully() -> Weight;38 fn burn_item_fully() -> Weight;
39 fn transfer_normal() -> Weight;39 fn transfer_normal() -> Weight;
45 fn transfer_from_creating() -> Weight;45 fn transfer_from_creating() -> Weight;
46 fn transfer_from_removing() -> Weight;46 fn transfer_from_removing() -> Weight;
47 fn transfer_from_creating_removing() -> Weight;47 fn transfer_from_creating_removing() -> Weight;
48 fn burn_from() -> Weight;
48 fn set_variable_metadata(b: u32, ) -> Weight;49 fn set_variable_metadata(b: u32, ) -> Weight;
49}50}
5051
modifiedprimitives/nft/src/lib.rsdiffbeforeafterboth
327 D: ser::Serializer,327 D: ser::Serializer,
328 V: Serialize,328 V: Serialize,
329 {329 {
330 let vec: &Vec<_> = &value;330 (value as &Vec<_>).serialize(serializer)
331 vec.serialize(serializer)
332 }331 }
333332
334 pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>333 pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>
modifiedruntime/src/lib.rsdiffbeforeafterboth
1177 EVM::account_storages(address, H256::from_slice(&tmp[..]))1177 EVM::account_storages(address, H256::from_slice(&tmp[..]))
1178 }1178 }
11791179
1180 #[allow(clippy::redundant_closure)]
1180 fn call(1181 fn call(
1181 from: H160,1182 from: H160,
1182 to: H160,1183 to: H160,
1207 ).map_err(|err| err.into())1208 ).map_err(|err| err.into())
1208 }1209 }
12091210
1211 #[allow(clippy::redundant_closure)]
1210 fn create(1212 fn create(
1211 from: H160,1213 from: H160,
1212 data: Vec<u8>,1214 data: Vec<u8>,