mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
removed pallet::getter from pallet-sudo (#3370)
part of #3326 @ggwpez @kianenigma @shawntabrizi --------- Signed-off-by: Matteo Muraca <mmuraca247@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{Config, Pallet};
|
||||
use crate::{Config, Key};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{dispatch::DispatchInfo, ensure};
|
||||
use scale_info::TypeInfo;
|
||||
@@ -86,7 +86,7 @@ where
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
_len: usize,
|
||||
) -> TransactionValidity {
|
||||
let sudo_key: T::AccountId = <Pallet<T>>::key().ok_or(UnknownTransaction::CannotLookup)?;
|
||||
let sudo_key: T::AccountId = Key::<T>::get().ok_or(UnknownTransaction::CannotLookup)?;
|
||||
ensure!(*who == sudo_key, InvalidTransaction::BadSigner);
|
||||
|
||||
Ok(ValidTransaction {
|
||||
|
||||
@@ -329,7 +329,6 @@ pub mod pallet {
|
||||
|
||||
/// The `AccountId` of the sudo key.
|
||||
#[pallet::storage]
|
||||
#[pallet::getter(fn key)]
|
||||
pub(super) type Key<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
@@ -352,7 +351,7 @@ pub mod pallet {
|
||||
let sender = ensure_signed_or_root(origin)?;
|
||||
|
||||
if let Some(sender) = sender {
|
||||
if Self::key().map_or(false, |k| k == sender) {
|
||||
if Key::<T>::get().map_or(false, |k| k == sender) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::<T>::RequireSudo.into())
|
||||
|
||||
@@ -28,7 +28,7 @@ use mock::{
|
||||
fn test_setup_works() {
|
||||
// Environment setup, logger storage, and sudo `key` retrieval should work as expected.
|
||||
new_test_ext(1).execute_with(|| {
|
||||
assert_eq!(Sudo::key(), Some(1u64));
|
||||
assert_eq!(Key::<Test>::get(), Some(1u64));
|
||||
assert!(Logger::i32_log().is_empty());
|
||||
assert!(Logger::account_log().is_empty());
|
||||
});
|
||||
@@ -135,7 +135,7 @@ fn set_key_basics() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
// A root `key` can change the root `key`
|
||||
assert_ok!(Sudo::set_key(RuntimeOrigin::signed(1), 2));
|
||||
assert_eq!(Sudo::key(), Some(2u64));
|
||||
assert_eq!(Key::<Test>::get(), Some(2u64));
|
||||
});
|
||||
|
||||
new_test_ext(1).execute_with(|| {
|
||||
@@ -161,7 +161,7 @@ fn set_key_emits_events_correctly() {
|
||||
fn remove_key_works() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
assert_ok!(Sudo::remove_key(RuntimeOrigin::signed(1)));
|
||||
assert!(Sudo::key().is_none());
|
||||
assert!(Key::<Test>::get().is_none());
|
||||
System::assert_has_event(TestEvent::Sudo(Event::KeyRemoved {}));
|
||||
|
||||
assert_noop!(Sudo::remove_key(RuntimeOrigin::signed(1)), Error::<Test>::RequireSudo);
|
||||
@@ -173,11 +173,11 @@ fn remove_key_works() {
|
||||
fn using_root_origin_works() {
|
||||
new_test_ext(1).execute_with(|| {
|
||||
assert_ok!(Sudo::remove_key(RuntimeOrigin::root()));
|
||||
assert!(Sudo::key().is_none());
|
||||
assert!(Key::<Test>::get().is_none());
|
||||
System::assert_has_event(TestEvent::Sudo(Event::KeyRemoved {}));
|
||||
|
||||
assert_ok!(Sudo::set_key(RuntimeOrigin::root(), 1));
|
||||
assert_eq!(Some(1), Sudo::key());
|
||||
assert_eq!(Some(1), Key::<Test>::get());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user