This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Make MultiSigGeneric
define virtual emit{EVENT_NAME}
functions from which events get emitted
#252
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
272ab00
Create virtual event emitter funcs in MultiSigGeneric
0xNeshi 524bd23
Override emit funcs in EndowmentMultiSig
0xNeshi 5395e2f
Make MultiSigGeneric.initialize internal
0xNeshi f3219cb
Use Validator in MSs
0xNeshi 7eedfbe
Make emit funcs internal
0xNeshi 69b819c
Move MultiSigGeneric down to internal funcs section
0xNeshi bd7e890
Revert contract-address.json
0xNeshi 6bbcc6e
Revert "Use Validator in MSs"
0xNeshi a0a5dd1
Add comments
0xNeshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -88,36 +88,6 @@ contract MultiSigGeneric is | |
/* | ||
* Public functions | ||
*/ | ||
/// @dev Contract constructor sets initial owners and required number of confirmations. | ||
/// @param owners List of initial owners. | ||
/// @param _approvalsRequired Number of required confirmations. | ||
/// @param _requireExecution setting for if an explicit execution call is required | ||
/// @param _transactionExpiry Proposal expiry time in seconds | ||
function initialize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just moved it down to "internal functions" section |
||
address[] memory owners, | ||
uint256 _approvalsRequired, | ||
bool _requireExecution, | ||
uint256 _transactionExpiry | ||
) public virtual initializer validApprovalsRequirement(owners.length, _approvalsRequired) { | ||
require(owners.length > 0, "Must pass at least one owner address"); | ||
for (uint256 i = 0; i < owners.length; i++) { | ||
require(!isOwner[owners[i]] && owners[i] != address(0)); | ||
isOwner[owners[i]] = true; | ||
} | ||
activeOwnersCount = owners.length; | ||
|
||
// set storage variables | ||
approvalsRequired = _approvalsRequired; | ||
requireExecution = _requireExecution; | ||
transactionExpiry = _transactionExpiry; | ||
emit InitializedMultiSig( | ||
address(this), | ||
owners, | ||
approvalsRequired, | ||
requireExecution, | ||
transactionExpiry | ||
); | ||
} | ||
|
||
/// @dev Allows to add new owners. Transaction has to be sent by wallet. | ||
/// @param owners Addresses of new owners. | ||
|
@@ -130,7 +100,7 @@ contract MultiSigGeneric is | |
// set the owner address to false in mapping | ||
isOwner[owners[o]] = true; | ||
} | ||
emit OwnersAdded(address(this), owners); | ||
emitOwnersAdded(owners); | ||
} | ||
|
||
/// @dev Allows to remove owners. Transaction has to be sent by wallet. | ||
|
@@ -148,7 +118,7 @@ contract MultiSigGeneric is | |
// set the owner address to false in mapping | ||
isOwner[owners[o]] = false; | ||
} | ||
emit OwnersRemoved(address(this), owners); | ||
emitOwnersRemoved(owners); | ||
// adjust the approval threshold downward if we've removed more members than can meet the currently | ||
// set threshold level. (ex. Prevent 10 owners total needing 15 approvals to execute txs) | ||
if (approvalsRequired > activeOwnersCount) changeApprovalsRequirement(activeOwnersCount); | ||
|
@@ -163,7 +133,7 @@ contract MultiSigGeneric is | |
) public virtual override onlyWallet ownerExists(currOwner) ownerDoesNotExist(newOwner) { | ||
isOwner[currOwner] = false; | ||
isOwner[newOwner] = true; | ||
emit OwnerReplaced(address(this), currOwner, newOwner); | ||
emitOwnerReplaced(currOwner, newOwner); | ||
} | ||
|
||
/// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. | ||
|
@@ -178,21 +148,21 @@ contract MultiSigGeneric is | |
validApprovalsRequirement(activeOwnersCount, _approvalsRequired) | ||
{ | ||
approvalsRequired = _approvalsRequired; | ||
emit ApprovalsRequiredChanged(address(this), _approvalsRequired); | ||
emitApprovalsRequiredChanged(_approvalsRequired); | ||
} | ||
|
||
/// @dev Allows to change whether explicit execution step is needed once the required number of confirmations is met. Transaction has to be sent by wallet. | ||
/// @param _requireExecution Is an explicit execution step is needed | ||
function changeRequireExecution(bool _requireExecution) public virtual override onlyWallet { | ||
requireExecution = _requireExecution; | ||
emit RequireExecutionChanged(address(this), _requireExecution); | ||
emitRequireExecutionChanged(_requireExecution); | ||
} | ||
|
||
/// @dev Allows to change the expiry time for transactions. | ||
/// @param _transactionExpiry time that a newly created transaction is valid for | ||
function changeTransactionExpiry(uint256 _transactionExpiry) public virtual override onlyWallet { | ||
transactionExpiry = _transactionExpiry; | ||
emit ExpiryChanged(address(this), _transactionExpiry); | ||
emitExpiryChanged(_transactionExpiry); | ||
} | ||
|
||
/// @dev Allows an owner to submit and confirm a transaction. | ||
|
@@ -227,7 +197,7 @@ contract MultiSigGeneric is | |
{ | ||
confirmations[transactionId].confirmationsByOwner[msg.sender] = true; | ||
confirmations[transactionId].count += 1; | ||
emit TransactionConfirmed(address(this), msg.sender, transactionId); | ||
emitTransactionConfirmed(msg.sender, transactionId); | ||
// if execution is required, do not auto execute | ||
if (!requireExecution) { | ||
executeTransaction(transactionId); | ||
|
@@ -250,7 +220,7 @@ contract MultiSigGeneric is | |
{ | ||
confirmations[transactionId].confirmationsByOwner[msg.sender] = false; | ||
confirmations[transactionId].count -= 1; | ||
emit TransactionConfirmationRevoked(address(this), msg.sender, transactionId); | ||
emitTransactionConfirmationRevoked(msg.sender, transactionId); | ||
} | ||
|
||
/// @dev Allows current owners to revoke a confirmation for a non-executed transaction from a removed/non-current owner. | ||
|
@@ -272,7 +242,7 @@ contract MultiSigGeneric is | |
require(!isOwner[formerOwner], "Attempting to revert confirmation of a current owner"); | ||
confirmations[transactionId].confirmationsByOwner[formerOwner] = false; | ||
confirmations[transactionId].count -= 1; | ||
emit TransactionConfirmationRevoked(address(this), formerOwner, transactionId); | ||
emitTransactionConfirmationRevoked(formerOwner, transactionId); | ||
} | ||
|
||
/// @dev Allows anyone to execute a confirmed transaction. | ||
|
@@ -290,7 +260,7 @@ contract MultiSigGeneric is | |
MultiSigStorage.Transaction storage txn = transactions[transactionId]; | ||
txn.executed = true; | ||
Utils._execute(txn.destination, txn.value, txn.data); | ||
emit TransactionExecuted(address(this), transactionId); | ||
emitTransactionExecuted(transactionId); | ||
} | ||
|
||
/// @dev Returns the confirmation status of a transaction. | ||
|
@@ -326,6 +296,31 @@ contract MultiSigGeneric is | |
/* | ||
* Internal functions | ||
*/ | ||
/// @dev Contract constructor sets initial owners and required number of confirmations. | ||
/// @param owners List of initial owners. | ||
/// @param _approvalsRequired Number of required confirmations. | ||
/// @param _requireExecution setting for if an explicit execution call is required | ||
/// @param _transactionExpiry Proposal expiry time in seconds | ||
function initialize( | ||
address[] memory owners, | ||
uint256 _approvalsRequired, | ||
bool _requireExecution, | ||
uint256 _transactionExpiry | ||
) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { | ||
require(owners.length > 0, "Must pass at least one owner address"); | ||
for (uint256 i = 0; i < owners.length; i++) { | ||
require(!isOwner[owners[i]] && owners[i] != address(0)); | ||
isOwner[owners[i]] = true; | ||
} | ||
activeOwnersCount = owners.length; | ||
|
||
// set storage variables | ||
approvalsRequired = _approvalsRequired; | ||
requireExecution = _requireExecution; | ||
transactionExpiry = _transactionExpiry; | ||
emitInitializedMultiSig(owners, approvalsRequired, requireExecution, transactionExpiry); | ||
} | ||
|
||
/// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. | ||
/// @param destination Transaction target address. | ||
/// @param value Transaction ether value. | ||
|
@@ -348,6 +343,98 @@ contract MultiSigGeneric is | |
metadata: metadata | ||
}); | ||
transactionCount += 1; | ||
emit TransactionSubmitted(address(this), msg.sender, transactionId, metadata); | ||
emitTransactionSubmitted(msg.sender, transactionId, metadata); | ||
} | ||
|
||
/// @dev Emits an event post-initialization. | ||
/// @param owners List of initial owners. | ||
/// @param _approvalsRequired Number of required confirmations. | ||
/// @param _requireExecution setting for if an explicit execution call is required. | ||
/// @param _transactionExpiry Proposal expiry time in seconds. | ||
function emitInitializedMultiSig( | ||
address[] memory owners, | ||
uint256 _approvalsRequired, | ||
bool _requireExecution, | ||
uint256 _transactionExpiry | ||
) internal virtual { | ||
emit InitializedMultiSig( | ||
address(this), | ||
owners, | ||
_approvalsRequired, | ||
_requireExecution, | ||
_transactionExpiry | ||
); | ||
} | ||
|
||
/// @dev Emits an event when owners are added. | ||
/// @param owners Addresses of new owners. | ||
function emitOwnersAdded(address[] memory owners) internal virtual { | ||
emit OwnersAdded(address(this), owners); | ||
} | ||
|
||
/// @dev Emits an event when owners are removed. | ||
/// @param owners Addresses of new owners. | ||
function emitOwnersRemoved(address[] memory owners) internal virtual { | ||
emit OwnersRemoved(address(this), owners); | ||
} | ||
|
||
/// @dev Emits an event when owners are replaced. | ||
/// @param currOwner Address of current owner to be replaced. | ||
/// @param newOwner Address of new owner. | ||
function emitOwnerReplaced(address currOwner, address newOwner) internal virtual { | ||
emit OwnerReplaced(address(this), currOwner, newOwner); | ||
} | ||
|
||
/// @dev Emits an event when the number of required confirmations is updated. | ||
/// @param _approvalsRequired Number of required confirmations. | ||
function emitApprovalsRequiredChanged(uint256 _approvalsRequired) internal virtual { | ||
emit ApprovalsRequiredChanged(address(this), _approvalsRequired); | ||
} | ||
|
||
/// @dev Emits an event when there's an update to the flag indicating whether explicit execution step is needed. | ||
/// @param _requireExecution Is an explicit execution step is needed. | ||
function emitRequireExecutionChanged(bool _requireExecution) internal virtual { | ||
emit RequireExecutionChanged(address(this), _requireExecution); | ||
} | ||
|
||
/// @dev Emits an event when expiry time for transactions is updated. | ||
/// @param _transactionExpiry time that a newly created transaction is valid for. | ||
function emitExpiryChanged(uint256 _transactionExpiry) internal virtual { | ||
emit ExpiryChanged(address(this), _transactionExpiry); | ||
} | ||
|
||
/// @dev Emits an event when a transaction is submitted. | ||
/// @param sender Sender of the Transaction. | ||
/// @param transactionId Transaction ID. | ||
/// @param metadata Encoded transaction metadata, can contain dynamic content. | ||
function emitTransactionSubmitted( | ||
address sender, | ||
uint256 transactionId, | ||
bytes memory metadata | ||
) internal virtual { | ||
emit TransactionSubmitted(address(this), sender, transactionId, metadata); | ||
} | ||
|
||
/// @dev Emits an event when a transaction is confirmed. | ||
/// @param sender Sender of the Transaction. | ||
/// @param transactionId Transaction ID. | ||
function emitTransactionConfirmed(address sender, uint256 transactionId) internal virtual { | ||
emit TransactionConfirmed(address(this), sender, transactionId); | ||
} | ||
|
||
/// @dev Emits an event when a transaction confirmation is revoked. | ||
/// @param sender Sender of the Transaction. | ||
/// @param transactionId Transaction ID. | ||
function emitTransactionConfirmationRevoked( | ||
address sender, | ||
uint256 transactionId | ||
) internal virtual { | ||
emit TransactionConfirmationRevoked(address(this), sender, transactionId); | ||
} | ||
|
||
/// @dev Emits an event when a transaction is executed. | ||
/// @param transactionId Transaction ID. | ||
function emitTransactionExecuted(uint256 transactionId) internal virtual { | ||
emit TransactionExecuted(address(this), transactionId); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By making
MultiSigGeneric.initialize
internal and non-virtual, we make it possible to remove this "not implemented funcs" there were cluttering the contract code only to avoid a compiler error.Every child of
MultiSigGeneric
must now implement its own initializer and optionally callsuper.initialize
.