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

difftreelog

fix typos , teminology

PraetorP2022-09-13parent: #31a5766.patch.diff
in: master

2 files changed

modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -116,10 +116,10 @@
 		/// Type for interacting with conrtacts
 		type ContractHandler: ContractHandler<AccountId = Self::CrossAccountId, ContractId = H160>;
 
-		/// ID for treasury
+		/// `AccountId` for treasury
 		type TreasuryAccountId: Get<Self::AccountId>;
 
-		/// The app's pallet id, used for deriving its sovereign account ID.
+		/// The app's pallet id, used for deriving its sovereign account address.
 		#[pallet::constant]
 		type PalletId: Get<PalletId>;
 
@@ -159,7 +159,7 @@
 		/// Staking recalculation was performed
 		///
 		/// # Arguments
-		/// * AccountId: ID of the staker.
+		/// * AccountId: account of the staker.
 		/// * Balance : recalculation base
 		/// * Balance : total income
 		StakingRecalculation(
@@ -174,21 +174,21 @@
 		/// Staking was performed
 		///
 		/// # Arguments
-		/// * AccountId: ID of the staker
+		/// * AccountId: account of the staker
 		/// * Balance : staking amount
 		Stake(T::AccountId, BalanceOf<T>),
 
 		/// Unstaking was performed
 		///
 		/// # Arguments
-		/// * AccountId: ID of the staker
+		/// * AccountId: account of the staker
 		/// * Balance : unstaking amount
 		Unstake(T::AccountId, BalanceOf<T>),
 
 		/// The admin was set
 		///
 		/// # Arguments
-		/// * AccountId: ID of the admin
+		/// * AccountId: account address of the admin
 		SetAdmin(T::AccountId),
 	}
 
@@ -212,13 +212,13 @@
 	#[pallet::storage]
 	pub type TotalStaked<T: Config> = StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;
 
-	/// Stores the `admin` ID. Some extrinsics can only be executed if they were signed by `admin`.
+	/// Stores the `admin` account. Some extrinsics can only be executed if they were signed by `admin`.
 	#[pallet::storage]
 	pub type Admin<T: Config> = StorageValue<Value = T::AccountId, QueryKind = OptionQuery>;
 
 	/// Stores the amount of tokens staked by account in the blocknumber.
 	///
-	/// * **Key1** - Staker ID.
+	/// * **Key1** - Staker account.
 	/// * **Key2** - Relay block number when the stake was made.
 	/// * **(Balance, BlockNumber)** - Balance of the stake.
 	/// The number of the relay block in which we must perform the interest recalculation
@@ -234,7 +234,7 @@
 
 	/// Stores amount of stakes for an `Account`.
 	///
-	/// * **Key** - Staker ID.
+	/// * **Key** - Staker account.
 	/// * **Value** - Amount of stakes.
 	#[pallet::storage]
 	pub type StakesPerAccount<T: Config> =
@@ -242,7 +242,7 @@
 
 	/// Stores amount of stakes for an `Account`.
 	///
-	/// * **Key** - Staker ID.
+	/// * **Key** - Staker account.
 	/// * **Value** - Amount of stakes.
 	#[pallet::storage]
 	pub type PendingUnstake<T: Config> = StorageMap<
@@ -296,7 +296,7 @@
 		///
 		/// # Arguments
 		///
-		/// * `admin`: ID of the new admin.
+		/// * `admin`: account of the new admin.
 		#[pallet::weight(T::WeightInfo::set_admin_address())]
 		pub fn set_admin_address(origin: OriginFor<T>, admin: T::CrossAccountId) -> DispatchResult {
 			ensure_root(origin)?;
@@ -332,7 +332,7 @@
 			let balance =
 				<<T as Config>::Currency as Currency<T::AccountId>>::free_balance(&staker_id);
 
-			// cheks that we can lock `amount` on the `staker` account.
+			// checks that we can lock `amount` on the `staker` account.
 			<<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(
 				&staker_id,
 				amount,
@@ -498,7 +498,7 @@
 		///
 		/// # Arguments
 		///
-		/// * `contract_id`: ID of the contract that will be sponsored by `pallet_id`
+		/// * `contract_id`: the contract address that will be sponsored by `pallet_id`
 		#[pallet::weight(T::WeightInfo::sponsor_contract())]
 		pub fn sponsor_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {
 			let admin_id = ensure_signed(admin)?;
@@ -524,7 +524,7 @@
 		///
 		/// # Arguments
 		///
-		/// * `contract_id`: ID of the contract that is sponsored by `pallet_id`
+		/// * `contract_id`: the contract address that is sponsored by `pallet_id`
 		#[pallet::weight(T::WeightInfo::stop_sponsoring_contract())]
 		pub fn stop_sponsoring_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {
 			let admin_id = ensure_signed(admin)?;
@@ -584,7 +584,7 @@
 				let income_acc = RefCell::new(BalanceOf::<T>::default());
 				let amount_acc = RefCell::new(BalanceOf::<T>::default());
 
-				// this closure is uded to perform some of the actions if we break the loop because we reached the number of stakers for recalculation,
+				// this closure is used to perform some of the actions if we break the loop because we reached the number of stakers for recalculation,
 				// but there were unrecalculated records in the storage.
 				let flush_stake = || -> DispatchResult {
 					if let Some(last_id) = &*last_id.borrow() {
@@ -654,7 +654,7 @@
 }
 
 impl<T: Config> Pallet<T> {
-	/// The account ID of the app promotion pot.
+	/// The account address of the app promotion pot.
 	///
 	/// This actually does computation. If you need to keep using it, then make sure you cache the
 	/// value and only call this once.
@@ -664,7 +664,7 @@
 
 	/// Unlocks the balance that was locked by the pallet.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	/// - `amount`: amount of unlocked funds.
 	fn unlock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {
 		let locked_balance = Self::get_locked_balance(staker)
@@ -684,7 +684,7 @@
 
 	/// Adds the balance to locked by the pallet.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	/// - `amount`: amount of added locked funds.
 	fn add_lock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {
 		Self::get_locked_balance(staker)
@@ -696,7 +696,7 @@
 
 	/// Sets the new state of a balance locked by the pallet.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	/// - `amount`: amount of locked funds.
 	fn set_lock_unchecked(staker: &T::AccountId, amount: BalanceOf<T>) {
 		if amount.is_zero() {
@@ -713,7 +713,7 @@
 
 	/// Returns the balance locked by the pallet for the staker.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	pub fn get_locked_balance(
 		staker: impl EncodeLike<T::AccountId>,
 	) -> Option<BalanceLock<BalanceOf<T>>> {
@@ -724,7 +724,7 @@
 
 	/// Returns the total staked balance for the staker.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	pub fn total_staked_by_id(staker: impl EncodeLike<T::AccountId>) -> Option<BalanceOf<T>> {
 		let staked = Staked::<T>::iter_prefix((staker,))
 			.into_iter()
@@ -741,7 +741,7 @@
 	/// Returns all relay block numbers when stake was made,
 	/// the amount of the stake.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	pub fn total_staked_by_id_per_block(
 		staker: impl EncodeLike<T::AccountId>,
 	) -> Option<Vec<(T::BlockNumber, BalanceOf<T>)>> {
@@ -759,9 +759,8 @@
 
 	/// Returns the total staked balance for the staker.
 	/// If `staker` is `None`, returns the total amount staked.
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	///
-	/// **Note**: This `fn` has been added to implement RPC
 	pub fn cross_id_total_staked(staker: Option<T::CrossAccountId>) -> Option<BalanceOf<T>> {
 		staker.map_or(Some(<TotalStaked<T>>::get()), |s| {
 			Self::total_staked_by_id(s.as_sub())
@@ -777,9 +776,8 @@
 	/// Returns all relay block numbers when stake was made,
 	/// the amount of the stake.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	///
-	/// **Note**: This `fn` has been added to implement RPC
 	pub fn cross_id_total_staked_per_block(
 		staker: T::CrossAccountId,
 	) -> Vec<(T::BlockNumber, BalanceOf<T>)> {
@@ -829,7 +827,7 @@
 	/// Returns the amount reserved by the pending.
 	/// If `staker` is `None`, returns the total pending.
 	///
-	/// -`staker`: staker ID.
+	/// -`staker`: staker account.
 	///
 	/// Since user funds are not transferred anywhere by staking, overflow protection is provided
 	/// at the level of the associated type `Balance` of `Currency` trait. In order to overflow,
@@ -859,7 +857,7 @@
 	/// Returns all parachain block numbers when unreserve is expected,
 	/// the amount of the unreserved funds.
 	///
-	/// - `staker`: staker ID.
+	/// - `staker`: staker account.
 	///
 	/// **Note**: This `fn` has been added to implement RPC
 	pub fn cross_id_pending_unstake_per_block(
modifiedpallets/app-promotion/src/types.rsdiffbeforeafterboth
before · pallets/app-promotion/src/types.rs
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}
after · pallets/app-promotion/src/types.rs
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 an account. 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`: 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`: the account of the sponsor-to-be.90	/// - `contract_address`: the address 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`: the address 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`: the contract address.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}