Struct spl_governance::state::token_owner_record::TokenOwnerRecordV2
source · [−]#[repr(C)]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: u32,
pub total_votes_count: u32,
pub outstanding_proposal_count: u8,
pub reserved: [u8; 7],
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: u32
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
total_votes_count: u32
The total number of votes cast by the TokenOwner If TokenOwner withdraws vote while voting is still in progress total_votes_count is decreased and the vote doesn’t count towards the total
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
reserved: [u8; 7]
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: This space won’t be available to v1 accounts until runtime supports resizing
Implementations
sourceimpl 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,
program_id: &Pubkey,
realm_config_info: &AccountInfo<'_>,
account_info_iter: &mut Iter<'_, AccountInfo<'_>>,
realm: &Pubkey,
realm_data: &RealmV2,
weight_action: VoterWeightAction,
weight_action_target: &Pubkey
) -> Result<u64, ProgramError>
pub fn resolve_voter_weight(
&self,
program_id: &Pubkey,
realm_config_info: &AccountInfo<'_>,
account_info_iter: &mut Iter<'_, AccountInfo<'_>>,
realm: &Pubkey,
realm_data: &RealmV2,
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
sourceimpl AccountMaxSize for TokenOwnerRecordV2
impl AccountMaxSize for TokenOwnerRecordV2
sourcefn get_max_size(&self) -> Option<usize>
fn get_max_size(&self) -> Option<usize>
Returns max account size or None if max size is not known and actual instance size should be used
sourceimpl BorshDeserialize for TokenOwnerRecordV2 where
GovernanceAccountType: BorshDeserialize,
Pubkey: BorshDeserialize,
Pubkey: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
u32: BorshDeserialize,
u32: BorshDeserialize,
u8: BorshDeserialize,
[u8; 7]: BorshDeserialize,
Option<Pubkey>: BorshDeserialize,
[u8; 128]: BorshDeserialize,
impl BorshDeserialize for TokenOwnerRecordV2 where
GovernanceAccountType: BorshDeserialize,
Pubkey: BorshDeserialize,
Pubkey: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
u32: BorshDeserialize,
u32: BorshDeserialize,
u8: BorshDeserialize,
[u8; 7]: BorshDeserialize,
Option<Pubkey>: BorshDeserialize,
[u8; 128]: BorshDeserialize,
sourceimpl BorshSchema for TokenOwnerRecordV2 where
GovernanceAccountType: BorshSchema,
Pubkey: BorshSchema,
Pubkey: BorshSchema,
Pubkey: BorshSchema,
u64: BorshSchema,
u32: BorshSchema,
u32: BorshSchema,
u8: BorshSchema,
[u8; 7]: BorshSchema,
Option<Pubkey>: BorshSchema,
[u8; 128]: BorshSchema,
impl BorshSchema for TokenOwnerRecordV2 where
GovernanceAccountType: BorshSchema,
Pubkey: BorshSchema,
Pubkey: BorshSchema,
Pubkey: BorshSchema,
u64: BorshSchema,
u32: BorshSchema,
u32: BorshSchema,
u8: BorshSchema,
[u8; 7]: BorshSchema,
Option<Pubkey>: BorshSchema,
[u8; 128]: BorshSchema,
sourcefn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
sourcefn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
fn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
Recursively, using DFS, add type definitions required for this type. For primitive types this is an empty map. Type definition explains how to serialize/deserialize a type. Read more
sourcefn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition, RandomState>
)
fn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition, RandomState>
)
Helper method to add a single type definition to the map.
fn schema_container() -> BorshSchemaContainer
sourceimpl BorshSerialize for TokenOwnerRecordV2 where
GovernanceAccountType: BorshSerialize,
Pubkey: BorshSerialize,
Pubkey: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
u32: BorshSerialize,
u32: BorshSerialize,
u8: BorshSerialize,
[u8; 7]: BorshSerialize,
Option<Pubkey>: BorshSerialize,
[u8; 128]: BorshSerialize,
impl BorshSerialize for TokenOwnerRecordV2 where
GovernanceAccountType: BorshSerialize,
Pubkey: BorshSerialize,
Pubkey: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
u32: BorshSerialize,
u32: BorshSerialize,
u8: BorshSerialize,
[u8; 7]: BorshSerialize,
Option<Pubkey>: BorshSerialize,
[u8; 128]: BorshSerialize,
sourceimpl Clone for TokenOwnerRecordV2
impl Clone for TokenOwnerRecordV2
sourcefn clone(&self) -> TokenOwnerRecordV2
fn clone(&self) -> TokenOwnerRecordV2
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TokenOwnerRecordV2
impl Debug for TokenOwnerRecordV2
sourceimpl IsInitialized for TokenOwnerRecordV2
impl IsInitialized for TokenOwnerRecordV2
sourcefn is_initialized(&self) -> bool
fn is_initialized(&self) -> bool
Is initialized
sourceimpl PartialEq<TokenOwnerRecordV2> for TokenOwnerRecordV2
impl PartialEq<TokenOwnerRecordV2> for TokenOwnerRecordV2
sourcefn eq(&self, other: &TokenOwnerRecordV2) -> bool
fn eq(&self, other: &TokenOwnerRecordV2) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TokenOwnerRecordV2) -> bool
fn ne(&self, other: &TokenOwnerRecordV2) -> bool
This method tests for !=
.
impl StructuralPartialEq for TokenOwnerRecordV2
Auto Trait Implementations
impl RefUnwindSafe for TokenOwnerRecordV2
impl Send for TokenOwnerRecordV2
impl Sync for TokenOwnerRecordV2
impl Unpin for TokenOwnerRecordV2
impl UnwindSafe for TokenOwnerRecordV2
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
pub default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more