Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add small Peggy contract refactors #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions solidity/contracts/Peggy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the comment correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, why would it be wrong?

"New batch nonce must be less than 10_000_000_000_000 greater than the current nonce"
);

Expand Down Expand Up @@ -515,6 +515,8 @@ contract Peggy is
transferAmount = balanceAfterTransfer - balanceBeforeTransfer;
}

require(transferAmount > 0, "Transfer amount must be greater than 0");

gorgos marked this conversation as resolved.
Show resolved Hide resolved
state_lastEventNonce = state_lastEventNonce + 1;

emit SendToInjectiveEvent(
Expand Down