Skip to content

Commit

Permalink
spl: Bump token-2022 to v1 (#34412)
Browse files Browse the repository at this point in the history
* Update toml and lockfiles

* account-decoder: Add group and group member extensions

* transaction-status: Add token group + pointer extensions

* program-test: Update token-2022 binary
  • Loading branch information
joncinque authored Dec 22, 2023
1 parent 2fd0bae commit 8a8466c
Show file tree
Hide file tree
Showing 12 changed files with 577 additions and 23 deletions.
38 changes: 30 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ solana-zk-keygen = { path = "zk-keygen", version = "=1.18.0" }
solana-zk-token-proof-program = { path = "programs/zk-token-proof", version = "=1.18.0" }
solana-zk-token-sdk = { path = "zk-token-sdk", version = "=1.18.0" }
solana_rbpf = "=0.8.0"
spl-associated-token-account = "=2.2.0"
spl-associated-token-account = "=2.3.0"
spl-instruction-padding = "0.1"
spl-memo = "=4.0.0"
spl-pod = "=0.1.0"
spl-token = "=4.0.0"
spl-token-2022 = "=0.9.0"
spl-token-2022 = "=1.0.0"
spl-token-group-interface = "=0.1.0"
spl-token-metadata-interface = "=0.2.0"
static_assertions = "1.1.0"
stream-cancel = "0.8.2"
Expand Down
1 change: 1 addition & 0 deletions account-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ solana-config-program = { workspace = true }
solana-sdk = { workspace = true }
spl-token = { workspace = true, features = ["no-entrypoint"] }
spl-token-2022 = { workspace = true, features = ["no-entrypoint"] }
spl-token-group-interface = { workspace = true }
spl-token-metadata-interface = { workspace = true }
thiserror = { workspace = true }
zstd = { workspace = true }
Expand Down
96 changes: 96 additions & 0 deletions account-decoder/src/parse_token_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
solana_program::pubkey::Pubkey,
solana_zk_token_sdk::zk_token_elgamal::pod::ElGamalPubkey,
},
spl_token_group_interface::state::{TokenGroup, TokenGroupMember},
spl_token_metadata_interface::state::TokenMetadata,
};

Expand All @@ -32,6 +33,10 @@ pub enum UiExtension {
TransferHookAccount(UiTransferHookAccount),
MetadataPointer(UiMetadataPointer),
TokenMetadata(UiTokenMetadata),
GroupPointer(UiGroupPointer),
GroupMemberPointer(UiGroupMemberPointer),
TokenGroup(UiTokenGroup),
TokenGroupMember(UiTokenGroupMember),
UnparseableExtension,
}

Expand Down Expand Up @@ -108,6 +113,22 @@ pub fn parse_extension<S: BaseState>(
.get_extension::<extension::transfer_hook::TransferHookAccount>()
.map(|&extension| UiExtension::TransferHookAccount(extension.into()))
.unwrap_or(UiExtension::UnparseableExtension),
ExtensionType::GroupPointer => account
.get_extension::<extension::group_pointer::GroupPointer>()
.map(|&extension| UiExtension::GroupPointer(extension.into()))
.unwrap_or(UiExtension::UnparseableExtension),
ExtensionType::GroupMemberPointer => account
.get_extension::<extension::group_member_pointer::GroupMemberPointer>()
.map(|&extension| UiExtension::GroupMemberPointer(extension.into()))
.unwrap_or(UiExtension::UnparseableExtension),
ExtensionType::TokenGroup => account
.get_extension::<TokenGroup>()
.map(|&extension| UiExtension::TokenGroup(extension.into()))
.unwrap_or(UiExtension::UnparseableExtension),
ExtensionType::TokenGroupMember => account
.get_extension::<TokenGroupMember>()
.map(|&extension| UiExtension::TokenGroupMember(extension.into()))
.unwrap_or(UiExtension::UnparseableExtension),
}
}

Expand Down Expand Up @@ -481,3 +502,78 @@ impl From<extension::transfer_hook::TransferHookAccount> for UiTransferHookAccou
}
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UiGroupPointer {
pub authority: Option<String>,
pub group_address: Option<String>,
}

impl From<extension::group_pointer::GroupPointer> for UiGroupPointer {
fn from(group_pointer: extension::group_pointer::GroupPointer) -> Self {
let authority: Option<Pubkey> = group_pointer.authority.into();
let group_address: Option<Pubkey> = group_pointer.group_address.into();
Self {
authority: authority.map(|pubkey| pubkey.to_string()),
group_address: group_address.map(|pubkey| pubkey.to_string()),
}
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UiGroupMemberPointer {
pub authority: Option<String>,
pub member_address: Option<String>,
}

impl From<extension::group_member_pointer::GroupMemberPointer> for UiGroupMemberPointer {
fn from(member_pointer: extension::group_member_pointer::GroupMemberPointer) -> Self {
let authority: Option<Pubkey> = member_pointer.authority.into();
let member_address: Option<Pubkey> = member_pointer.member_address.into();
Self {
authority: authority.map(|pubkey| pubkey.to_string()),
member_address: member_address.map(|pubkey| pubkey.to_string()),
}
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UiTokenGroup {
pub update_authority: Option<String>,
pub mint: String,
pub size: u32,
pub max_size: u32,
}

impl From<TokenGroup> for UiTokenGroup {
fn from(token_group: TokenGroup) -> Self {
let update_authority: Option<Pubkey> = token_group.update_authority.into();
Self {
update_authority: update_authority.map(|pubkey| pubkey.to_string()),
mint: token_group.mint.to_string(),
size: token_group.size.into(),
max_size: token_group.max_size.into(),
}
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct UiTokenGroupMember {
pub mint: String,
pub group: String,
pub member_number: u32,
}

impl From<TokenGroupMember> for UiTokenGroupMember {
fn from(member: TokenGroupMember) -> Self {
Self {
mint: member.mint.to_string(),
group: member.group.to_string(),
member_number: member.member_number.into(),
}
}
}
2 changes: 1 addition & 1 deletion program-test/src/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static SPL_PROGRAMS: &[(Pubkey, Pubkey, &[u8])] = &[
(
spl_token_2022::ID,
solana_sdk::bpf_loader_upgradeable::ID,
include_bytes!("programs/spl_token_2022-0.9.0.so"),
include_bytes!("programs/spl_token_2022-1.0.0.so"),
),
(
spl_memo_1_0::ID,
Expand Down
Binary file removed program-test/src/programs/spl_token_2022-0.9.0.so
Binary file not shown.
Binary file not shown.
38 changes: 30 additions & 8 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8a8466c

Please sign in to comment.