Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add purchase module to westend (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored Jul 17, 2020
1 parent 5b27dd3 commit 7071a02
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
5 changes: 3 additions & 2 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch =
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
hex-literal = { version = "0.2.1", optional = true }
hex-literal = { version = "0.2.1" }

runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
Expand Down Expand Up @@ -172,7 +172,8 @@ runtime-benchmarks = [
"vesting/runtime-benchmarks",
"pallet-offences-benchmarking",
"pallet-session-benchmarking",
"hex-literal",
# uncomment when it is made optional again
# "hex-literal",
]
# When enabled, the runtime api will not be build.
#
Expand Down
51 changes: 47 additions & 4 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ use primitives::v0::{
ActiveParas, AbridgedCandidateReceipt, SigningContext,
};
use runtime_common::{
attestations, parachains, registrar, SlowAdjustingFeeUpdate,
attestations, parachains, registrar, purchase, SlowAdjustingFeeUpdate,
impls::{CurrencyToVoteHandler, ToAuthor},
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
ApplyExtrinsicResult, KeyTypeId, Permill, Perbill, curve::PiecewiseLinear,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
Expand All @@ -51,15 +51,15 @@ use version::NativeVersion;
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug, RuntimeDebug,
parameter_types, ord_parameter_types, construct_runtime, debug, RuntimeDebug,
traits::{KeyOwnerProofSystem, Randomness, Filter, InstanceFilter},
weights::Weight,
};
use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use session::historical as session_historical;
use system::EnsureRoot;
use system::{EnsureRoot, EnsureSignedBy, EnsureOneOf};

#[cfg(feature = "std")]
pub use staking::StakerStatus;
Expand Down Expand Up @@ -690,6 +690,46 @@ impl proxy::Trait for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const MaxStatementLength: usize = 1_000;
pub const UnlockedProportion: Permill = Permill::zero();
pub const MaxUnlocked: Balance = 0;
}

ord_parameter_types! {
pub const PurchaseValidity: AccountId = AccountId::from(
// 5CqSB6zNHcp3mvTAyh5Vr2MbSdb7DgLi9yWoAppHRveGcYQh
hex_literal::hex!("221d409ba60508368d4448ccda40182aca2744bcdfa0881944c08108a9fd966d")
);
pub const PurchaseConfiguration: AccountId = AccountId::from(
// 5FUP4BwQzi8F5WBTmaHsoobGbMSUTiX7Exwb7QzTjgNQypo1
hex_literal::hex!("96c34c8c60b3690701176bdbc9b16aced2898d754385a84ee0cfe7fb015db800")
);
}

type ValidityOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
EnsureSignedBy<PurchaseValidity, AccountId>,
>;

type ConfigurationOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
EnsureSignedBy<PurchaseConfiguration, AccountId>,
>;

impl purchase::Trait for Runtime {
type Event = Event;
type Currency = Balances;
type VestingSchedule = Vesting;
type ValidityOrigin = ValidityOrigin;
type ConfigurationOrigin = ConfigurationOrigin;
type MaxStatementLength = MaxStatementLength;
type UnlockedProportion = UnlockedProportion;
type MaxUnlocked = MaxUnlocked;
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -748,6 +788,9 @@ construct_runtime! {

// Multisig module. Late addition.
Multisig: multisig::{Module, Call, Storage, Event<T>},

// Purchase module. Late addition.
Purchase: purchase::{Module, Call, Storage, Event<T>},
}
}

Expand Down

0 comments on commit 7071a02

Please sign in to comment.