This contract implements a custom multi-signature wallet where transactions must be confirmed by a
threshold of signers. The signers and threshold may be updated every epoch
.
struct Voting {
uint256 voteCount;
mapping(address => bool) hasVoted;
}
struct Signers {
address[] accounts;
uint256 threshold;
mapping(address => bool) isSigner;
}
struct BaseMultisig.Signers signers
uint256 signerEpoch
Gets the current epoch.
| Name | Type | Description | | —- | —- | ———– |
mapping(uint256 => mapping(bytes32 => struct BaseMultisig.Voting)) votingPerTopic
constructor(address[] accounts, uint256 threshold) public
Contract constructor
Sets the initial list of signers and corresponding threshold.
Name | Type | Description |
---|---|---|
accounts | address[] | Address array of the signers |
threshold | uint256 | Signature threshold required to validate a transaction |
modifier onlySigners()
Modifier to ensure the caller is a signer
Keeps track of votes for each operation and resets the vote count if the operation is executed. Given the early void return, this modifier should be used with care on functions that return data.
function signerThreshold() external view returns (uint256)
Returns the current signer threshold
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 The signer threshold |
function signerAccounts() external view returns (address[])
Returns an array of current signers
Name | Type | Description |
---|---|---|
[0] | address[] | array of signer addresses |
function isSigner(address account) external view returns (bool)
Getter to determine if an account is a signer
Name | Type | Description |
---|---|---|
[0] | bool | boolean indicating if the account is a signer |
function hasSignerVoted(address account, bytes32 topic) external view returns (bool)
Getter to determine if an account has voted on a topic
Name | Type | Description |
---|---|---|
[0] | bool | boolean indicating if the account has voted |
function getSignerVotesCount(bytes32 topic) external view returns (uint256)
Get the number of votes for a topic
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 indicating the number of votes for a topic |
function rotateSigners(address[] newAccounts, uint256 newThreshold) external virtual
Rotate the signers for the multisig
Updates the current set of signers and threshold and increments the epoch
This function is protected by the onlySigners modifier
Name | Type | Description |
---|---|---|
newAccounts | address[] | Address array of the new signers |
newThreshold | uint256 | The new signature threshold for executing operations |
function _rotateSigners(address[] newAccounts, uint256 newThreshold) internal
Internal function that implements signer rotation logic
function _isFinalSignerVote() internal returns (bool)
Internal function that implements onlySigners logic
function _resetSignerVotes(bytes32 topic) internal
Internal function to reset the votes for a topic
function _resetVoting(struct BaseMultisig.Voting voting) internal
Internal function to reset the votes for a topic