Skip to content

Commit 66f31b9

Browse files
authored
[js-legacy] Fix program check in amountToUiAmount helper functions (#444)
* [js-legacy] Fix program check in amountToUiAmount helper functions This PR fixes a bug in the amountToUiAmount helper functions for the scaled ui and interest bearing token extensions * use equals enforcement
1 parent e58ef98 commit 66f31b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clients/js-legacy/src/actions/amountToUiAmount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export async function amountToUiAmountForMintWithoutSimulation(
190190
const accountInfo = await connection.getAccountInfo(mint);
191191
const programId = accountInfo?.owner;
192192

193-
if (programId !== TOKEN_PROGRAM_ID && programId !== TOKEN_2022_PROGRAM_ID) {
193+
if (!programId?.equals(TOKEN_PROGRAM_ID) && !programId?.equals(TOKEN_2022_PROGRAM_ID)) {
194194
throw new Error('Invalid program ID');
195195
}
196196

@@ -317,7 +317,7 @@ export async function uiAmountToAmountForMintWithoutSimulation(
317317
const accountInfo = await connection.getAccountInfo(mint);
318318
const programId = accountInfo?.owner;
319319

320-
if (programId !== TOKEN_PROGRAM_ID && programId !== TOKEN_2022_PROGRAM_ID) {
320+
if (!programId?.equals(TOKEN_PROGRAM_ID) && !programId?.equals(TOKEN_2022_PROGRAM_ID)) {
321321
throw new Error('Invalid program ID');
322322
}
323323

0 commit comments

Comments
 (0)