diff --git a/components/GovernancePower/Vanilla/useDepositCallback.tsx b/components/GovernancePower/Vanilla/useDepositCallback.tsx index 3d8e2dfa8e..08b47f7bde 100644 --- a/components/GovernancePower/Vanilla/useDepositCallback.tsx +++ b/components/GovernancePower/Vanilla/useDepositCallback.tsx @@ -38,24 +38,30 @@ export const useDepositCallback = ( ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, mint, - walletPk // owner + walletPk, // owner + true ) const instructions: TransactionInstruction[] = [] const signers: Keypair[] = [] - const transferAuthority = approveTokenTransfer( - instructions, - [], - userAtaPk, - wallet!.publicKey!, - amount - ) + // Checks if the connected wallet is the Squads Multisig extension (or any PDA wallet for future reference). If it is the case, it will not use an ephemeral signer. + const transferAuthority = wallet?.name == "SquadsX" + ? undefined + : approveTokenTransfer(instructions, [], userAtaPk, wallet!.publicKey!, amount); - signers.push(transferAuthority) + if (transferAuthority) { + signers.push(transferAuthority); + } const programVersion = await fetchProgramVersion(connection, realm.owner) + const publicKeyToUse = transferAuthority != undefined && wallet?.publicKey != null ? transferAuthority.publicKey : wallet?.publicKey; + + if (!publicKeyToUse) { + throw new Error() + } + await withDepositGoverningTokens( instructions, realm.owner, @@ -64,7 +70,7 @@ export const useDepositCallback = ( userAtaPk, mint, walletPk, - transferAuthority.publicKey, + publicKeyToUse, walletPk, amount ) diff --git a/hooks/useUserGovTokenAccount.ts b/hooks/useUserGovTokenAccount.ts index cf6311f973..c723199cc5 100644 --- a/hooks/useUserGovTokenAccount.ts +++ b/hooks/useUserGovTokenAccount.ts @@ -24,7 +24,8 @@ const useUserGovTokenAccountQuery = (role: 'community' | 'council') => { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, mint, - walletPk + walletPk, + true ), [mint, walletPk] ) diff --git a/utils/instructions/PsyFinance/index.ts b/utils/instructions/PsyFinance/index.ts index f829b90a6a..b6f88eb11e 100644 --- a/utils/instructions/PsyFinance/index.ts +++ b/utils/instructions/PsyFinance/index.ts @@ -175,7 +175,8 @@ export const initializeOptionInstruction = async ( ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, underlyingMint, - FEE_OWNER_KEY + FEE_OWNER_KEY, + true ) remainingAccounts.push({ pubkey: mintFeeKey, @@ -199,7 +200,8 @@ export const initializeOptionInstruction = async ( ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, quoteMint, - FEE_OWNER_KEY + FEE_OWNER_KEY, + true ) remainingAccounts.push({ pubkey: exerciseFeeKey, diff --git a/utils/uiTypes/VotePlugin.ts b/utils/uiTypes/VotePlugin.ts index 648fe63788..9bab49d3ec 100644 --- a/utils/uiTypes/VotePlugin.ts +++ b/utils/uiTypes/VotePlugin.ts @@ -207,7 +207,7 @@ export class VotingClient { ) for (const pos of this.heliumVsrVotingPositions) { - const tokenAccount = await getAssociatedTokenAddress(pos.mint, walletPk) + const tokenAccount = await getAssociatedTokenAddress(pos.mint, walletPk, true) remainingAccounts.push( new AccountData(tokenAccount), @@ -396,7 +396,7 @@ export class VotingClient { for (let i = 0; i < unusedPositions.length; i++) { const pos = unusedPositions[i] - const tokenAccount = await getAssociatedTokenAddress(pos.mint, walletPk) + const tokenAccount = await getAssociatedTokenAddress(pos.mint, walletPk, true) const [nftVoteRecord] = nftVoteRecordKey( proposal.pubkey, pos.mint,