Skip to content

Commit 6a3846d

Browse files
committed
Set nonce(0) as processed during initialization
1 parent 6022c93 commit 6a3846d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ abstract contract AbstractCCTPIntegrator is Governable, IMessageHandlerV2 {
195195
_setOperator(_operator);
196196
_setMinFinalityThreshold(_minFinalityThreshold);
197197
_setFeePremiumBps(_feePremiumBps);
198+
199+
// Nonce starts at 1, so assume nonce 0 as processed.
200+
// NOTE: This will cause the deposit/withdraw to fail if the
201+
// strategy is not initialized properly (which is expected).
202+
nonceProcessed[0] = true;
198203
}
199204

200205
/***************************************
@@ -543,8 +548,7 @@ abstract contract AbstractCCTPIntegrator is Governable, IMessageHandlerV2 {
543548
* @return True if a transfer is pending, false otherwise
544549
*/
545550
function isTransferPending() public view returns (bool) {
546-
uint64 nonce = lastTransferNonce;
547-
return nonce > 0 && !nonceProcessed[nonce];
551+
return !nonceProcessed[lastTransferNonce];
548552
}
549553

550554
/**
@@ -554,7 +558,7 @@ abstract contract AbstractCCTPIntegrator is Governable, IMessageHandlerV2 {
554558
* @return True if the nonce is processed, false otherwise
555559
*/
556560
function isNonceProcessed(uint64 nonce) public view returns (bool) {
557-
return nonce == 0 || nonceProcessed[nonce];
561+
return nonceProcessed[nonce];
558562
}
559563

560564
/**
@@ -594,7 +598,7 @@ abstract contract AbstractCCTPIntegrator is Governable, IMessageHandlerV2 {
594598
function _getNextNonce() internal returns (uint64) {
595599
uint64 nonce = lastTransferNonce;
596600

597-
require(nonce == 0 || nonceProcessed[nonce], "Pending token transfer");
601+
require(nonceProcessed[nonce], "Pending token transfer");
598602

599603
nonce = nonce + 1;
600604
lastTransferNonce = nonce;

0 commit comments

Comments
 (0)