@@ -166,7 +166,7 @@ abstract contract ManagerBase is
166
166
) internal returns (bytes32 , bool ) {
167
167
bytes32 digest = TransceiverStructs.nttManagerMessageDigest (sourceChainId, message);
168
168
169
- if (! isMessageApproved (digest)) {
169
+ if (! isMessageApproved (sourceChainId, digest)) {
170
170
revert MessageNotApproved (digest);
171
171
}
172
172
@@ -284,15 +284,15 @@ abstract contract ManagerBase is
284
284
}
285
285
286
286
/// @inheritdoc IManagerBase
287
- function getThreshold () public view returns (uint8 ) {
288
- return _getThresholdStorage ().num;
287
+ function getThreshold (
288
+ uint16 sourceChainId
289
+ ) public view returns (uint8 ) {
290
+ return _getPerChainRecvTransceiverDataStorage ()[sourceChainId].threshold;
289
291
}
290
292
291
293
/// @inheritdoc IManagerBase
292
- function isMessageApproved (
293
- bytes32 digest
294
- ) public view returns (bool ) {
295
- uint8 threshold = getThreshold ();
294
+ function isMessageApproved (uint16 sourceChainId , bytes32 digest ) public view returns (bool ) {
295
+ uint8 threshold = getThreshold (sourceChainId);
296
296
return messageAttestations (digest) >= threshold && threshold > 0 ;
297
297
}
298
298
@@ -401,20 +401,8 @@ abstract contract ManagerBase is
401
401
}
402
402
403
403
/// @inheritdoc IManagerBase
404
- function setThreshold (
405
- uint8 threshold
406
- ) external onlyOwner {
407
- if (threshold == 0 ) {
408
- revert ZeroThreshold ();
409
- }
410
-
411
- _Threshold storage _threshold = _getThresholdStorage ();
412
- uint8 oldThreshold = _threshold.num;
413
-
414
- _threshold.num = threshold;
415
- _checkThresholdInvariants ();
416
-
417
- emit ThresholdChanged (oldThreshold, threshold);
404
+ function setThreshold (uint16 sourceChainId , uint8 threshold ) external onlyOwner {
405
+ _setThreshold (sourceChainId, threshold);
418
406
}
419
407
420
408
// =============== Internal ==============================================================
@@ -484,20 +472,4 @@ abstract contract ManagerBase is
484
472
);
485
473
}
486
474
}
487
-
488
- function _checkThresholdInvariants () internal view {
489
- uint8 threshold = _getThresholdStorage ().num;
490
- _NumTransceivers memory numTransceivers = _getNumTransceiversStorage ();
491
-
492
- // invariant: threshold <= enabledTransceivers.length
493
- if (threshold > numTransceivers.enabled) {
494
- revert ThresholdTooHigh (threshold, numTransceivers.enabled);
495
- }
496
-
497
- if (numTransceivers.registered > 0 ) {
498
- if (threshold == 0 ) {
499
- revert ZeroThreshold ();
500
- }
501
- }
502
- }
503
475
}
0 commit comments