Skip to content

Commit

Permalink
salary pallet migration to umbrella crate
Browse files Browse the repository at this point in the history
  • Loading branch information
seemantaggarwal committed Jan 2, 2025
1 parent 5abdc5c commit 1bf72c4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 50 deletions.
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.

22 changes: 4 additions & 18 deletions substrate/frame/salary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,29 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = ["derive"], workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
pallet-ranked-collective = { optional = true, workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-arithmetic = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/experimental",
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-ranked-collective/std",
"scale-info/std",
"sp-arithmetic/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"frame/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-ranked-collective?/try-runtime",
"sp-runtime/try-runtime",
"frame/try-runtime",
]
5 changes: 2 additions & 3 deletions substrate/frame/salary/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
use super::*;
use crate::Pallet as Salary;

use frame_benchmarking::v2::*;
use frame_system::{Pallet as System, RawOrigin};
use sp_core::Get;

#[allow(deprecated)]
use frame::benchmarking::v1::*;
const SEED: u32 = 0;

fn ensure_member_with_salary<T: Config<I>, I: 'static>(who: &T::AccountId) {
Expand Down
11 changes: 7 additions & 4 deletions substrate/frame/salary/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode, MaxEncodedLen};
use core::marker::PhantomData;
use scale_info::TypeInfo;
use sp_arithmetic::traits::{Saturating, Zero};
use sp_runtime::{Perbill, RuntimeDebug};


use frame_support::{
defensive,
dispatch::DispatchResultWithPostInfo,
ensure,

};
use frame::{
hashing::blake2_256,
prelude::*,
traits::{
tokens::{GetSalary, Pay, PaymentStatus},
RankedMembers, RankedMembersSwapHandler,
Expand Down Expand Up @@ -75,6 +77,7 @@ pub enum ClaimState<Balance, Id> {
}

use ClaimState::*;
use frame::deps::frame_support;

/// The status of a single payee/claimant.
#[derive(Encode, Decode, Eq, PartialEq, Clone, TypeInfo, MaxEncodedLen, RuntimeDebug)]
Expand Down
29 changes: 14 additions & 15 deletions substrate/frame/salary/src/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@
use crate as pallet_salary;
use crate::*;
use frame_support::{
assert_noop, assert_ok, derive_impl, hypothetically,
pallet_prelude::Weight,
parameter_types,
traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll},
};

use frame::{prelude::*, runtime::prelude::*, testing_prelude::*,
traits::{ConstU64, EitherOf, MapSuccess, NoOpPoll,
Convert, ReduceBy, ReplaceWithDefault},
deps::{
sp_io::{self, MultiRemovalResults},
sp_runtime,
}};
use pallet_ranked_collective::{EnsureRanked, Geometric};
use sp_core::{ConstU16, Get};
use sp_runtime::{
traits::{Convert, ReduceBy, ReplaceWithDefault},
BuildStorage,
};
use crate::tests::integration::sp_api_hidden_includes_construct_runtime::hidden_include::hypothetically;

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

frame_support::construct_runtime!(
pub enum Test
construct_runtime!(
pub struct Test
{
System: frame_system,
Salary: pallet_salary,
Expand Down Expand Up @@ -145,9 +144,9 @@ impl pallet_ranked_collective::Config for Test {
type BenchmarkSetup = Salary;
}

pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestState{
let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
let mut ext = TestState::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
}
Expand Down Expand Up @@ -194,7 +193,7 @@ fn swap_exhaustive_works() {

// The events mess up the storage root:
System::reset_events();
sp_io::storage::root(sp_runtime::StateVersion::V1)
sp_io::storage::root( frame::deps::sp_runtime::StateVersion::V1)
});

let root_swap = hypothetically!({
Expand Down
5 changes: 1 addition & 4 deletions substrate/frame/salary/src/tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
use std::collections::BTreeMap;

use core::cell::RefCell;
use frame_support::{
assert_noop, assert_ok, derive_impl,
pallet_prelude::Weight,
parameter_types,
use frame::{prelude::*, runtime::prelude::*, testing_prelude::*,
traits::{tokens::ConvertRank, ConstU64},
};
use sp_runtime::{traits::Identity, BuildStorage, DispatchResult};
Expand Down
3 changes: 2 additions & 1 deletion substrate/frame/salary/src/weights.rs

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

0 comments on commit 1bf72c4

Please sign in to comment.