difftreelog
fmt
in: master
3 files changed
pallets/app-promotion/src/types.rsdiffbeforeafterboth1use codec::EncodeLike;2use frame_support::{traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult};34use pallet_balances::{BalanceLock, Config as BalancesConfig, Pallet as PalletBalances};5use pallet_common::CollectionHandle;67use sp_runtime::DispatchError;8use up_data_structs::{CollectionId};9use sp_std::borrow::ToOwned;10use pallet_evm_contract_helpers::{Pallet as EvmHelpersPallet, Config as EvmHelpersConfig};1112/// This trait was defined because `LockableCurrency`13/// has no way to know the state of the lock for an account.14pub trait ExtendedLockableCurrency<AccountId: Parameter>: LockableCurrency<AccountId> {15 /// Returns lock balance for ID. Allows to determine the cause of the lock.16 fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>17 where18 KArg: EncodeLike<AccountId>;19}2021impl<T: BalancesConfig<I>, I: 'static> ExtendedLockableCurrency<T::AccountId>22 for PalletBalances<T, I>23{24 fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>25 where26 KArg: EncodeLike<T::AccountId>,27 {28 Self::locks(who)29 }30}31/// Trait for interacting with collections.32pub trait CollectionHandler {33 type CollectionId;34 type AccountId;3536 /// Sets sponsor for a collection.37 ///38 /// - `sponsor_id`: ID of the account of the sponsor-to-be.39 /// - `collection_id`: ID of the modified collection.40 fn set_sponsor(41 sponsor_id: Self::AccountId,42 collection_id: Self::CollectionId,43 ) -> DispatchResult;4445 /// Removes sponsor for a collection.46 ///47 /// - `collection_id`: ID of the modified collection.48 fn remove_collection_sponsor(collection_id: Self::CollectionId) -> DispatchResult;4950 /// Retuns the current sponsor for a collection if one is set.51 ///52 /// - `collection_id`: ID of the collection.53 fn sponsor(collection_id: Self::CollectionId)54 -> Result<Option<Self::AccountId>, DispatchError>;55}5657impl<T: pallet_unique::Config> CollectionHandler for pallet_unique::Pallet<T> {58 type CollectionId = CollectionId;5960 type AccountId = T::AccountId;6162 fn set_sponsor(63 sponsor_id: Self::AccountId,64 collection_id: Self::CollectionId,65 ) -> DispatchResult {66 Self::force_set_sponsor(sponsor_id, collection_id)67 }6869 fn remove_collection_sponsor(collection_id: Self::CollectionId) -> DispatchResult {70 Self::force_remove_collection_sponsor(collection_id)71 }7273 fn sponsor(74 collection_id: Self::CollectionId,75 ) -> Result<Option<Self::AccountId>, DispatchError> {76 Ok(<CollectionHandle<T>>::try_get(collection_id)?77 .sponsorship78 .sponsor()79 .map(|acc| acc.to_owned()))80 }81}82/// Trait for interacting with contracts.83pub trait ContractHandler {84 type ContractId;85 type AccountId;8687 /// Sets sponsor for a contract.88 ///89 /// - `sponsor_id`: ID of the account of the sponsor-to-be.90 /// - `contract_address`: ID of the modified contract.91 fn set_sponsor(92 sponsor_id: Self::AccountId,93 contract_address: Self::ContractId,94 ) -> DispatchResult;95 96 /// Removes sponsor for a contract.97 ///98 /// - `contract_address`: ID of the modified contract.99 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult;100101 /// Retuns the current sponsor for a contract if one is set.102 ///103 /// - `contract_address`: ID of the contract.104 fn sponsor(105 contract_address: Self::ContractId,106 ) -> Result<Option<Self::AccountId>, DispatchError>;107}108109impl<T: EvmHelpersConfig> ContractHandler for EvmHelpersPallet<T> {110 type ContractId = sp_core::H160;111112 type AccountId = T::CrossAccountId;113114 fn set_sponsor(115 sponsor_id: Self::AccountId,116 contract_address: Self::ContractId,117 ) -> DispatchResult {118 Self::force_set_sponsor(contract_address, &sponsor_id)119 }120121 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult {122 Self::force_remove_sponsor(contract_address)123 }124125 fn sponsor(126 contract_address: Self::ContractId,127 ) -> Result<Option<Self::AccountId>, DispatchError> {128 Ok(Self::get_sponsor(contract_address))129 }130}1use codec::EncodeLike;2use frame_support::{traits::LockableCurrency, WeakBoundedVec, Parameter, dispatch::DispatchResult};34use pallet_balances::{BalanceLock, Config as BalancesConfig, Pallet as PalletBalances};5use pallet_common::CollectionHandle;67use sp_runtime::DispatchError;8use up_data_structs::{CollectionId};9use sp_std::borrow::ToOwned;10use pallet_evm_contract_helpers::{Pallet as EvmHelpersPallet, Config as EvmHelpersConfig};1112/// This trait was defined because `LockableCurrency`13/// has no way to know the state of the lock for an account.14pub trait ExtendedLockableCurrency<AccountId: Parameter>: LockableCurrency<AccountId> {15 /// Returns lock balance for ID. Allows to determine the cause of the lock.16 fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>17 where18 KArg: EncodeLike<AccountId>;19}2021impl<T: BalancesConfig<I>, I: 'static> ExtendedLockableCurrency<T::AccountId>22 for PalletBalances<T, I>23{24 fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>25 where26 KArg: EncodeLike<T::AccountId>,27 {28 Self::locks(who)29 }30}31/// Trait for interacting with collections.32pub trait CollectionHandler {33 type CollectionId;34 type AccountId;3536 /// Sets sponsor for a collection.37 ///38 /// - `sponsor_id`: ID of the account of the sponsor-to-be.39 /// - `collection_id`: ID of the modified collection.40 fn set_sponsor(41 sponsor_id: Self::AccountId,42 collection_id: Self::CollectionId,43 ) -> DispatchResult;4445 /// Removes sponsor for a collection.46 ///47 /// - `collection_id`: ID of the modified collection.48 fn remove_collection_sponsor(collection_id: Self::CollectionId) -> DispatchResult;4950 /// Retuns the current sponsor for a collection if one is set.51 ///52 /// - `collection_id`: ID of the collection.53 fn sponsor(collection_id: Self::CollectionId)54 -> Result<Option<Self::AccountId>, DispatchError>;55}5657impl<T: pallet_unique::Config> CollectionHandler for pallet_unique::Pallet<T> {58 type CollectionId = CollectionId;5960 type AccountId = T::AccountId;6162 fn set_sponsor(63 sponsor_id: Self::AccountId,64 collection_id: Self::CollectionId,65 ) -> DispatchResult {66 Self::force_set_sponsor(sponsor_id, collection_id)67 }6869 fn remove_collection_sponsor(collection_id: Self::CollectionId) -> DispatchResult {70 Self::force_remove_collection_sponsor(collection_id)71 }7273 fn sponsor(74 collection_id: Self::CollectionId,75 ) -> Result<Option<Self::AccountId>, DispatchError> {76 Ok(<CollectionHandle<T>>::try_get(collection_id)?77 .sponsorship78 .sponsor()79 .map(|acc| acc.to_owned()))80 }81}82/// Trait for interacting with contracts.83pub trait ContractHandler {84 type ContractId;85 type AccountId;8687 /// Sets sponsor for a contract.88 ///89 /// - `sponsor_id`: ID of the account of the sponsor-to-be.90 /// - `contract_address`: ID of the modified contract.91 fn set_sponsor(92 sponsor_id: Self::AccountId,93 contract_address: Self::ContractId,94 ) -> DispatchResult;9596 /// Removes sponsor for a contract.97 ///98 /// - `contract_address`: ID of the modified contract.99 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult;100101 /// Retuns the current sponsor for a contract if one is set.102 ///103 /// - `contract_address`: ID of the contract.104 fn sponsor(105 contract_address: Self::ContractId,106 ) -> Result<Option<Self::AccountId>, DispatchError>;107}108109impl<T: EvmHelpersConfig> ContractHandler for EvmHelpersPallet<T> {110 type ContractId = sp_core::H160;111112 type AccountId = T::CrossAccountId;113114 fn set_sponsor(115 sponsor_id: Self::AccountId,116 contract_address: Self::ContractId,117 ) -> DispatchResult {118 Self::force_set_sponsor(contract_address, &sponsor_id)119 }120121 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult {122 Self::force_remove_sponsor(contract_address)123 }124125 fn sponsor(126 contract_address: Self::ContractId,127 ) -> Result<Option<Self::AccountId>, DispatchError> {128 Ok(Self::get_sponsor(contract_address))129 }130}pallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -272,7 +272,7 @@
/// Force remove `sponsor` for `contract`.
///
- /// Differs from `remove_sponsor` in that
+ /// Differs from `remove_sponsor` in that
/// it doesn't require consent from the `owner` of the contract.
pub fn force_remove_sponsor(contract_address: H160) -> DispatchResult {
Sponsoring::<T>::remove(contract_address);
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -1138,7 +1138,7 @@
///
/// Differs from `remove_sponsor` in that
/// it doesn't require consent from the `owner` of the collection.
- ///
+ ///
/// # Arguments
///
/// * `collection_id`: ID of the modified collection.