From 9a9ac1f0dfb01f9345d12bb86da87a451f642636 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Fri, 22 Aug 2025 13:02:18 -0400 Subject: [PATCH 1/4] add ctoken program to token_interface --- spl/src/token_interface.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spl/src/token_interface.rs b/spl/src/token_interface.rs index 6e6047cd4e..ab9767c1da 100644 --- a/spl/src/token_interface.rs +++ b/spl/src/token_interface.rs @@ -9,7 +9,12 @@ pub use crate::token_2022::*; #[cfg(feature = "token_2022_extensions")] pub use crate::token_2022_extensions::*; -static IDS: [Pubkey; 2] = [spl_token::ID, spl_token_2022::ID]; +pub const COMPRESSED_TOKEN_ID: Pubkey = Pubkey::new_from_array([ + 9, 21, 163, 87, 35, 121, 78, 143, 182, 93, 7, 91, 107, 114, 105, 156, 56, 221, 2, 229, 148, + 139, 117, 176, 229, 160, 65, 142, 128, 151, 91, 68, +]); + +static IDS: [Pubkey; 3] = [spl_token::ID, spl_token_2022::ID, COMPRESSED_TOKEN_ID]; #[derive(Clone, Debug, Default, PartialEq, Copy)] pub struct TokenAccount(spl_token_2022::state::Account); From d8a2b3d99d61ef900d1f6cdaabcef14eb9af6279 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Fri, 22 Aug 2025 13:10:33 -0400 Subject: [PATCH 2/4] use external anchor dep in anchor-spl --- spl/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spl/Cargo.toml b/spl/Cargo.toml index 8c5ec66baf..766ad13a5f 100644 --- a/spl/Cargo.toml +++ b/spl/Cargo.toml @@ -26,7 +26,7 @@ token_2022 = ["spl-token-2022"] token_2022_extensions = ["spl-token-2022", "spl-token-group-interface", "spl-token-metadata-interface", "spl-pod"] [dependencies] -anchor-lang = { path = "../lang", version = "0.31.1", features = ["derive"] } +anchor-lang = { version = "0.31.1", features = ["derive"] } borsh = { version = "0.10.3", optional = true } mpl-token-metadata = { version = "5", optional = true } spl-associated-token-account = { version = "6", features = ["no-entrypoint"], optional = true } From da005d7f1f977d5220eaa65da26cdae2df0fe25e Mon Sep 17 00:00:00 2001 From: ananas Date: Sat, 17 Jan 2026 21:24:32 +0000 Subject: [PATCH 3/4] Simplify Mint deserialization and add account type validation - Remove StateWithExtensions overhead, just unpack base 82-byte mint - Validate byte 165 == 1 for mints with extensions (rejects token accounts) --- spl/src/token_interface.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spl/src/token_interface.rs b/spl/src/token_interface.rs index ab9767c1da..33a29743c8 100644 --- a/spl/src/token_interface.rs +++ b/spl/src/token_interface.rs @@ -50,7 +50,14 @@ pub struct Mint(spl_token_2022::state::Mint); impl anchor_lang::AccountDeserialize for Mint { fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result { - spl_token_2022::extension::StateWithExtensions::::unpack(buf) + // If >= 166 bytes, validate account type byte is Mint (1) + if buf.len() >= 166 && buf[165] != 1 { + return Err(anchor_lang::error::ErrorCode::AccountDidNotDeserialize.into()); + } + + // Deserialize base mint only (82 bytes) + let base_slice = &buf[..spl_token_2022::state::Mint::LEN]; + spl_token_2022::extension::StateWithExtensions::::unpack(base_slice) .map(|t| Mint(t.base)) .map_err(Into::into) } From eb2e1dad59060e7a3624079698fcb216faabc616 Mon Sep 17 00:00:00 2001 From: ananas Date: Tue, 20 Jan 2026 03:11:05 +0000 Subject: [PATCH 4/4] Rename anchor-spl to light-anchor-spl --- Cargo.lock | 247 ++++++++++++++++++++++++++++++++++++++++++------- spl/Cargo.toml | 2 +- 2 files changed, 214 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e9749a844..ab8cc26d23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,19 @@ dependencies = [ name = "anchor-attribute-access-control" version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-access-control" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f70fd141a4d18adf11253026b32504f885447048c7494faf5fa83b01af9c0cf" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2", "quote", "syn 1.0.109", @@ -114,7 +126,20 @@ dependencies = [ name = "anchor-attribute-account" version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "bs58", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-account" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715a261c57c7679581e06f07a74fa2af874ac30f86bd8ea07cca4a7e5388a064" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "bs58", "proc-macro2", "quote", @@ -125,7 +150,27 @@ dependencies = [ name = "anchor-attribute-constant" version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-constant" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "730d6df8ae120321c5c25e0779e61789e4b70dc8297102248902022f286102e4" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-error" +version = "0.31.1" +dependencies = [ + "anchor-syn 0.31.1", "quote", "syn 1.0.109", ] @@ -133,8 +178,20 @@ dependencies = [ [[package]] name = "anchor-attribute-error" version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27e6e449cc3a37b2880b74dcafb8e5a17b954c0e58e376432d7adc646fb333ef" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-event" +version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "proc-macro2", "quote", "syn 1.0.109", ] @@ -142,8 +199,10 @@ dependencies = [ [[package]] name = "anchor-attribute-event" version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7710e4c54adf485affcd9be9adec5ef8846d9c71d7f31e16ba86ff9fc1dd49f" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2", "quote", "syn 1.0.109", @@ -153,8 +212,25 @@ dependencies = [ name = "anchor-attribute-program" version = "0.31.1" dependencies = [ - "anchor-lang-idl", - "anchor-syn", + "anchor-lang-idl 0.1.2", + "anchor-syn 0.31.1", + "anyhow", + "bs58", + "heck 0.3.3", + "proc-macro2", + "quote", + "serde_json", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-program" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ecfd49b2aeadeb32f35262230db402abed76ce87e27562b34f61318b2ec83c" +dependencies = [ + "anchor-lang-idl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "anyhow", "bs58", "heck 0.3.3", @@ -169,8 +245,8 @@ name = "anchor-cli" version = "0.31.1" dependencies = [ "anchor-client", - "anchor-lang", - "anchor-lang-idl", + "anchor-lang 0.31.1", + "anchor-lang-idl 0.1.2", "anyhow", "base64 0.21.7", "bincode", @@ -204,7 +280,7 @@ dependencies = [ name = "anchor-client" version = "0.31.1" dependencies = [ - "anchor-lang", + "anchor-lang 0.31.1", "anyhow", "futures", "regex", @@ -221,7 +297,18 @@ dependencies = [ name = "anchor-derive-accounts" version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-accounts" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be89d160793a88495af462a7010b3978e48e30a630c91de47ce2c1d3cb7a6149" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "quote", "syn 1.0.109", ] @@ -230,7 +317,20 @@ dependencies = [ name = "anchor-derive-serde" version = "0.31.1" dependencies = [ - "anchor-syn", + "anchor-syn 0.31.1", + "borsh-derive-internal", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-serde" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc6ee78acb7bfe0c2dd2abc677aaa4789c0281a0c0ef01dbf6fe85e0fd9e6e4" +dependencies = [ + "anchor-syn 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", "borsh-derive-internal", "proc-macro2", "quote", @@ -246,20 +346,31 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "anchor-derive-space" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134a01c0703f6fd355a0e472c033f6f3e41fac1ef6e370b20c50f4c8d022cea7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "anchor-lang" version = "0.31.1" dependencies = [ - "anchor-attribute-access-control", - "anchor-attribute-account", - "anchor-attribute-constant", - "anchor-attribute-error", - "anchor-attribute-event", - "anchor-attribute-program", - "anchor-derive-accounts", - "anchor-derive-serde", - "anchor-derive-space", - "anchor-lang-idl", + "anchor-attribute-access-control 0.31.1", + "anchor-attribute-account 0.31.1", + "anchor-attribute-constant 0.31.1", + "anchor-attribute-error 0.31.1", + "anchor-attribute-event 0.31.1", + "anchor-attribute-program 0.31.1", + "anchor-derive-accounts 0.31.1", + "anchor-derive-serde 0.31.1", + "anchor-derive-space 0.31.1", + "anchor-lang-idl 0.1.2", "base64 0.21.7", "bincode", "borsh 0.10.3", @@ -268,11 +379,50 @@ dependencies = [ "thiserror", ] +[[package]] +name = "anchor-lang" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6bab117055905e930f762c196e08f861f8dfe7241b92cee46677a3b15561a0a" +dependencies = [ + "anchor-attribute-access-control 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-attribute-account 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-attribute-constant 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-attribute-error 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-attribute-event 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-attribute-program 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-derive-accounts 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-derive-serde 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-derive-space 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-lang-idl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.21.7", + "bincode", + "borsh 0.10.3", + "bytemuck", + "solana-program", + "thiserror", +] + +[[package]] +name = "anchor-lang-idl" +version = "0.1.2" +dependencies = [ + "anchor-lang-idl-spec 0.1.0", + "anyhow", + "heck 0.3.3", + "regex", + "serde", + "serde_json", + "sha2 0.10.8", +] + [[package]] name = "anchor-lang-idl" version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e8599d21995f68e296265aa5ab0c3cef582fd58afec014d01bd0bce18a4418" dependencies = [ - "anchor-lang-idl-spec", + "anchor-lang-idl-spec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "anyhow", "heck 0.3.3", "regex", @@ -290,24 +440,37 @@ dependencies = [ ] [[package]] -name = "anchor-spl" +name = "anchor-lang-idl-spec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bdf143115440fe621bdac3a29a1f7472e09f6cd82b2aa569429a0c13f103838" +dependencies = [ + "anyhow", + "serde", +] + +[[package]] +name = "anchor-syn" version = "0.31.1" dependencies = [ - "anchor-lang", - "borsh 0.10.3", - "mpl-token-metadata", - "spl-associated-token-account", - "spl-memo 6.0.0", - "spl-pod 0.5.0", - "spl-token 7.0.0", - "spl-token-2022 6.0.0", - "spl-token-group-interface 0.5.0", - "spl-token-metadata-interface 0.6.0", + "anyhow", + "bs58", + "cargo_toml", + "heck 0.3.3", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.10.8", + "syn 1.0.109", + "thiserror", ] [[package]] name = "anchor-syn" version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dc7a6d90cc643df0ed2744862cdf180587d1e5d28936538c18fc8908489ed67" dependencies = [ "anyhow", "bs58", @@ -2409,6 +2572,22 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "light-anchor-spl" +version = "0.31.1" +dependencies = [ + "anchor-lang 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "borsh 0.10.3", + "mpl-token-metadata", + "spl-associated-token-account", + "spl-memo 6.0.0", + "spl-pod 0.5.0", + "spl-token 7.0.0", + "spl-token-2022 6.0.0", + "spl-token-group-interface 0.5.0", + "spl-token-metadata-interface 0.6.0", +] + [[package]] name = "linux-raw-sys" version = "0.4.8" diff --git a/spl/Cargo.toml b/spl/Cargo.toml index 766ad13a5f..3e048fe18f 100644 --- a/spl/Cargo.toml +++ b/spl/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "anchor-spl" +name = "light-anchor-spl" version = "0.31.1" authors = ["Anchor Maintainers "] edition = "2021"