mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 17:11:05 +00:00
Don't return misleading result with PostInfo in proxy-pallet (#9426)
also autoformatting two unrelated files fixes #9421
This commit is contained in:
committed by
GitHub
parent
4e653bfa3c
commit
b7dc3bc6f2
@@ -788,7 +788,7 @@ pub enum ResponseFailure {
|
|||||||
/// Implements the libp2p [`RequestResponseCodec`] trait. Defines how streams of bytes are turned
|
/// Implements the libp2p [`RequestResponseCodec`] trait. Defines how streams of bytes are turned
|
||||||
/// into requests and responses and vice-versa.
|
/// into requests and responses and vice-versa.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[doc(hidden)]// Needs to be public in order to satisfy the Rust compiler.
|
#[doc(hidden)] // Needs to be public in order to satisfy the Rust compiler.
|
||||||
pub struct GenericCodec {
|
pub struct GenericCodec {
|
||||||
max_request_size: u64,
|
max_request_size: u64,
|
||||||
max_response_size: u64,
|
max_response_size: u64,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub mod weights;
|
|||||||
|
|
||||||
use codec::{Decode, Encode, MaxEncodedLen};
|
use codec::{Decode, Encode, MaxEncodedLen};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
dispatch::{DispatchError, DispatchResultWithPostInfo, PostDispatchInfo},
|
dispatch::DispatchError,
|
||||||
ensure,
|
ensure,
|
||||||
traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency},
|
traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency},
|
||||||
weights::GetDispatchInfo,
|
weights::GetDispatchInfo,
|
||||||
@@ -102,7 +102,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
/// The overarching call type.
|
/// The overarching call type.
|
||||||
type Call: Parameter
|
type Call: Parameter
|
||||||
+ Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
|
+ Dispatchable<Origin = Self::Origin>
|
||||||
+ GetDispatchInfo
|
+ GetDispatchInfo
|
||||||
+ From<frame_system::Call<Self>>
|
+ From<frame_system::Call<Self>>
|
||||||
+ IsSubType<Call<Self>>
|
+ IsSubType<Call<Self>>
|
||||||
@@ -196,7 +196,7 @@ pub mod pallet {
|
|||||||
real: T::AccountId,
|
real: T::AccountId,
|
||||||
force_proxy_type: Option<T::ProxyType>,
|
force_proxy_type: Option<T::ProxyType>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
let def = Self::find_proxy(&real, &who, force_proxy_type)?;
|
let def = Self::find_proxy(&real, &who, force_proxy_type)?;
|
||||||
ensure!(def.delay.is_zero(), Error::<T>::Unannounced);
|
ensure!(def.delay.is_zero(), Error::<T>::Unannounced);
|
||||||
@@ -225,7 +225,7 @@ pub mod pallet {
|
|||||||
delegate: T::AccountId,
|
delegate: T::AccountId,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
Self::add_proxy_delegate(&who, delegate, proxy_type, delay)
|
Self::add_proxy_delegate(&who, delegate, proxy_type, delay)
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@ pub mod pallet {
|
|||||||
delegate: T::AccountId,
|
delegate: T::AccountId,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
Self::remove_proxy_delegate(&who, delegate, proxy_type, delay)
|
Self::remove_proxy_delegate(&who, delegate, proxy_type, delay)
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ pub mod pallet {
|
|||||||
/// Weight is a function of the number of proxies the user has (P).
|
/// Weight is a function of the number of proxies the user has (P).
|
||||||
/// # </weight>
|
/// # </weight>
|
||||||
#[pallet::weight(T::WeightInfo::remove_proxies(T::MaxProxies::get().into()))]
|
#[pallet::weight(T::WeightInfo::remove_proxies(T::MaxProxies::get().into()))]
|
||||||
pub fn remove_proxies(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
pub fn remove_proxies(origin: OriginFor<T>) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
let (_, old_deposit) = Proxies::<T>::take(&who);
|
let (_, old_deposit) = Proxies::<T>::take(&who);
|
||||||
T::Currency::unreserve(&who, old_deposit);
|
T::Currency::unreserve(&who, old_deposit);
|
||||||
@@ -300,7 +300,7 @@ pub mod pallet {
|
|||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
index: u16,
|
index: u16,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
let anonymous = Self::anonymous_account(&who, &proxy_type, index, None);
|
let anonymous = Self::anonymous_account(&who, &proxy_type, index, None);
|
||||||
@@ -348,7 +348,7 @@ pub mod pallet {
|
|||||||
index: u16,
|
index: u16,
|
||||||
#[pallet::compact] height: T::BlockNumber,
|
#[pallet::compact] height: T::BlockNumber,
|
||||||
#[pallet::compact] ext_index: u32,
|
#[pallet::compact] ext_index: u32,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
|
|
||||||
let when = (height, ext_index);
|
let when = (height, ext_index);
|
||||||
@@ -387,7 +387,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
real: T::AccountId,
|
real: T::AccountId,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
Proxies::<T>::get(&real)
|
Proxies::<T>::get(&real)
|
||||||
.0
|
.0
|
||||||
@@ -443,7 +443,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
real: T::AccountId,
|
real: T::AccountId,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
Self::edit_announcements(&who, |ann| ann.real != real || ann.call_hash != call_hash)?;
|
Self::edit_announcements(&who, |ann| ann.real != real || ann.call_hash != call_hash)?;
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ pub mod pallet {
|
|||||||
origin: OriginFor<T>,
|
origin: OriginFor<T>,
|
||||||
delegate: T::AccountId,
|
delegate: T::AccountId,
|
||||||
call_hash: CallHashOf<T>,
|
call_hash: CallHashOf<T>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
let who = ensure_signed(origin)?;
|
let who = ensure_signed(origin)?;
|
||||||
Self::edit_announcements(&delegate, |ann| {
|
Self::edit_announcements(&delegate, |ann| {
|
||||||
ann.real != who || ann.call_hash != call_hash
|
ann.real != who || ann.call_hash != call_hash
|
||||||
@@ -513,7 +513,7 @@ pub mod pallet {
|
|||||||
real: T::AccountId,
|
real: T::AccountId,
|
||||||
force_proxy_type: Option<T::ProxyType>,
|
force_proxy_type: Option<T::ProxyType>,
|
||||||
call: Box<<T as Config>::Call>,
|
call: Box<<T as Config>::Call>,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
ensure_signed(origin)?;
|
ensure_signed(origin)?;
|
||||||
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
|
let def = Self::find_proxy(&real, &delegate, force_proxy_type)?;
|
||||||
|
|
||||||
@@ -641,7 +641,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
delegatee: T::AccountId,
|
delegatee: T::AccountId,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
ensure!(delegator != &delegatee, Error::<T>::NoSelfProxy);
|
ensure!(delegator != &delegatee, Error::<T>::NoSelfProxy);
|
||||||
Proxies::<T>::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| {
|
Proxies::<T>::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| {
|
||||||
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };
|
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };
|
||||||
@@ -671,7 +671,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
delegatee: T::AccountId,
|
delegatee: T::AccountId,
|
||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
) -> DispatchResultWithPostInfo {
|
) -> DispatchResult {
|
||||||
Proxies::<T>::try_mutate_exists(delegator, |x| {
|
Proxies::<T>::try_mutate_exists(delegator, |x| {
|
||||||
let (mut proxies, old_deposit) = x.take().ok_or(Error::<T>::NotFound)?;
|
let (mut proxies, old_deposit) = x.take().ok_or(Error::<T>::NotFound)?;
|
||||||
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };
|
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };
|
||||||
|
|||||||
@@ -2365,8 +2365,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let controller = Self::bonded(&validator_stash).ok_or_else(|| {
|
let controller = Self::bonded(&validator_stash).ok_or_else(|| {
|
||||||
Error::<T>::NotStash
|
Error::<T>::NotStash.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
|
||||||
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))
|
|
||||||
})?;
|
})?;
|
||||||
let mut ledger = <Ledger<T>>::get(&controller).ok_or(Error::<T>::NotController)?;
|
let mut ledger = <Ledger<T>>::get(&controller).ok_or(Error::<T>::NotController)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user