Unverified Commit 5b27dd39 authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

Pallet for Purchase (#1369)

* initial mock

* remove statement

* Merge branch 'master' into shawntabrizi-crowdsale

* only work for dead accounts

* Revert "Merge branch 'master' into shawntabrizi-crowdsale"

This reverts commit 6f8fde1b

.

* update storage name

* Re-mock

* Update comment

* payouts

* test signature verification

* Update wording

* fix tests

* support both free and locked balance

* Single statement set in configuration trait

* Configurable purchase limit, initiated status

* Account creation tests

* make note about `max_amount` check

* Update validity status tests

* update balance tests

* payment test

* finish tests

* enable in runtime

* Test and verify ed25519

* make purchase pallet more configurable on the fly

* Remove runtime check on purchase amount.

* clean up trait

* add basic weights

* add extra super saftey check for vesting

* Add vat tracking

* remove unused const

* Update to W3F Origins

* remove stale comment

* Support existing accounts w/o existing vesting schedule

* Update runtime/common/src/purchase.rs

Co-authored-by: default avatarGavin Wood <gavin@parity.io>

* Add support for partially unlocked portion of purchased DOTs

* add trait import

* Expose constants from pallet

* Fixes

* Fixes

* Update runtime/polkadot/src/lib.rs

Co-authored-by: default avatarGavin Wood <gavin@parity.io>
parent 37793976
Pipeline #100843 passed with stages
in 24 minutes and 33 seconds
......@@ -25,6 +25,7 @@ pub mod slot_range;
pub mod registrar;
pub mod slots;
pub mod crowdfund;
pub mod purchase;
pub mod impls;
use primitives::v0::BlockNumber;
......
This diff is collapsed.
......@@ -68,7 +68,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 }
......@@ -163,7 +163,8 @@ runtime-benchmarks = [
"vesting/runtime-benchmarks",
"pallet-offences-benchmarking",
"pallet-session-benchmarking",
"hex-literal",
# renable when optional
# "hex-literal",
]
# When enabled, the runtime api will not be build.
#
......
......@@ -25,7 +25,7 @@ use runtime_common::{
impls::{CurrencyToVoteHandler, ToAuthor},
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
MaximumExtrinsicWeight,
MaximumExtrinsicWeight, purchase,
};
use sp_std::prelude::*;
......@@ -57,11 +57,11 @@ 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, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight,
};
use system::{EnsureRoot, EnsureOneOf};
use system::{EnsureRoot, EnsureOneOf, EnsureSignedBy};
use im_online::sr25519::AuthorityId as ImOnlineId;
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
......@@ -135,7 +135,8 @@ impl Filter<Call> for BaseFilter {
Call::Session(_) | Call::FinalityTracker(_) | Call::Grandpa(_) | Call::ImOnline(_) |
Call::AuthorityDiscovery(_) |
Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) | Call::Sudo(_) |
Call::Identity(_) | Call::Proxy(_) | Call::Multisig(_) | Call::Poll(_) =>
Call::Identity(_) | Call::Proxy(_) | Call::Multisig(_) | Call::Poll(_) |
Call::Purchase(_) =>
true,
}
}
......@@ -944,6 +945,46 @@ impl poll::Trait for Runtime {
type End = PollEnd;
}
parameter_types! {
pub const MaxStatementLength: usize = 1_000;
pub const UnlockedProportion: Permill = Permill::zero();
pub const MaxUnlocked: Balance = 0;
}
ord_parameter_types! {
pub const W3FValidity: AccountId = AccountId::from(
// 142wAF65SK7PxhyzzrWz5m5PXDtooehgePBd7rc2NWpfc8Wa
hex_literal::hex!("862e432e0cf75693899c62691ac0f48967f815add97ae85659dcde8332708551")
);
pub const W3FConfiguration: AccountId = AccountId::from(
// 1KvKReVmUiTc2LW2a4qyHsaJJ9eE9LRsywZkMk5hyBeyHgw
hex_literal::hex!("0e6de68b13b82479fbe988ab9ecb16bad446b67b993cdd9198cd41c7c6259c49")
);
}
type ValidityOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
EnsureSignedBy<W3FValidity, AccountId>,
>;
type ConfigurationOrigin = EnsureOneOf<
AccountId,
EnsureRoot<AccountId>,
EnsureSignedBy<W3FConfiguration, 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,
......@@ -1012,6 +1053,9 @@ construct_runtime! {
// Poll module.
Poll: poll::{Module, Call, Storage, Event<T>},
// DOT Purchase module. Late addition.
Purchase: purchase::{Module, Call, Storage, Event<T>},
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment