Skip to content

Commit

Permalink
Use CallOrHash enum instead of only hash
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Feb 18, 2024
1 parent ff36f57 commit f1fa3c2
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions text/0074-stateful-multisig-pallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Config> {
Call(<T as Config>::RuntimeCall),
Hash(T::Hash),
}
```

* `create_multisig` - Create a multisig account with a given threshold and initial signers. (Needs Deposit)

```rust
Expand Down Expand Up @@ -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
///
Expand All @@ -137,7 +146,7 @@ Notes on above diagram:
pub fn start_proposal(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -> DispatchResult
```

Expand All @@ -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
///
Expand All @@ -164,7 +173,7 @@ Notes on above diagram:
pub fn approve(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -> DispatchResult
```

Expand All @@ -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
///
Expand All @@ -193,7 +202,7 @@ Notes on above diagram:
pub fn reject(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -> DispatchResult
```

Expand All @@ -212,7 +221,7 @@ Notes on above diagram:
/// # Arguments
///
/// * `multisig_account` - The multisig account ID.
/// * `call` - The call to be executed.
/// * `call` - The call to be executed. (Might as well store the preimage of the call hash and make this a call_or_hash)
///
/// # Errors
///
Expand Down Expand Up @@ -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
///
Expand All @@ -250,7 +259,7 @@ Notes on above diagram:
pub fn cancel_proposal(
origin: OriginFor<T>,
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)
Expand All @@ -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
///
Expand All @@ -275,7 +284,7 @@ Notes on above diagram:
pub fn cancel_own_proposal(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
) -> DispatchResult
```

Expand Down Expand Up @@ -424,7 +433,6 @@ pub struct MultisigAccountDetails<T: Config> {
pub signers: BoundedBTreeSet<T::AccountId, T::MaxSignatories>,
/// 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<T>,
}
```
Expand Down Expand Up @@ -513,15 +521,15 @@ We have the following extrinsics:
pub fn start_proposal(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
)
```

```rust
pub fn approve(
origin: OriginFor<T>,
multisig_account: T::AccountId,
call_hash: T::Hash,
call_or_hash: CallOrHash,
)
```

Expand Down

0 comments on commit f1fa3c2

Please sign in to comment.