Skip to content

Conversation

@raj-bitgo
Copy link
Contributor

  • Added functions to support mints and burns for sol

TICKET: TMS-977

@raj-bitgo raj-bitgo requested a review from a team as a code owner July 29, 2025 06:09
@raj-bitgo raj-bitgo force-pushed the TMS-977-sol-mint-burn-instructions branch from e8e88ea to 5e15b3a Compare July 29, 2025 06:10
@dpkjnr dpkjnr requested a review from Copilot July 29, 2025 06:28
Copy link

Copilot AI left a 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

Comment on lines 544 to 546
burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber(), [], TOKEN_2022_PROGRAM_ID);
} else {
burnInstr = createBurnInstruction(account, mint, authority, amountBN.toNumber());
Copy link

Copilot AI Jul 29, 2025

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.

Suggested change
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()));

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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
sachushaji previously approved these changes Jul 29, 2025
Copy link
Contributor

@sachushaji sachushaji left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you type this?

Copy link
Contributor Author

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
@raj-bitgo raj-bitgo force-pushed the TMS-977-sol-mint-burn-instructions branch from 5e15b3a to 28dcc38 Compare July 29, 2025 07:19
@raj-bitgo raj-bitgo requested a review from sachushaji July 29, 2025 07:24
if (instruction.programId) {
programIDForMint = instruction.programId.toString();
}
const mintTo: MintTo = {
Copy link
Contributor

@abhishekagrawal080 abhishekagrawal080 Jul 29, 2025

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)?

Copy link
Contributor Author

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.

@raj-bitgo raj-bitgo requested review from a team and abhishekagrawal080 July 29, 2025 07:35
Copy link
Contributor

@Phani024 Phani024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nice work!

@raj-bitgo raj-bitgo merged commit b8c3df5 into master Jul 29, 2025
12 checks passed
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