Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions program-libs/ctoken-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "MIT"
anchor = ["light-compressed-account/anchor", "dep:anchor-lang", "light-compressible/anchor"]
solana = ["dep:solana-program-error", "dep:solana-sysvar", "solana-msg"]
default = []
test-only = []
profile-program = []
profile-heap = ["dep:light-heap"]
poseidon = ["light-hasher/poseidon"]
Expand Down Expand Up @@ -51,6 +52,7 @@ light-account-checks = { workspace = true, features = [
"solana",
] }
spl-token-metadata-interface = "0.6.0"
light-ctoken-interface = { workspace = true, features = ["poseidon", "test-only"] }
light-hasher = { workspace = true, features = ["keccak", "sha256", "poseidon"] }

[lints.rust.unexpected_cfgs]
Expand Down
20 changes: 19 additions & 1 deletion program-libs/ctoken-interface/src/state/ctoken/zero_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl<'a> Deref for ZCToken<'a> {
}
}

#[cfg(feature = "test-only")]
impl PartialEq<CToken> for ZCToken<'_> {
fn eq(&self, other: &CToken) -> bool {
// Compare basic fields
Expand Down Expand Up @@ -380,7 +381,23 @@ impl PartialEq<CToken> for ZCToken<'_> {
}
}
}
_ => return false, // Different extension types
// Mismatched known extension types (e.g., Compressible vs TokenMetadata)
(
crate::state::extensions::ZExtensionStruct::Compressible(_),
crate::state::extensions::ExtensionStruct::TokenMetadata(_),
)
| (
crate::state::extensions::ZExtensionStruct::TokenMetadata(_),
crate::state::extensions::ExtensionStruct::Compressible(_),
) => return false,
// Unknown or unhandled extension types should panic to surface bugs early
(zc_ext, regular_ext) => {
panic!(
"Unknown extension type comparison: ZCToken extension {:?} vs CToken extension {:?}",
std::mem::discriminant(zc_ext),
std::mem::discriminant(regular_ext)
);
}
}
}
}
Expand All @@ -392,6 +409,7 @@ impl PartialEq<CToken> for ZCToken<'_> {
}
}

#[cfg(feature = "test-only")]
impl PartialEq<ZCToken<'_>> for CToken {
fn eq(&self, other: &ZCToken<'_>) -> bool {
other.eq(self)
Expand Down
2 changes: 1 addition & 1 deletion program-tests/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ solana-sdk = { workspace = true }
thiserror = { workspace = true }
account-compression = { workspace = true, features = ["cpi"] }
light-compressed-token = { workspace = true, features = ["cpi"] }
light-ctoken-interface = { workspace = true }
light-ctoken-interface = { workspace = true, features = ["test-only"] }
light-system-program-anchor = { workspace = true, features = ["cpi"] }
light-registry = { workspace = true, features = ["cpi"] }
spl-token = { workspace = true, features = ["no-entrypoint"] }
Expand Down