mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 10:27:59 +00:00
FRAME: inherited call weight syntax (#13932)
* First approach on pallet::call_weight Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use attr on pallet::call instead Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Ui tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename to weight(prefix = ...)) Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Simplify to #[pallet::call(weight(T))] Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add stray token error Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Migrate remaining pallets Using script from https://github.com/ggwpez/substrate-scripts/blob/e1b5ea5b5b4018867f3e869fce6f448b4ba9d71f/frame-code-migration/src/call_weight.rs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Try to add some docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Revert "Migrate remaining pallets" Lets do this as a follow-up, I dont want to bloat this small MR. This reverts commit 331d4b42d72de1dacaed714d69166fa1bc9c92dd. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Renames Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review fixes Co-authored-by: Sam Johnson <sam@durosoft.com> Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Test weights Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update UI tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update frame/support/procedural/src/pallet/parse/mod.rs Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> * Remove old code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update docs Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6e5141fc23
commit
b5201fa0ec
@@ -497,7 +497,7 @@ pub mod pallet {
|
||||
pub type UnscrupulousWebsites<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, BoundedVec<UrlOf<T, I>, T::MaxUnscrupulousItems>, ValueQuery>;
|
||||
|
||||
#[pallet::call]
|
||||
#[pallet::call(weight(<T as Config<I>>::WeightInfo))]
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Add a new proposal to be voted on.
|
||||
///
|
||||
@@ -649,7 +649,6 @@ pub mod pallet {
|
||||
|
||||
/// Set a new IPFS CID to the alliance rule.
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(T::WeightInfo::set_rule())]
|
||||
pub fn set_rule(origin: OriginFor<T>, rule: Cid) -> DispatchResult {
|
||||
T::AdminOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -661,7 +660,6 @@ pub mod pallet {
|
||||
|
||||
/// Make an announcement of a new IPFS CID about alliance issues.
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight(T::WeightInfo::announce())]
|
||||
pub fn announce(origin: OriginFor<T>, announcement: Cid) -> DispatchResult {
|
||||
T::AnnouncementOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -677,7 +675,6 @@ pub mod pallet {
|
||||
|
||||
/// Remove an announcement.
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight(T::WeightInfo::remove_announcement())]
|
||||
pub fn remove_announcement(origin: OriginFor<T>, announcement: Cid) -> DispatchResult {
|
||||
T::AnnouncementOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -695,7 +692,6 @@ pub mod pallet {
|
||||
|
||||
/// Submit oneself for candidacy. A fixed deposit is reserved.
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::weight(T::WeightInfo::join_alliance())]
|
||||
pub fn join_alliance(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -732,7 +728,6 @@ pub mod pallet {
|
||||
/// A Fellow can nominate someone to join the alliance as an Ally. There is no deposit
|
||||
/// required from the nominator or nominee.
|
||||
#[pallet::call_index(9)]
|
||||
#[pallet::weight(T::WeightInfo::nominate_ally())]
|
||||
pub fn nominate_ally(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||
let nominator = ensure_signed(origin)?;
|
||||
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
|
||||
@@ -757,7 +752,6 @@ pub mod pallet {
|
||||
|
||||
/// Elevate an Ally to Fellow.
|
||||
#[pallet::call_index(10)]
|
||||
#[pallet::weight(T::WeightInfo::elevate_ally())]
|
||||
pub fn elevate_ally(origin: OriginFor<T>, ally: AccountIdLookupOf<T>) -> DispatchResult {
|
||||
T::MembershipManager::ensure_origin(origin)?;
|
||||
let ally = T::Lookup::lookup(ally)?;
|
||||
@@ -774,7 +768,6 @@ pub mod pallet {
|
||||
/// As a member, give a retirement notice and start a retirement period required to pass in
|
||||
/// order to retire.
|
||||
#[pallet::call_index(11)]
|
||||
#[pallet::weight(T::WeightInfo::give_retirement_notice())]
|
||||
pub fn give_retirement_notice(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let role = Self::member_role_of(&who).ok_or(Error::<T, I>::NotMember)?;
|
||||
@@ -797,7 +790,6 @@ pub mod pallet {
|
||||
/// This can only be done once you have called `give_retirement_notice` and the
|
||||
/// `RetirementPeriod` has passed.
|
||||
#[pallet::call_index(12)]
|
||||
#[pallet::weight(T::WeightInfo::retire())]
|
||||
pub fn retire(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let retirement_period_end = RetiringMembers::<T, I>::get(&who)
|
||||
@@ -820,7 +812,6 @@ pub mod pallet {
|
||||
|
||||
/// Kick a member from the Alliance and slash its deposit.
|
||||
#[pallet::call_index(13)]
|
||||
#[pallet::weight(T::WeightInfo::kick_member())]
|
||||
pub fn kick_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
|
||||
T::MembershipManager::ensure_origin(origin)?;
|
||||
let member = T::Lookup::lookup(who)?;
|
||||
@@ -922,7 +913,6 @@ pub mod pallet {
|
||||
/// who do not want to leave the Alliance but do not have the capacity to participate
|
||||
/// operationally for some time.
|
||||
#[pallet::call_index(17)]
|
||||
#[pallet::weight(T::WeightInfo::abdicate_fellow_status())]
|
||||
pub fn abdicate_fellow_status(origin: OriginFor<T>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let role = Self::member_role_of(&who).ok_or(Error::<T, I>::NotMember)?;
|
||||
|
||||
@@ -629,3 +629,12 @@ fn remove_unscrupulous_items_works() {
|
||||
assert_eq!(Alliance::unscrupulous_accounts(), Vec::<u64>::new());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weights_sane() {
|
||||
let info = crate::Call::<Test>::join_alliance {}.get_dispatch_info();
|
||||
assert_eq!(<() as crate::WeightInfo>::join_alliance(), info.weight);
|
||||
|
||||
let info = crate::Call::<Test>::nominate_ally { who: 10 }.get_dispatch_info();
|
||||
assert_eq!(<() as crate::WeightInfo>::nominate_ally(), info.weight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user