Skip to content

Commit adc5a74

Browse files
Merge pull request #6259 from BitGo/WIN-5840
fix(sdk-coin-sol): make spl program id as default
2 parents 0e76b0a + d96dfe9 commit adc5a74

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/sdk-coin-sol/src/lib/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,14 @@ export async function getAssociatedTokenAccountAddress(
544544
}
545545

546546
const coin = getSolTokenFromAddressOnly(tokenMintAddress);
547-
if (!coin || !(coin instanceof SolCoin)) {
548-
throw new UtilsError(`Token not found or not a Solana token: ${tokenMintAddress}`);
547+
let ataAddress: PublicKey;
548+
let programId: string;
549+
if (coin && coin instanceof SolCoin && (coin as any).programId) {
550+
programId = (coin as any).programId.toString();
551+
} else {
552+
programId = TOKEN_PROGRAM_ID.toString();
549553
}
550554

551-
let ataAddress: PublicKey;
552-
const programId = coin.programId;
553555
if (programId === TOKEN_2022_PROGRAM_ID.toString()) {
554556
ataAddress = await getAssociatedTokenAddress(mintPublicKey, ownerPublicKey, false, TOKEN_2022_PROGRAM_ID);
555557
} else {

0 commit comments

Comments
 (0)