diff --git a/polkadot/xcm/xcm-builder/src/unique_instances/adapter.rs b/polkadot/xcm/xcm-builder/src/unique_instances/adapter.rs index 052638d49e47..ed2a329490cf 100644 --- a/polkadot/xcm/xcm-builder/src/unique_instances/adapter.rs +++ b/polkadot/xcm/xcm-builder/src/unique_instances/adapter.rs @@ -37,10 +37,10 @@ impl TransactAsset where AccountIdConverter: ConvertLocation, Matcher: MatchesInstance, - for<'a> InstanceOps: AssetDefinition - + Create>> - + Transfer> - + Destroy>, + InstanceOps: AssetDefinition + + Create>> + + Transfer> + + Destroy>, { fn deposit_asset(what: &Asset, who: &Location, context: Option<&XcmContext>) -> XcmResult { log::trace!( @@ -55,7 +55,7 @@ where let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; - InstanceOps::create(Owned::new(&who, AssignId(&instance_id))) + InstanceOps::create(Owned::new(who, AssignId(instance_id))) .map_err(|e| XcmError::FailedToTransactAsset(e.into())) } @@ -75,7 +75,7 @@ where let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; - InstanceOps::destroy(&instance_id, IfOwnedBy(&who)) + InstanceOps::destroy(&instance_id, IfOwnedBy(who)) .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; Ok(what.clone().into()) @@ -102,7 +102,7 @@ where let to = AccountIdConverter::convert_location(to) .ok_or(MatchError::AccountIdConversionFailed)?; - InstanceOps::transfer(&instance_id, FromTo(&from, &to)) + InstanceOps::transfer(&instance_id, FromTo(from, to)) .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; Ok(what.clone().into()) @@ -133,7 +133,7 @@ impl Tra AccountIdConverter: ConvertLocation, IdAssignment: asset_ops::IdAssignment, Matcher: MatchesInstance, - for<'a> InstanceCreateOp: Create>, + InstanceCreateOp: Create>, { fn deposit_asset(what: &Asset, who: &Location, context: Option<&XcmContext>) -> XcmResult { log::trace!( @@ -148,7 +148,7 @@ impl Tra let who = AccountIdConverter::convert_location(who) .ok_or(MatchError::AccountIdConversionFailed)?; - InstanceCreateOp::create(Owned::new(&who, instance_id_assignment)) + InstanceCreateOp::create(Owned::new(who, instance_id_assignment)) .map(|_reported_id| ()) .map_err(|e| XcmError::FailedToTransactAsset(e.into())) } diff --git a/polkadot/xcm/xcm-builder/src/unique_instances/derivatives.rs b/polkadot/xcm/xcm-builder/src/unique_instances/derivatives.rs index c911e77958dc..15d106f7aac6 100644 --- a/polkadot/xcm/xcm-builder/src/unique_instances/derivatives.rs +++ b/polkadot/xcm/xcm-builder/src/unique_instances/derivatives.rs @@ -37,16 +37,13 @@ pub struct RegisterDerivativeId { } pub struct RegisterOnCreate(PhantomData<(Registrar, InstanceOps)>); -impl<'a, AccountId, InstanceIdSource, Registrar, InstanceOps> - Create>>> +impl + Create>>> for RegisterOnCreate where Registrar: TryRegisterDerivative, InstanceOps: AssetDefinition - + for<'b> Create< - Instance, - Owned<'b, AccountId, DeriveAndReportId<'b, InstanceIdSource, InstanceOps::Id>>, - >, + + Create>>, { fn create( strategy: Owned>>, @@ -57,7 +54,7 @@ where .. } = strategy; - if Registrar::is_derivative_registered(foreign_asset) { + if Registrar::is_derivative_registered(&foreign_asset) { return Err(DispatchError::Other( "an attempt to register a duplicate of an existing derivative instance", )); @@ -66,7 +63,7 @@ where let instance_id = InstanceOps::create(Owned::new(owner, DeriveAndReportId::from(instance_id_source)))?; - Registrar::try_register_derivative(foreign_asset, &instance_id) + Registrar::try_register_derivative(&foreign_asset, &instance_id) } } @@ -78,11 +75,11 @@ where { type Id = InstanceOps::Id; } -impl<'a, AccountId, Registrar, InstanceOps> Destroy> +impl Destroy> for DeregisterOnDestroy where Registrar: TryDeregisterDerivative, - InstanceOps: for<'b> Destroy>, + InstanceOps: Destroy>, { fn destroy(id: &Self::Id, strategy: IfOwnedBy) -> DispatchResult { if !Registrar::is_derivative(id) { diff --git a/polkadot/xcm/xcm-builder/src/unique_instances/ops.rs b/polkadot/xcm/xcm-builder/src/unique_instances/ops.rs index 1c3e2aa79dd9..ac949529619f 100644 --- a/polkadot/xcm/xcm-builder/src/unique_instances/ops.rs +++ b/polkadot/xcm/xcm-builder/src/unique_instances/ops.rs @@ -61,44 +61,43 @@ where { type Id = InstanceOps::Id; } -impl<'a, StashAccount, InstanceOps> Stash> +impl Stash> for SimpleStash where StashAccount: TypedGet, - InstanceOps: for<'b> Transfer>, + InstanceOps: Transfer>, { fn stash( id: &Self::Id, IfOwnedBy(possible_owner): IfOwnedBy, ) -> DispatchResult { - InstanceOps::transfer(id, FromTo(possible_owner, &StashAccount::get())) + InstanceOps::transfer(id, FromTo(possible_owner, StashAccount::get())) } } -impl<'a, StashAccount, InstanceOps> Restore> +impl Restore> for SimpleStash where StashAccount: TypedGet, - InstanceOps: for<'b> Transfer>, + InstanceOps: Transfer>, { fn restore( id: &Self::Id, IfRestorable(owner): IfRestorable, ) -> DispatchResult { - InstanceOps::transfer(id, FromTo(&StashAccount::get(), owner)) + InstanceOps::transfer(id, FromTo(StashAccount::get(), owner)) } } pub struct RestoreOnCreate(PhantomData); -impl<'a, AccountId, InstanceOps> - Create>> +impl Create>> for RestoreOnCreate where - InstanceOps: for<'b> Restore>, + InstanceOps: Restore>, { fn create(strategy: Owned>) -> DispatchResult { let Owned { owner, id_assignment: AssignId(instance_id), .. } = strategy; - InstanceOps::restore(instance_id, IfRestorable(owner)) + InstanceOps::restore(&instance_id, IfRestorable(owner)) } } @@ -109,12 +108,11 @@ where { type Id = InstanceOps::Id; } -impl<'a, AccountId, InstanceOps> Destroy> - for StashOnDestroy +impl Destroy> for StashOnDestroy where - InstanceOps: for<'b> Stash>, + InstanceOps: Stash>, { - fn destroy(id: &Self::Id, strategy: IfOwnedBy<'a, AccountId>) -> DispatchResult { + fn destroy(id: &Self::Id, strategy: IfOwnedBy) -> DispatchResult { InstanceOps::stash(id, strategy) } } diff --git a/substrate/frame/support/src/traits/tokens/asset_ops.rs b/substrate/frame/support/src/traits/tokens/asset_ops.rs index f196a81502ee..f25d1e8231c8 100644 --- a/substrate/frame/support/src/traits/tokens/asset_ops.rs +++ b/substrate/frame/support/src/traits/tokens/asset_ops.rs @@ -291,18 +291,18 @@ pub mod common_strategies { /// It accepts whatever parameters are set in its generic argument. /// For instance, for an unchecked transfer, /// this strategy may take a reference to a beneficiary account. - pub struct JustDo<'a, Params = ()>(pub &'a Params); - impl<'a> Default for JustDo<'a, ()> { + pub struct JustDo(pub Params); + impl Default for JustDo<()> { fn default() -> Self { - Self(&()) + Self(()) } } - impl<'a, Owner> TransferStrategy for JustDo<'a, Owner> {} - impl<'a> DestroyStrategy for JustDo<'a> { + impl TransferStrategy for JustDo {} + impl DestroyStrategy for JustDo { type Success = (); } - impl<'a> StashStrategy for JustDo<'a> {} - impl<'a, Owner> RestoreStrategy for JustDo<'a, Owner> {} + impl StashStrategy for JustDo {} + impl RestoreStrategy for JustDo {} /// The `Bytes` strategy represents raw metadata bytes. /// It is both an [inspect](MetadataInspectStrategy) and [update](MetadataUpdateStrategy) @@ -459,8 +459,8 @@ pub mod common_strategies { /// It accepts `Params` to assign an ID to the newly created asset. /// This ID assignment approach doesn't report the ID upon the asset's creation. #[derive(RuntimeDebug, PartialEq, Eq, Clone, Encode, Decode, MaxEncodedLen, TypeInfo)] - pub struct AssignId<'a, Params>(pub &'a Params); - impl<'a, Params> IdAssignment for AssignId<'a, Params> { + pub struct AssignId(pub Params); + impl IdAssignment for AssignId { type ReportedId = (); } @@ -475,13 +475,13 @@ pub mod common_strategies { /// An example of ID derivation is the creation of an NFT inside a collection using the /// collection ID as `Params`. The `Id` in this case is the full ID of the NFT. #[derive(RuntimeDebug, PartialEq, Eq, Clone, Encode, Decode, MaxEncodedLen, TypeInfo)] - pub struct DeriveAndReportId<'a, Params, Id>(pub &'a Params, pub PhantomData); - impl<'a, Params, Id> DeriveAndReportId<'a, Params, Id> { - pub fn from(params: &'a Params) -> Self { + pub struct DeriveAndReportId(pub Params, pub PhantomData); + impl DeriveAndReportId { + pub fn from(params: Params) -> Self { Self(params, PhantomData) } } - impl<'a, ParentId, Id> IdAssignment for DeriveAndReportId<'a, ParentId, Id> { + impl IdAssignment for DeriveAndReportId { type ReportedId = Id; } @@ -495,28 +495,24 @@ pub mod common_strategies { /// /// The [`Success`](CreateStrategy::Success) will contain /// the [reported ID](IdAssignment::ReportedId) of the ID assignment approach. - pub struct Owned<'a, Owner, Assignment: IdAssignment, Config = (), Witness = ()> { - pub owner: &'a Owner, + pub struct Owned { + pub owner: Owner, pub id_assignment: Assignment, - pub config: &'a Config, - pub witness: &'a Witness, + pub config: Config, + pub witness: Witness, } - impl<'a, Owner, Assignment: IdAssignment> Owned<'a, Owner, Assignment, (), ()> { - pub fn new(owner: &'a Owner, id_assignment: Assignment) -> Self { - Self { id_assignment, owner, config: &(), witness: &() } + impl Owned { + pub fn new(owner: Owner, id_assignment: Assignment) -> Self { + Self { id_assignment, owner, config: (), witness: () } } } - impl<'a, Owner, Assignment: IdAssignment, Config> Owned<'a, Owner, Assignment, Config, ()> { - pub fn new_configured( - owner: &'a Owner, - id_assignment: Assignment, - config: &'a Config, - ) -> Self { - Self { id_assignment, owner, config, witness: &() } + impl Owned { + pub fn new_configured(owner: Owner, id_assignment: Assignment, config: Config) -> Self { + Self { id_assignment, owner, config, witness: () } } } - impl<'a, Owner, Assignment: IdAssignment, Config, Witness> CreateStrategy - for Owned<'a, Owner, Assignment, Config, Witness> + impl CreateStrategy + for Owned { type Success = Assignment::ReportedId; } @@ -532,30 +528,30 @@ pub mod common_strategies { /// /// The [`Success`](CreateStrategy::Success) will contain /// the [reported ID](IdAssignment::ReportedId) of the ID assignment approach. - pub struct Adminable<'a, Account, Assignment: IdAssignment, Config = (), Witness = ()> { - pub owner: &'a Account, - pub admin: &'a Account, + pub struct Adminable { + pub owner: Account, + pub admin: Account, pub id_assignment: Assignment, - pub config: &'a Config, - pub witness: &'a Witness, + pub config: Config, + pub witness: Witness, } - impl<'a, Account, Assignment: IdAssignment> Adminable<'a, Account, Assignment, (), ()> { - pub fn new(id_assignment: Assignment, owner: &'a Account, admin: &'a Account) -> Self { - Self { id_assignment, owner, admin, config: &(), witness: &() } + impl Adminable { + pub fn new(id_assignment: Assignment, owner: Account, admin: Account) -> Self { + Self { id_assignment, owner, admin, config: (), witness: () } } } - impl<'a, Account, Assignment: IdAssignment, Config> Adminable<'a, Account, Assignment, Config, ()> { + impl Adminable { pub fn new_configured( - owner: &'a Account, - admin: &'a Account, + owner: Account, + admin: Account, id_assignment: Assignment, - config: &'a Config, + config: Config, ) -> Self { - Self { id_assignment, owner, admin, config, witness: &() } + Self { id_assignment, owner, admin, config, witness: () } } } - impl<'a, Account, Assignment: IdAssignment, Config, Witness> CreateStrategy - for Adminable<'a, Account, Assignment, Config, Witness> + impl CreateStrategy + for Adminable { type Success = Assignment::ReportedId; } @@ -563,19 +559,19 @@ pub mod common_strategies { /// The `FromTo` is a [`transfer strategy`](TransferStrategy). /// /// It accepts two parameters: `from` and `to` whom the asset should be transferred. - pub struct FromTo<'a, Owner>(pub &'a Owner, pub &'a Owner); - impl<'a, Owner> TransferStrategy for FromTo<'a, Owner> {} + pub struct FromTo(pub Owner, pub Owner); + impl TransferStrategy for FromTo {} /// The `IfOwnedBy` is both a [`destroy strategy`](DestroyStrategy) /// and a [`stash strategy`](StashStrategy). /// /// It accepts a possible owner of the asset. /// If the provided entity owns the asset, the corresponding operation will be performed. - pub struct IfOwnedBy<'a, Owner>(pub &'a Owner); - impl<'a, Owner> DestroyStrategy for IfOwnedBy<'a, Owner> { + pub struct IfOwnedBy(pub Owner); + impl DestroyStrategy for IfOwnedBy { type Success = (); } - impl<'a, Owner> StashStrategy for IfOwnedBy<'a, Owner> {} + impl StashStrategy for IfOwnedBy {} /// The `IfRestorable` is a [`restore strategy`](RestoreStrategy). /// @@ -583,26 +579,26 @@ pub mod common_strategies { /// For instance, if an asset is restorable, /// this strategy may reference a beneficiary account, /// which should own the asset upon restoration. - pub struct IfRestorable<'a, Params>(pub &'a Params); - impl<'a, Params> RestoreStrategy for IfRestorable<'a, Params> {} + pub struct IfRestorable(pub Params); + impl RestoreStrategy for IfRestorable {} /// The `WithWitness` is a [`destroy strategy`](DestroyStrategy). /// /// It accepts a `Witness` to destroy an asset. /// It will also return a `Witness` value upon destruction. - pub struct WithWitness<'a, Witness>(pub &'a Witness); - impl<'a, Witness> DestroyStrategy for WithWitness<'a, Witness> { + pub struct WithWitness(pub Witness); + impl DestroyStrategy for WithWitness { type Success = Witness; } /// The `IfOwnedByWithWitness` is a [`destroy strategy`](DestroyStrategy). /// /// It is a combination of the [`IfOwnedBy`] and the [`WithWitness`] strategies. - pub struct IfOwnedByWithWitness<'a, Owner, Witness> { - pub owner: &'a Owner, - pub witness: &'a Witness, + pub struct IfOwnedByWithWitness { + pub owner: Owner, + pub witness: Witness, } - impl<'a, Owner, Witness> DestroyStrategy for IfOwnedByWithWitness<'a, Owner, Witness> { + impl DestroyStrategy for IfOwnedByWithWitness { type Success = Witness; } } diff --git a/substrate/frame/uniques/src/impl_asset_ops/class.rs b/substrate/frame/uniques/src/impl_asset_ops/class.rs index f3efbbd79f97..fba000848c07 100644 --- a/substrate/frame/uniques/src/impl_asset_ops/class.rs +++ b/substrate/frame/uniques/src/impl_asset_ops/class.rs @@ -56,8 +56,8 @@ impl<'a, T: Config, I: 'static> InspectMetadata>> } } -impl<'a, T: Config, I: 'static> - Create>> for Pallet +impl, I: 'static> Create>> + for Pallet { fn create(strategy: Adminable>) -> DispatchResult { let Adminable { owner, admin, id_assignment: AssignId(collection), .. } = strategy; @@ -68,32 +68,25 @@ impl<'a, T: Config, I: 'static> admin.clone(), T::CollectionDeposit::get(), false, - Event::Created { - collection: collection.clone(), - creator: owner.clone(), - owner: admin.clone(), - }, + Event::Created { collection, creator: owner, owner: admin }, ) } } -impl<'a, T: Config, I: 'static> - Create< - Class, - WithOrigin>>, - > for Pallet +impl, I: 'static> + Create>>> + for Pallet { fn create( strategy: WithOrigin>>, ) -> DispatchResult { - let WithOrigin( - origin, - creation @ Adminable { owner, id_assignment: AssignId(collection), .. }, - ) = strategy; + let WithOrigin(origin, creation) = strategy; + + let Adminable { owner, id_assignment: AssignId(collection), .. } = &creation; let maybe_check_signer = T::ForceOrigin::try_origin(origin).map(|_| None).or_else(|origin| { - T::CreateOrigin::ensure_origin(origin, &collection) + T::CreateOrigin::ensure_origin(origin, collection) .map(Some) .map_err(DispatchError::from) })?; @@ -106,25 +99,23 @@ impl<'a, T: Config, I: 'static> } } -impl<'a, T: Config, I: 'static> Destroy> - for Pallet -{ +impl, I: 'static> Destroy> for Pallet { fn destroy( collection: &Self::Id, strategy: WithWitness, ) -> Result { let WithWitness(witness) = strategy; - Self::do_destroy_collection(collection.clone(), *witness, None) + Self::do_destroy_collection(collection.clone(), witness, None) } } -impl<'a, T: Config, I: 'static> - Destroy>> for Pallet +impl, I: 'static> + Destroy>> for Pallet { fn destroy( collection: &Self::Id, - strategy: WithOrigin>, + strategy: WithOrigin>, ) -> Result { let WithOrigin(origin, destroy) = strategy; @@ -134,8 +125,8 @@ impl<'a, T: Config, I: 'static> } } -impl<'a, T: Config, I: 'static> - Destroy> for Pallet +impl, I: 'static> Destroy> + for Pallet { fn destroy( collection: &Self::Id, @@ -143,15 +134,13 @@ impl<'a, T: Config, I: 'static> ) -> Result { let IfOwnedByWithWitness { owner, witness } = strategy; - Self::do_destroy_collection(collection.clone(), *witness, Some(owner.clone())) + Self::do_destroy_collection(collection.clone(), witness, Some(owner)) } } -impl<'a, T: Config, I: 'static> - Destroy< - Class, - WithOrigin>, - > for Pallet +impl, I: 'static> + Destroy>> + for Pallet { fn destroy( collection: &Self::Id, @@ -164,9 +153,9 @@ impl<'a, T: Config, I: 'static> }; if let Some(signer) = maybe_check_owner { - ensure!(signer == *owner, Error::::NoPermission); + ensure!(signer == owner, Error::::NoPermission); } - Self::do_destroy_collection(collection.clone(), *witness, Some(owner.clone())) + Self::do_destroy_collection(collection.clone(), witness, Some(owner)) } } diff --git a/substrate/frame/uniques/src/impl_asset_ops/instance.rs b/substrate/frame/uniques/src/impl_asset_ops/instance.rs index ac4cb2443df9..9a41f9685ece 100644 --- a/substrate/frame/uniques/src/impl_asset_ops/instance.rs +++ b/substrate/frame/uniques/src/impl_asset_ops/instance.rs @@ -69,26 +69,22 @@ impl, I: 'static> InspectMetadata for Pallet } } -impl<'a, T: Config, I: 'static> - Create>> - for Pallet +impl, I: 'static> + Create>> for Pallet { fn create( strategy: Owned>, ) -> DispatchResult { let Owned { owner, id_assignment: AssignId((collection, item)), .. } = strategy; - Self::do_mint(collection.clone(), *item, owner.clone(), |_| Ok(())) + Self::do_mint(collection, item, owner, |_| Ok(())) } } -impl<'a, T: Config, I: 'static> +impl, I: 'static> Create< Instance, - WithOrigin< - T::RuntimeOrigin, - Owned<'a, T::AccountId, AssignId<'a, (T::CollectionId, T::ItemId)>>, - >, + WithOrigin>>, > for Pallet { fn create( @@ -102,23 +98,23 @@ impl<'a, T: Config, I: 'static> let signer = ensure_signed(origin)?; - Self::do_mint(collection.clone(), *item, owner.clone(), |collection_details| { + Self::do_mint(collection, item, owner, |collection_details| { ensure!(collection_details.issuer == signer, Error::::NoPermission); Ok(()) }) } } -impl<'a, T: Config, I: 'static> Transfer> for Pallet { +impl, I: 'static> Transfer> for Pallet { fn transfer((collection, item): &Self::Id, strategy: JustDo) -> DispatchResult { let JustDo(dest) = strategy; - Self::do_transfer(collection.clone(), *item, dest.clone(), |_, _| Ok(())) + Self::do_transfer(collection.clone(), *item, dest, |_, _| Ok(())) } } -impl<'a, T: Config, I: 'static> - Transfer>> for Pallet +impl, I: 'static> + Transfer>> for Pallet { fn transfer( (collection, item): &Self::Id, @@ -138,24 +134,24 @@ impl<'a, T: Config, I: 'static> } } -impl<'a, T: Config, I: 'static> Transfer> for Pallet { +impl, I: 'static> Transfer> for Pallet { fn transfer((collection, item): &Self::Id, strategy: FromTo) -> DispatchResult { let FromTo(from, to) = strategy; Self::do_transfer(collection.clone(), *item, to.clone(), |_, details| { - ensure!(details.owner == *from, Error::::WrongOwner); + ensure!(details.owner == from, Error::::WrongOwner); Ok(()) }) } } -impl, I: 'static> Destroy> for Pallet { +impl, I: 'static> Destroy for Pallet { fn destroy((collection, item): &Self::Id, _strategy: JustDo) -> DispatchResult { Self::do_burn(collection.clone(), *item, |_, _| Ok(())) } } -impl<'a, T: Config, I: 'static> Destroy>> +impl, I: 'static> Destroy> for Pallet { fn destroy( @@ -166,23 +162,23 @@ impl<'a, T: Config, I: 'static> Destroy::get(collection, item).ok_or(Error::::UnknownCollection)?; - >::destroy(id, WithOrigin(origin, IfOwnedBy(&details.owner))) + >::destroy(id, WithOrigin(origin, IfOwnedBy(details.owner))) } } -impl<'a, T: Config, I: 'static> Destroy> for Pallet { +impl, I: 'static> Destroy> for Pallet { fn destroy((collection, item): &Self::Id, strategy: IfOwnedBy) -> DispatchResult { let IfOwnedBy(who) = strategy; Self::do_burn(collection.clone(), *item, |_, d| { - ensure!(d.owner == *who, Error::::NoPermission); + ensure!(d.owner == who, Error::::NoPermission); Ok(()) }) } } -impl<'a, T: Config, I: 'static> - Destroy>> for Pallet +impl, I: 'static> + Destroy>> for Pallet { fn destroy( (collection, item): &Self::Id, @@ -195,7 +191,7 @@ impl<'a, T: Config, I: 'static> Self::do_burn(collection.clone(), *item, |collection_details, details| { let is_permitted = collection_details.admin == signer || details.owner == signer; ensure!(is_permitted, Error::::NoPermission); - ensure!(*who == details.owner, Error::::WrongOwner); + ensure!(who == details.owner, Error::::WrongOwner); Ok(()) }) }