Merge pull request #71 from SebastianBor/fix/transfer-authority-signers

Governance: Fix transfer authority signers
This commit is contained in:
Jordan Prince 2021-04-16 13:04:36 -05:00 committed by GitHub
commit 73fd0aac7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 20 deletions

View File

@ -65,27 +65,17 @@ export function approve(
const transferAuthority = existingTransferAuthority || new Account(); const transferAuthority = existingTransferAuthority || new Account();
const delegateKey = delegate ?? transferAuthority.publicKey; const delegateKey = delegate ?? transferAuthority.publicKey;
const instruction = Token.createApproveInstruction( instructions.push(
tokenProgram, Token.createApproveInstruction(
account, tokenProgram,
delegateKey, account,
owner, delegate ?? transferAuthority.publicKey,
[], owner,
amount, [],
amount,
),
); );
// Temp. workaround for a bug in Token.createApproveInstruction which doesn't add the delegate account to signers
instruction.keys = instruction.keys.map(k =>
k.pubkey.equals(delegateKey)
? {
...k,
isSigner: true,
}
: k,
);
instructions.push(instruction);
if (autoRevoke) { if (autoRevoke) {
cleanupInstructions.push( cleanupInstructions.push(
Token.createRevokeInstruction(tokenProgram, account, owner, []), Token.createRevokeInstruction(tokenProgram, account, owner, []),

View File

@ -55,7 +55,7 @@ export const depositSourceTokensInstruction = (
{ pubkey: sourceHoldingAccount, isSigner: false, isWritable: true }, { pubkey: sourceHoldingAccount, isSigner: false, isWritable: true },
{ pubkey: votingMint, isSigner: false, isWritable: true }, { pubkey: votingMint, isSigner: false, isWritable: true },
{ pubkey: timelockSetAccount, isSigner: false, isWritable: false }, { pubkey: timelockSetAccount, isSigner: false, isWritable: false },
{ pubkey: transferAuthority, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false },
{ pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false },
{ pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false },
]; ];