Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token-2022(feat): add serialisation option for the extensions #5437

Merged
merged 2 commits into from Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading