Merge pull request #84 from SebastianBor/feat/check-upgrade-authority-when-governance-created

Governance: Pass program data account and upgrade authority accounts
This commit is contained in:
Jordan Prince 2021-04-22 15:37:40 -05:00 committed by GitHub
commit 9d30c4b12e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -127,10 +127,17 @@ export const registerProgramGovernance = async (
PROGRAM_IDS.timelock.programId, PROGRAM_IDS.timelock.programId,
); );
const [programDataAccount] = await PublicKey.findProgramAddress(
[uninitializedTimelockConfig.program.toBuffer()],
PROGRAM_IDS.bpf_upgrade_loader,
);
instructions.push( instructions.push(
createEmptyTimelockConfigInstruction( createEmptyTimelockConfigInstruction(
timelockConfigKey, timelockConfigKey,
uninitializedTimelockConfig.program, uninitializedTimelockConfig.program,
programDataAccount,
wallet.publicKey,
uninitializedTimelockConfig.governanceMint, uninitializedTimelockConfig.governanceMint,
wallet.publicKey, wallet.publicKey,
uninitializedTimelockConfig.councilMint, uninitializedTimelockConfig.councilMint,

View File

@ -20,6 +20,8 @@ import * as Layout from '../utils/layout';
export const createEmptyTimelockConfigInstruction = ( export const createEmptyTimelockConfigInstruction = (
timelockConfigAccount: PublicKey, timelockConfigAccount: PublicKey,
programAccount: PublicKey, programAccount: PublicKey,
programDataAccount: PublicKey,
programUpgradeAuthority: PublicKey,
governanceMint: PublicKey, governanceMint: PublicKey,
payer: PublicKey, payer: PublicKey,
councilMint?: PublicKey, councilMint?: PublicKey,
@ -40,15 +42,16 @@ export const createEmptyTimelockConfigInstruction = (
const keys = [ const keys = [
{ pubkey: timelockConfigAccount, isSigner: false, isWritable: false }, { pubkey: timelockConfigAccount, isSigner: false, isWritable: false },
{ pubkey: programAccount, isSigner: false, isWritable: false }, { pubkey: programAccount, isSigner: false, isWritable: false },
{ pubkey: programDataAccount, isSigner: false, isWritable: true },
{ pubkey: programUpgradeAuthority, isSigner: true, isWritable: false },
{ pubkey: governanceMint, isSigner: false, isWritable: false }, { pubkey: governanceMint, isSigner: false, isWritable: false },
{ pubkey: payer, isSigner: true, isWritable: false }, { pubkey: payer, isSigner: true, isWritable: false },
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
{ {
pubkey: PROGRAM_IDS.timelock.programId, pubkey: PROGRAM_IDS.bpf_upgrade_loader,
isSigner: false, isSigner: false,
isWritable: false, isWritable: false,
}, },
{ pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false },
]; ];
if (councilMint) { if (councilMint) {