#[repr(C)]
pub struct TokenRecord { pub key: Key, pub bump: u8, pub state: TokenState, pub rule_set_revision: Option<u64>, pub delegate: Option<Pubkey>, pub delegate_role: Option<TokenDelegateRole>, pub locked_transfer: Option<Pubkey>, }
Expand description

The TokenRecord struct represents the state of the token account holding a pNFT. Given that the token account is always frozen, it includes a state that provides an abstraction of frozen (locked) and thaw (unlocked).

It also stores state regarding token delegates that are set on the token account: the pubkey of the delegate set (this would match the spl-token account delegate) and the role.

Every token account holding a pNFT has a token record associated. The seeds for the token record PDA are:

  1. "metadata"
  2. program id
  3. mint id
  4. "token_record"
  5. token account id

Fields§

§key: Key

Account key.

§bump: u8

Derivation bump.

§state: TokenState

Represented the token state.

§rule_set_revision: Option<u64>

Stores the rule set revision (if any). The revision is updated every time a new token delegate is approved.

§delegate: Option<Pubkey>

Pubkey of the current token delegate. This delegate key will match the spl-token delegate pubkey.

§delegate_role: Option<TokenDelegateRole>

The role of the current token delegate.

§locked_transfer: Option<Pubkey>

Stores the destination pubkey when a transfer is lock to an allowed address. This pubkey gets set when a ‘LockTransfer’ delegate is approved.

Implementations§

source§

impl TokenRecord

source

pub fn is_locked(&self) -> bool

source

pub fn reset(&mut self)

Resets the token state by clearing any state stored.

Trait Implementations§

source§

impl BorshDeserialize for TokenRecordwhere
Key: BorshDeserialize,
u8: BorshDeserialize,
TokenState: BorshDeserialize,
Option<u64>: BorshDeserialize,
Option<Pubkey>: BorshDeserialize,
Option<TokenDelegateRole>: BorshDeserialize,

source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
source§

impl BorshSerialize for TokenRecordwhere
Key: BorshSerialize,
u8: BorshSerialize,
TokenState: BorshSerialize,
Option<u64>: BorshSerialize,
Option<Pubkey>: BorshSerialize,
Option<TokenDelegateRole>: BorshSerialize,

source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

source§

fn try_to_vec(&self) -> Result<Vec<u8, Global>, Error>

Serialize this instance into a vector of bytes.
source§

impl Clone for TokenRecord

source§

fn clone(&self) -> TokenRecord

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TokenRecord

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TokenRecord

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq<TokenRecord> for TokenRecord

source§

fn eq(&self, other: &TokenRecord) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Resizable for TokenRecord

source§

fn from_bytes<'a>(account_data: &[u8]) -> Result<TokenRecord, ProgramError>

Deserializes the struct data from the specified byte array. Read more
source§

fn save<'a>(
&self,
account_info: &'a AccountInfo<'a>,
payer_info: &'a AccountInfo<'a>,
system_program_info: &'a AccountInfo<'a>
) -> Result<(), ProgramError>

Saves the information to the specified account, resizing the account if needed. Read more
source§

impl TokenMetadataAccount for TokenRecord

source§

fn key() -> Key

source§

fn size() -> usize

source§

fn safe_deserialize(data: &[u8]) -> Result<Self, BorshError>

source§

fn from_account_info(
account_info: &AccountInfo<'_>
) -> Result<Self, ProgramError>

source§

fn is_correct_account_type(data: &[u8], data_type: Key, data_size: usize) -> bool

source§

fn pad_length(buf: &mut Vec<u8>) -> Result<(), MetadataError>

source§

impl Eq for TokenRecord

source§

impl StructuralEq for TokenRecord

source§

impl StructuralPartialEq for TokenRecord

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> AbiExample for T

§

default fn example() -> T

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,

§

fn vzip(self) -> V