diff --git a/solidity/contracts/Peggy.sol b/solidity/contracts/Peggy.sol index a8a48d19..ddd80131 100644 --- a/solidity/contracts/Peggy.sol +++ b/solidity/contracts/Peggy.sol @@ -376,17 +376,17 @@ contract Peggy is ) external nonReentrant whenNotPaused { // CHECKS scoped to reduce stack depth { + uint256 currentBatchNonce = state_lastBatchNonces[_tokenContract]; + // Check that the batch nonce is higher than the last nonce for this token require( - state_lastBatchNonces[_tokenContract] < _batchNonce, + currentBatchNonce < _batchNonce, "New batch nonce must be greater than the current nonce" ); // Prevent insane jumps potentially leaving the contract unable to process further batches require( - _batchNonce < - state_lastBatchNonces[_tokenContract] + - MAX_NONCE_JUMP_LIMIT, + _batchNonce < currentBatchNonce + MAX_NONCE_JUMP_LIMIT, "New batch nonce must be less than 10_000_000_000_000 greater than the current nonce" ); @@ -515,6 +515,8 @@ contract Peggy is transferAmount = balanceAfterTransfer - balanceBeforeTransfer; } + require(transferAmount > 0, "Transfer amount must be greater than 0"); + state_lastEventNonce = state_lastEventNonce + 1; emit SendToInjectiveEvent(