Skip to content

feat: compressed token sdk #1869

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
58 changes: 58 additions & 0 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ members = [
"sdk-libs/sdk-types",
"sdk-libs/photon-api",
"sdk-libs/program-test",
"sdk-libs/compressed-token-types",
"sdk-libs/compressed-token-sdk",
"xtask",
"examples/anchor/token-escrow",
# "examples/anchor/name-service-without-macros",
Expand All @@ -41,6 +43,7 @@ members = [
# Issue is that anchor discriminator now returns a slice instead of an array
"program-tests/sdk-anchor-test/programs/sdk-anchor-test",
"program-tests/sdk-test",
"program-tests/sdk-token-test",
"program-tests/sdk-pinocchio-test",
"program-tests/create-address-test-program",
"program-tests/utils",
Expand All @@ -61,6 +64,10 @@ strip = "none"
[profile.release]
overflow-checks = true

[workspace.package]
version = "0.1.0"
edition = "2021"

[workspace.dependencies]
solana-banks-client = { version = "2.2" }
solana-banks-interface = { version = "2.2" }
Expand Down Expand Up @@ -177,6 +184,8 @@ account-compression = { path = "programs/account-compression", version = "2.0.0"
light-compressed-token = { path = "programs/compressed-token", version = "2.0.0", features = [
"cpi",
] }
light-compressed-token-types = { path = "sdk-libs/compressed-token-types", name = "light-compressed-token-types" }
light-compressed-token-sdk = { path = "sdk-libs/compressed-token-sdk" }
light-system-program-anchor = { path = "anchor-programs/system", version = "2.0.0", features = [
"cpi",
] }
Expand Down
10 changes: 5 additions & 5 deletions examples/anchor/counter/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(counter::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let rpc_result = rpc
.get_validity_proof(
Expand Down Expand Up @@ -180,7 +180,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(counter::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let hash = compressed_account.hash;

Expand Down Expand Up @@ -241,7 +241,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(counter::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let hash = compressed_account.hash;

Expand Down Expand Up @@ -301,7 +301,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(counter::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let hash = compressed_account.hash;

Expand Down Expand Up @@ -361,7 +361,7 @@ where
{
let mut remaining_accounts = PackedAccounts::default();
let config = SystemAccountMetaConfig::new(counter::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let hash = compressed_account.hash;

Expand Down
2 changes: 1 addition & 1 deletion program-libs/compressed-account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ light-zero-copy = { workspace = true, features = ["std"] }
light-macros = { workspace = true }
pinocchio = { workspace = true, optional = true }
solana-program-error = { workspace = true, optional = true }

solana-msg = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Verify the solana-msg dependency is utilized.

Ensure that the newly added solana-msg dependency is actually used within the light-compressed-account crate to avoid accumulating unused dependencies.


🏁 Script executed:

#!/bin/bash
# Description: Verify that solana-msg is used in the light-compressed-account crate
# Expected: Find usage of solana-msg items in the crate

# Search for solana-msg usage in the compressed-account library
rg -A 3 "use.*solana_msg|solana_msg::" program-libs/compressed-account/src/

Length of output: 77


🏁 Script executed:

#!/bin/bash
# Search for any direct references to the solana-msg crate in the compressed-account code
rg -n "solana_msg" program-libs/compressed-account/src/ -t rust

# Search for any use of the `msg!` macro (provided by solana-msg) in the compressed-account code
rg -n "msg!" program-libs/compressed-account/src/ -t rust

Length of output: 123


Unused solana-msg dependency

Ripgrep searches for both solana_msg references and the msg! macro in program-libs/compressed-account/src/ returned no results. It appears the newly added workspace dependency isn’t actually used.

• Please remove the solana-msg = { workspace = true } line from program-libs/compressed-account/Cargo.toml (line 25) or add the intended messaging calls.

🤖 Prompt for AI Agents
In program-libs/compressed-account/Cargo.toml at line 25, the solana-msg
dependency is declared but not used anywhere in the source code. Remove the line
`solana-msg = { workspace = true }` from the Cargo.toml file to clean up unused
dependencies, unless you plan to add messaging calls that require this
dependency.

# Feature-gated dependencies
anchor-lang = { workspace = true, optional = true }
bytemuck = { workspace = true, optional = true, features = ["derive"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ pub fn hash_with_hashed_values(
vec.push(&discriminator_bytes);
vec.push(data_hash);
}

Ok(Poseidon::hashv(&vec)?)
}

Expand Down
6 changes: 1 addition & 5 deletions program-tests/create-address-test-program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ pub mod system_cpi_test {
let cpi_accounts =
CpiAccounts::new_with_config(&fee_payer, ctx.remaining_accounts, config);

let account_infos = cpi_accounts
.to_account_infos()
.into_iter()
.cloned()
.collect::<Vec<_>>();
let account_infos = cpi_accounts.to_account_infos();

let config = CpiInstructionConfig::try_from(&cpi_accounts)
.map_err(|_| ErrorCode::AccountNotEnoughKeys)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn create_compressed_account(
) -> Result<Signature, RpcError> {
let config = SystemAccountMetaConfig::new(sdk_anchor_test::ID);
let mut remaining_accounts = PackedAccounts::default();
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();

let address_merkle_tree_info = rpc.get_address_tree_v1();

Expand Down Expand Up @@ -149,7 +149,7 @@ async fn update_compressed_account(
let mut remaining_accounts = PackedAccounts::default();

let config = SystemAccountMetaConfig::new(sdk_anchor_test::ID);
remaining_accounts.add_system_accounts(config);
remaining_accounts.add_system_accounts(config).unwrap();
let hash = compressed_account.hash;

let rpc_result = rpc
Expand Down
8 changes: 6 additions & 2 deletions program-tests/sdk-pinocchio-test/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ pub async fn create_pda(
SystemAccountMetaConfig::new(Pubkey::new_from_array(sdk_pinocchio_test::ID));
let mut accounts = PackedAccounts::default();
accounts.add_pre_accounts_signer(payer.pubkey());
accounts.add_system_accounts(system_account_meta_config);
accounts
.add_system_accounts(system_account_meta_config)
.unwrap();

let rpc_result = rpc
.get_validity_proof(
Expand Down Expand Up @@ -142,7 +144,9 @@ pub async fn update_pda(
SystemAccountMetaConfig::new(Pubkey::new_from_array(sdk_pinocchio_test::ID));
let mut accounts = PackedAccounts::default();
accounts.add_pre_accounts_signer(payer.pubkey());
accounts.add_system_accounts(system_account_meta_config);
accounts
.add_system_accounts(system_account_meta_config)
.unwrap();

let rpc_result = rpc
.get_validity_proof(vec![compressed_account.hash().unwrap()], vec![], None)
Expand Down
3 changes: 1 addition & 2 deletions program-tests/sdk-test/src/create_pda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub fn create_pda<const BATCHED: bool>(
&accounts[0],
&accounts[instruction_data.system_accounts_offset as usize..],
config,
)
.unwrap();
)?;

let address_tree_info = instruction_data.address_tree_info;
let (address, address_seed) = if BATCHED {
Expand Down
8 changes: 6 additions & 2 deletions program-tests/sdk-test/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ pub async fn create_pda(
let system_account_meta_config = SystemAccountMetaConfig::new(sdk_test::ID);
let mut accounts = PackedAccounts::default();
accounts.add_pre_accounts_signer(payer.pubkey());
accounts.add_system_accounts(system_account_meta_config);
accounts
.add_system_accounts(system_account_meta_config)
.unwrap();

let rpc_result = rpc
.get_validity_proof(
Expand Down Expand Up @@ -129,7 +131,9 @@ pub async fn update_pda(
let system_account_meta_config = SystemAccountMetaConfig::new(sdk_test::ID);
let mut accounts = PackedAccounts::default();
accounts.add_pre_accounts_signer(payer.pubkey());
accounts.add_system_accounts(system_account_meta_config);
accounts
.add_system_accounts(system_account_meta_config)
.unwrap();

let rpc_result = rpc
.get_validity_proof(vec![compressed_account.hash().unwrap()], vec![], None)
Expand Down
Loading