pub struct TokenOwnerRecordV2 {
pub account_type: GovernanceAccountType,
pub realm: Pubkey,
pub governing_token_mint: Pubkey,
pub governing_token_owner: Pubkey,
pub governing_token_deposit_amount: u64,
pub unrelinquished_votes_count: u64,
pub outstanding_proposal_count: u8,
pub version: u8,
pub reserved: [u8; 6],
pub governance_delegate: Option<Pubkey>,
pub reserved_v2: [u8; 128],
}
Expand description
Governance Token Owner Record Account PDA seeds: [‘governance’, realm, token_mint, token_owner ]
Fields§
§account_type: GovernanceAccountType
Governance account type
realm: Pubkey
The Realm the TokenOwnerRecord belongs to
governing_token_mint: Pubkey
Governing Token Mint the TokenOwnerRecord holds deposit for
governing_token_owner: Pubkey
The owner (either single or multisig) of the deposited governing SPL Tokens This is who can authorize a withdrawal of the tokens
governing_token_deposit_amount: u64
The amount of governing tokens deposited into the Realm This amount is the voter weight used when voting on proposals
unrelinquished_votes_count: u64
The number of votes cast by TokenOwner but not relinquished yet Every time a vote is cast this number is increased and it’s always decreased when relinquishing a vote regardless of the vote state
outstanding_proposal_count: u8
The number of outstanding proposals the TokenOwner currently owns The count is increased when TokenOwner creates a proposal and decreased once it’s either voted on (Succeeded or Defeated) or Cancelled By default it’s restricted to 1 outstanding Proposal per token owner
version: u8
Version of the account layout Note: In future versions (>program V3) we should introduce GovernanceAccountType::TokenOwnerRecord(version:u8) as a way to version this account (and all other accounts too) It can’t be done in program V3 because it would require to fetch another GovernanceAccountType by the UI and the RPC is already overloaded with all the existing types The new account type and versioning scheme can be introduced once we migrate UI to use indexer to fetch all the accounts Once the new versioning scheme is introduced this field can be migrated and removed
The other issues which need to be addressed before we can cleanup the account versioning code:
- Remove the specific governance accounts (ProgramGovernance, TokenGovernance, MintGovernance) The only reason they exist is the UI which can’t handle the generic use case for those assets
- For account layout breaking changes all plugins would have to be upgraded
- For account layout changes the Holaplex indexer would have to be upgraded
- We should migrate the UI to use the indexer for fetching data and stop using getProgramAccounts
- The UI would have to be upgraded to support account migration to the latest version
- The client sdk is already messy because of the different program/account versions and it should be cleaned up before we add even more versions.
reserved: [u8; 6]
Reserved space for future versions
governance_delegate: Option<Pubkey>
A single account that is allowed to operate governance with the deposited governing tokens It can be delegated to by the governing_token_owner or current governance_delegate
reserved_v2: [u8; 128]
Reserved space for versions v2 and onwards Note: V1 accounts must be resized before using this space
Implementations§
source§impl TokenOwnerRecordV2
impl TokenOwnerRecordV2
sourcepub fn assert_token_owner_or_delegate_is_signer(
&self,
governance_authority_info: &AccountInfo<'_>
) -> Result<(), ProgramError>
pub fn assert_token_owner_or_delegate_is_signer( &self, governance_authority_info: &AccountInfo<'_> ) -> Result<(), ProgramError>
Checks whether the provided Governance Authority signed transaction
sourcepub fn assert_can_create_proposal(
&self,
realm_data: &RealmV2,
config: &GovernanceConfig,
voter_weight: u64
) -> Result<(), ProgramError>
pub fn assert_can_create_proposal( &self, realm_data: &RealmV2, config: &GovernanceConfig, voter_weight: u64 ) -> Result<(), ProgramError>
Asserts TokenOwner has enough tokens to be allowed to create proposal and doesn’t have any outstanding proposals
sourcepub fn assert_can_create_governance(
&self,
realm_data: &RealmV2,
voter_weight: u64
) -> Result<(), ProgramError>
pub fn assert_can_create_governance( &self, realm_data: &RealmV2, voter_weight: u64 ) -> Result<(), ProgramError>
Asserts TokenOwner has enough tokens to be allowed to create governance
sourcepub fn assert_can_withdraw_governing_tokens(&self) -> Result<(), ProgramError>
pub fn assert_can_withdraw_governing_tokens(&self) -> Result<(), ProgramError>
Asserts TokenOwner can withdraw tokens from Realm
sourcepub fn decrease_outstanding_proposal_count(&mut self)
pub fn decrease_outstanding_proposal_count(&mut self)
Decreases outstanding_proposal_count
sourcepub fn resolve_voter_weight(
&self,
account_info_iter: &mut Iter<'_, AccountInfo<'_>>,
realm_data: &RealmV2,
realm_config_data: &RealmConfigAccount,
weight_action: VoterWeightAction,
weight_action_target: &Pubkey
) -> Result<u64, ProgramError>
pub fn resolve_voter_weight( &self, account_info_iter: &mut Iter<'_, AccountInfo<'_>>, realm_data: &RealmV2, realm_config_data: &RealmConfigAccount, weight_action: VoterWeightAction, weight_action_target: &Pubkey ) -> Result<u64, ProgramError>
Resolves voter’s weight using either the amount deposited into the realm or weight provided by voter weight addin (if configured)
Trait Implementations§
source§impl AccountMaxSize for TokenOwnerRecordV2
impl AccountMaxSize for TokenOwnerRecordV2
source§fn get_max_size(&self) -> Option<usize>
fn get_max_size(&self) -> Option<usize>
source§impl BorshDeserialize for TokenOwnerRecordV2where
GovernanceAccountType: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
u8: BorshDeserialize,
[u8; 6]: BorshDeserialize,
Option<Pubkey>: BorshDeserialize,
[u8; 128]: BorshDeserialize,
impl BorshDeserialize for TokenOwnerRecordV2where
GovernanceAccountType: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
u8: BorshDeserialize,
[u8; 6]: BorshDeserialize,
Option<Pubkey>: BorshDeserialize,
[u8; 128]: BorshDeserialize,
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSchema for TokenOwnerRecordV2where
GovernanceAccountType: BorshSchema,
Pubkey: BorshSchema,
u64: BorshSchema,
u8: BorshSchema,
[u8; 6]: BorshSchema,
Option<Pubkey>: BorshSchema,
[u8; 128]: BorshSchema,
impl BorshSchema for TokenOwnerRecordV2where
GovernanceAccountType: BorshSchema,
Pubkey: BorshSchema,
u64: BorshSchema,
u8: BorshSchema,
[u8; 6]: BorshSchema,
Option<Pubkey>: BorshSchema,
[u8; 128]: BorshSchema,
source§fn declaration() -> Declaration
fn declaration() -> Declaration
source§fn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
fn add_definitions_recursively( definitions: &mut HashMap<Declaration, Definition> )
source§fn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition>
)
fn add_definition( declaration: String, definition: Definition, definitions: &mut HashMap<String, Definition> )
fn schema_container() -> BorshSchemaContainer
source§impl BorshSerialize for TokenOwnerRecordV2where
GovernanceAccountType: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
u8: BorshSerialize,
[u8; 6]: BorshSerialize,
Option<Pubkey>: BorshSerialize,
[u8; 128]: BorshSerialize,
impl BorshSerialize for TokenOwnerRecordV2where
GovernanceAccountType: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
u8: BorshSerialize,
[u8; 6]: BorshSerialize,
Option<Pubkey>: BorshSerialize,
[u8; 128]: BorshSerialize,
source§impl Clone for TokenOwnerRecordV2
impl Clone for TokenOwnerRecordV2
source§fn clone(&self) -> TokenOwnerRecordV2
fn clone(&self) -> TokenOwnerRecordV2
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TokenOwnerRecordV2
impl Debug for TokenOwnerRecordV2
source§impl IsInitialized for TokenOwnerRecordV2
impl IsInitialized for TokenOwnerRecordV2
source§fn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
source§impl PartialEq for TokenOwnerRecordV2
impl PartialEq for TokenOwnerRecordV2
source§fn eq(&self, other: &TokenOwnerRecordV2) -> bool
fn eq(&self, other: &TokenOwnerRecordV2) -> bool
self
and other
values to be equal, and is used
by ==
.