Skip to content

Commit cc94ea4

Browse files
authored
MultiSignerERC7913: prevent setting the threshold to zero (#5772)
1 parent 1a87de9 commit cc94ea4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

contracts/utils/cryptography/signers/MultiSignerERC7913.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
6666
/// @dev The `signer` is less than 20 bytes long.
6767
error MultiSignerERC7913InvalidSigner(bytes signer);
6868

69+
/// @dev The `threshold` is zero.
70+
error MultiSignerERC7913ZeroThreshold();
71+
6972
/// @dev The `threshold` is unreachable given the number of `signers`.
7073
error MultiSignerERC7913UnreachableThreshold(uint64 signers, uint64 threshold);
7174

@@ -146,6 +149,7 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
146149
* * See {_validateReachableThreshold} for the threshold validation.
147150
*/
148151
function _setThreshold(uint64 newThreshold) internal virtual {
152+
require(newThreshold > 0, MultiSignerERC7913ZeroThreshold());
149153
_threshold = newThreshold;
150154
_validateReachableThreshold();
151155
emit ERC7913ThresholdSet(newThreshold);

test/account/AccountMultiSigner.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,14 @@ describe('AccountMultiSigner', function () {
176176
await expect(this.mock.$_setThreshold(2)).to.emit(this.mock, 'ERC7913ThresholdSet');
177177

178178
// Unreachable threshold reverts
179-
await expect(this.mock.$_setThreshold(3)).to.revertedWithCustomError(
179+
await expect(this.mock.$_setThreshold(3))
180+
.to.revertedWithCustomError(this.mock, 'MultiSignerERC7913UnreachableThreshold')
181+
.withArgs(2, 3);
182+
183+
// Zero threshold reverts
184+
await expect(this.mock.$_setThreshold(0)).to.revertedWithCustomError(
180185
this.mock,
181-
'MultiSignerERC7913UnreachableThreshold',
186+
'MultiSignerERC7913ZeroThreshold',
182187
);
183188
});
184189

0 commit comments

Comments
 (0)