fix: support Anchor 0.32+ by defining LAMPORTS_PER_SOL constant#11
fix: support Anchor 0.32+ by defining LAMPORTS_PER_SOL constant#110x-pankaj wants to merge 1 commit intomagicblock-labs:masterfrom
Conversation
WalkthroughA local constant definition replaces an external import of Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (2)
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. Comment |
Problem
Compilation fails with Anchor 0.32+ due to the removal of the
native_tokenmodule:This breaks compatibility for all users attempting to build with Anchor 0.32.1 or higher.
Solution
Removed the import of
LAMPORTS_PER_SOLfromsolana_program::native_tokenand defined it as a constant directly in the code:This approach:
LAMPORTS_PER_SOLis a Solana protocol constant that will never changeBefore & After Screenshots
BEFORE:
Result: ❌ Compilation error with Anchor 0.32+
AFTER:
Result: ✅ Compiles successfully with all Anchor versions
Other changes (e.g. bug fixes, small refactors)
None - this is a minimal focused fix affecting only the import statement.
Deploy Notes
No deployment changes required. This is purely a compilation fix with no runtime behavioral changes.
New scripts: None
New dependencies: None
Summary by CodeRabbit