difftreelog
fix typos , teminology
in: master
2 files changed
pallets/app-promotion/src/lib.rsdiffbeforeafterboth116 /// Type for interacting with conrtacts116 /// Type for interacting with conrtacts117 type ContractHandler: ContractHandler<AccountId = Self::CrossAccountId, ContractId = H160>;117 type ContractHandler: ContractHandler<AccountId = Self::CrossAccountId, ContractId = H160>;118118119 /// ID for treasury119 /// `AccountId` for treasury120 type TreasuryAccountId: Get<Self::AccountId>;120 type TreasuryAccountId: Get<Self::AccountId>;121121122 /// The app's pallet id, used for deriving its sovereign account ID.122 /// The app's pallet id, used for deriving its sovereign account address.123 #[pallet::constant]123 #[pallet::constant]124 type PalletId: Get<PalletId>;124 type PalletId: Get<PalletId>;125125159 /// Staking recalculation was performed159 /// Staking recalculation was performed160 ///160 ///161 /// # Arguments161 /// # Arguments162 /// * AccountId: ID of the staker.162 /// * AccountId: account of the staker.163 /// * Balance : recalculation base163 /// * Balance : recalculation base164 /// * Balance : total income164 /// * Balance : total income165 StakingRecalculation(165 StakingRecalculation(174 /// Staking was performed174 /// Staking was performed175 ///175 ///176 /// # Arguments176 /// # Arguments177 /// * AccountId: ID of the staker177 /// * AccountId: account of the staker178 /// * Balance : staking amount178 /// * Balance : staking amount179 Stake(T::AccountId, BalanceOf<T>),179 Stake(T::AccountId, BalanceOf<T>),180180181 /// Unstaking was performed181 /// Unstaking was performed182 ///182 ///183 /// # Arguments183 /// # Arguments184 /// * AccountId: ID of the staker184 /// * AccountId: account of the staker185 /// * Balance : unstaking amount185 /// * Balance : unstaking amount186 Unstake(T::AccountId, BalanceOf<T>),186 Unstake(T::AccountId, BalanceOf<T>),187187188 /// The admin was set188 /// The admin was set189 ///189 ///190 /// # Arguments190 /// # Arguments191 /// * AccountId: ID of the admin191 /// * AccountId: account address of the admin192 SetAdmin(T::AccountId),192 SetAdmin(T::AccountId),193 }193 }194194212 #[pallet::storage]212 #[pallet::storage]213 pub type TotalStaked<T: Config> = StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;213 pub type TotalStaked<T: Config> = StorageValue<Value = BalanceOf<T>, QueryKind = ValueQuery>;214214215 /// Stores the `admin` ID. Some extrinsics can only be executed if they were signed by `admin`.215 /// Stores the `admin` account. Some extrinsics can only be executed if they were signed by `admin`.216 #[pallet::storage]216 #[pallet::storage]217 pub type Admin<T: Config> = StorageValue<Value = T::AccountId, QueryKind = OptionQuery>;217 pub type Admin<T: Config> = StorageValue<Value = T::AccountId, QueryKind = OptionQuery>;218218219 /// Stores the amount of tokens staked by account in the blocknumber.219 /// Stores the amount of tokens staked by account in the blocknumber.220 ///220 ///221 /// * **Key1** - Staker ID.221 /// * **Key1** - Staker account.222 /// * **Key2** - Relay block number when the stake was made.222 /// * **Key2** - Relay block number when the stake was made.223 /// * **(Balance, BlockNumber)** - Balance of the stake.223 /// * **(Balance, BlockNumber)** - Balance of the stake.224 /// The number of the relay block in which we must perform the interest recalculation224 /// The number of the relay block in which we must perform the interest recalculation234234235 /// Stores amount of stakes for an `Account`.235 /// Stores amount of stakes for an `Account`.236 ///236 ///237 /// * **Key** - Staker ID.237 /// * **Key** - Staker account.238 /// * **Value** - Amount of stakes.238 /// * **Value** - Amount of stakes.239 #[pallet::storage]239 #[pallet::storage]240 pub type StakesPerAccount<T: Config> =240 pub type StakesPerAccount<T: Config> =241 StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>;241 StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>;242242243 /// Stores amount of stakes for an `Account`.243 /// Stores amount of stakes for an `Account`.244 ///244 ///245 /// * **Key** - Staker ID.245 /// * **Key** - Staker account.246 /// * **Value** - Amount of stakes.246 /// * **Value** - Amount of stakes.247 #[pallet::storage]247 #[pallet::storage]248 pub type PendingUnstake<T: Config> = StorageMap<248 pub type PendingUnstake<T: Config> = StorageMap<296 ///296 ///297 /// # Arguments297 /// # Arguments298 ///298 ///299 /// * `admin`: ID of the new admin.299 /// * `admin`: account of the new admin.300 #[pallet::weight(T::WeightInfo::set_admin_address())]300 #[pallet::weight(T::WeightInfo::set_admin_address())]301 pub fn set_admin_address(origin: OriginFor<T>, admin: T::CrossAccountId) -> DispatchResult {301 pub fn set_admin_address(origin: OriginFor<T>, admin: T::CrossAccountId) -> DispatchResult {302 ensure_root(origin)?;302 ensure_root(origin)?;332 let balance =332 let balance =333 <<T as Config>::Currency as Currency<T::AccountId>>::free_balance(&staker_id);333 <<T as Config>::Currency as Currency<T::AccountId>>::free_balance(&staker_id);334334335 // cheks that we can lock `amount` on the `staker` account.335 // checks that we can lock `amount` on the `staker` account.336 <<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(336 <<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(337 &staker_id,337 &staker_id,338 amount,338 amount,498 ///498 ///499 /// # Arguments499 /// # Arguments500 ///500 ///501 /// * `contract_id`: ID of the contract that will be sponsored by `pallet_id`501 /// * `contract_id`: the contract address that will be sponsored by `pallet_id`502 #[pallet::weight(T::WeightInfo::sponsor_contract())]502 #[pallet::weight(T::WeightInfo::sponsor_contract())]503 pub fn sponsor_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {503 pub fn sponsor_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {504 let admin_id = ensure_signed(admin)?;504 let admin_id = ensure_signed(admin)?;524 ///524 ///525 /// # Arguments525 /// # Arguments526 ///526 ///527 /// * `contract_id`: ID of the contract that is sponsored by `pallet_id`527 /// * `contract_id`: the contract address that is sponsored by `pallet_id`528 #[pallet::weight(T::WeightInfo::stop_sponsoring_contract())]528 #[pallet::weight(T::WeightInfo::stop_sponsoring_contract())]529 pub fn stop_sponsoring_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {529 pub fn stop_sponsoring_contract(admin: OriginFor<T>, contract_id: H160) -> DispatchResult {530 let admin_id = ensure_signed(admin)?;530 let admin_id = ensure_signed(admin)?;584 let income_acc = RefCell::new(BalanceOf::<T>::default());584 let income_acc = RefCell::new(BalanceOf::<T>::default());585 let amount_acc = RefCell::new(BalanceOf::<T>::default());585 let amount_acc = RefCell::new(BalanceOf::<T>::default());586586587 // this closure is uded to perform some of the actions if we break the loop because we reached the number of stakers for recalculation,587 // this closure is used to perform some of the actions if we break the loop because we reached the number of stakers for recalculation,588 // but there were unrecalculated records in the storage.588 // but there were unrecalculated records in the storage.589 let flush_stake = || -> DispatchResult {589 let flush_stake = || -> DispatchResult {590 if let Some(last_id) = &*last_id.borrow() {590 if let Some(last_id) = &*last_id.borrow() {654}654}655655656impl<T: Config> Pallet<T> {656impl<T: Config> Pallet<T> {657 /// The account ID of the app promotion pot.657 /// The account address of the app promotion pot.658 ///658 ///659 /// This actually does computation. If you need to keep using it, then make sure you cache the659 /// This actually does computation. If you need to keep using it, then make sure you cache the660 /// value and only call this once.660 /// value and only call this once.664664665 /// Unlocks the balance that was locked by the pallet.665 /// Unlocks the balance that was locked by the pallet.666 ///666 ///667 /// - `staker`: staker ID.667 /// - `staker`: staker account.668 /// - `amount`: amount of unlocked funds.668 /// - `amount`: amount of unlocked funds.669 fn unlock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {669 fn unlock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {670 let locked_balance = Self::get_locked_balance(staker)670 let locked_balance = Self::get_locked_balance(staker)684684685 /// Adds the balance to locked by the pallet.685 /// Adds the balance to locked by the pallet.686 ///686 ///687 /// - `staker`: staker ID.687 /// - `staker`: staker account.688 /// - `amount`: amount of added locked funds.688 /// - `amount`: amount of added locked funds.689 fn add_lock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {689 fn add_lock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {690 Self::get_locked_balance(staker)690 Self::get_locked_balance(staker)696696697 /// Sets the new state of a balance locked by the pallet.697 /// Sets the new state of a balance locked by the pallet.698 ///698 ///699 /// - `staker`: staker ID.699 /// - `staker`: staker account.700 /// - `amount`: amount of locked funds.700 /// - `amount`: amount of locked funds.701 fn set_lock_unchecked(staker: &T::AccountId, amount: BalanceOf<T>) {701 fn set_lock_unchecked(staker: &T::AccountId, amount: BalanceOf<T>) {702 if amount.is_zero() {702 if amount.is_zero() {713713714 /// Returns the balance locked by the pallet for the staker.714 /// Returns the balance locked by the pallet for the staker.715 ///715 ///716 /// - `staker`: staker ID.716 /// - `staker`: staker account.717 pub fn get_locked_balance(717 pub fn get_locked_balance(718 staker: impl EncodeLike<T::AccountId>,718 staker: impl EncodeLike<T::AccountId>,719 ) -> Option<BalanceLock<BalanceOf<T>>> {719 ) -> Option<BalanceLock<BalanceOf<T>>> {724724725 /// Returns the total staked balance for the staker.725 /// Returns the total staked balance for the staker.726 ///726 ///727 /// - `staker`: staker ID.727 /// - `staker`: staker account.728 pub fn total_staked_by_id(staker: impl EncodeLike<T::AccountId>) -> Option<BalanceOf<T>> {728 pub fn total_staked_by_id(staker: impl EncodeLike<T::AccountId>) -> Option<BalanceOf<T>> {729 let staked = Staked::<T>::iter_prefix((staker,))729 let staked = Staked::<T>::iter_prefix((staker,))730 .into_iter()730 .into_iter()741 /// Returns all relay block numbers when stake was made,741 /// Returns all relay block numbers when stake was made,742 /// the amount of the stake.742 /// the amount of the stake.743 ///743 ///744 /// - `staker`: staker ID.744 /// - `staker`: staker account.745 pub fn total_staked_by_id_per_block(745 pub fn total_staked_by_id_per_block(746 staker: impl EncodeLike<T::AccountId>,746 staker: impl EncodeLike<T::AccountId>,747 ) -> Option<Vec<(T::BlockNumber, BalanceOf<T>)>> {747 ) -> Option<Vec<(T::BlockNumber, BalanceOf<T>)>> {759759760 /// Returns the total staked balance for the staker.760 /// Returns the total staked balance for the staker.761 /// If `staker` is `None`, returns the total amount staked.761 /// If `staker` is `None`, returns the total amount staked.762 /// - `staker`: staker ID.762 /// - `staker`: staker account.763 ///763 ///764 /// **Note**: This `fn` has been added to implement RPC765 pub fn cross_id_total_staked(staker: Option<T::CrossAccountId>) -> Option<BalanceOf<T>> {764 pub fn cross_id_total_staked(staker: Option<T::CrossAccountId>) -> Option<BalanceOf<T>> {766 staker.map_or(Some(<TotalStaked<T>>::get()), |s| {765 staker.map_or(Some(<TotalStaked<T>>::get()), |s| {767 Self::total_staked_by_id(s.as_sub())766 Self::total_staked_by_id(s.as_sub())777 /// Returns all relay block numbers when stake was made,776 /// Returns all relay block numbers when stake was made,778 /// the amount of the stake.777 /// the amount of the stake.779 ///778 ///780 /// - `staker`: staker ID.779 /// - `staker`: staker account.781 ///780 ///782 /// **Note**: This `fn` has been added to implement RPC783 pub fn cross_id_total_staked_per_block(781 pub fn cross_id_total_staked_per_block(784 staker: T::CrossAccountId,782 staker: T::CrossAccountId,785 ) -> Vec<(T::BlockNumber, BalanceOf<T>)> {783 ) -> Vec<(T::BlockNumber, BalanceOf<T>)> {829 /// Returns the amount reserved by the pending.827 /// Returns the amount reserved by the pending.830 /// If `staker` is `None`, returns the total pending.828 /// If `staker` is `None`, returns the total pending.831 ///829 ///832 /// -`staker`: staker ID.830 /// -`staker`: staker account.833 ///831 ///834 /// Since user funds are not transferred anywhere by staking, overflow protection is provided832 /// Since user funds are not transferred anywhere by staking, overflow protection is provided835 /// at the level of the associated type `Balance` of `Currency` trait. In order to overflow,833 /// at the level of the associated type `Balance` of `Currency` trait. In order to overflow,859 /// Returns all parachain block numbers when unreserve is expected,857 /// Returns all parachain block numbers when unreserve is expected,860 /// the amount of the unreserved funds.858 /// the amount of the unreserved funds.861 ///859 ///862 /// - `staker`: staker ID.860 /// - `staker`: staker account.863 ///861 ///864 /// **Note**: This `fn` has been added to implement RPC862 /// **Note**: This `fn` has been added to implement RPC865 pub fn cross_id_pending_unstake_per_block(863 pub fn cross_id_pending_unstake_per_block(pallets/app-promotion/src/types.rsdiffbeforeafterboth12/// This trait was defined because `LockableCurrency`12/// This trait was defined because `LockableCurrency`13/// has no way to know the state of the lock for an account.13/// has no way to know the state of the lock for an account.14pub trait ExtendedLockableCurrency<AccountId: Parameter>: LockableCurrency<AccountId> {14pub trait ExtendedLockableCurrency<AccountId: Parameter>: LockableCurrency<AccountId> {15 /// Returns lock balance for ID. Allows to determine the cause of the lock.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>16 fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>17 where17 where18 KArg: EncodeLike<AccountId>;18 KArg: EncodeLike<AccountId>;353536 /// Sets sponsor for a collection.36 /// Sets sponsor for a collection.37 ///37 ///38 /// - `sponsor_id`: ID of the account of the sponsor-to-be.38 /// - `sponsor_id`: the account of the sponsor-to-be.39 /// - `collection_id`: ID of the modified collection.39 /// - `collection_id`: ID of the modified collection.40 fn set_sponsor(40 fn set_sponsor(41 sponsor_id: Self::AccountId,41 sponsor_id: Self::AccountId,868687 /// Sets sponsor for a contract.87 /// Sets sponsor for a contract.88 ///88 ///89 /// - `sponsor_id`: ID of the account of the sponsor-to-be.89 /// - `sponsor_id`: the account of the sponsor-to-be.90 /// - `contract_address`: ID of the modified contract.90 /// - `contract_address`: the address of the modified contract.91 fn set_sponsor(91 fn set_sponsor(92 sponsor_id: Self::AccountId,92 sponsor_id: Self::AccountId,93 contract_address: Self::ContractId,93 contract_address: Self::ContractId,94 ) -> DispatchResult;94 ) -> DispatchResult;959596 /// Removes sponsor for a contract.96 /// Removes sponsor for a contract.97 ///97 ///98 /// - `contract_address`: ID of the modified contract.98 /// - `contract_address`: the address of the modified contract.99 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult;99 fn remove_contract_sponsor(contract_address: Self::ContractId) -> DispatchResult;100100101 /// Retuns the current sponsor for a contract if one is set.101 /// Retuns the current sponsor for a contract if one is set.102 ///102 ///103 /// - `contract_address`: ID of the contract.103 /// - `contract_address`: the contract address.104 fn sponsor(104 fn sponsor(105 contract_address: Self::ContractId,105 contract_address: Self::ContractId,106 ) -> Result<Option<Self::AccountId>, DispatchError>;106 ) -> Result<Option<Self::AccountId>, DispatchError>;