Parcourir la source

runtime: proposals: Add vote rationale.

Shamil Gadelshin il y a 4 ans
Parent
commit
2b51faca90

+ 8 - 2
runtime-modules/proposals/engine/src/lib.rs

@@ -139,9 +139,9 @@ use frame_support::{
 use sp_arithmetic::traits::Zero;
 use sp_std::vec::Vec;
 use system::{ensure_root, RawOrigin};
+use frame_support::sp_std::marker::PhantomData;
 
 use common::origin::ActorOriginValidator;
-use frame_support::sp_std::marker::PhantomData;
 
 /// Proposals engine trait.
 pub trait Trait:
@@ -354,7 +354,13 @@ decl_module! {
 
         /// Vote extrinsic. Conditions:  origin must allow votes.
         #[weight = 10_000_000] // TODO: adjust weight
-        pub fn vote(origin, voter_id: MemberId<T>, proposal_id: T::ProposalId, vote: VoteKind)  {
+        pub fn vote(
+            origin,
+            voter_id: MemberId<T>,
+            proposal_id: T::ProposalId,
+            vote: VoteKind,
+            _rationale: Vec<u8>, // we use it on the query node side.
+        )  {
             T::VoterOriginValidator::ensure_actor_origin(
                 origin,
                 voter_id,

+ 8 - 1
runtime-modules/proposals/engine/src/tests/mod.rs

@@ -259,6 +259,7 @@ impl VoteGenerator {
             self.current_voter_id,
             self.proposal_id,
             vote_kind,
+            Vec::new(),
         )
     }
 }
@@ -336,7 +337,13 @@ fn vote_succeeds() {
 fn vote_fails_with_insufficient_rights() {
     initial_test_ext().execute_with(|| {
         assert_eq!(
-            ProposalsEngine::vote(system::RawOrigin::None.into(), 1, 1, VoteKind::Approve),
+            ProposalsEngine::vote(
+                system::RawOrigin::None.into(),
+                1,
+                1,
+                VoteKind::Approve,
+                Vec::new()
+            ),
             Err(DispatchError::Other("Bad origin"))
         );
     });

+ 1 - 0
runtime/src/tests/proposals_integration/mod.rs

@@ -135,6 +135,7 @@ impl VoteGenerator {
             self.current_voter_id,
             self.proposal_id,
             vote_kind,
+            Vec::new(),
         )
     }
 }