-
Notifications
You must be signed in to change notification settings - Fork 529
Add Token-2022 Program Support #265
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
Conversation
Remove two sunset services
Remove two sunset services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped PR review on 1aef700 because no changed files had a supported extension. If you think this was in error, please contact us and we'll fix it right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to a12376b in 2 minutes and 23 seconds. Click for details.
- Reviewed
984lines of code in14files - Skipped
1files when reviewing. - Skipped posting
9draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. core/src/createTransfer.ts:143
- Draft comment:
Good implementation of Token-2022 detection. Consider adding an inline comment clarifying that if getParsedAccountInfo returns null or an unexpected owner, the legacy TOKEN_PROGRAM_ID is used. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% The code is fairly self-explanatory with the existing comment and clear ternary operator. The fallback behavior is standard programming practice - if a condition isn't met, use the default. The suggestion would add verbosity without adding much clarity. The code change itself is good but doesn't need more documentation. Perhaps some developers less familiar with Token-2022 would benefit from the extra clarity about fallback behavior. The current comment doesn't explicitly state what happens in the negative case. While extra documentation can sometimes help, in this case the logic is straightforward enough that the existing comment plus the clear code structure is sufficient. We should avoid over-documenting simple patterns. The comment should be deleted as it suggests adding unnecessary documentation to already clear code.
2. core/src/createTransfer.ts:150
- Draft comment:
Mint initialization check and precision validation are clear. No changes required. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. core/src/fetchTransaction.ts:28
- Draft comment:
Nice update using getLatestBlockhash over the deprecated getRecentBlockhash, which improves compatibility for Token-2022. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. core/test/createTransfer.test.ts:269
- Draft comment:
Comprehensive tests for both legacy SPL and Token-2022 transfers. The mocks and error validations appear robust. Great job! - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
5. docs/src/INTRODUCTION.md:2
- Draft comment:
Minor title spacing issue: 'Solana Pay' has an extra space. Consider changing it to 'Solana Pay' for consistency. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. docs/src/SPEC.md:100
- Draft comment:
Verify query string delimiter; the example URL appears to use '&label=Michael' without a preceding '?' delimiter. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. SPEC.md:173
- Draft comment:
Typographical note: There is an extra space between 'set the' and '[feePayer]' in this line. Consider removing the additional space for consistency. - Reason this comment was not posted:
Comment was on unchanged code.
8. SPEC1.1.md:187
- Draft comment:
Typographical error: There is an extra space before [feePayer] in this line. Please remove the extra space. - Reason this comment was not posted:
Comment was on unchanged code.
9. docs/src/SPEC.md:178
- Draft comment:
Typo: There is an extra space between 'set the' and '[feePayer]' in this line. Please remove the extra space. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_5afmfGYCOd89NvSc
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Add Token-2022 Program Support
Overview
This PR branches off of #247 to support recent changes and improve test coverage. It adds comprehensive support for the Token-2022 program to Solana Pay's
createTransferfunctionality, enabling seamless transfers of both legacy SPL tokens and Token-2022 tokens while maintaining full backward compatibility.Key Changes
Core Functionality
createTransferfunction now automatically detects whether a token uses the Token-2022 program (TOKEN_2022_PROGRAM_ID) or the legacy Token program (TOKEN_PROGRAM_ID) by checking the token mint's account owner🔧 Implementation Details
core/src/createTransfer.tsTOKEN_2022_PROGRAM_IDandTOKEN_PROGRAM_IDfrom@solana/spl-tokencreateSPLTokenInstruction():tokenProgramparameter:getMint(connection, splToken, undefined, tokenProgram)getAssociatedTokenAddress(splToken, sender, undefined, tokenProgram)getAccount(connection, senderATA, undefined, tokenProgram)createTransferCheckedInstruction(..., tokenProgram)🧪 Testing Improvements
core/test/createTransfer.test.tsTestFixturesclass for consistent test dataMockFactoriesfor creating mock objectsTestHelpersfor common test setup patternsBenefits
✅ Backward Compatibility: Existing integrations continue to work without any changes
✅ Future-Proof: Ready for the growing Token-2022 ecosystem
✅ Automatic Detection: No manual configuration required - the library automatically detects the correct token program
✅ Comprehensive Testing: Robust test coverage ensures reliability across both token standards
Testing
Migration Guide
No migration required! This change is fully backward compatible. The library will automatically detect and handle both legacy SPL tokens and Token-2022 tokens seamlessly.
Closes: Issues related to Token-2022 support
Branch:
t22-support→masterImportant
Adds support for Token-2022 in Solana Pay's
createTransfer, with automatic token program detection and comprehensive test updates.createTransferincreateTransfer.tsnow detects Token-2022 or legacy SPL tokens automatically.createTransfer.test.tsfor better organization.TestFixtures,MockFactories, andTestHelpersfor reusable test components.@solana/spl-tokento^0.4.13and@solana/web3.jsto^1.98.2inpackage.json.SPEC.mdandSPEC1.1.mdto usesolana-foundation.github.ioURLs.This description was created by
for a12376b. You can customize this summary. It will automatically update as commits are pushed.