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 extra validation to withdraw spl token instruction #39

Merged
merged 5 commits into from
Oct 7, 2024

Conversation

brewmaster012
Copy link
Contributor

@brewmaster012 brewmaster012 commented Oct 5, 2024

  • add mint_account (the SPL token id, analogous to ERC20 address) to the accounts, and validate the associated token address (ATA) of the PDA address as the from in the SPL token transfer.
  • add decimals to the instruction parameter
  • use transfer_checked instead of transfer for additional validation

These redundant validation can prevent accidental programming error and reduce potential attack surface.

@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 8.30%. Comparing base (812ec18) to head (e340809).

Files with missing lines Patch % Lines
programs/protocol-contracts-solana/src/lib.rs 0.00% 13 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main     #39      +/-   ##
========================================
- Coverage   8.60%   8.30%   -0.31%     
========================================
  Files          1       1              
  Lines        244     253       +9     
========================================
  Hits          21      21              
- Misses       223     232       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brewmaster012 brewmaster012 marked this pull request as ready for review October 6, 2024 00:17
programs/protocol-contracts-solana/src/lib.rs Outdated Show resolved Hide resolved
tests/protocol-contracts-solana.ts Show resolved Hide resolved
@brewmaster012 brewmaster012 merged commit d1250ea into main Oct 7, 2024
13 checks passed
@brewmaster012 brewmaster012 deleted the withdraw-spl-enhancement branch October 7, 2024 18:50
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.

5 participants