-
Notifications
You must be signed in to change notification settings - Fork 300
feat: add sol mint and burn instruction functions #6564
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
e8e88ea to
5e15b3a
Compare
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.
Pull Request Overview
This PR adds support for Solana token mint and burn operations to the SDK, enabling both standard SPL token and Token-2022 program instructions.
- Implements mint and burn instruction factories and parsers
- Adds comprehensive test coverage for both standard SPL and Token-2022 programs
- Updates utilities to properly detect and handle mint/burn instruction types
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sdk-coin-sol/src/lib/constants.ts | Adds MintTo and Burn instruction type enums |
| modules/sdk-coin-sol/src/lib/iface.ts | Defines MintTo and Burn interfaces with required parameters |
| modules/sdk-coin-sol/src/lib/utils.ts | Updates instruction type detection to recognize mint and burn operations |
| modules/sdk-coin-sol/src/lib/solInstructionFactory.ts | Implements mintToInstruction and burnInstruction factory functions |
| modules/sdk-coin-sol/src/lib/instructionParamsFactory.ts | Adds parsing logic for mint and burn instructions |
| modules/sdk-coin-sol/test/unit/solInstructionFactory.ts | Comprehensive test coverage for instruction factory functions |
| modules/sdk-coin-sol/test/unit/instructionParamsFactory.ts | Test coverage for instruction parsing functionality |
| burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber(), [], TOKEN_2022_PROGRAM_ID); | ||
| } else { | ||
| burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber()); |
Copilot
AI
Jul 29, 2025
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.
Converting BigNumber to number using .toNumber() may cause precision loss for large amounts. Consider using .toString() and BigInt conversion instead.
| burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber(), [], TOKEN_2022_PROGRAM_ID); | |
| } else { | |
| burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber()); | |
| burnInstr = createBurnInstruction(account, mint, authority, BigInt(amountBN.toString()), [], TOKEN_2022_PROGRAM_ID); | |
| } else { | |
| burnInstr = createBurnInstruction(account, mint, authority, BigInt(amountBN.toString())); |
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.
+1, actually this is a good point
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.
But, since SPL tokens only have 9 decimal places, this should probably be okay as well, double check
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.
converted into bigint anyway just in case
sachushaji
left a comment
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.
Nice Work!!
|
|
||
| // Check for burn instructions (instruction code 8) | ||
| try { | ||
| let burnInstruction; |
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.
can you type this?
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.
updated
- Added functions to support mints and burns for sol TICKET: TMS-977
5e15b3a to
28dcc38
Compare
| if (instruction.programId) { | ||
| programIDForMint = instruction.programId.toString(); | ||
| } | ||
| const mintTo: MintTo = { |
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.
suggestion can we move this common piece of code in one json generator function (for line 256-268 and 284-294)?
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.
MintTo and Burn take in different params, I don't think we need a common piece of code here? Or did you mean something else? If you can elaborate.
Phani024
left a comment
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.
LGTM. Nice work!
TICKET: TMS-977