difftreelog
ci fix clippy warnings
in: master
13 files changed
Cargo.lockdiffbeforeafterboth5993 "sp-std",5993 "sp-std",5994]5994]59955996[[package]]5997name = "pallet-scheduler"5998version = "3.0.0"5999source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"6000dependencies = [6001 "frame-benchmarking",6002 "frame-support",6003 "frame-system",6004 "log",6005 "parity-scale-codec 2.1.3",6006 "sp-io",6007 "sp-runtime",6008 "sp-std",6009]601059956011[[package]]5996[[package]]6012name = "pallet-scheduler"5997name = "pallet-scheduler"6026 "up-sponsorship",6011 "up-sponsorship",6027]6012]60136014[[package]]6015name = "pallet-scheduler"6016version = "3.0.0"6017source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.3#c94e0cdfe5556680dca1996004751eeb114755d7"6018dependencies = [6019 "frame-benchmarking",6020 "frame-support",6021 "frame-system",6022 "log",6023 "parity-scale-codec 2.1.3",6024 "sp-io",6025 "sp-runtime",6026 "sp-std",6027]602860286029[[package]]6029[[package]]6030name = "pallet-session"6030name = "pallet-session"crates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterboth264 ReturnType::Type(_, ty) => ty,264 ReturnType::Type(_, ty) => ty,265 _ => 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)")),265 _ => 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)")),266 };266 };267 let result = parse_result_ok(&result)?;267 let result = parse_result_ok(result)?;268268269 let camel_name = info269 let camel_name = info270 .rename_selector270 .rename_selector285 Ok(Self {285 Ok(Self {286 name: ident.clone(),286 name: ident.clone(),287 camel_name,287 camel_name,288 pascal_name: snake_ident_to_pascal(&ident),288 pascal_name: snake_ident_to_pascal(ident),289 screaming_name: snake_ident_to_screaming(&ident),289 screaming_name: snake_ident_to_screaming(ident),290 selector_str,290 selector_str,291 selector,291 selector,292 args,292 args,433 found_error = true;433 found_error = true;434 }434 }435 }435 }436 TraitItem::Method(method) => methods.push(Method::try_from(&method)?),436 TraitItem::Method(method) => methods.push(Method::try_from(method)?),437 _ => {}437 _ => {}438 }438 }439 }439 }crates/evm-coder-macros/src/to_log.rsdiffbeforeafterboth41impl Event {41impl Event {42 fn try_from(variant: &Variant) -> syn::Result<Self> {42 fn try_from(variant: &Variant) -> syn::Result<Self> {43 let name = &variant.ident;43 let name = &variant.ident;44 let name_screaming = snake_ident_to_screaming(&name);44 let name_screaming = snake_ident_to_screaming(name);454546 let named = match &variant.fields {46 let named = match &variant.fields {47 Fields::Named(named) => named,47 Fields::Named(named) => named,54 };54 };55 let mut fields = Vec::new();55 let mut fields = Vec::new();56 for field in &named.named {56 for field in &named.named {57 fields.push(EventField::try_from(&field)?);57 fields.push(EventField::try_from(field)?);58 }58 }59 let mut selector_str = format!("{}(", name);59 let mut selector_str = format!("{}(", name);60 for (i, arg) in fields.iter().enumerate() {60 for (i, arg) in fields.iter().enumerate() {crates/evm-coder/src/abi.rsdiffbeforeafterboth104 fn subresult(&mut self) -> Result<AbiReader<'i>> {104 fn subresult(&mut self) -> Result<AbiReader<'i>> {105 let offset = self.read_usize()?;105 let offset = self.read_usize()?;106 Ok(AbiReader {106 Ok(AbiReader {107 buf: &self.buf,107 buf: self.buf,108 offset: offset + self.offset,108 offset: offset + self.offset,109 })109 })110 }110 }252impl_abi_writeable!(&str, string);252impl_abi_writeable!(&str, string);253impl AbiWrite for &string {253impl AbiWrite for &string {254 fn abi_write(&self, writer: &mut AbiWriter) {254 fn abi_write(&self, writer: &mut AbiWriter) {255 writer.string(&self)255 writer.string(self)256 }256 }257}257}258258node/cli/src/cli.rsdiffbeforeafterboth1use crate::chain_spec;1use crate::chain_spec;2use cumulus_client_cli;3use sc_cli;4use std::path::PathBuf;2use std::path::PathBuf;5use structopt::StructOpt;3use structopt::StructOpt;64node/cli/src/command.rsdiffbeforeafterboth120 }120 }121121122 fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {122 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())123 polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)124 .load_spec(id)125 }124 }126125129 }128 }130}129}131130131#[allow(clippy::borrowed_box)]132fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {132fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<Vec<u8>> {133 let mut storage = chain_spec.build_storage()?;133 let mut storage = chain_spec.build_storage()?;134134189 runner.sync_run(|config| {189 runner.sync_run(|config| {190 let polkadot_cli = RelayChainCli::new(190 let polkadot_cli = RelayChainCli::new(191 &config,191 &config,192 [RelayChainCli::executable_name().to_string()]192 [RelayChainCli::executable_name()]193 .iter()193 .iter()194 .chain(cli.relaychain_args.iter()),194 .chain(cli.relaychain_args.iter()),195 );195 );275275276 let polkadot_cli = RelayChainCli::new(276 let polkadot_cli = RelayChainCli::new(277 &config,277 &config,278 [RelayChainCli::executable_name().to_string()]278 [RelayChainCli::executable_name()]279 .iter()279 .iter()280 .chain(cli.relaychain_args.iter()),280 .chain(cli.relaychain_args.iter()),281 );281 );node/cli/src/service.rsdiffbeforeafterboth141141142 let (client, backend, keystore_container, task_manager) =142 let (client, backend, keystore_container, task_manager) =143 sc_service::new_full_parts::<Block, RuntimeApi, Executor>(143 sc_service::new_full_parts::<Block, RuntimeApi, Executor>(144 &config,144 config,145 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),145 telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),146 )?;146 )?;147 let client = Arc::new(client);147 let client = Arc::new(client);pallets/contract-helpers/src/lib.rsdiffbeforeafterboth213 Ok(Some((who.clone(), *code_hash, salt.clone())))213 Ok(Some((who.clone(), *code_hash, salt.clone())))214 }214 }215 Some(pallet_contracts::Call::instantiate_with_code(_, _, code, _, salt)) => {215 Some(pallet_contracts::Call::instantiate_with_code(_, _, code, _, salt)) => {216 let code_hash = &T::Hashing::hash(&code);216 let code_hash = &T::Hashing::hash(code);217 Ok(Some((who.clone(), *code_hash, salt.clone())))217 Ok(Some((who.clone(), *code_hash, salt.clone())))218 }218 }219 _ => Ok(None),219 _ => Ok(None),pallets/nft/src/eth/erc_impl.rsdiffbeforeafterboth114 let to = T::CrossAccountId::from_eth(to);114 let to = T::CrossAccountId::from_eth(to);115 let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;115 let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;116116117 <Module<T>>::transfer_from_internal(&caller, &from, &to, &self, token_id, 1)117 <Module<T>>::transfer_from_internal(&caller, &from, &to, self, token_id, 1)118 .map_err(|_| "transferFrom error")?;118 .map_err(|_| "transferFrom error")?;119 Ok(())119 Ok(())120 }120 }130 let approved = T::CrossAccountId::from_eth(approved);130 let approved = T::CrossAccountId::from_eth(approved);131 let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;131 let token_id = token_id.try_into().map_err(|_| "token_id overflow")?;132132133 <Module<T>>::approve_internal(&caller, &approved, &self, token_id, 1)133 <Module<T>>::approve_internal(&caller, &approved, self, token_id, 1)134 .map_err(|_| "approve internal")?;134 .map_err(|_| "approve internal")?;135 Ok(())135 Ok(())136 }136 }176 let to = T::CrossAccountId::from_eth(to);176 let to = T::CrossAccountId::from_eth(to);177 let token_id = token_id.try_into().map_err(|_| "amount overflow")?;177 let token_id = token_id.try_into().map_err(|_| "amount overflow")?;178178179 <Module<T>>::transfer_internal(&caller, &to, &self, token_id, 1)179 <Module<T>>::transfer_internal(&caller, &to, self, token_id, 1)180 .map_err(|_| "transfer error")?;180 .map_err(|_| "transfer error")?;181 Ok(())181 Ok(())182 }182 }226 let to = T::CrossAccountId::from_eth(to);226 let to = T::CrossAccountId::from_eth(to);227 let amount = amount.try_into().map_err(|_| "amount overflow")?;227 let amount = amount.try_into().map_err(|_| "amount overflow")?;228228229 <Module<T>>::transfer_internal(&caller, &to, &self, 1, amount)229 <Module<T>>::transfer_internal(&caller, &to, self, 1, amount)230 .map_err(|_| "transfer error")?;230 .map_err(|_| "transfer error")?;231 Ok(true)231 Ok(true)232 }232 }242 let to = T::CrossAccountId::from_eth(to);242 let to = T::CrossAccountId::from_eth(to);243 let amount = amount.try_into().map_err(|_| "amount overflow")?;243 let amount = amount.try_into().map_err(|_| "amount overflow")?;244244245 <Module<T>>::transfer_from_internal(&caller, &from, &to, &self, 1, amount)245 <Module<T>>::transfer_from_internal(&caller, &from, &to, self, 1, amount)246 .map_err(|_| "transferFrom error")?;246 .map_err(|_| "transferFrom error")?;247 Ok(true)247 Ok(true)248 }248 }251 let spender = T::CrossAccountId::from_eth(spender);251 let spender = T::CrossAccountId::from_eth(spender);252 let amount = amount.try_into().map_err(|_| "amount overflow")?;252 let amount = amount.try_into().map_err(|_| "amount overflow")?;253253254 <Module<T>>::approve_internal(&caller, &spender, &self, 1, amount)254 <Module<T>>::approve_internal(&caller, &spender, self, 1, amount)255 .map_err(|_| "approve internal")?;255 .map_err(|_| "approve internal")?;256 Ok(true)256 Ok(true)257 }257 }pallets/nft/src/eth/mod.rsdiffbeforeafterboth108 .unwrap_or(false)108 .unwrap_or(false)109 }109 }110 fn get_code(target: &H160) -> Option<Vec<u8>> {110 fn get_code(target: &H160) -> Option<Vec<u8>> {111 map_eth_to_id(&target)111 map_eth_to_id(target)112 .and_then(<CollectionById<T>>::get)112 .and_then(<CollectionById<T>>::get)113 .map(|collection| {113 .map(|collection| {114 match collection.mode {114 match collection.mode {127 input: &[u8],127 input: &[u8],128 value: U256,128 value: U256,129 ) -> Option<PrecompileOutput> {129 ) -> Option<PrecompileOutput> {130 let mut collection = map_eth_to_id(&target)130 let mut collection = map_eth_to_id(target)131 .and_then(|id| <CollectionHandle<T>>::get_with_gas_limit(id, gas_limit))?;131 .and_then(|id| <CollectionHandle<T>>::get_with_gas_limit(id, gas_limit))?;132 let (method_id, input) = AbiReader::new_call(input).unwrap();132 let (method_id, input) = AbiReader::new_call(input).unwrap();133 let result = call_internal(&mut collection, *source, method_id, input, value);133 let result = call_internal(&mut collection, *source, method_id, input, value);pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth132 ) -> Result<Self::LiquidityInfo, pallet_evm::Error<T>> {132 ) -> Result<Self::LiquidityInfo, pallet_evm::Error<T>> {133 let mut who_pays_fee = *who;133 let mut who_pays_fee = *who;134 if let WithdrawReason::Call { target, input } = &reason {134 if let WithdrawReason::Call { target, input } = &reason {135 if let Some(collection_id) = crate::eth::map_eth_to_id(&target) {135 if let Some(collection_id) = crate::eth::map_eth_to_id(target) {136 if let Some(collection) = <CollectionById<T>>::get(collection_id) {136 if let Some(collection) = <CollectionById<T>>::get(collection_id) {137 if let Some(sponsor) = collection.sponsorship.sponsor() {137 if let Some(sponsor) = collection.sponsorship.sponsor() {138 if try_sponsor(who, collection_id, &collection, &input).is_ok() {138 if try_sponsor(who, collection_id, &collection, input).is_ok() {139 who_pays_fee =139 who_pays_fee =140 T::EvmBackwardsAddressMapping::from_account_id(sponsor.clone());140 T::EvmBackwardsAddressMapping::from_account_id(sponsor.clone());141 }141 }pallets/nft/src/lib.rsdiffbeforeafterboth1232 ) -> DispatchResult {1232 ) -> DispatchResult {1233 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1233 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1234 let mut target_collection = Self::get_collection(collection_id)?;1234 let mut target_collection = Self::get_collection(collection_id)?;1235 Self::check_owner_permissions(&target_collection, &sender.as_sub())?;1235 Self::check_owner_permissions(&target_collection, sender.as_sub())?;1236 let old_limits = &target_collection.limits;1236 let old_limits = &target_collection.limits;1237 let chain_limits = ChainLimit::get();1237 let chain_limits = ChainLimit::get();123812381267 owner: &T::CrossAccountId,1267 owner: &T::CrossAccountId,1268 data: CreateItemData,1268 data: CreateItemData,1269 ) -> DispatchResult {1269 ) -> DispatchResult {1270 Self::can_create_items_in_collection(&collection, &sender, &owner, 1)?;1270 Self::can_create_items_in_collection(collection, sender, owner, 1)?;1271 Self::validate_create_item_args(&collection, &data)?;1271 Self::validate_create_item_args(collection, &data)?;1272 Self::create_item_no_validation(&collection, owner, data)?;1272 Self::create_item_no_validation(collection, owner, data)?;127312731274 Ok(())1274 Ok(())1275 }1275 }1283 ) -> DispatchResult {1283 ) -> DispatchResult {1284 target_collection.consume_gas(2000000)?;1284 target_collection.consume_gas(2000000)?;1285 // Limits check1285 // Limits check1286 Self::is_correct_transfer(target_collection, &recipient)?;1286 Self::is_correct_transfer(target_collection, recipient)?;128712871288 // Transfer permissions check1288 // Transfer permissions check1289 ensure!(1289 ensure!(1290 Self::is_item_owner(&sender, target_collection, item_id)1290 Self::is_item_owner(sender, target_collection, item_id)1291 || Self::is_owner_or_admin_permissions(target_collection, &sender),1291 || Self::is_owner_or_admin_permissions(target_collection, sender),1292 Error::<T>::NoPermission1292 Error::<T>::NoPermission1293 );1293 );129412941295 if target_collection.access == AccessMode::WhiteList {1295 if target_collection.access == AccessMode::WhiteList {1296 Self::check_white_list(target_collection, &sender)?;1296 Self::check_white_list(target_collection, sender)?;1297 Self::check_white_list(target_collection, &recipient)?;1297 Self::check_white_list(target_collection, recipient)?;1298 }1298 }129912991300 match target_collection.mode {1300 match target_collection.mode {1305 recipient.clone(),1305 recipient.clone(),1306 )?,1306 )?,1307 CollectionMode::Fungible(_) => {1307 CollectionMode::Fungible(_) => {1308 Self::transfer_fungible(target_collection, value, &sender, &recipient)?1308 Self::transfer_fungible(target_collection, value, sender, recipient)?1309 }1309 }1310 CollectionMode::ReFungible => Self::transfer_refungible(1310 CollectionMode::ReFungible => Self::transfer_refungible(1311 target_collection,1311 target_collection,1336 amount: u128,1336 amount: u128,1337 ) -> DispatchResult {1337 ) -> DispatchResult {1338 collection.consume_gas(2000000)?;1338 collection.consume_gas(2000000)?;1339 Self::token_exists(&collection, item_id)?;1339 Self::token_exists(collection, item_id)?;134013401341 // Transfer permissions check1341 // Transfer permissions check1342 let bypasses_limits = collection.limits.owner_can_transfer1342 let bypasses_limits = collection.limits.owner_can_transfer1343 && Self::is_owner_or_admin_permissions(&collection, &sender);1343 && Self::is_owner_or_admin_permissions(collection, sender);134413441345 let allowance_limit = if bypasses_limits {1345 let allowance_limit = if bypasses_limits {1346 None1346 None1347 } else if let Some(amount) = Self::owned_amount(&sender, &collection, item_id) {1347 } else if let Some(amount) = Self::owned_amount(sender, collection, item_id) {1348 Some(amount)1348 Some(amount)1349 } else {1349 } else {1350 fail!(Error::<T>::NoPermission);1350 fail!(Error::<T>::NoPermission);1351 };1351 };135213521353 if collection.access == AccessMode::WhiteList {1353 if collection.access == AccessMode::WhiteList {1354 Self::check_white_list(&collection, &sender)?;1354 Self::check_white_list(collection, sender)?;1355 Self::check_white_list(&collection, &spender)?;1355 Self::check_white_list(collection, spender)?;1356 }1356 }135713571358 let allowance: u128 = amount1358 let allowance: u128 = amount1412 <Allowances<T>>::get(collection.id, (item_id, from.as_sub(), sender.as_sub()));1412 <Allowances<T>>::get(collection.id, (item_id, from.as_sub(), sender.as_sub()));141314131414 // Limits check1414 // Limits check1415 Self::is_correct_transfer(&collection, &recipient)?;1415 Self::is_correct_transfer(collection, recipient)?;141614161417 // Transfer permissions check1417 // Transfer permissions check1418 ensure!(1418 ensure!(1419 approval >= amount1419 approval >= amount1420 || (collection.limits.owner_can_transfer1420 || (collection.limits.owner_can_transfer1421 && Self::is_owner_or_admin_permissions(&collection, &sender)),1421 && Self::is_owner_or_admin_permissions(collection, sender)),1422 Error::<T>::NoPermission1422 Error::<T>::NoPermission1423 );1423 );142414241425 if collection.access == AccessMode::WhiteList {1425 if collection.access == AccessMode::WhiteList {1426 Self::check_white_list(&collection, &sender)?;1426 Self::check_white_list(collection, sender)?;1427 Self::check_white_list(&collection, &recipient)?;1427 Self::check_white_list(collection, recipient)?;1428 }1428 }142914291430 // Reduce approval by transferred amount or remove if remaining approval drops to 01430 // Reduce approval by transferred amount or remove if remaining approval drops to 0144114411442 match collection.mode {1442 match collection.mode {1443 CollectionMode::NFT => {1443 CollectionMode::NFT => {1444 Self::transfer_nft(&collection, item_id, from.clone(), recipient.clone())?1444 Self::transfer_nft(collection, item_id, from.clone(), recipient.clone())?1445 }1445 }1446 CollectionMode::Fungible(_) => {1446 CollectionMode::Fungible(_) => {1447 Self::transfer_fungible(&collection, amount, &from, &recipient)?1447 Self::transfer_fungible(collection, amount, from, recipient)?1448 }1448 }1449 CollectionMode::ReFungible => Self::transfer_refungible(1449 CollectionMode::ReFungible => Self::transfer_refungible(1450 &collection,1450 collection,1451 item_id,1451 item_id,1452 amount,1452 amount,1453 from.clone(),1453 from.clone(),1473 item_id: TokenId,1473 item_id: TokenId,1474 data: Vec<u8>,1474 data: Vec<u8>,1475 ) -> DispatchResult {1475 ) -> DispatchResult {1476 Self::token_exists(&collection, item_id)?;1476 Self::token_exists(collection, item_id)?;147714771478 ensure!(1478 ensure!(1479 ChainLimit::get().custom_data_limit >= data.len() as u32,1479 ChainLimit::get().custom_data_limit >= data.len() as u32,148214821483 // Modify permissions check1483 // Modify permissions check1484 ensure!(1484 ensure!(1485 Self::is_item_owner(&sender, &collection, item_id)1485 Self::is_item_owner(sender, collection, item_id)1486 || Self::is_owner_or_admin_permissions(&collection, &sender),1486 || Self::is_owner_or_admin_permissions(collection, sender),1487 Error::<T>::NoPermission1487 Error::<T>::NoPermission1488 );1488 );148914891490 match collection.mode {1490 match collection.mode {1491 CollectionMode::NFT => Self::set_nft_variable_data(&collection, item_id, data)?,1491 CollectionMode::NFT => Self::set_nft_variable_data(collection, item_id, data)?,1492 CollectionMode::ReFungible => {1492 CollectionMode::ReFungible => {1493 Self::set_re_fungible_variable_data(&collection, item_id, data)?1493 Self::set_re_fungible_variable_data(collection, item_id, data)?1494 }1494 }1495 CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),1495 CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),1496 _ => fail!(Error::<T>::UnexpectedCollectionType),1496 _ => fail!(Error::<T>::UnexpectedCollectionType),1506 items_data: Vec<CreateItemData>,1506 items_data: Vec<CreateItemData>,1507 ) -> DispatchResult {1507 ) -> DispatchResult {1508 Self::can_create_items_in_collection(1508 Self::can_create_items_in_collection(collection, sender, owner, items_data.len() as u32)?;1509 &collection,1510 &sender,1511 &owner,1512 items_data.len() as u32,1513 )?;151415091515 for data in &items_data {1510 for data in &items_data {1516 Self::validate_create_item_args(&collection, data)?;1511 Self::validate_create_item_args(collection, data)?;1517 }1512 }1518 for data in &items_data {1513 for data in &items_data {1519 Self::create_item_no_validation(&collection, owner, data.clone())?;1514 Self::create_item_no_validation(collection, owner, data.clone())?;1520 }1515 }152115161522 Ok(())1517 Ok(())1529 value: u128,1524 value: u128,1530 ) -> DispatchResult {1525 ) -> DispatchResult {1531 ensure!(1526 ensure!(1532 Self::is_item_owner(&sender, &collection, item_id)1527 Self::is_item_owner(sender, collection, item_id)1533 || (collection.limits.owner_can_transfer1528 || (collection.limits.owner_can_transfer1534 && Self::is_owner_or_admin_permissions(&collection, &sender)),1529 && Self::is_owner_or_admin_permissions(collection, sender)),1535 Error::<T>::NoPermission1530 Error::<T>::NoPermission1536 );1531 );153715321538 if collection.access == AccessMode::WhiteList {1533 if collection.access == AccessMode::WhiteList {1539 Self::check_white_list(&collection, &sender)?;1534 Self::check_white_list(collection, sender)?;1540 }1535 }154115361542 match collection.mode {1537 match collection.mode {1543 CollectionMode::NFT => Self::burn_nft_item(&collection, item_id)?,1538 CollectionMode::NFT => Self::burn_nft_item(collection, item_id)?,1544 CollectionMode::Fungible(_) => Self::burn_fungible_item(&sender, &collection, value)?,1539 CollectionMode::Fungible(_) => Self::burn_fungible_item(sender, collection, value)?,1545 CollectionMode::ReFungible => {1540 CollectionMode::ReFungible => Self::burn_refungible_item(collection, item_id, sender)?,1546 Self::burn_refungible_item(&collection, item_id, &sender)?1547 }1548 _ => (),1541 _ => (),1549 };1542 };155015431557 address: &T::CrossAccountId,1550 address: &T::CrossAccountId,1558 whitelisted: bool,1551 whitelisted: bool,1559 ) -> DispatchResult {1552 ) -> DispatchResult {1560 Self::check_owner_or_admin_permissions(&collection, &sender)?;1553 Self::check_owner_or_admin_permissions(collection, sender)?;156115541562 if whitelisted {1555 if whitelisted {1563 <WhiteList<T>>::insert(collection.id, address.as_sub(), true);1556 <WhiteList<T>>::insert(collection.id, address.as_sub(), true);1610 Error::<T>::AccountTokenLimitExceeded1603 Error::<T>::AccountTokenLimitExceeded1611 );1604 );161216051613 if !Self::is_owner_or_admin_permissions(collection, &sender) {1606 if !Self::is_owner_or_admin_permissions(collection, sender) {1614 ensure!(collection.mint_mode, Error::<T>::PublicMintingNotAllowed);1607 ensure!(collection.mint_mode, Error::<T>::PublicMintingNotAllowed);1615 Self::check_white_list(collection, owner)?;1608 Self::check_white_list(collection, owner)?;1616 Self::check_white_list(collection, sender)?;1609 Self::check_white_list(collection, sender)?;1691 Self::add_nft_item(collection, item)?;1684 Self::add_nft_item(collection, item)?;1692 }1685 }1693 CreateItemData::Fungible(data) => {1686 CreateItemData::Fungible(data) => {1694 Self::add_fungible_item(collection, &owner, data.value)?;1687 Self::add_fungible_item(collection, owner, data.value)?;1695 }1688 }1696 CreateItemData::ReFungible(data) => {1689 CreateItemData::ReFungible(data) => {1697 let owner_list = vec![Ownership {1690 let owner_list = vec![Ownership {1934 subject: &T::CrossAccountId,1927 subject: &T::CrossAccountId,1935 ) -> bool {1928 ) -> bool {1936 *subject.as_sub() == collection.owner1929 *subject.as_sub() == collection.owner1937 || <AdminList<T>>::get(collection.id).contains(&subject)1930 || <AdminList<T>>::get(collection.id).contains(subject)1938 }1931 }193919321940 fn check_owner_or_admin_permissions(1933 fn check_owner_or_admin_permissions(1979 ) -> bool {1972 ) -> bool {1980 match target_collection.mode {1973 match target_collection.mode {1981 CollectionMode::Fungible(_) => true,1974 CollectionMode::Fungible(_) => true,1982 _ => Self::owned_amount(&subject, target_collection, item_id).is_some(),1975 _ => Self::owned_amount(subject, target_collection, item_id).is_some(),1983 }1976 }1984 }1977 }19851978pallets/nft/src/sponsorship.rsdiffbeforeafterboth179{179{180 fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {180 fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {181 match IsSubType::<Call<T>>::is_sub_type(call)? {181 match IsSubType::<Call<T>>::is_sub_type(call)? {182 Call::create_item(collection_id, _owner, _properties) => {182 Call::create_item(collection_id, _owner, properties) => {183 Self::withdraw_create_item(who, collection_id, &_properties)183 Self::withdraw_create_item(who, collection_id, properties)184 }184 }185 Call::transfer(_new_owner, collection_id, item_id, _value) => {185 Call::transfer(_new_owner, collection_id, item_id, _value) => {186 Self::withdraw_transfer(who, collection_id, item_id)186 Self::withdraw_transfer(who, collection_id, item_id)187 }187 }188 Call::set_variable_meta_data(collection_id, item_id, data) => {188 Call::set_variable_meta_data(collection_id, item_id, data) => {189 Self::withdraw_set_variable_meta_data(collection_id, item_id, &data)189 Self::withdraw_set_variable_meta_data(collection_id, item_id, data)190 }190 }191 _ => None,191 _ => None,192 }192 }