Skip to content

Commit

Permalink
migrate pallet-asset-rate to use umbrella crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathy-bajo committed Jan 15, 2025
1 parent d5539aa commit 99bf86d
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 67 deletions.
7 changes: 1 addition & 6 deletions Cargo.lock

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

40 changes: 5 additions & 35 deletions substrate/frame/asset-rate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,15 @@ workspace = true
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 }
codec = { features = ["derive"], workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"] }
scale-info = { features = ["derive"], workspace = true }
sp-core = { optional = true, workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true, default-features = true }
sp-core = { workspace = true }
sp-io = { workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"scale-info/std",
"sp-core?/std",
"sp-io/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"sp-core",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
]
std = ["codec/std", "frame/std", "pallet-balances/std", "scale-info/std"]
runtime-benchmarks = ["pallet-balances/runtime-benchmarks"]
try-runtime = ["pallet-balances/try-runtime", "frame/try-runtime"]
5 changes: 1 addition & 4 deletions substrate/frame/asset-rate/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ use super::*;
use crate::{pallet as pallet_asset_rate, Pallet as AssetRate};

use codec::Encode;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use sp_core::crypto::FromEntropy;
use frame::{benchmarking::prelude::*, deps::sp_core::crypto::FromEntropy};

/// Trait describing the factory function for the `AssetKind` parameter.
pub trait AssetKindFactory<AssetKind> {
Expand Down
13 changes: 2 additions & 11 deletions substrate/frame/asset-rate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@
extern crate alloc;

use alloc::boxed::Box;
use frame_support::traits::{
fungible::Inspect,
tokens::{ConversionFromAssetBalance, ConversionToAssetBalance},
};
use sp_runtime::{
traits::{CheckedDiv, Zero},
FixedPointNumber, FixedU128,
};
use frame::{prelude::*, traits::fungible::Inspect};

pub use pallet::*;
pub use weights::WeightInfo;
Expand All @@ -91,11 +84,9 @@ type AssetKindOf<T> = <T as Config>::AssetKind;
// Generic fungible balance type.
type BalanceOf<T> = <<T as Config>::Currency as Inspect<AccountIdOf<T>>>::Balance;

#[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>(_);
Expand Down
9 changes: 4 additions & 5 deletions substrate/frame/asset-rate/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
//! The crate's mock.
use crate as pallet_asset_rate;
use frame_support::derive_impl;
use sp_runtime::BuildStorage;
use frame::testing_prelude::*;

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

frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand Down Expand Up @@ -56,6 +55,6 @@ impl pallet_asset_rate::Config for Test {
}

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestState {
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
}
3 changes: 1 addition & 2 deletions substrate/frame/asset-rate/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
use super::*;
use crate::pallet as pallet_asset_rate;
use frame_support::{assert_noop, assert_ok};
use frame::testing_prelude::*;
use mock::{new_test_ext, AssetRate, RuntimeOrigin, Test};
use sp_runtime::FixedU128;

const ASSET_ID: u32 = 42;

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/asset-rate/src/weights.rs

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

11 changes: 8 additions & 3 deletions substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ pub mod prelude {
pub use frame_support::{
defensive, defensive_assert,
traits::{
tokens::{ConversionFromAssetBalance, ConversionToAssetBalance},
Contains, EitherOf, EstimateNextSessionRotation, IsSubType, MapSuccess, NoOpPoll,
OnRuntimeUpgrade, OneSessionHandler, RankedMembers, RankedMembersSwapHandler,
},
Expand All @@ -231,9 +232,13 @@ pub mod prelude {

/// Runtime traits
#[doc(no_inline)]
pub use sp_runtime::traits::{
BlockNumberProvider, Bounded, Convert, DispatchInfoOf, Dispatchable, ReduceBy,
ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup, TrailingZeroInput,
pub use sp_runtime::{
traits::{
BlockNumberProvider, Bounded, CheckedDiv, Convert, DispatchInfoOf, Dispatchable,
ReduceBy, ReplaceWithDefault, SaturatedConversion, Saturating, StaticLookup,
TrailingZeroInput, Zero,
},
FixedPointNumber, FixedU128,
};
/// Other error/result types for runtime
#[doc(no_inline)]
Expand Down

0 comments on commit 99bf86d

Please sign in to comment.