Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
token-2022(feat): add serialisation option for the extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
niks3089 committed Oct 5, 2023
1 parent d97f735 commit f2d6fac
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/cpi_guard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use {
spl_pod::primitives::PodBool,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// CPI Guard extension instructions
pub mod instruction;

Expand All @@ -16,6 +19,7 @@ pub mod processor;

/// CPI Guard extension for Accounts
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct CpiGuard {
/// Lock privileged token operations from happening via CPI
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/default_account_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use {
bytemuck::{Pod, Zeroable},
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Default Account state extension instructions
pub mod instruction;

Expand All @@ -11,6 +14,7 @@ pub mod processor;

/// Default Account::state extension data for mints.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct DefaultAccountState {
/// Default Account::state in which new Accounts should be initialized
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/immutable_owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use {
bytemuck::{Pod, Zeroable},
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Indicates that the Account owner authority cannot be changed
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
#[repr(transparent)]
pub struct ImmutableOwner;
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/interest_bearing_mint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use {
std::convert::TryInto,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Interest-bearing mint extension instructions
pub mod instruction;

Expand All @@ -32,6 +35,7 @@ pub type UnixTimestamp = PodI64;
/// To support changing the rate, the config also maintains state for the previous
/// rate.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct InterestBearingConfig {
/// Authority that can set the interest rate and authority
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/memo_transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use {
spl_pod::primitives::PodBool,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Memo Transfer extension instructions
pub mod instruction;

Expand All @@ -19,6 +22,7 @@ pub mod processor;

/// Memo Transfer extension for Accounts
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct MemoTransfer {
/// Require transfers into this account to be accompanied by a memo
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/metadata_pointer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ use {
spl_pod::optional_keys::OptionalNonZeroPubkey,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Instructions for the MetadataPointer extension
pub mod instruction;
/// Instruction processor for the MetadataPointer extension
pub mod processor;

/// Metadata pointer extension data for mints.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct MetadataPointer {
/// Authority that can set the metadata address
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/mint_close_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ use {
spl_pod::optional_keys::OptionalNonZeroPubkey,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Close authority extension data for mints.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct MintCloseAuthority {
/// Optional authority to close the mint
Expand Down
5 changes: 5 additions & 0 deletions token/program-2022/src/extension/non_transferable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ use {
bytemuck::{Pod, Zeroable},
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Indicates that the tokens from this mint can't be transfered
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
#[repr(transparent)]
pub struct NonTransferable;

/// Indicates that the tokens from this account belong to a non-transferable mint
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
#[repr(transparent)]
pub struct NonTransferableAccount;
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/permanent_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ use {
spl_pod::optional_keys::OptionalNonZeroPubkey,
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Permanent delegate extension data for mints.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct PermanentDelegate {
/// Optional permanent delegate for transferring or burning tokens
Expand Down
4 changes: 4 additions & 0 deletions token/program-2022/src/extension/transfer_fee/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ use {
},
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Transfer fee extension instructions
pub mod instruction;

Expand All @@ -27,6 +30,7 @@ const ONE_IN_BASIS_POINTS: u128 = MAX_FEE_BASIS_POINTS as u128;

/// Transfer fee information
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct TransferFee {
/// First epoch where the transfer fee takes effect
Expand Down
5 changes: 5 additions & 0 deletions token/program-2022/src/extension/transfer_hook/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ use {
spl_pod::{optional_keys::OptionalNonZeroPubkey, primitives::PodBool},
};

#[cfg(feature = "serde-traits")]
use serde::{Deserialize, Serialize};

/// Instructions for the TransferHook extension
pub mod instruction;
/// Instruction processor for the TransferHook extension
pub mod processor;

/// Transfer hook extension data for mints.
#[repr(C)]
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
pub struct TransferHook {
/// Authority that can set the transfer hook program id
Expand All @@ -26,6 +30,7 @@ pub struct TransferHook {
}

/// Indicates that the tokens from this account belong to a mint with a transfer hook
#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
#[repr(transparent)]
pub struct TransferHookAccount {
Expand Down

0 comments on commit f2d6fac

Please sign in to comment.