-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Multisig initial implementation * Edit error messages * Change Multisig naming: quorum instead of threshold * Add Multisig mock * Refactor Multisig not to store calls * Add Multisig target mock * Cover Multisig functionality with tests * Add tests for signer management functionality * Add more test cases for Multisig * Run linter * Address review comments * Support review fixes in tests * Change quorum and confirmations types to u32 * Optimize Multisig storage usage * Solve confirmation issue when signer is removed * Update changelog * Fix review issues * Run linter * Add breaking change entry to changelog * Make review fixes * Fix review issues * Document storage helpers * Document events * Document Multisig component itself * Document all the Multisig functions * Run linter * Make minor doc fixes * Fix in-code doc according to review comments * Improve couple of comments
- Loading branch information
Showing
18 changed files
with
2,459 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
pub mod multisig; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
pub mod timelock; | ||
pub mod utils; | ||
pub mod votes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod interface; | ||
pub mod multisig; | ||
pub mod storage_utils; | ||
|
||
pub use interface::{TransactionID, TransactionState}; | ||
pub use multisig::MultisigComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts for Cairo v0.18.0 (governance/multisig/interface.cairo) | ||
|
||
use starknet::ContractAddress; | ||
use starknet::account::Call; | ||
|
||
pub type TransactionID = felt252; | ||
|
||
/// Represents the possible states of a Multisig transaction. | ||
#[derive(Copy, Drop, Serde, PartialEq, Debug)] | ||
pub enum TransactionState { | ||
NotFound, | ||
Pending, | ||
Confirmed, | ||
Executed | ||
} | ||
|
||
/// Interface of a contract providing the Multisig functionality. | ||
#[starknet::interface] | ||
pub trait IMultisig<TState> { | ||
fn get_quorum(self: @TState) -> u32; | ||
fn is_signer(self: @TState, signer: ContractAddress) -> bool; | ||
fn get_signers(self: @TState) -> Span<ContractAddress>; | ||
fn is_confirmed(self: @TState, id: TransactionID) -> bool; | ||
fn is_confirmed_by(self: @TState, id: TransactionID, signer: ContractAddress) -> bool; | ||
fn is_executed(self: @TState, id: TransactionID) -> bool; | ||
fn get_submitted_block(self: @TState, id: TransactionID) -> u64; | ||
fn get_transaction_state(self: @TState, id: TransactionID) -> TransactionState; | ||
fn get_transaction_confirmations(self: @TState, id: TransactionID) -> u32; | ||
fn hash_transaction( | ||
self: @TState, | ||
to: ContractAddress, | ||
selector: felt252, | ||
calldata: Span<felt252>, | ||
salt: felt252 | ||
) -> TransactionID; | ||
fn hash_transaction_batch(self: @TState, calls: Span<Call>, salt: felt252) -> TransactionID; | ||
|
||
fn add_signers(ref self: TState, new_quorum: u32, signers_to_add: Span<ContractAddress>); | ||
fn remove_signers(ref self: TState, new_quorum: u32, signers_to_remove: Span<ContractAddress>); | ||
fn replace_signer( | ||
ref self: TState, signer_to_remove: ContractAddress, signer_to_add: ContractAddress | ||
); | ||
fn change_quorum(ref self: TState, new_quorum: u32); | ||
fn submit_transaction( | ||
ref self: TState, | ||
to: ContractAddress, | ||
selector: felt252, | ||
calldata: Span<felt252>, | ||
salt: felt252, | ||
) -> TransactionID; | ||
fn submit_transaction_batch( | ||
ref self: TState, calls: Span<Call>, salt: felt252 | ||
) -> TransactionID; | ||
fn confirm_transaction(ref self: TState, id: TransactionID); | ||
fn revoke_confirmation(ref self: TState, id: TransactionID); | ||
fn execute_transaction( | ||
ref self: TState, | ||
to: ContractAddress, | ||
selector: felt252, | ||
calldata: Span<felt252>, | ||
salt: felt252 | ||
); | ||
fn execute_transaction_batch(ref self: TState, calls: Span<Call>, salt: felt252); | ||
} |
Oops, something went wrong.