-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec43128
commit 98bd7f6
Showing
32 changed files
with
1,651 additions
and
566 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,85 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.27; | ||
|
||
import {IMultiSigEnterpriseVault} from './interfaces/IMultiSigEnterpriseVault.sol'; | ||
import {MultiSigTransaction} from './components/MultiSigTransaction.sol'; | ||
import {AddressUtils} from './libraries/AddressUtils.sol'; | ||
|
||
/** | ||
* @title MultiSig Enterprise Vault Contract | ||
* @author Emmanuel Joseph (JET) | ||
* @notice This contract manages a Multi-Signature Vault system, providing role-based access control with customizable | ||
* signatory threshold and timelocks for actions. The vault supports both ETH and ERC20 tokens for transaction execution. | ||
*/ | ||
contract MultiSigEnterpriseVault is MultiSigTransaction, IMultiSigEnterpriseVault { | ||
contract MultiSigEnterpriseVault is MultiSigTransaction { | ||
/** | ||
* @dev Initializes the MultiSigEnterpriseVault with the owner, initial signatory threshold, and owner override limit. | ||
* @dev Initializes the MultiSigEnterpriseVault with the owner, initial signatory threshold, initial timelock, and owner override timelock. | ||
* @param owner The address of the contract owner. | ||
* @param initialThreshold The initial threshold for signatory approval. | ||
* @param initialOwnerOverrideLimit The initial timelock limit for owner override. | ||
* @param initialMultiSigTimelock The initial timelock for signatory approval. | ||
* @param initialOwnerOverrideTimelock The initial timelock for owner override. | ||
*/ | ||
constructor( | ||
address owner, | ||
uint256 initialThreshold, | ||
uint256 initialOwnerOverrideLimit | ||
) MultiSigTransaction(owner, initialThreshold, initialOwnerOverrideLimit) { | ||
AddressUtils.requireValidUserAddress(owner); | ||
uint256 initialMultiSigTimelock, | ||
uint256 initialOwnerOverrideTimelock | ||
) MultiSigTransaction(owner, initialThreshold, initialMultiSigTimelock, initialOwnerOverrideTimelock) {} | ||
|
||
/** | ||
* @dev Modifier to ensure an owner can perform an action without requiring signatory approval. | ||
* Reverts with `SignersApprovalRequired` if the total number of signers is equal to or greater than the signatory threshold. | ||
*/ | ||
modifier withoutSignersApproval() { | ||
if (_totalValidSigners() >= signatoryThreshold) { | ||
revert SignersApprovalRequired(); | ||
} | ||
_; | ||
} | ||
|
||
/** | ||
* @notice Owner updates the signatory threshold for the vault. | ||
* @notice Updates the signatory threshold for the vault. | ||
* @param newThreshold The new threshold value for signatory approval. | ||
* @dev Only callable by the owner of the contract. | ||
* @dev | ||
* - Requires the total valid signers to be less than the signatory threshold. | ||
* - Emits a `ThresholdUpdated` event upon successful execution. | ||
* - Only callable by the owner. | ||
*/ | ||
function ownerUpdateSignatoryThreshold( | ||
function updateSignatoryThreshold( | ||
uint256 newThreshold | ||
) public onlyOwner { | ||
if (newThreshold > signatoryThreshold && totalSigners() >= signatoryThreshold) { | ||
revert SignersApprovalRequired(); | ||
} | ||
) public onlyOwner withoutSignersApproval { | ||
_updateSignatoryThreshold(newThreshold); | ||
} | ||
|
||
signatoryThreshold = newThreshold; | ||
emit ThresholdUpdated(newThreshold); | ||
/** | ||
* @notice Adds a new signer to the vault. | ||
* @param newSigner The address of the new signer. | ||
* @dev | ||
* - Requires the new signer to be a valid address. | ||
* - Requires the total valid signers to be less than the signatory threshold. | ||
* - Emits a `SignerAdded` event upon successful execution. | ||
* - Only callable by the owner. | ||
*/ | ||
function addSigner( | ||
address newSigner | ||
) public onlyOwner withoutSignersApproval { | ||
AddressUtils.requireValidUserAddress(newSigner); | ||
if (isSigner(newSigner)) revert SignerAlreadyExists(newSigner); | ||
_addSigner(newSigner); | ||
} | ||
|
||
/** | ||
* @notice Removes a signer from the vault. | ||
* @param signer The address of the signer to be removed. | ||
* @dev | ||
* - Requires the signer to be a valid address. | ||
* - Requires the total valid signers to be less than the signatory threshold. | ||
* - Emits a `SignerRemoved` event upon successful execution. | ||
* - Only callable by the owner. | ||
*/ | ||
function removeSigner( | ||
address signer | ||
) public onlyOwner withoutSignersApproval { | ||
if (!isSigner(signer)) revert SignerDoesNotExist(signer); | ||
_removeSigner(signer); | ||
} | ||
} |
Oops, something went wrong.