Skip to content

Commit

Permalink
use parachain system as vesting blockprovider
Browse files Browse the repository at this point in the history
Update lib.rs
  • Loading branch information
mclyk committed Nov 18, 2021
1 parent 5a061d0 commit c2b3484
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 52 deletions.
23 changes: 3 additions & 20 deletions runtime/heiko/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ use sp_core::{
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{
self, AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT,
BlockNumberProvider, Convert,
},
traits::{self, AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, DispatchError, KeyTypeId, Perbill, Permill, RuntimeDebug,
SaturatedConversion,
Expand Down Expand Up @@ -133,7 +130,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("heiko"),
impl_name: create_runtime_str!("heiko"),
authoring_version: 1,
spec_version: 171,
spec_version: 172,
impl_version: 20,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -1235,28 +1232,14 @@ parameter_types! {
pub const MaxVestingSchedules: u32 = 100;
}

pub struct RelaychainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);

impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
for RelaychainBlockNumberProvider<T>
{
type BlockNumber = BlockNumber;

fn current_block_number() -> Self::BlockNumber {
cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
.map(|d| d.relay_parent_number)
.unwrap_or_default()
}
}

impl orml_vesting::Config for Runtime {
type Event = Event;
type Currency = Balances;
type MinVestedTransfer = MinVestedTransfer;
type VestedTransferOrigin = frame_system::EnsureSigned<AccountId>;
type WeightInfo = ();
type MaxVestingSchedules = MaxVestingSchedules;
type BlockNumberProvider = RelaychainBlockNumberProvider<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down
18 changes: 2 additions & 16 deletions runtime/parallel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("parallel"),
impl_name: create_runtime_str!("parallel"),
authoring_version: 1,
spec_version: 171,
spec_version: 172,
impl_version: 20,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -1224,28 +1224,14 @@ parameter_types! {
pub const MaxVestingSchedules: u32 = 100;
}

pub struct RelaychainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);

impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
for RelaychainBlockNumberProvider<T>
{
type BlockNumber = BlockNumber;

fn current_block_number() -> Self::BlockNumber {
cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
.map(|d| d.relay_parent_number)
.unwrap_or_default()
}
}

impl orml_vesting::Config for Runtime {
type Event = Event;
type Currency = Balances;
type MinVestedTransfer = MinVestedTransfer;
type VestedTransferOrigin = EnsureSigned<AccountId>;
type WeightInfo = ();
type MaxVestingSchedules = MaxVestingSchedules;
type BlockNumberProvider = RelaychainBlockNumberProvider<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down
18 changes: 2 additions & 16 deletions runtime/vanilla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("vanilla"),
impl_name: create_runtime_str!("vanilla"),
authoring_version: 1,
spec_version: 171,
spec_version: 172,
impl_version: 20,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -1206,28 +1206,14 @@ parameter_types! {
pub const MaxVestingSchedules: u32 = 100;
}

pub struct RelaychainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);

impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
for RelaychainBlockNumberProvider<T>
{
type BlockNumber = BlockNumber;

fn current_block_number() -> Self::BlockNumber {
cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
.map(|d| d.relay_parent_number)
.unwrap_or_default()
}
}

impl orml_vesting::Config for Runtime {
type Event = Event;
type Currency = Balances;
type MinVestedTransfer = MinVestedTransfer;
type VestedTransferOrigin = frame_system::EnsureSigned<AccountId>;
type WeightInfo = ();
type MaxVestingSchedules = MaxVestingSchedules;
type BlockNumberProvider = RelaychainBlockNumberProvider<Runtime>;
type BlockNumberProvider = frame_system::Pallet<Runtime>;
}

parameter_types! {
Expand Down

0 comments on commit c2b3484

Please sign in to comment.