mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 16:21:02 +00:00
Proposal: Defensive trait for infallible frame operations (#10626)
* add a blueprint of how defensive traits could look like * add something for arithmetic as well * add some use cases in different pallets * some build fixing * Some new stuff and examples * Fix deadly bug * add more doc. * undo faulty change to assets pallet * Update frame/support/src/traits/misc.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * some review comments * remove draft comment * Fix ident test * Fix proxy tests as well * a few new ideas * Fix build * Fix doc Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -102,9 +102,9 @@ use codec::{Decode, Encode};
|
||||
use frame_support::{
|
||||
dispatch::WithPostDispatchInfo,
|
||||
traits::{
|
||||
ChangeMembers, Contains, ContainsLengthBound, Currency, CurrencyToVote, Get,
|
||||
InitializeMembers, LockIdentifier, LockableCurrency, OnUnbalanced, ReservableCurrency,
|
||||
SortedMembers, StorageVersion, WithdrawReasons,
|
||||
defensive_prelude::*, ChangeMembers, Contains, ContainsLengthBound, Currency,
|
||||
CurrencyToVote, Get, InitializeMembers, LockIdentifier, LockableCurrency, OnUnbalanced,
|
||||
ReservableCurrency, SortedMembers, StorageVersion, WithdrawReasons,
|
||||
},
|
||||
weights::Weight,
|
||||
};
|
||||
@@ -1028,7 +1028,7 @@ impl<T: Config> Pallet<T> {
|
||||
candidates_and_deposit
|
||||
.iter()
|
||||
.find_map(|(c, d)| if c == x { Some(*d) } else { None })
|
||||
.unwrap_or_default()
|
||||
.defensive_unwrap_or_default()
|
||||
};
|
||||
// fetch deposits from the one recorded one. This will make sure that a candidate who
|
||||
// submitted candidacy before a change to candidacy deposit will have the correct amount
|
||||
|
||||
Reference in New Issue
Block a user