Use explicit call indices (#12891)

* frame-system: explicit call index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Use explicit call indices

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-template: explicit call index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* DNM: Temporarily require call_index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Revert "DNM: Temporarily require call_index"

This reverts commit c4934e312e12af72ca05a8029d7da753a9c99346.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-12-12 15:32:41 +01:00
committed by GitHub
parent 6e0453a298
commit 31f5119ecd
67 changed files with 403 additions and 0 deletions
@@ -1506,6 +1506,7 @@ pub mod pallet {
/// * This call will *not* dust the member account, so the member must have at least
/// `existential deposit + amount` in their account.
/// * Only a pool with [`PoolState::Open`] can be joined
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::join())]
pub fn join(
origin: OriginFor<T>,
@@ -1563,6 +1564,7 @@ pub mod pallet {
// NOTE: this transaction is implemented with the sole purpose of readability and
// correctness, not optimization. We read/write several storage items multiple times instead
// of just once, in the spirit reusing code.
#[pallet::call_index(1)]
#[pallet::weight(
T::WeightInfo::bond_extra_transfer()
.max(T::WeightInfo::bond_extra_reward())
@@ -1605,6 +1607,7 @@ pub mod pallet {
///
/// The member will earn rewards pro rata based on the members stake vs the sum of the
/// members in the pools stake. Rewards do not "expire".
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::claim_payout())]
pub fn claim_payout(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -1644,6 +1647,7 @@ pub mod pallet {
/// [`Call::pool_withdraw_unbonded`] can be called to try and minimize unlocking chunks. If
/// there are too many unlocking chunks, the result of this call will likely be the
/// `NoMoreChunks` error from the staking system.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::unbond())]
pub fn unbond(
origin: OriginFor<T>,
@@ -1719,6 +1723,7 @@ pub mod pallet {
/// can be cleared by withdrawing. In the case there are too many unlocking chunks, the user
/// would probably see an error like `NoMoreChunks` emitted from the staking system when
/// they attempt to unbond.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::pool_withdraw_unbonded(*num_slashing_spans))]
pub fn pool_withdraw_unbonded(
origin: OriginFor<T>,
@@ -1753,6 +1758,7 @@ pub mod pallet {
/// # Note
///
/// If the target is the depositor, the pool will be destroyed.
#[pallet::call_index(5)]
#[pallet::weight(
T::WeightInfo::withdraw_unbonded_kill(*num_slashing_spans)
)]
@@ -1874,6 +1880,7 @@ pub mod pallet {
///
/// In addition to `amount`, the caller will transfer the existential deposit; so the caller
/// needs at have at least `amount + existential_deposit` transferrable.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::create())]
pub fn create(
origin: OriginFor<T>,
@@ -1898,6 +1905,7 @@ pub mod pallet {
///
/// same as `create` with the inclusion of
/// * `pool_id` - `A valid PoolId.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::create())]
pub fn create_with_pool_id(
origin: OriginFor<T>,
@@ -1922,6 +1930,7 @@ pub mod pallet {
///
/// This directly forward the call to the staking pallet, on behalf of the pool bonded
/// account.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::nominate(validators.len() as u32))]
pub fn nominate(
origin: OriginFor<T>,
@@ -1944,6 +1953,7 @@ pub mod pallet {
/// 1. signed by the state toggler, or the root role of the pool,
/// 2. if the pool conditions to be open are NOT met (as described by `ok_to_be_open`), and
/// then the state of the pool can be permissionlessly changed to `Destroying`.
#[pallet::call_index(9)]
#[pallet::weight(T::WeightInfo::set_state())]
pub fn set_state(
origin: OriginFor<T>,
@@ -1972,6 +1982,7 @@ pub mod pallet {
///
/// The dispatch origin of this call must be signed by the state toggler, or the root role
/// of the pool.
#[pallet::call_index(10)]
#[pallet::weight(T::WeightInfo::set_metadata(metadata.len() as u32))]
pub fn set_metadata(
origin: OriginFor<T>,
@@ -2003,6 +2014,7 @@ pub mod pallet {
/// * `max_pools` - Set [`MaxPools`].
/// * `max_members` - Set [`MaxPoolMembers`].
/// * `max_members_per_pool` - Set [`MaxPoolMembersPerPool`].
#[pallet::call_index(11)]
#[pallet::weight(T::WeightInfo::set_configs())]
pub fn set_configs(
origin: OriginFor<T>,
@@ -2039,6 +2051,7 @@ pub mod pallet {
///
/// It emits an event, notifying UIs of the role change. This event is quite relevant to
/// most pool members and they should be informed of changes to pool roles.
#[pallet::call_index(12)]
#[pallet::weight(T::WeightInfo::update_roles())]
pub fn update_roles(
origin: OriginFor<T>,
@@ -2091,6 +2104,7 @@ pub mod pallet {
///
/// This directly forward the call to the staking pallet, on behalf of the pool bonded
/// account.
#[pallet::call_index(13)]
#[pallet::weight(T::WeightInfo::chill())]
pub fn chill(origin: OriginFor<T>, pool_id: PoolId) -> DispatchResult {
let who = ensure_signed(origin)?;