Crates.io | noble-sudo |
lib.rs | noble-sudo |
version | 2.0.0 |
source | src |
created_at | 2021-04-04 05:01:35.401311 |
updated_at | 2021-04-04 05:01:35.401311 |
description | FABRIC noble for sudo |
homepage | https://core.tetcoin.org |
repository | https://github.com/tetcoin/tetcore |
max_upload_size | |
id | 378626 |
size | 24,531 |
The Sudo module allows for a single account (called the "sudo key")
to execute dispatchable functions that require a Root
call
or designate a new account to replace them as the sudo key.
Only one account can be the sudo key at a time.
Only the sudo key can call the dispatchable functions from the Sudo module.
sudo
- Make a Root
call to a dispatchable function.set_key
- Assign a new account to be the sudo key.The Sudo module itself is not intended to be used within other modules.
Instead, you can build "privileged functions" (i.e. functions that require Root
origin) in other modules.
You can execute these privileged functions by calling sudo
with the sudo key account.
Privileged functions cannot be directly executed via an extrinsic.
Learn more about privileged functions and Root
origin in the Origin
type documentation.
This is an example of a module that exposes a privileged function:
use fabric_support::{decl_module, dispatch};
use fabric_system::ensure_root;
pub trait Config: fabric_system::Config {}
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
#[weight = 0]
pub fn privileged_function(origin) -> dispatch::DispatchResult {
ensure_root(origin)?;
// do something...
Ok(())
}
}
}
The Sudo module depends on the GenesisConfig
.
You need to set an initial superuser account as the sudo key
.
License: Apache-2.0