Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Successful note_imminent_preimage is free
  • Loading branch information
shawntabrizi committed Aug 3, 2020
commit 921c4e42675414985d3ffa99e74e06739bf2e8db
16 changes: 11 additions & 5 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ use sp_runtime::{
use codec::{Encode, Decode, Input};
use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, Parameter,
weights::{Weight, DispatchClass},
weights::{Weight, DispatchClass, Pays},
traits::{
Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get,
OnUnbalanced, BalanceStatus, schedule::{Named as ScheduleNamed, DispatchTime}, EnsureOrigin
Expand Down Expand Up @@ -491,14 +491,14 @@ decl_event! {
Vetoed(AccountId, Hash, BlockNumber),
/// A proposal's preimage was noted, and the deposit taken. [proposal_hash, who, deposit]
PreimageNoted(Hash, AccountId, Balance),
/// A proposal preimage was removed and used (the deposit was returned).
/// A proposal preimage was removed and used (the deposit was returned).
/// [proposal_hash, provider, deposit]
PreimageUsed(Hash, AccountId, Balance),
/// A proposal could not be executed because its preimage was invalid. [proposal_hash, ref_index]
PreimageInvalid(Hash, ReferendumIndex),
/// A proposal could not be executed because its preimage was missing. [proposal_hash, ref_index]
PreimageMissing(Hash, ReferendumIndex),
/// A registered preimage was removed and the deposit collected by the reaper.
/// A registered preimage was removed and the deposit collected by the reaper.
/// [proposal_hash, provider, deposit, reaper]
PreimageReaped(Hash, AccountId, Balance, AccountId),
/// An [account] has been unlocked successfully.
Expand Down Expand Up @@ -1119,18 +1119,24 @@ decl_module! {
/// see `weight_for::note_preimage`
/// # </weight>
#[weight = weight_for::note_imminent_preimage::<T>((encoded_proposal.len() as u32).into())]
fn note_imminent_preimage(origin, encoded_proposal: Vec<u8>) {
fn note_imminent_preimage(origin, encoded_proposal: Vec<u8>) -> DispatchResultWithPostInfo {
Self::note_imminent_preimage_inner(ensure_signed(origin)?, encoded_proposal)?;
// We check that this preimage was not uploaded before in `note_imminent_preimage_inner`,
// thus this call can only be successful once. If successful, user does not pay a fee.
Ok(Pays::No.into())
}

/// Same as `note_imminent_preimage` but origin is `OperationalPreimageOrigin`.
#[weight = (
weight_for::note_imminent_preimage::<T>((encoded_proposal.len() as u32).into()),
DispatchClass::Operational,
)]
fn note_imminent_preimage_operational(origin, encoded_proposal: Vec<u8>) {
fn note_imminent_preimage_operational(origin, encoded_proposal: Vec<u8>) -> DispatchResultWithPostInfo {
let who = T::OperationalPreimageOrigin::ensure_origin(origin)?;
Self::note_imminent_preimage_inner(who, encoded_proposal)?;
// We check that this preimage was not uploaded before in `note_imminent_preimage_inner`,
// thus this call can only be successful once. If successful, user does not pay a fee.
Ok(Pays::No.into())
}

/// Remove an expired proposal preimage and collect the deposit.
Expand Down