@@ -91,19 +91,14 @@ pub struct GovernanceV2 {
9191 /// Governance Realm
9292 pub realm : Pubkey ,
9393
94- /// Account governed by this Governance and/or PDA identity seed
95- /// It can be Program account, Mint account, Token account or any other
96- /// account
94+ /// The seed used to create Governance account PDA
9795 ///
98- /// Note: The account doesn't have to exist. In that case the field is only
99- /// a PDA seed
100- ///
101- /// Note: Setting governed_account doesn't give any authority over the
102- /// governed account The relevant authorities for specific account types
103- /// must still be transferred to the Governance PDA Ex: mint_authority/
104- /// freeze_authority for a Mint account or upgrade_authority for a
105- /// Program account should be transferred to the Governance PDA
106- pub governed_account : Pubkey ,
96+ /// Note: For the legacy asset specific Governance accounts
97+ /// the seed by convention is:
98+ /// MintGovernance -> mint address
99+ /// TokenAccountGovernance -> token account address
100+ /// ProgramGovernance -> program address
101+ pub governance_seed : Pubkey ,
107102
108103 /// Reserved space for future versions
109104 pub reserved1 : u32 ,
@@ -221,17 +216,17 @@ impl GovernanceV2 {
221216 pub fn get_governance_address_seeds ( & self ) -> Result < [ & [ u8 ] ; 3 ] , ProgramError > {
222217 let seeds = match self . account_type {
223218 GovernanceAccountType :: GovernanceV1 | GovernanceAccountType :: GovernanceV2 => {
224- get_governance_address_seeds ( & self . realm , & self . governed_account )
219+ get_governance_address_seeds ( & self . realm , & self . governance_seed )
225220 }
226221 GovernanceAccountType :: ProgramGovernanceV1
227222 | GovernanceAccountType :: ProgramGovernanceV2 => {
228- get_program_governance_address_seeds ( & self . realm , & self . governed_account )
223+ get_program_governance_address_seeds ( & self . realm , & self . governance_seed )
229224 }
230225 GovernanceAccountType :: MintGovernanceV1 | GovernanceAccountType :: MintGovernanceV2 => {
231- get_mint_governance_address_seeds ( & self . realm , & self . governed_account )
226+ get_mint_governance_address_seeds ( & self . realm , & self . governance_seed )
232227 }
233228 GovernanceAccountType :: TokenGovernanceV1 | GovernanceAccountType :: TokenGovernanceV2 => {
234- get_token_governance_address_seeds ( & self . realm , & self . governed_account )
229+ get_token_governance_address_seeds ( & self . realm , & self . governance_seed )
235230 }
236231 GovernanceAccountType :: Uninitialized
237232 | GovernanceAccountType :: RealmV1
@@ -277,7 +272,7 @@ impl GovernanceV2 {
277272 let governance_data_v1 = GovernanceV1 {
278273 account_type : self . account_type ,
279274 realm : self . realm ,
280- governed_account : self . governed_account ,
275+ governance_seed : self . governance_seed ,
281276 proposals_count : 0 ,
282277 config : self . config ,
283278 } ;
@@ -419,7 +414,7 @@ pub fn get_governance_data(
419414 GovernanceV2 {
420415 account_type,
421416 realm : governance_data_v1. realm ,
422- governed_account : governance_data_v1. governed_account ,
417+ governance_seed : governance_data_v1. governance_seed ,
423418 reserved1 : 0 ,
424419 config : governance_data_v1. config ,
425420 reserved_v2 : Reserved119 :: default ( ) ,
@@ -560,22 +555,26 @@ pub fn get_mint_governance_address<'a>(
560555/// Returns legacy TokenGovernance PDA seeds
561556pub fn get_token_governance_address_seeds < ' a > (
562557 realm : & ' a Pubkey ,
563- governed_token : & ' a Pubkey ,
558+ governed_token_account : & ' a Pubkey ,
564559) -> [ & ' a [ u8 ] ; 3 ] {
565560 // 'token-governance' prefix ensures uniqueness of the PDA
566561 // Note: Only the current token account owner can create an account with this
567562 // PDA using CreateTokenGovernance instruction
568- [ b"token-governance" , realm. as_ref ( ) , governed_token. as_ref ( ) ]
563+ [
564+ b"token-governance" ,
565+ realm. as_ref ( ) ,
566+ governed_token_account. as_ref ( ) ,
567+ ]
569568}
570569
571570/// Returns legacy TokenGovernance PDA address
572571pub fn get_token_governance_address < ' a > (
573572 program_id : & Pubkey ,
574573 realm : & ' a Pubkey ,
575- governed_token : & ' a Pubkey ,
574+ governed_token_account : & ' a Pubkey ,
576575) -> Pubkey {
577576 Pubkey :: find_program_address (
578- & get_token_governance_address_seeds ( realm, governed_token ) ,
577+ & get_token_governance_address_seeds ( realm, governed_token_account ) ,
579578 program_id,
580579 )
581580 . 0
@@ -584,23 +583,23 @@ pub fn get_token_governance_address<'a>(
584583/// Returns Governance PDA seeds
585584pub fn get_governance_address_seeds < ' a > (
586585 realm : & ' a Pubkey ,
587- governed_account : & ' a Pubkey ,
586+ governance_seed : & ' a Pubkey ,
588587) -> [ & ' a [ u8 ] ; 3 ] {
589588 [
590589 b"account-governance" ,
591590 realm. as_ref ( ) ,
592- governed_account . as_ref ( ) ,
591+ governance_seed . as_ref ( ) ,
593592 ]
594593}
595594
596595/// Returns Governance PDA address
597596pub fn get_governance_address < ' a > (
598597 program_id : & Pubkey ,
599598 realm : & ' a Pubkey ,
600- governed_account : & ' a Pubkey ,
599+ governance_seed : & ' a Pubkey ,
601600) -> Pubkey {
602601 Pubkey :: find_program_address (
603- & get_governance_address_seeds ( realm, governed_account ) ,
602+ & get_governance_address_seeds ( realm, governance_seed ) ,
604603 program_id,
605604 )
606605 . 0
@@ -697,7 +696,7 @@ mod test {
697696 GovernanceV2 {
698697 account_type : GovernanceAccountType :: GovernanceV2 ,
699698 realm : Pubkey :: new_unique ( ) ,
700- governed_account : Pubkey :: new_unique ( ) ,
699+ governance_seed : Pubkey :: new_unique ( ) ,
701700 reserved1 : 0 ,
702701 config : create_test_governance_config ( ) ,
703702 reserved_v2 : Reserved119 :: default ( ) ,
@@ -710,7 +709,7 @@ mod test {
710709 GovernanceV1 {
711710 account_type : GovernanceAccountType :: GovernanceV1 ,
712711 realm : Pubkey :: new_unique ( ) ,
713- governed_account : Pubkey :: new_unique ( ) ,
712+ governance_seed : Pubkey :: new_unique ( ) ,
714713 proposals_count : 10 ,
715714 config : create_test_governance_config ( ) ,
716715 }
0 commit comments