mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
Implement a proper generic resolution in decl_storage! (#2913)
* Add failing test case * move storage maps to blake2_128 (#2268) * remove default hash, introduce twox_128 and blake2 * use blake2_128 & create ext_blake2_128 * refactor code * add benchmark * factorize generator * fix * parameterizable hasher * some fix * fix * fix * fix * metadata * fix * remove debug print * map -> blake2_256 * fix test * fix test * Apply suggestions from code review Co-Authored-By: thiolliere <gui.thiolliere@gmail.com> * impl twox 128 concat (#2353) * impl twox_128_concat * comment addressed * fix * impl twox_128->64_concat * fix test * Fix compilation and cleanup some docs * Lol * Remove traits from storage types that are not generic * Get instance test almost working as wanted * Make `srml-support-test` compile again :) * Fixes test of srml-support * Fix compilation * Break some lines * Remove incorrect macro match arm * Integrates review feedback * Update documentation * Fix compilation
This commit is contained in:
@@ -129,7 +129,7 @@ decl_module! {
|
||||
.map_err(|_| "Proposer's balance too low")?;
|
||||
|
||||
let c = Self::proposal_count();
|
||||
<ProposalCount<T>>::put(c + 1);
|
||||
ProposalCount::put(c + 1);
|
||||
<Proposals<T>>::insert(c, Proposal { proposer, value, beneficiary, bond });
|
||||
|
||||
Self::deposit_event(RawEvent::Proposed(c));
|
||||
@@ -148,10 +148,10 @@ decl_module! {
|
||||
#[compact] spend_period: T::BlockNumber,
|
||||
#[compact] burn: Permill
|
||||
) {
|
||||
<ProposalBond<T>>::put(proposal_bond);
|
||||
ProposalBond::put(proposal_bond);
|
||||
<ProposalBondMinimum<T>>::put(proposal_bond_minimum);
|
||||
<SpendPeriod<T>>::put(spend_period);
|
||||
<Burn<T>>::put(burn);
|
||||
Burn::put(burn);
|
||||
}
|
||||
|
||||
/// Reject a proposed spend. The original deposit will be slashed.
|
||||
@@ -183,7 +183,7 @@ decl_module! {
|
||||
|
||||
ensure!(<Proposals<T>>::exists(proposal_id), "No proposal at that index");
|
||||
|
||||
<Approvals<T>>::mutate(|v| v.push(proposal_id));
|
||||
Approvals::mutate(|v| v.push(proposal_id));
|
||||
}
|
||||
|
||||
fn on_finalize(n: T::BlockNumber) {
|
||||
@@ -272,7 +272,7 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
let mut missed_any = false;
|
||||
let mut imbalance = <PositiveImbalanceOf<T>>::zero();
|
||||
<Approvals<T>>::mutate(|v| {
|
||||
Approvals::mutate(|v| {
|
||||
v.retain(|&index| {
|
||||
// Should always be true, but shouldn't panic if false or we're screwed.
|
||||
if let Some(p) = Self::proposals(index) {
|
||||
@@ -336,9 +336,7 @@ mod tests {
|
||||
use runtime_io::with_externalities;
|
||||
use srml_support::{impl_outer_origin, assert_ok, assert_noop};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use runtime_primitives::BuildStorage;
|
||||
use runtime_primitives::traits::{BlakeTwo256, OnFinalize, IdentityLookup};
|
||||
use runtime_primitives::testing::Header;
|
||||
use runtime_primitives::{traits::{BlakeTwo256, OnFinalize, IdentityLookup}, testing::Header};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
@@ -378,7 +376,7 @@ mod tests {
|
||||
type Treasury = Module<Test>;
|
||||
|
||||
fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
|
||||
t.extend(balances::GenesisConfig::<Test>{
|
||||
balances: vec![(0, 100), (1, 99), (2, 1)],
|
||||
transaction_base_fee: 0,
|
||||
|
||||
Reference in New Issue
Block a user