From 15b62a252d33659aeedbad0a81dec587737c10be Mon Sep 17 00:00:00 2001 From: asoliman Date: Sun, 18 Feb 2024 23:58:45 +0400 Subject: [PATCH] Use CallOrHash enum instead of only hash --- text/0074-stateful-multisig-pallet.md | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/text/0074-stateful-multisig-pallet.md b/text/0074-stateful-multisig-pallet.md index c40f4f141..486f56103 100644 --- a/text/0074-stateful-multisig-pallet.md +++ b/text/0074-stateful-multisig-pallet.md @@ -89,6 +89,15 @@ Notes on above diagram: ### State Transition Functions +having the following enum to store the call or the hash: + +```rust +enum CallOrHash { + Call(::RuntimeCall), + Hash(T::Hash), +} +``` + * `create_multisig` - Create a multisig account with a given threshold and initial signers. (Needs Deposit) ```rust @@ -127,7 +136,7 @@ Notes on above diagram: /// # Arguments /// /// * `multisig_account` - The multisig account ID. - /// * `call` - The dispatchable call to be executed. + /// * `call_or_hash` - The enum having the call or the hash of the call to be approved and executed later. /// /// # Errors /// @@ -137,7 +146,7 @@ Notes on above diagram: pub fn start_proposal( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) -> DispatchResult ``` @@ -153,7 +162,7 @@ Notes on above diagram: /// # Arguments /// /// * `multisig_account` - The multisig account ID. - /// * `call_hash` - The hash of the call to be approved. (This will be the hash of the call that was used in `start_proposal`) + /// * `call_or_hash` - The enum having the call or the hash of the call to be approved. /// /// # Errors /// @@ -164,7 +173,7 @@ Notes on above diagram: pub fn approve( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) -> DispatchResult ``` @@ -181,7 +190,7 @@ Notes on above diagram: /// # Arguments /// /// * `multisig_account` - The multisig account ID. - /// * `call_hash` - The hash of the call to be approved. (This will be the hash of the call that was used in `start_proposal`) + /// * `call_or_hash` - The enum having the call or the hash of the call to be rejected. /// /// # Errors /// @@ -193,7 +202,7 @@ Notes on above diagram: pub fn reject( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) -> DispatchResult ``` @@ -212,7 +221,7 @@ Notes on above diagram: /// # Arguments /// /// * `multisig_account` - The multisig account ID. - /// * `call` - The call to be executed. + /// * `call_or_hash` - We should have gotten the RuntimeCall (preimage) and stored it in the proposal by the time the extrinsic is called. /// /// # Errors /// @@ -222,7 +231,7 @@ Notes on above diagram: pub fn execute_proposal( origin: OriginFor, multisig_account: T::AccountId, - call: Box<::RuntimeCall>, + call_or_hash: CallOrHash, ) -> DispatchResult ``` @@ -241,7 +250,7 @@ Notes on above diagram: /// # Arguments /// /// * `origin` - The origin multisig account who wants to cancel the proposal. - /// * `call_hash` - The hash of the call to be canceled. (This will be the hash of the call that was used in `start_proposal`) + /// * `call_or_hash` - The call or hash of the call to be canceled. /// /// # Errors /// @@ -250,7 +259,7 @@ Notes on above diagram: pub fn cancel_proposal( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash) -> DispatchResult + call_or_hash: CallOrHash) -> DispatchResult ``` * `cancel_own_proposal` - Cancel a multisig proposal started by the caller in case no other signers approved it yet. (Releases Deposit) @@ -266,7 +275,7 @@ Notes on above diagram: /// # Arguments /// /// * `multisig_account` - The multisig account ID. - /// * `call_hash` - The hash of the call to be canceled. (This will be the hash of the call that was used in `start_proposal`) + /// * `call_or_hash` - The hash of the call to be canceled. /// /// # Errors /// @@ -275,7 +284,7 @@ Notes on above diagram: pub fn cancel_own_proposal( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) -> DispatchResult ``` @@ -424,7 +433,6 @@ pub struct MultisigAccountDetails { pub signers: BoundedBTreeSet, /// The threshold of approvers required for the multisig account to be able to execute a call. pub threshold: u32, - pub creator: T::AccountId, pub deposit: BalanceOf, } ``` @@ -513,7 +521,7 @@ We have the following extrinsics: pub fn start_proposal( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) ``` @@ -521,7 +529,7 @@ pub fn start_proposal( pub fn approve( origin: OriginFor, multisig_account: T::AccountId, - call_hash: T::Hash, + call_or_hash: CallOrHash, ) ``` @@ -529,7 +537,7 @@ pub fn approve( pub fn execute_proposal( origin: OriginFor, multisig_account: T::AccountId, - call: Box<::RuntimeCall>, + call_or_hash: CallOrHash, ) ```