Skip to content

refactor: fail by default to get restricted mint seed#2245

Merged
sergeytimoshin merged 1 commit into
mainfrom
jorrit/refactor-restricted-seed-fail-by-default
Feb 6, 2026
Merged

refactor: fail by default to get restricted mint seed#2245
sergeytimoshin merged 1 commit into
mainfrom
jorrit/refactor-restricted-seed-fail-by-default

Conversation

@ananas-block
Copy link
Copy Markdown
Contributor

@ananas-block ananas-block commented Feb 6, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for token pool creation to prevent panics and provide clearer error messages when invalid mint data is encountered.
  • Refactor

    • Enhanced error propagation throughout mint validation and account space calculations for more consistent and reliable error reporting.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

This pull request refactors error handling in token pool creation by converting the restricted_seed function from returning a Vec<u8> to returning a Result<Vec<u8>>. All call sites are updated to propagate errors via the ? operator, replacing unwrap-based extraction with explicit error handling using map_err to prevent panics on data unpacking or extension type failures.

Changes

Cohort / File(s) Summary
Error Handling Refactoring
programs/compressed-token/anchor/src/instructions/create_token_pool.rs
Converted restricted_seed return type from Vec<u8> to Result<Vec<u8>>, updated all seed constructions to use restricted_seed(&mint)?.as_slice(), and replaced unwrap-based extraction with map_err error handling in get_token_account_space and assert_mint_extensions to propagate InvalidMint errors instead of panicking.
Cascading Changes
programs/compressed-token/anchor/src/lib.rs
Updated add_token_pool to use the try operator when calling restricted_seed, allowing error propagation through the is_empty() check instead of proceeding with a potentially invalid value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

This refactoring requires careful verification that error propagation is consistent across all call sites and that the new error handling logic correctly surfaces InvalidMint errors without altering intended behavior. The changes follow a predictable pattern but span critical account initialization logic.

Suggested reviewers

  • SwenSchaeferjohann

Poem

🔒 No more unwraps that make the code unwind,
Results propagate, errors well-defined,
InvalidMint now caught before the crash,
Safer seeds, no panicked dash! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main refactoring: changing restricted_seed error handling to fail by default instead of silently returning empty results.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/refactor-restricted-seed-fail-by-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sergeytimoshin sergeytimoshin merged commit b1cc65c into main Feb 6, 2026
31 checks passed
@sergeytimoshin sergeytimoshin deleted the jorrit/refactor-restricted-seed-fail-by-default branch February 6, 2026 08:46
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