@@ -508,8 +508,18 @@ pub mod pallet {
508
508
pub fn add_validator ( origin : OriginFor < T > , validator_id : T :: AccountId ) -> DispatchResult {
509
509
T :: AddRemoveOrigin :: ensure_origin ( origin) ?;
510
510
511
+ Self :: do_add_validator ( validator_id. clone ( ) , true ) ?;
512
+ Self :: approve_validator ( validator_id) ?;
513
+
514
+ Ok ( ( ) )
515
+ }
516
+
517
+ #[ pallet:: weight( 10_000_000 ) ]
518
+ pub fn add_validator_self ( origin : OriginFor < T > ) -> DispatchResult {
519
+ let validator_id = ensure_signed ( origin) ?;
520
+
511
521
let deposit = Self :: calc_deposit ( & validator_id) ?;
512
- Self :: check_new ( & validator_id, deposit, false ) ?;
522
+ Self :: check_new ( & validator_id, deposit, true ) ?;
513
523
Self :: push_validator_in_queue ( & validator_id) ?;
514
524
515
525
Ok ( ( ) )
@@ -938,9 +948,9 @@ impl<T: Config> Pallet<T> {
938
948
val
939
949
}
940
950
941
- fn do_add_validator ( validator_id : T :: AccountId , check_block_num : bool ) -> DispatchResult {
951
+ fn do_add_validator ( validator_id : T :: AccountId , do_pot_transfer : bool ) -> DispatchResult {
942
952
let deposit = Self :: calc_deposit ( & validator_id) ?;
943
- Self :: check_new ( & validator_id, deposit, check_block_num ) ?;
953
+ Self :: check_new ( & validator_id, deposit, do_pot_transfer ) ?;
944
954
Self :: insert_validator ( & validator_id, deposit) ?;
945
955
946
956
Ok ( ( ) )
@@ -962,7 +972,7 @@ impl<T: Config> Pallet<T> {
962
972
return Err ( Error :: < T > :: TransferToTreasuryFailed . into ( ) ) ;
963
973
}
964
974
}
965
- else if !Self :: check_lock ( validator_id) {
975
+ if !Self :: check_lock ( validator_id) {
966
976
return Err ( Error :: < T > :: AmountLockedBelowLimit . into ( ) ) ;
967
977
}
968
978
0 commit comments