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

Add validation for zero amount in Jetton operations #14

Merged
merged 17 commits into from
Dec 18, 2024

Conversation

iamIcarus
Copy link
Collaborator

Validation for Zero amount

Added a nativeThrowUnless(ERROR_CODE_INVALID_AMOUNT, msg.amount > 0) check to prevent operations with amount <= 0 in:

  • JettonMint
  • JettonBurn
  • JettonTransfer
  • JettonBurnInternal
  • JettonTransferInternal

This ensures that invalid transactions are rejected early, adhering to best practices for Jetton implementations.

Prevent Invalid max_supply Updates

  • Removed the ability to initialize Jetton with a max_supply of 0.
  • Prevented updating max_supply to a value lower than the current supply or to 0.

Test Improvements

  • Updated tests to use opcode constants from constants for better maintainability and consistency.

Copy link
Member

@ya7on ya7on left a comment

Choose a reason for hiding this comment

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

Thank you again for contribution! These changes are very helpful.
Below I commented questions you asked in code comments.

contracts/jetton/master.tact Outdated Show resolved Hide resolved
contracts/jetton/master.tact Show resolved Hide resolved
tests/JettonMaster.spec.ts Outdated Show resolved Hide resolved
@ya7on ya7on mentioned this pull request Dec 18, 2024
3 tasks
@iamIcarus iamIcarus force-pushed the enhancement/nonzero-amount-checks branch from fd8582d to 2721036 Compare December 18, 2024 17:20
@iamIcarus
Copy link
Collaborator Author

Summary of changes:

  • reverts the added logic to max_supply
  • commits now comply with commitlint
  • adds ERROR_CODE_INVALID_AMOUNT zero amount check [escape early, guard unexcepted behavior]
  • refactor test to use OP_CODE names instead of the values

@ya7on ya7on merged commit d9e464b into supadupadao:master Dec 18, 2024
2 checks passed
ya7on added a commit that referenced this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants