git.delta.rocks / unique-network / refs/commits / 8d05c70ee567

difftreelog

fix clippy warnings

Grigoriy Simonov2023-06-07parent: #cf59f49.patch.diff
in: master

9 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
328macro_rules! pass_method {328macro_rules! pass_method {
329 (329 (
330 $method_name:ident(330 $method_name:ident(
331 $($(#[map(|$map_arg:ident| $map:expr)])? $name:ident: $ty:ty),* $(,)?331 $($(#[map = $map:expr])? $name:ident: $ty:ty),* $(,)?
332 ) -> $result:ty $(=> $mapper:expr)?,332 ) -> $result:ty $(=> $mapper:expr)?,
333 //$runtime_name:ident $(<$($lt: tt),+>)*333 //$runtime_name:ident $(<$($lt: tt),+>)*
334 $runtime_api_macro:ident334 $runtime_api_macro:ident
355 let result = $(if _api_version < $ver {355 let result = $(if _api_version < $ver {
356 api.$changed_method_name(at, $($changed_name),*).map(|r| r.and_then($fixer))356 api.$changed_method_name(at, $($changed_name),*).map(|r| r.and_then($fixer))
357 } else)*357 } else)*
358 { api.$method_name(at, $($((|$map_arg: $ty| $map))? ($name)),*) };358 { api.$method_name(at, $($($map)? ($name)),*) };
359359
360 Ok(result360 Ok(result
361 .map_err(|e| anyhow!("unable to query: {e}"))?361 .map_err(|e| anyhow!("unable to query: {e}"))?
413 pass_method!(collection_properties(413 pass_method!(collection_properties(
414 collection: CollectionId,414 collection: CollectionId,
415415
416 #[map(|keys| string_keys_to_bytes_keys(keys))]416 #[map = string_keys_to_bytes_keys]
417 keys: Option<Vec<String>>417 keys: Option<Vec<String>>
418 ) -> Vec<Property>, unique_api);418 ) -> Vec<Property>, unique_api);
419419
420 pass_method!(token_properties(420 pass_method!(token_properties(
421 collection: CollectionId,421 collection: CollectionId,
422 token_id: TokenId,422 token_id: TokenId,
423423
424 #[map(|keys| string_keys_to_bytes_keys(keys))]424 #[map = string_keys_to_bytes_keys]
425 keys: Option<Vec<String>>425 keys: Option<Vec<String>>
426 ) -> Vec<Property>, unique_api);426 ) -> Vec<Property>, unique_api);
427427
428 pass_method!(property_permissions(428 pass_method!(property_permissions(
429 collection: CollectionId,429 collection: CollectionId,
430430
431 #[map(|keys| string_keys_to_bytes_keys(keys))]431 #[map = string_keys_to_bytes_keys]
432 keys: Option<Vec<String>>432 keys: Option<Vec<String>>
433 ) -> Vec<PropertyKeyPermission>, unique_api);433 ) -> Vec<PropertyKeyPermission>, unique_api);
434434
437 collection: CollectionId,437 collection: CollectionId,
438 token_id: TokenId,438 token_id: TokenId,
439439
440 #[map(|keys| string_keys_to_bytes_keys(keys))]440 #[map = string_keys_to_bytes_keys]
441 keys: Option<Vec<String>>,441 keys: Option<Vec<String>>,
442 ) -> TokenData<CrossAccountId>, unique_api;442 ) -> TokenData<CrossAccountId>, unique_api;
443 changed_in 3, token_data_before_version_3(collection, token_id, string_keys_to_bytes_keys(keys)) => |value| Ok(value.into())443 changed_in 3, token_data_before_version_3(collection, token_id, string_keys_to_bytes_keys(keys)) => |value| Ok(value.into())
modifiednode/cli/src/command.rsdiffbeforeafterboth
531 debug!("Parachain genesis block: {:?}", block);531 debug!("Parachain genesis block: {:?}", block);
532 info!(532 info!(
533 "Is collating: {}",533 "Is collating: {}",
534 config.role.is_authority().then_some("yes").unwrap_or("no")534 if config.role.is_authority() {
535 "yes"
536 } else {
537 "no"
538 }
535 );539 );
536540
537 start_node_using_chain_runtime! {541 start_node_using_chain_runtime! {
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
30//!30//!
31//!31//!
32//! ## Interface32//! ## Interface
33//! The pallet provides interfaces for funds, collection/contract operations (see [types] module).33//! The pallet provides interfaces for funds, collection/contract operations (see [types] module).
3434
35//!35//!
36//! ### Dispatchable Functions36//! ### Dispatchable Functions
37//! - [`set_admin_address`][`Pallet::set_admin_address`] - sets an address as the the admin.37//! - [`set_admin_address`][`Pallet::set_admin_address`] - sets an address as the the admin.
38//! - [`stake`][`Pallet::stake`] - stakes the amount of native tokens.38//! - [`stake`][`Pallet::stake`] - stakes the amount of native tokens.
39//! - [`unstake`][`Pallet::unstake`] - unstakes all stakes.39//! - [`unstake`][`Pallet::unstake`] - unstakes all stakes.
40//! - [`sponsor_collection`][`Pallet::sponsor_collection`] - sets the pallet to be the sponsor for the collection.40//! - [`sponsor_collection`][`Pallet::sponsor_collection`] - sets the pallet to be the sponsor for the collection.
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
73//!73//!
74//! - [`WithRecorder`](pallet_evm_coder_substrate::WithRecorder): Trait for EVM support74//! - [`WithRecorder`](pallet_evm_coder_substrate::WithRecorder): Trait for EVM support
75//! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing with collections75//! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing with collections
76//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight76//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight
77//! - [`CommonEvmHandler`](pallet_common::erc::CommonEvmHandler): Function for handling EVM runtime calls77//! - [`CommonEvmHandler`](pallet_common::erc::CommonEvmHandler): Function for handling EVM runtime calls
7878
79#![cfg_attr(not(feature = "std"), no_std)]79#![cfg_attr(not(feature = "std"), no_std)]
728 /// Transfer fungible tokens from one account to another.728 /// Transfer fungible tokens from one account to another.
729 /// Same as the [`transfer`][`Pallet::transfer`] but spender doesn't needs to be an owner of the token pieces.729 /// Same as the [`transfer`][`Pallet::transfer`] but spender doesn't needs to be an owner of the token pieces.
730 /// The owner should set allowance for the spender to transfer pieces.730 /// The owner should set allowance for the spender to transfer pieces.
731 /// See [`set_allowance`][`Pallet::set_allowance`] for more details.731 /// See [`set_allowance`][`Pallet::set_allowance`] for more details.
732 pub fn transfer_from(732 pub fn transfer_from(
733 collection: &FungibleHandle<T>,733 collection: &FungibleHandle<T>,
734 spender: &T::CrossAccountId,734 spender: &T::CrossAccountId,
778 Ok(())778 Ok(())
779 }779 }
780780
781 /// Creates fungible token.781 /// Creates fungible token.
782 ///782 ///
783 /// The sender should be the owner/admin of the collection or collection should be configured783 /// The sender should be the owner/admin of the collection or collection should be configured
784 /// to allow public minting.784 /// to allow public minting.
799 )799 )
800 }800 }
801801
802 /// Creates fungible token.802 /// Creates fungible token.
803 ///803 ///
804 /// - `data`: Contains user who will become the owners of the tokens and amount804 /// - `data`: Contains user who will become the owners of the tokens and amount
805 /// of tokens he will receive.805 /// of tokens he will receive.
modifiedpallets/identity/src/lib.rsdiffbeforeafterboth
95mod types;95mod types;
96pub mod weights;96pub mod weights;
9797
98use frame_support::traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency};98use frame_support::{
99 traits::{BalanceStatus, Currency, OnUnbalanced, ReservableCurrency},
100};
99use sp_runtime::traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero};101use sp_runtime::{
102 BoundedVec,
103 traits::{AppendZerosInput, Hash, Saturating, StaticLookup, Zero},
104};
100use sp_std::prelude::*;105use sp_std::prelude::*;
101pub use weights::WeightInfo;106pub use weights::WeightInfo;
102107
112 <T as frame_system::Config>::AccountId,117 <T as frame_system::Config>::AccountId,
113>>::NegativeImbalance;118>>::NegativeImbalance;
114type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;119type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
120type RegistrarInfoOf<T> = RegistrarInfo<BalanceOf<T>, <T as frame_system::Config>::AccountId>;
121type RegistrationOf<T> =
122 Registration<BalanceOf<T>, <T as Config>::MaxRegistrars, <T as Config>::MaxAdditionalFields>;
123type SubAccounts<T> =
124 sp_runtime::BoundedVec<<T as frame_system::Config>::AccountId, <T as Config>::MaxSubAccounts>;
125type SubAccountsByAccountId<T> = (
126 <T as frame_system::Config>::AccountId,
127 (
128 BalanceOf<T>,
129 BoundedVec<(<T as frame_system::Config>::AccountId, Data), <T as Config>::MaxSubAccounts>,
130 ),
131);
115132
116#[frame_support::pallet]133#[frame_support::pallet]
117pub mod pallet {134pub mod pallet {
199 #[pallet::storage]216 #[pallet::storage]
200 #[pallet::getter(fn subs_of)]217 #[pallet::getter(fn subs_of)]
201 pub(super) type SubsOf<T: Config> = StorageMap<218 pub(super) type SubsOf<T: Config> =
202 _,219 StorageMap<_, Twox64Concat, T::AccountId, (BalanceOf<T>, SubAccounts<T>), ValueQuery>;
203 Twox64Concat,
204 T::AccountId,
205 (BalanceOf<T>, BoundedVec<T::AccountId, T::MaxSubAccounts>),
206 ValueQuery,
207 >;
208220
209 /// The set of registrars. Not expected to get very big as can only be added through a221 /// The set of registrars. Not expected to get very big as can only be added through a
213 #[pallet::storage]225 #[pallet::storage]
214 #[pallet::getter(fn registrars)]226 #[pallet::getter(fn registrars)]
215 pub(super) type Registrars<T: Config> = StorageValue<227 pub(super) type Registrars<T: Config> =
216 _,228 StorageValue<_, BoundedVec<Option<RegistrarInfoOf<T>>, T::MaxRegistrars>, ValueQuery>;
217 BoundedVec<Option<RegistrarInfo<BalanceOf<T>, T::AccountId>>, T::MaxRegistrars>,
218 ValueQuery,
219 >;
220229
221 #[pallet::error]230 #[pallet::error]
482 .all(|i| i.0 == sender);491 .all(|i| i.0 == sender);
483 ensure!(not_other_sub, Error::<T>::AlreadyClaimed);492 ensure!(not_other_sub, Error::<T>::AlreadyClaimed);
484493
485 if old_deposit < new_deposit {494 match old_deposit.cmp(&new_deposit) {
486 T::Currency::reserve(&sender, new_deposit - old_deposit)?;495 core::cmp::Ordering::Less => {
496 T::Currency::reserve(&sender, new_deposit - old_deposit)?
497 }
498 core::cmp::Ordering::Equal => { /* do nothing if they're equal. */ }
487 } else if old_deposit > new_deposit {499 core::cmp::Ordering::Greater => {
488 let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);500 let err_amount = T::Currency::unreserve(&sender, old_deposit - new_deposit);
489 debug_assert!(err_amount.is_zero());501 debug_assert!(err_amount.is_zero());
490 }502 }
491 // do nothing if they're equal.503 }
492504
493 for s in old_ids.iter() {505 for s in old_ids.iter() {
494 <SuperOf<T>>::remove(s);506 <SuperOf<T>>::remove(s);
495 }507 }
496 let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();508 let mut ids = <SubAccounts<T>>::default();
497 for (id, name) in subs {509 for (id, name) in subs {
498 <SuperOf<T>>::insert(&id, (sender.clone(), name));510 <SuperOf<T>>::insert(&id, (sender.clone(), name));
499 ids.try_push(id)511 ids.try_push(id)
1107 ))]1119 ))]
1108 pub fn force_insert_identities(1120 pub fn force_insert_identities(
1109 origin: OriginFor<T>,1121 origin: OriginFor<T>,
1110 identities: Vec<(1122 identities: Vec<(T::AccountId, RegistrationOf<T>)>,
1111 T::AccountId,
1112 Registration<BalanceOf<T>, T::MaxRegistrars, T::MaxAdditionalFields>,
1113 )>,
1114 ) -> DispatchResult {1123 ) -> DispatchResult {
1115 T::ForceOrigin::ensure_origin(origin)?;1124 T::ForceOrigin::ensure_origin(origin)?;
1162 ))]1171 ))]
1163 pub fn force_set_subs(1172 pub fn force_set_subs(
1164 origin: OriginFor<T>,1173 origin: OriginFor<T>,
1165 subs: Vec<(1174 subs: Vec<SubAccountsByAccountId<T>>,
1166 T::AccountId,
1167 (
1168 BalanceOf<T>,
1169 BoundedVec<(T::AccountId, Data), T::MaxSubAccounts>,
1170 ),
1171 )>,
1172 ) -> DispatchResult {1175 ) -> DispatchResult {
1173 T::ForceOrigin::ensure_origin(origin)?;1176 T::ForceOrigin::ensure_origin(origin)?;
1174 for identity in subs.clone() {1177 for identity in subs.clone() {
1178 <SuperOf<T>>::remove(old_sub);1181 <SuperOf<T>>::remove(old_sub);
1179 }1182 }
11801183
1181 let mut ids = BoundedVec::<T::AccountId, T::MaxSubAccounts>::default();1184 let mut ids = <SubAccounts<T>>::default();
1182 for (id, name) in identity.1 .1 {1185 for (id, name) in identity.1 .1 {
1183 <SuperOf<T>>::insert(&id, (account.clone(), name));1186 <SuperOf<T>>::insert(&id, (account.clone(), name));
1184 ids.try_push(id)1187 ids.try_push(id)
modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
26//!26//!
27//! * `start_inflation` - This method sets the inflation start date. Can be only called once.27//! * `start_inflation` - This method sets the inflation start date. Can be only called once.
28//! Inflation start block can be backdated and will catch up. The method will create Treasury28//! Inflation start block can be backdated and will catch up. The method will create Treasury
29//! account if it does not exist and perform the first inflation deposit.29//! account if it does not exist and perform the first inflation deposit.
3030
31// #![recursion_limit = "1024"]31// #![recursion_limit = "1024"]
32#![cfg_attr(not(feature = "std"), no_std)]32#![cfg_attr(not(feature = "std"), no_std)]
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
90use crate::erc_token::ERC20Events;90use crate::erc_token::ERC20Events;
91use crate::erc::ERC721Events;91use crate::erc::ERC721Events;
9292
93use core::ops::Deref;93use core::{ops::Deref, cmp::Ordering};
94use evm_coder::ToLog;94use evm_coder::ToLog;
95use frame_support::{ensure, storage::with_transaction, transactional};95use frame_support::{ensure, storage::with_transaction, transactional};
96use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};96use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
1266 <Balance<T>>::insert((collection.id, token, owner), amount);1266 <Balance<T>>::insert((collection.id, token, owner), amount);
1267 <TotalSupply<T>>::insert((collection.id, token), amount);1267 <TotalSupply<T>>::insert((collection.id, token), amount);
12681268
1269 if amount > total_pieces {1269 match total_pieces.cmp(&amount) {
1270 Ordering::Less => {
1270 let mint_amount = amount - total_pieces;1271 let mint_amount = amount - total_pieces;
1271 <PalletEvm<T>>::deposit_log(1272 <PalletEvm<T>>::deposit_log(
1272 ERC20Events::Transfer {1273 ERC20Events::Transfer {
1285 owner.clone(),1286 owner.clone(),
1286 mint_amount,1287 mint_amount,
1287 ));1288 ));
1288 } else if total_pieces > amount {1289 }
1290 Ordering::Greater => {
1289 let burn_amount = total_pieces - amount;1291 let burn_amount = total_pieces - amount;
1290 <PalletEvm<T>>::deposit_log(1292 <PalletEvm<T>>::deposit_log(
1291 ERC20Events::Transfer {1293 ERC20Events::Transfer {
1305 burn_amount,1307 burn_amount,
1306 ));1308 ));
1307 }1309 }
1310 Ordering::Equal => {}
1311 }
13081312
1309 Ok(())1313 Ok(())
1310 }1314 }
modifiedruntime/common/ethereum/precompiles/utils/macro/src/lib.rsdiffbeforeafterboth
35/// ```ignore35/// ```ignore
36/// #[generate_function_selector]36/// #[generate_function_selector]
37/// enum Action {37/// enum Action {
38/// Toto = "toto()",38/// Toto = "toto()",
39/// Tata = "tata()",39/// Tata = "tata()",
40/// }40/// }
41/// ```41/// ```
42///42///
45/// ```rust45/// ```rust
46/// #[repr(u32)]46/// #[repr(u32)]
47/// enum Action {47/// enum Action {
48/// Toto = 119097542u32,48/// Toto = 119097542u32,
49/// Tata = 1414311903u32,49/// Tata = 1414311903u32,
50/// }50/// }
51/// ```51/// ```
52///52///
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
687 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {687 fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
688 log::info!("try-runtime::on_runtime_upgrade unique-chain.");688 log::info!("try-runtime::on_runtime_upgrade unique-chain.");
689 let weight = Executive::try_runtime_upgrade(checks).unwrap();689 let weight = Executive::try_runtime_upgrade(checks).unwrap();
690 (weight, crate::config::substrate::RuntimeBlockWeights::get().max_block)690 (weight, $crate::config::substrate::RuntimeBlockWeights::get().max_block)
691 }691 }
692692
693 fn execute_block(693 fn execute_block(