Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pallet-insecure-randomness-collective-flip to umbrella crate #6738

Merged
merged 12 commits into from
Jan 22, 2025
Next Next commit
import umbrella crate
FereMouSiopi committed Dec 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 05e458b7624aa3eea7f527afee24c678af8bd973
6 changes: 1 addition & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions substrate/frame/insecure-randomness-collective-flip/Cargo.toml
Original file line number Diff line number Diff line change
@@ -19,28 +19,16 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { features = ["derive"], workspace = true }
safe-mix = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
frame = { workspace = true, features = ["experimental", "runtime"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
frame = { workspace = true, features = ["experimental", "runtime"] }
frame = { workspace = true, features = ["runtime"] }

See #7177


[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"safe-mix/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"frame/try-runtime",
]
31 changes: 22 additions & 9 deletions substrate/frame/insecure-randomness-collective-flip/src/lib.rs
Original file line number Diff line number Diff line change
@@ -42,13 +42,11 @@
//! ### Example - Get random seed for the current block
//!
//! ```
//! use frame_support::traits::Randomness;
//! use frame::{prelude::*, traits::Randomness};
//!
//! #[frame_support::pallet]
//! #[frame::pallet]
//! pub mod pallet {
//! use super::*;
//! use frame_support::pallet_prelude::*;
//! use frame_system::pallet_prelude::*;
//!
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
@@ -73,10 +71,15 @@
use safe_mix::TripletMix;

use codec::Encode;
/*
use frame_support::{pallet_prelude::Weight, traits::Randomness};
use frame_system::pallet_prelude::BlockNumberFor;
use sp_runtime::traits::{Hash, Saturating};

*/
use frame::{
prelude::*,
traits::{Hash, Randomness, Saturating},
};
const RANDOM_MATERIAL_LEN: u32 = 81;

fn block_number_to_index<T: Config>(block_number: BlockNumberFor<T>) -> usize {
@@ -87,10 +90,10 @@ fn block_number_to_index<T: Config>(block_number: BlockNumberFor<T>) -> usize {

pub use pallet::*;

#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
//use frame_support::pallet_prelude::*;

#[pallet::pallet]
pub struct Pallet<T>(_);
@@ -167,7 +170,16 @@ impl<T: Config> Randomness<T::Hash, BlockNumberFor<T>> for Pallet<T> {
mod tests {
use super::*;
use crate as pallet_insecure_randomness_collective_flip;
use frame::{
runtime::{
prelude::{construct_runtime, derive_impl, parameter_types},
testing_prelude::BuildStorage,
},
testing_prelude::frame_system::limits,
traits::{Header, Randomness},
};

/*
use sp_core::H256;
use sp_runtime::{traits::Header as _, BuildStorage};
@@ -176,10 +188,11 @@ mod tests {
traits::{OnInitialize, Randomness},
};
use frame_system::limits;
*/

type Block = frame_system::mocking::MockBlock<Test>;

frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
@@ -199,7 +212,7 @@ mod tests {

impl pallet_insecure_randomness_collective_flip::Config for Test {}

fn new_test_ext() -> sp_io::TestExternalities {
fn new_test_ext() -> frame::deps::sp_io::TestExternalities {
let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
t.into()
}