@@ -14,7 +14,7 @@ import BN from 'bn.js'
1414import { fetchVotingPower } from '@hooks/queries/plugins/vsr'
1515import { getMint , TOKEN_2022_PROGRAM_ID } from '@solana/spl-token-new'
1616import { getAssociatedTokenAddressSync } from '@solana/spl-token-new'
17- import { MintInfo , u64 } from '@solana/spl-token'
17+ import { MintInfo , TOKEN_PROGRAM_ID , u64 } from '@solana/spl-token'
1818
1919export const DEFAULT_VSR_ID = new web3 . PublicKey (
2020 'vsr2nfGVNHmSY8uxoBGqq8AQbwz3JwaEaHqGbsTPXqQ' ,
@@ -180,12 +180,17 @@ export class VsrClient extends Client<typeof IDL> {
180180
181181 if ( registrarAccount . votingMints . length ) {
182182 const depositMint = registrarAccount . votingMints [ 0 ] . mint
183+ const mintInfo = await this . program . provider . connection . getAccountInfo ( depositMint )
184+ const tokenProgram = mintInfo ?. owner . equals ( TOKEN_2022_PROGRAM_ID )
185+ ? TOKEN_2022_PROGRAM_ID
186+ : TOKEN_PROGRAM_ID
187+
183188 const ata = getAssociatedTokenAddressSync (
184- depositMint , owner , true , TOKEN_2022_PROGRAM_ID
189+ depositMint , owner , true , tokenProgram
185190 )
186191
187192 const account = await this . program . provider . connection . getAccountInfo ( ata )
188- const mintAccount = await getMint ( this . program . provider . connection , depositMint , undefined , TOKEN_2022_PROGRAM_ID )
193+ const mintAccount = await getMint ( this . program . provider . connection , depositMint , undefined , tokenProgram )
189194
190195 return {
191196 pubkey : ata ,
0 commit comments