Migrate all doc to new pallet macro (#10187)

* Migrate all doc to new pallet macro

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix indent

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix format

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2021-11-19 06:08:17 +08:00
committed by GitHub
parent 78e60cbc4f
commit 69478639b3
23 changed files with 265 additions and 191 deletions
@@ -20,18 +20,28 @@ the system trait.
### Example - Get random seed for the current block
```rust
use frame_support::{decl_module, dispatch, traits::Randomness};
use frame_support::traits::Randomness;
pub trait Config: frame_system::Config {}
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
decl_module! {
pub struct Module<T: Config> for enum Call where origin: T::Origin {
#[weight = 0]
pub fn random_module_example(origin) -> dispatch::DispatchResult {
let _random_value = <pallet_randomness_collective_flip::Module<T>>::random(&b"my context"[..]);
Ok(())
}
}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config + pallet_randomness_collective_flip::Config {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(0)]
pub fn random_module_example(origin: OriginFor<T>) -> DispatchResult {
let _random_value = <pallet_randomness_collective_flip::Pallet<T>>::random(&b"my context"[..]);
Ok(())
}
}
}
```
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Randomness Module
//! # Randomness Pallet
//!
//! The Randomness Collective Flip module provides a [`random`](./struct.Module.html#method.random)
//! The Randomness Collective Flip pallet provides a [`random`](./struct.Module.html#method.random)
//! function that generates low-influence random values based on the block hashes from the previous
//! `81` blocks. Low-influence randomness can be useful when defending against relatively weak
//! adversaries. Using this pallet as a randomness source is advisable primarily in low-security
@@ -31,7 +31,7 @@
//!
//! ### Prerequisites
//!
//! Import the Randomness Collective Flip module and derive your module's configuration trait from
//! Import the Randomness Collective Flip pallet and derive your pallet's configuration trait from
//! the system trait.
//!
//! ### Example - Get random seed for the current block
@@ -41,9 +41,9 @@
//!
//! #[frame_support::pallet]
//! pub mod pallet {
//! use super::*;
//! use frame_support::pallet_prelude::*;
//! use frame_system::pallet_prelude::*;
//! use super::*;
//!
//! #[pallet::pallet]
//! #[pallet::generate_store(pub(super) trait Store)]