diff --git a/packages/common/src/models/account.ts b/packages/common/src/models/account.ts index 3447dd2..6570c81 100644 --- a/packages/common/src/models/account.ts +++ b/packages/common/src/models/account.ts @@ -58,10 +58,11 @@ export function approve( // if delegate is not passed ephemeral transfer authority is used delegate?: PublicKey, + existingTransferAuthority?: Account, ): Account { const tokenProgram = TOKEN_PROGRAM_ID; - const transferAuthority = new Account(); + const transferAuthority = existingTransferAuthority || new Account(); const delegateKey = delegate ?? transferAuthority.publicKey; const instruction = Token.createApproveInstruction( diff --git a/packages/common/src/utils/ids.ts b/packages/common/src/utils/ids.ts index 298e93c..f4ee9b9 100644 --- a/packages/common/src/utils/ids.ts +++ b/packages/common/src/utils/ids.ts @@ -69,7 +69,7 @@ export const PROGRAM_IDS = [ { name: 'testnet', timelock: () => ({ - programId: new PublicKey('8DevpkpN6CsdczP6rQ64CHraApXFrq96oGm4VjSNCs4q'), + programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'), }), wormhole: () => ({ pubkey: new PublicKey('5gQf5AUhAgWYgUCt9ouShm9H7dzzXUsLdssYwe5krKhg'), diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/proposals/src/actions/withdrawVotingTokens.ts index 1b16aaf..d11971b 100644 --- a/packages/proposals/src/actions/withdrawVotingTokens.ts +++ b/packages/proposals/src/actions/withdrawVotingTokens.ts @@ -93,20 +93,26 @@ export const withdrawVotingTokens = async ( votingTokenAmount, ); - const yesTransferAuthority = approve( + approve( instructions, [], existingYesVoteAccount, wallet.publicKey, votingTokenAmount, + undefined, + undefined, + transferAuthority, ); - const noTransferAuthority = approve( + approve( instructions, [], existingNoVoteAccount, wallet.publicKey, votingTokenAmount, + undefined, + undefined, + transferAuthority, ); const [governanceVotingRecord] = await PublicKey.findProgramAddress( @@ -119,8 +125,6 @@ export const withdrawVotingTokens = async ( ); signers.push(transferAuthority); - signers.push(yesTransferAuthority); - signers.push(noTransferAuthority); instructions.push( withdrawVotingTokensInstruction( @@ -138,8 +142,6 @@ export const withdrawVotingTokens = async ( state.pubkey, proposal.pubkey, transferAuthority.publicKey, - yesTransferAuthority.publicKey, - noTransferAuthority.publicKey, mintAuthority, votingTokenAmount, ), diff --git a/packages/proposals/src/components/Proposal/WithdrawVote.tsx b/packages/proposals/src/components/Proposal/WithdrawVote.tsx index dd12858..ddf1597 100644 --- a/packages/proposals/src/components/Proposal/WithdrawVote.tsx +++ b/packages/proposals/src/components/Proposal/WithdrawVote.tsx @@ -43,6 +43,7 @@ export function WithdrawVote({ votingTokens > 0 && (state.info.status === TimelockStateStatus.Voting || state.info.status === TimelockStateStatus.Completed || + state.info.status === TimelockStateStatus.Executing || state.info.status === TimelockStateStatus.Defeated); const [btnLabel, title, msg, action] = diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/proposals/src/models/withdrawVotingTokens.ts index 6aa5f26..f488e5d 100644 --- a/packages/proposals/src/models/withdrawVotingTokens.ts +++ b/packages/proposals/src/models/withdrawVotingTokens.ts @@ -20,10 +20,8 @@ import BN from 'bn.js'; /// 11. `[]` Timelock state account. /// 12. `[]` Timelock set account. /// 13. `[]` Transfer authority -/// 14. `[]` Yes Transfer authority -/// 15. `[]` No Transfer authority -/// 16. `[]` Timelock program mint authority -/// 17. `[]` Token program account. +/// 14. `[]` Timelock program mint authority +/// 15. `[]` Token program account. export const withdrawVotingTokensInstruction = ( governanceVotingRecord: PublicKey, votingAccount: PublicKey, @@ -39,8 +37,6 @@ export const withdrawVotingTokensInstruction = ( timelockStateAccount: PublicKey, timelockSetAccount: PublicKey, transferAuthority: PublicKey, - yesTransferAuthority: PublicKey, - noTransferAuthority: PublicKey, mintAuthority: PublicKey, votingTokenAmount: number, ): TransactionInstruction => { @@ -75,9 +71,7 @@ export const withdrawVotingTokensInstruction = ( { pubkey: noVotingMint, isSigner: false, isWritable: true }, { pubkey: timelockStateAccount, isSigner: false, isWritable: false }, { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: transferAuthority, isSigner: false, isWritable: false }, - { pubkey: yesTransferAuthority, isSigner: false, isWritable: false }, - { pubkey: noTransferAuthority, isSigner: false, isWritable: false }, + { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ];