diff --git a/.github/workflows/sdk-tests.yml b/.github/workflows/sdk-tests.yml index 27fbd5c385..34089cfb88 100644 --- a/.github/workflows/sdk-tests.yml +++ b/.github/workflows/sdk-tests.yml @@ -54,7 +54,7 @@ jobs: - program: token test sub-tests: '["cargo-test-sbf -p sdk-token-test"]' - program: sdk-libs - packages: light-sdk-macros light-sdk light-program-test light-client light-token-types light-token-sdk + packages: light-sdk-macros light-sdk light-program-test light-client light-token-types light-token test_cmd: | cargo test -p light-sdk-macros cargo test -p light-sdk-macros --all-features @@ -64,7 +64,7 @@ jobs: cargo test -p light-client cargo test -p light-sparse-merkle-tree cargo test -p light-token-types - cargo test -p light-token-sdk --all-features + cargo test -p light-token --all-features steps: - name: Checkout sources uses: actions/checkout@v6 diff --git a/CLAUDE.md b/CLAUDE.md index 2d3c2502fb..36a3738929 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -251,3 +251,35 @@ assert_eq!(ctoken, expected_ctoken, "CToken account should match expected"); - Maintainable - if account layout changes, deserialization handles it - Readable - clear field names vs `account.data[108]` - Single assertion point for the entire account state + +### Getting Anchor Program Instruction Discriminators + +Anchor uses 8-byte discriminators derived from the instruction name. To get discriminators from an Anchor program: + +```rust +#[cfg(test)] +mod discriminator_tests { + use super::*; + use anchor_lang::Discriminator; + + #[test] + fn print_instruction_discriminators() { + // Each instruction in the #[program] module has a corresponding struct + // in the `instruction` module with the DISCRIMINATOR constant + println!("InstructionName: {:?}", instruction::InstructionName::DISCRIMINATOR); + } +} +``` + +Run with: `cargo test -p print_instruction_discriminators -- --nocapture` + +**Example output:** +``` +Claim: [62, 198, 214, 193, 213, 159, 108, 210] +CompressAndClose: [96, 94, 135, 18, 121, 42, 213, 117] +``` + +**When to use discriminators:** +- Building instructions manually without Anchor's `InstructionData` trait +- Creating SDK functions that don't depend on Anchor crate +- Verifying instruction data in tests or validators diff --git a/Cargo.lock b/Cargo.lock index b9bf2210ea..3141a9f235 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ version = "1.1.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "ark-bn254 0.5.0", "ark-ff 0.5.0", "light-account-checks", @@ -294,7 +294,7 @@ version = "2.0.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "light-compressed-account", "light-hasher", "light-heap", @@ -410,22 +410,6 @@ dependencies = [ "spl-token-metadata-interface 0.6.0", ] -[[package]] -name = "anchor-spl" -version = "0.31.1" -source = "git+https://github.com/lightprotocol/anchor?rev=da005d7f#da005d7f1f977d5220eaa65da26cdae2df0fe25e" -dependencies = [ - "anchor-lang", - "mpl-token-metadata", - "spl-associated-token-account 6.0.0", - "spl-memo", - "spl-pod", - "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 = "anchor-syn" version = "0.31.1" @@ -1356,7 +1340,7 @@ dependencies = [ "light-sdk-pinocchio", "light-sdk-types", "light-test-utils", - "light-token-sdk", + "light-token", "light-zero-copy", "num-bigint 0.4.6", "rand 0.8.5", @@ -1420,7 +1404,7 @@ version = "1.1.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "borsh 0.10.4", "forester-utils", "light-batched-merkle-tree", @@ -1434,9 +1418,9 @@ dependencies = [ "light-sdk", "light-system-program-anchor", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-verifier", "light-zero-copy", "rand 0.8.5", @@ -1638,10 +1622,10 @@ name = "csdk-anchor-full-derived-test" version = "0.1.0" dependencies = [ "anchor-lang", - "anchor-spl 0.31.1 (git+https://github.com/lightprotocol/anchor?rev=da005d7f)", "bincode", "borsh 0.10.4", "csdk-anchor-full-derived-test-sdk", + "light-anchor-spl", "light-client", "light-compressed-account", "light-compressible", @@ -1653,9 +1637,9 @@ dependencies = [ "light-sdk-macros", "light-sdk-types", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-token-types", "solana-account", "solana-account-info", @@ -1681,7 +1665,7 @@ dependencies = [ "csdk-anchor-full-derived-test", "light-client", "light-sdk", - "light-token-sdk", + "light-token", "solana-pubkey 2.4.0", ] @@ -2362,9 +2346,9 @@ dependencies = [ "light-sdk", "light-system-program-anchor", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "photon-api", "prometheus", "rand 0.8.5", @@ -3496,6 +3480,23 @@ dependencies = [ "thiserror 2.0.17", ] +[[package]] +name = "light-anchor-spl" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c802e3de6de4bb03bc9e9bacbba8aa94823a083046aaf0ef275b1321984e3" +dependencies = [ + "anchor-lang", + "mpl-token-metadata", + "spl-associated-token-account 6.0.0", + "spl-memo", + "spl-pod", + "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 = "light-array-map" version = "0.1.1" @@ -3575,8 +3576,8 @@ dependencies = [ "light-merkle-tree-metadata", "light-prover-client", "light-sdk", + "light-token", "light-token-interface", - "light-token-sdk", "litesvm", "num-bigint 0.4.6", "photon-api", @@ -3913,8 +3914,8 @@ dependencies = [ "light-registry", "light-sdk", "light-sdk-types", + "light-token", "light-token-interface", - "light-token-sdk", "light-zero-copy", "litesvm", "log", @@ -4015,6 +4016,7 @@ dependencies = [ "solana-instruction", "solana-loader-v3-interface", "solana-msg 2.2.1", + "solana-program", "solana-program-error 2.2.2", "solana-pubkey 2.4.0", "solana-system-interface 1.0.0", @@ -4133,7 +4135,7 @@ version = "1.2.1" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "base64 0.13.1", "create-address-test-program", "forester-utils", @@ -4156,9 +4158,9 @@ dependencies = [ "light-sdk", "light-sparse-merkle-tree", "light-system-program-anchor", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-zero-copy", "log", "num-bigint 0.4.6", @@ -4174,6 +4176,37 @@ dependencies = [ "thiserror 2.0.17", ] +[[package]] +name = "light-token" +version = "0.2.1" +dependencies = [ + "anchor-lang", + "arrayvec", + "borsh 0.10.4", + "light-account-checks", + "light-batched-merkle-tree", + "light-compressed-account", + "light-compressed-token", + "light-compressible", + "light-macros", + "light-program-profiler", + "light-sdk", + "light-sdk-macros", + "light-sdk-types", + "light-token-interface", + "light-token-types", + "light-zero-copy", + "pinocchio", + "solana-account-info", + "solana-cpi", + "solana-instruction", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "spl-pod", + "thiserror 2.0.17", +] + [[package]] name = "light-token-client" version = "0.1.0" @@ -4183,8 +4216,8 @@ dependencies = [ "light-compressed-account", "light-compressible", "light-sdk", + "light-token", "light-token-interface", - "light-token-sdk", "light-token-types", "light-zero-copy", "solana-instruction", @@ -4233,36 +4266,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "light-token-sdk" -version = "0.2.1" -dependencies = [ - "anchor-lang", - "arrayvec", - "borsh 0.10.4", - "light-account-checks", - "light-batched-merkle-tree", - "light-compressed-account", - "light-compressed-token", - "light-compressible", - "light-macros", - "light-program-profiler", - "light-sdk", - "light-sdk-types", - "light-token-interface", - "light-token-types", - "light-zero-copy", - "pinocchio", - "solana-account-info", - "solana-cpi", - "solana-instruction", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-pubkey 2.4.0", - "spl-pod", - "thiserror 2.0.17", -] - [[package]] name = "light-token-types" version = "0.2.1" @@ -5585,7 +5588,7 @@ version = "1.1.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "borsh 0.10.4", "forester-utils", "light-account-checks", @@ -5598,9 +5601,9 @@ dependencies = [ "light-prover-client", "light-registry", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-zero-copy", "serial_test", "solana-sdk", @@ -6016,7 +6019,7 @@ dependencies = [ name = "sdk-light-token-test" version = "0.1.0" dependencies = [ - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "borsh 0.10.4", "light-client", "light-compressed-account", @@ -6025,9 +6028,9 @@ dependencies = [ "light-sdk", "light-sdk-types", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-token-types", "solana-program", "solana-sdk", @@ -6092,7 +6095,7 @@ name = "sdk-token-test" version = "1.0.0" dependencies = [ "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "arrayvec", "borsh 0.10.4", "light-batched-merkle-tree", @@ -6105,9 +6108,9 @@ dependencies = [ "light-sdk", "light-sdk-types", "light-test-utils", + "light-token", "light-token-client", "light-token-interface", - "light-token-sdk", "light-token-types", "light-zero-copy", "serial_test", @@ -10184,7 +10187,7 @@ version = "1.1.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "create-address-test-program", "light-account-checks", "light-batched-merkle-tree", @@ -10200,7 +10203,7 @@ dependencies = [ "light-sdk-types", "light-system-program-anchor", "light-test-utils", - "light-token-sdk", + "light-token", "light-verifier", "rand 0.8.5", "serial_test", @@ -10214,7 +10217,7 @@ version = "0.1.0" dependencies = [ "account-compression", "anchor-lang", - "anchor-spl 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anchor-spl", "create-address-test-program", "light-account-checks", "light-batched-merkle-tree", @@ -11803,7 +11806,7 @@ dependencies = [ "light-program-test", "light-registry", "light-test-utils", - "light-token-sdk", + "light-token", "num-bigint 0.4.6", "quote", "rand 0.8.5", diff --git a/Cargo.toml b/Cargo.toml index 23dbd8b235..ad9c526830 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,7 +131,8 @@ bs58 = "^0.5.1" litesvm = "0.7" # Anchor anchor-lang = { version = "0.31.1" } -anchor-spl = "0.31.1" +anchor-spl = { version = "0.31.1" } +light-anchor-spl = { version = "0.31.1", features = ["idl-build", "memo"] } # Anchor compatibility borsh = { version = "0.10.4", default-features = false } @@ -204,7 +205,7 @@ light-compressed-token = { path = "programs/compressed-token/program", version = "cpi", ] } light-token-types = { path = "sdk-libs/token-types", version = "0.2.1" } -light-token-sdk = { path = "sdk-libs/token-sdk", version = "0.2.1" } +light-token = { path = "sdk-libs/token-sdk", version = "0.2.1" } light-token-client = { path = "sdk-libs/token-client", version = "0.1.0" } light-system-program-anchor = { path = "anchor-programs/system", version = "2.0.0", features = [ "cpi", diff --git a/forester/Cargo.toml b/forester/Cargo.toml index d1ff21e5c1..25371df790 100644 --- a/forester/Cargo.toml +++ b/forester/Cargo.toml @@ -28,7 +28,7 @@ light-sdk = { workspace = true, features = ["anchor"] } light-program-test = { workspace = true } light-compressible = { workspace = true, default-features = false, features = ["solana"] } light-token-interface = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } solana-rpc-client-api = { workspace = true } solana-transaction-status = { workspace = true } bb8 = { workspace = true } diff --git a/forester/src/compressible/compressor.rs b/forester/src/compressible/compressor.rs index 00d7d0f30a..d460aab7a3 100644 --- a/forester/src/compressible/compressor.rs +++ b/forester/src/compressible/compressor.rs @@ -10,8 +10,8 @@ use light_registry::{ instruction::CompressAndClose, }; use light_sdk::instruction::PackedAccounts; +use light_token::compressed_token::compress_and_close::CompressAndCloseAccounts as CTokenAccounts; use light_token_interface::LIGHT_TOKEN_PROGRAM_ID; -use light_token_sdk::compressed_token::compress_and_close::CompressAndCloseAccounts as CTokenAccounts; use solana_pubkey::pubkey; use solana_sdk::{ instruction::Instruction, diff --git a/forester/tests/e2e_test.rs b/forester/tests/e2e_test.rs index 31c950c022..3b0f7787f7 100644 --- a/forester/tests/e2e_test.rs +++ b/forester/tests/e2e_test.rs @@ -43,11 +43,11 @@ use light_test_utils::{ pack::pack_new_address_params_assigned, spl::create_mint_helper_with_keypair, system_program::create_invoke_instruction, }; +use light_token::compat::TokenDataWithMerkleContext; use light_token_client::actions::{ create_compressible_token_account, CreateCompressibleTokenAccountInputs, }; use light_token_interface::state::TokenDataVersion; -use light_token_sdk::compat::TokenDataWithMerkleContext; use rand::{prelude::SliceRandom, rngs::StdRng, Rng, SeedableRng}; use serial_test::serial; use solana_program::{native_token::LAMPORTS_PER_SOL, pubkey::Pubkey}; diff --git a/forester/tests/legacy/batched_state_async_indexer_test.rs b/forester/tests/legacy/batched_state_async_indexer_test.rs index d7af38989c..823087a6cb 100644 --- a/forester/tests/legacy/batched_state_async_indexer_test.rs +++ b/forester/tests/legacy/batched_state_async_indexer_test.rs @@ -23,7 +23,7 @@ use light_compressed_account::{ use light_compressed_token::process_transfer::{ transfer_sdk::create_transfer_instruction, TokenTransferOutputData, }; -use light_token_sdk::compat::TokenDataWithMerkleContext; +use light_token::compat::TokenDataWithMerkleContext; use light_program_test::accounts::test_accounts::TestAccounts; use light_prover_client::prover::spawn_prover; use light_registry::{ diff --git a/forester/tests/test_compressible_ctoken.rs b/forester/tests/test_compressible_ctoken.rs index d6aef471c4..094d48dbd9 100644 --- a/forester/tests/test_compressible_ctoken.rs +++ b/forester/tests/test_compressible_ctoken.rs @@ -20,11 +20,11 @@ use light_registry::{ utils::{get_forester_pda, get_protocol_config_pda_address}, ForesterConfig, }; +use light_token::compressed_token::create_compressed_mint; use light_token_client::actions::{ create_compressible_token_account, CreateCompressibleTokenAccountInputs, }; use light_token_interface::state::TokenDataVersion; -use light_token_sdk::compressed_token::create_compressed_mint; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction}; use tokio::{sync::oneshot, time::sleep}; diff --git a/program-tests/compressed-token-test/Cargo.toml b/program-tests/compressed-token-test/Cargo.toml index 3caadd3c53..9048593feb 100644 --- a/program-tests/compressed-token-test/Cargo.toml +++ b/program-tests/compressed-token-test/Cargo.toml @@ -46,7 +46,7 @@ serial_test = { workspace = true } light-token-interface = { workspace = true } light-token-client = { workspace = true } light-compressible = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } spl-token-2022 = { workspace = true } spl-pod = { workspace = true } light-zero-copy = { workspace = true , features = ["std", "derive", "mut"]} diff --git a/program-tests/compressed-token-test/tests/compress_only/all.rs b/program-tests/compressed-token-test/tests/compress_only/all.rs index 50b6861e11..f5b327852f 100644 --- a/program-tests/compressed-token-test/tests/compress_only/all.rs +++ b/program-tests/compressed-token-test/tests/compress_only/all.rs @@ -21,6 +21,10 @@ async fn test_compress_and_close_ctoken_with_extensions() { use light_client::indexer::CompressedTokenAccount; use light_client::indexer::Indexer; use light_test_utils::mint_2022::{create_token_22_account, mint_spl_tokens_22}; + use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, + }; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -30,10 +34,6 @@ async fn test_compress_and_close_ctoken_with_extensions() { }, state::TokenDataVersion, }; - use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, - }; let mut context = setup_extensions_test(ALL_EXTENSIONS).await.unwrap(); let payer = context.payer.insecure_clone(); diff --git a/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs b/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs index f8f934114f..002ccc9c52 100644 --- a/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs +++ b/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs @@ -14,6 +14,13 @@ use light_test_utils::{ }, Rpc, RpcError, }; +use light_token::{ + instruction::{ + derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, CreateTokenAccount, + TransferFromSpl, + }, + spl_interface::find_spl_interface_pda_with_index, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -21,13 +28,6 @@ use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, state::{ExtensionStruct, TokenDataVersion}, }; -use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{ - derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, CreateTokenAccount, - TransferFromSpl, - }, -}; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; use spl_token_2022::extension::ExtensionType; @@ -791,6 +791,9 @@ async fn test_ata_decompress_with_mismatched_amount_fails() { use borsh::BorshSerialize; use light_compressed_account::compressed_account::PackedMerkleContext; use light_sdk::instruction::PackedAccounts; + use light_token::compressed_token::transfer2::account_metas::{ + get_transfer2_instruction_account_metas, Transfer2AccountsMetaConfig, + }; use light_token_interface::{ instructions::transfer2::{ CompressedTokenInstructionDataTransfer2, Compression, CompressionMode, @@ -798,9 +801,6 @@ async fn test_ata_decompress_with_mismatched_amount_fails() { }, TRANSFER2, }; - use light_token_sdk::compressed_token::transfer2::account_metas::{ - get_transfer2_instruction_account_metas, Transfer2AccountsMetaConfig, - }; use solana_sdk::instruction::Instruction; let mut context = setup_ata_compressed_token(&[ExtensionType::Pausable], None, false) diff --git a/program-tests/compressed-token-test/tests/compress_only/decompress_restrictions.rs b/program-tests/compressed-token-test/tests/compress_only/decompress_restrictions.rs index 698ac6ed3b..d679b5a80a 100644 --- a/program-tests/compressed-token-test/tests/compress_only/decompress_restrictions.rs +++ b/program-tests/compressed-token-test/tests/compress_only/decompress_restrictions.rs @@ -14,6 +14,10 @@ use light_test_utils::mint_2022::{ create_mint_22_with_extension_types, create_token_22_account, mint_spl_tokens_22, RESTRICTED_EXTENSIONS, }; +use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -21,10 +25,6 @@ use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, state::TokenDataVersion, }; -use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, -}; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; use spl_token_2022::extension::ExtensionType; diff --git a/program-tests/compressed-token-test/tests/compress_only/default_state.rs b/program-tests/compressed-token-test/tests/compress_only/default_state.rs index 3086c388d9..dd9d236a97 100644 --- a/program-tests/compressed-token-test/tests/compress_only/default_state.rs +++ b/program-tests/compressed-token-test/tests/compress_only/default_state.rs @@ -19,8 +19,8 @@ use spl_token_2022::extension::ExtensionType; #[tokio::test] #[serial] async fn test_create_ctoken_with_frozen_default_state() { + use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::state::TokenDataVersion; - use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(false, None)) .await @@ -107,8 +107,8 @@ async fn test_create_ctoken_with_frozen_default_state() { #[tokio::test] #[serial] async fn test_create_ctoken_with_initialized_default_state() { + use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::state::TokenDataVersion; - use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(false, None)) .await diff --git a/program-tests/compressed-token-test/tests/compress_only/invalid_destination.rs b/program-tests/compressed-token-test/tests/compress_only/invalid_destination.rs index 53ab26b0eb..c93b1795f8 100644 --- a/program-tests/compressed-token-test/tests/compress_only/invalid_destination.rs +++ b/program-tests/compressed-token-test/tests/compress_only/invalid_destination.rs @@ -17,6 +17,10 @@ use light_test_utils::mint_2022::{ create_mint_22_with_extension_types, create_token_22_account, mint_spl_tokens_22, RESTRICTED_EXTENSIONS, }; +use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -24,10 +28,6 @@ use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, state::TokenDataVersion, }; -use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, -}; use serial_test::serial; use solana_sdk::{program_pack::Pack, pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/compress_only/invalid_extension_state.rs b/program-tests/compressed-token-test/tests/compress_only/invalid_extension_state.rs index 30e8f7223a..eb391b9c08 100644 --- a/program-tests/compressed-token-test/tests/compress_only/invalid_extension_state.rs +++ b/program-tests/compressed-token-test/tests/compress_only/invalid_extension_state.rs @@ -17,6 +17,11 @@ use light_program_test::{ use light_test_utils::mint_2022::{ create_token_22_account, mint_spl_tokens_22, set_mint_transfer_fee, set_mint_transfer_hook, }; +use light_token::{ + constants::CPI_AUTHORITY_PDA, + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl, TransferToSpl}, + spl_interface::find_spl_interface_pda_with_index as sdk_find_spl_interface_pda, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -25,11 +30,6 @@ use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, state::TokenDataVersion, }; -use light_token_sdk::{ - constants::CPI_AUTHORITY_PDA, - spl_interface::find_spl_interface_pda_with_index as sdk_find_spl_interface_pda, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl, TransferToSpl}, -}; use serial_test::serial; use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signature::Keypair, signer::Signer}; use spl_token_2022::{ diff --git a/program-tests/compressed-token-test/tests/compress_only/mod.rs b/program-tests/compressed-token-test/tests/compress_only/mod.rs index 091b7a988b..82be04d1eb 100644 --- a/program-tests/compressed-token-test/tests/compress_only/mod.rs +++ b/program-tests/compressed-token-test/tests/compress_only/mod.rs @@ -154,6 +154,10 @@ pub async fn run_compress_and_close_extension_test( config: CompressAndCloseTestConfig, ) -> Result<(), RpcError> { use light_client::indexer::Indexer; + use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, + }; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -165,10 +169,6 @@ pub async fn run_compress_and_close_extension_test( CompressedOnlyExtension, CompressedTokenAccountState, TokenData, TokenDataVersion, }, }; - use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, - }; let mut context = setup_extensions_test(config.extensions).await?; let has_restricted_extensions = config diff --git a/program-tests/compressed-token-test/tests/compress_only/restricted_required.rs b/program-tests/compressed-token-test/tests/compress_only/restricted_required.rs index d090ebdbd2..5c3619eb37 100644 --- a/program-tests/compressed-token-test/tests/compress_only/restricted_required.rs +++ b/program-tests/compressed-token-test/tests/compress_only/restricted_required.rs @@ -8,8 +8,8 @@ use light_program_test::{ program_test::LightProgramTest, utils::assert::assert_rpc_error, ProgramTestConfig, Rpc, }; use light_test_utils::mint_2022::create_mint_22_with_extension_types; +use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::state::TokenDataVersion; -use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; use serial_test::serial; use solana_sdk::{signature::Keypair, signer::Signer}; use spl_token_2022::extension::ExtensionType; diff --git a/program-tests/compressed-token-test/tests/compress_only/withheld_fee.rs b/program-tests/compressed-token-test/tests/compress_only/withheld_fee.rs index be76972c2c..ef82b12c7d 100644 --- a/program-tests/compressed-token-test/tests/compress_only/withheld_fee.rs +++ b/program-tests/compressed-token-test/tests/compress_only/withheld_fee.rs @@ -10,6 +10,10 @@ use light_test_utils::{ mint_2022::{create_mint_22_with_extension_types, create_token_22_account, mint_spl_tokens_22}, Rpc, RpcError, }; +use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -20,10 +24,6 @@ use light_token_interface::{ TokenDataVersion, }, }; -use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, -}; use serial_test::serial; use solana_sdk::{signature::Keypair, signer::Signer}; use spl_token_2022::extension::ExtensionType; diff --git a/program-tests/compressed-token-test/tests/freeze/compress_only.rs b/program-tests/compressed-token-test/tests/freeze/compress_only.rs index e101f51867..46c5ebed7e 100644 --- a/program-tests/compressed-token-test/tests/freeze/compress_only.rs +++ b/program-tests/compressed-token-test/tests/freeze/compress_only.rs @@ -16,6 +16,11 @@ use light_test_utils::{ }, Rpc, RpcError, }; +use light_token::{ + compat::{AccountState, TokenDataWithMerkleContext}, + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, + spl_interface::find_spl_interface_pda_with_index, +}; use light_token_client::instructions::transfer2::{ create_generic_transfer2_instruction, DecompressInput, Transfer2InstructionType, }; @@ -23,11 +28,6 @@ use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, state::TokenDataVersion, }; -use light_token_sdk::{ - compat::{AccountState, TokenDataWithMerkleContext}, - spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, -}; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; use spl_token_2022::extension::ExtensionType; diff --git a/program-tests/compressed-token-test/tests/freeze/functional.rs b/program-tests/compressed-token-test/tests/freeze/functional.rs index c8bf027e3b..4796a59a71 100644 --- a/program-tests/compressed-token-test/tests/freeze/functional.rs +++ b/program-tests/compressed-token-test/tests/freeze/functional.rs @@ -13,9 +13,9 @@ use light_test_utils::{ conversions::sdk_to_program_token_data, mint_2022::create_token_22_account, spl::create_mint_22_helper, Rpc, RpcError, }; +use light_token::compat::{AccountState, TokenDataWithMerkleContext}; use light_token_client::actions::transfer2::{compress_with_version, decompress}; use light_token_interface::state::TokenDataVersion; -use light_token_sdk::compat::{AccountState, TokenDataWithMerkleContext}; use serial_test::serial; use solana_sdk::{program_pack::Pack, pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/light_token/approve_revoke.rs b/program-tests/compressed-token-test/tests/light_token/approve_revoke.rs index fd001ef881..71febc7dc1 100644 --- a/program-tests/compressed-token-test/tests/light_token/approve_revoke.rs +++ b/program-tests/compressed-token-test/tests/light_token/approve_revoke.rs @@ -342,8 +342,8 @@ async fn test_revoke_fails() { use anchor_lang::AnchorDeserialize; use light_program_test::program_test::TestRpc; use light_test_utils::RpcError; +use light_token::instruction::{Approve, CreateTokenAccount, Revoke}; use light_token_interface::state::{Token, TokenDataVersion}; -use light_token_sdk::token::{Approve, CreateTokenAccount, Revoke}; use solana_sdk::program_pack::Pack; use super::extensions::setup_extensions_test; diff --git a/program-tests/compressed-token-test/tests/light_token/burn.rs b/program-tests/compressed-token-test/tests/light_token/burn.rs index 973bd4dac9..fb8efce92e 100644 --- a/program-tests/compressed-token-test/tests/light_token/burn.rs +++ b/program-tests/compressed-token-test/tests/light_token/burn.rs @@ -21,11 +21,11 @@ use light_program_test::{ program_test::TestRpc, utils::assert::assert_rpc_error, LightProgramTest, ProgramTestConfig, }; use light_test_utils::assert_ctoken_burn::assert_ctoken_burn; -use light_token_client::instructions::mint_action::DecompressMintParams; -use light_token_sdk::{ +use light_token::{ compressed_token::create_compressed_mint::find_mint_address, - token::{derive_token_ata, Burn, CreateAssociatedTokenAccount, MintTo}, + instruction::{derive_token_ata, Burn, CreateAssociatedTokenAccount, MintTo}, }; +use light_token_client::instructions::mint_action::DecompressMintParams; use super::shared::*; @@ -397,7 +397,7 @@ async fn setup_burn_test() -> BurnTestContext { // Burn Checked Tests // ============================================================================ -use light_token_sdk::token::BurnChecked; +use light_token::instruction::BurnChecked; /// MintDecimalsMismatch error code (SplMintDecimalsMismatch = 6166) const MINT_DECIMALS_MISMATCH: u32 = 6166; diff --git a/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs b/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs index 6451153751..d858945406 100644 --- a/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs +++ b/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs @@ -163,7 +163,7 @@ async fn test_compress_and_close_owner_scenarios() { .await; // Set token balance on ATA - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let (ata_pubkey, _bump) = derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); diff --git a/program-tests/compressed-token-test/tests/light_token/extensions.rs b/program-tests/compressed-token-test/tests/light_token/extensions.rs index bfe240c52e..942d7e85ba 100644 --- a/program-tests/compressed-token-test/tests/light_token/extensions.rs +++ b/program-tests/compressed-token-test/tests/light_token/extensions.rs @@ -79,11 +79,11 @@ async fn test_setup_mint_22_with_all_extensions() { #[tokio::test] #[serial] async fn test_mint_and_compress_with_extensions() { - use light_token_interface::state::TokenDataVersion; - use light_token_sdk::{ + use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, }; + use light_token_interface::state::TokenDataVersion; let mut context = setup_extensions_test().await.unwrap(); let payer = context.payer.insecure_clone(); @@ -202,8 +202,8 @@ async fn test_create_ctoken_with_extensions() { use light_test_utils::assert_create_token_account::{ assert_create_token_account, CompressibleData, }; + use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::state::TokenDataVersion; - use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; let mut context = setup_extensions_test().await.unwrap(); let payer = context.payer.insecure_clone(); @@ -284,11 +284,11 @@ async fn test_create_ctoken_with_extensions() { async fn test_transfer_with_permanent_delegate() { use anchor_lang::prelude::AccountMeta; use anchor_spl::token_2022::spl_token_2022; - use light_token_interface::state::TokenDataVersion; - use light_token_sdk::{ + use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, }; + use light_token_interface::state::TokenDataVersion; use solana_sdk::{instruction::Instruction, program_pack::Pack}; let mut context = setup_extensions_test().await.unwrap(); @@ -485,11 +485,11 @@ async fn test_transfer_with_owner_authority() { use anchor_lang::prelude::AccountMeta; use anchor_spl::token_2022::spl_token_2022; use borsh::BorshDeserialize; - use light_token_interface::state::{AccountState, Token, TokenDataVersion}; - use light_token_sdk::{ + use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferFromSpl}, }; + use light_token_interface::state::{AccountState, Token, TokenDataVersion}; use solana_sdk::{instruction::Instruction, program_pack::Pack}; let mut context = setup_extensions_test().await.unwrap(); diff --git a/program-tests/compressed-token-test/tests/light_token/extensions_failing.rs b/program-tests/compressed-token-test/tests/light_token/extensions_failing.rs index 567e8bbc7b..a8b4cb1fb8 100644 --- a/program-tests/compressed-token-test/tests/light_token/extensions_failing.rs +++ b/program-tests/compressed-token-test/tests/light_token/extensions_failing.rs @@ -16,11 +16,11 @@ use light_test_utils::{ }, Rpc, }; -use light_token_interface::state::TokenDataVersion; -use light_token_sdk::{ +use light_token::{ + instruction::{CompressibleParams, CreateTokenAccount, TransferChecked, TransferFromSpl}, spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, TransferChecked, TransferFromSpl}, }; +use light_token_interface::state::TokenDataVersion; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/light_token/freeze_thaw.rs b/program-tests/compressed-token-test/tests/light_token/freeze_thaw.rs index 777b1ab08c..a8d5827025 100644 --- a/program-tests/compressed-token-test/tests/light_token/freeze_thaw.rs +++ b/program-tests/compressed-token-test/tests/light_token/freeze_thaw.rs @@ -10,8 +10,8 @@ use light_test_utils::{ spl::create_mint_helper, Rpc, RpcError, }; +use light_token::instruction::{CompressibleParams, CreateTokenAccount, Freeze, Thaw}; use light_token_interface::state::{AccountState, Token, TokenDataVersion}; -use light_token_sdk::token::{CompressibleParams, CreateTokenAccount, Freeze, Thaw}; use serial_test::serial; use solana_sdk::{signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/light_token/functional_ata.rs b/program-tests/compressed-token-test/tests/light_token/functional_ata.rs index 08c5caf07a..c7b533a8a0 100644 --- a/program-tests/compressed-token-test/tests/light_token/functional_ata.rs +++ b/program-tests/compressed-token-test/tests/light_token/functional_ata.rs @@ -1,5 +1,5 @@ use light_test_utils::assert_create_token_account::assert_create_associated_token_account; -use light_token_sdk::token::{CloseAccount, CompressibleParams, CreateAssociatedTokenAccount}; +use light_token::instruction::{CloseAccount, CompressibleParams, CreateAssociatedTokenAccount}; use super::shared::*; diff --git a/program-tests/compressed-token-test/tests/light_token/shared.rs b/program-tests/compressed-token-test/tests/light_token/shared.rs index b4e8bc7fde..7b52bc1d98 100644 --- a/program-tests/compressed-token-test/tests/light_token/shared.rs +++ b/program-tests/compressed-token-test/tests/light_token/shared.rs @@ -14,13 +14,13 @@ pub use light_test_utils::{ assert_transfer2::assert_transfer2_compress, Rpc, RpcError, }; -pub use light_token_client::{ - actions::transfer2::compress, instructions::transfer2::CompressInput, -}; -pub use light_token_sdk::token::{ +pub use light_token::instruction::{ derive_token_ata, Approve, CloseAccount, CompressibleParams, CreateAssociatedTokenAccount, CreateTokenAccount, Revoke, }; +pub use light_token_client::{ + actions::transfer2::compress, instructions::transfer2::CompressInput, +}; pub use serial_test::serial; pub use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; /// Shared test context for account operations @@ -739,7 +739,7 @@ pub async fn compress_and_close_forester_with_invalid_output( }; // Add system accounts - use light_token_sdk::compressed_token::compress_and_close::CompressAndCloseAccounts as CTokenCompressAndCloseAccounts; + use light_token::compressed_token::compress_and_close::CompressAndCloseAccounts as CTokenCompressAndCloseAccounts; let config = CTokenCompressAndCloseAccounts { compressed_token_program: compressed_token_program_id, cpi_authority_pda: Pubkey::find_program_address( @@ -894,7 +894,7 @@ pub async fn approve_and_assert( ) { println!("Approve initiated for: {}", name); - // Use light-token-sdk + // Use light-token let approve_ix = Approve { token_account: context.token_account_keypair.pubkey(), delegate, @@ -969,7 +969,7 @@ pub async fn approve_and_assert_fails( pub async fn revoke_and_assert(context: &mut AccountTestContext, name: &str) { println!("Revoke initiated for: {}", name); - // Use light-token-sdk + // Use light-token let revoke_ix = Revoke { token_account: context.token_account_keypair.pubkey(), owner: context.owner_keypair.pubkey(), diff --git a/program-tests/compressed-token-test/tests/light_token/spl_instruction_compat.rs b/program-tests/compressed-token-test/tests/light_token/spl_instruction_compat.rs index 5fe336f002..810506fcc4 100644 --- a/program-tests/compressed-token-test/tests/light_token/spl_instruction_compat.rs +++ b/program-tests/compressed-token-test/tests/light_token/spl_instruction_compat.rs @@ -425,8 +425,8 @@ async fn test_spl_instruction_compatibility() { #[allow(deprecated)] async fn test_spl_instruction_compatibility_with_mint() { use light_program_test::ProgramTestConfig; + use light_token::compressed_token::create_compressed_mint::find_mint_address; use light_token_client::instructions::mint_action::DecompressMintParams; - use light_token_sdk::compressed_token::create_compressed_mint::find_mint_address; // Set up test environment let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(false, None)) diff --git a/program-tests/compressed-token-test/tests/light_token/transfer.rs b/program-tests/compressed-token-test/tests/light_token/transfer.rs index 38757a82ec..47727c17ba 100644 --- a/program-tests/compressed-token-test/tests/light_token/transfer.rs +++ b/program-tests/compressed-token-test/tests/light_token/transfer.rs @@ -585,7 +585,7 @@ async fn test_ctoken_transfer_max_top_up_exceeded() { // Transfer Checked Helper Functions // ============================================================================ -use light_token_sdk::token::TransferChecked; +use light_token::instruction::TransferChecked; /// Setup context with two token accounts for transfer_checked tests using a real SPL Token mint async fn setup_transfer_checked_test_with_spl_mint( diff --git a/program-tests/compressed-token-test/tests/light_token/transfer_checked.rs b/program-tests/compressed-token-test/tests/light_token/transfer_checked.rs index 1ed2287c37..84e60bc24c 100644 --- a/program-tests/compressed-token-test/tests/light_token/transfer_checked.rs +++ b/program-tests/compressed-token-test/tests/light_token/transfer_checked.rs @@ -10,11 +10,13 @@ use light_test_utils::{ mint_2022::{create_token_22_account, mint_spl_tokens_22}, Rpc, }; -use light_token_interface::state::TokenDataVersion; -use light_token_sdk::{ +use light_token::{ + instruction::{ + CompressibleParams, CreateTokenAccount, Transfer, TransferChecked, TransferFromSpl, + }, spl_interface::find_spl_interface_pda_with_index, - token::{CompressibleParams, CreateTokenAccount, Transfer, TransferChecked, TransferFromSpl}, }; +use light_token_interface::state::TokenDataVersion; use serial_test::serial; use solana_sdk::{native_token::LAMPORTS_PER_SOL, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/mint/burn.rs b/program-tests/compressed-token-test/tests/mint/burn.rs index f40d29667f..f3dba6224f 100644 --- a/program-tests/compressed-token-test/tests/mint/burn.rs +++ b/program-tests/compressed-token-test/tests/mint/burn.rs @@ -1,11 +1,11 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::{assert_ctoken_burn::assert_ctoken_burn, Rpc}; -use light_token_client::instructions::mint_action::DecompressMintParams; -use light_token_interface::instructions::mint_action::Recipient; -use light_token_sdk::{ +use light_token::{ compressed_token::create_compressed_mint::find_mint_address, - token::{derive_token_ata, Burn, CreateAssociatedTokenAccount}, + instruction::{derive_token_ata, Burn, CreateAssociatedTokenAccount}, }; +use light_token_client::instructions::mint_action::DecompressMintParams; +use light_token_interface::instructions::mint_action::Recipient; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/mint/cpi_context.rs b/program-tests/compressed-token-test/tests/mint/cpi_context.rs index 70b472a82c..58b20f7c3f 100644 --- a/program-tests/compressed-token-test/tests/mint/cpi_context.rs +++ b/program-tests/compressed-token-test/tests/mint/cpi_context.rs @@ -4,6 +4,13 @@ use light_client::indexer::Indexer; use light_compressed_account::instruction_data::traits::LightInstructionData; use light_program_test::{utils::assert::assert_rpc_error, LightProgramTest, ProgramTestConfig}; use light_test_utils::Rpc; +use light_token::compressed_token::{ + create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + mint_action::{ + get_mint_action_instruction_account_metas_cpi_write, MintActionMetaConfig, + MintActionMetaConfigCpiWrite, + }, +}; use light_token_interface::{ instructions::mint_action::{ CpiContext, DecompressMintAction, MintActionCompressedInstructionData, MintInstructionData, @@ -12,13 +19,6 @@ use light_token_interface::{ state::MintMetadata, LIGHT_TOKEN_PROGRAM_ID, MINT_ADDRESS_TREE, }; -use light_token_sdk::compressed_token::{ - create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - mint_action::{ - get_mint_action_instruction_account_metas_cpi_write, MintActionMetaConfig, - MintActionMetaConfigCpiWrite, - }, -}; use light_verifier::CompressedProof; use serial_test::serial; use solana_sdk::{ diff --git a/program-tests/compressed-token-test/tests/mint/edge_cases.rs b/program-tests/compressed-token-test/tests/mint/edge_cases.rs index 37008a658d..eceff31dd6 100644 --- a/program-tests/compressed-token-test/tests/mint/edge_cases.rs +++ b/program-tests/compressed-token-test/tests/mint/edge_cases.rs @@ -4,15 +4,15 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::{ assert_mint_action::assert_mint_action, mint_assert::assert_compressed_mint_account, Rpc, }; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::{CompressibleParams, CreateAssociatedTokenAccount}, +}; use light_token_client::{ actions::create_mint, instructions::mint_action::{MintActionType, MintToRecipient}, }; use light_token_interface::state::{extensions::AdditionalMetadata, Mint, TokenDataVersion}; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::{CompressibleParams, CreateAssociatedTokenAccount}, -}; use serial_test::serial; use solana_sdk::{signature::Keypair, signer::Signer}; @@ -180,7 +180,8 @@ async fn functional_all_in_one_instruction() { }, // 2. MintToCToken - mint to decompressed account MintActionType::MintToCToken { - account: light_token_sdk::token::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0, + account: light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda) + .0, amount: 2000u64, }, // 3. UpdateMintAuthority diff --git a/program-tests/compressed-token-test/tests/mint/failing.rs b/program-tests/compressed-token-test/tests/mint/failing.rs index c798bf1cb8..0036125642 100644 --- a/program-tests/compressed-token-test/tests/mint/failing.rs +++ b/program-tests/compressed-token-test/tests/mint/failing.rs @@ -6,15 +6,15 @@ use light_program_test::{utils::assert::assert_rpc_error, LightProgramTest, Prog use light_test_utils::{ assert_mint_action::assert_mint_action, mint_assert::assert_compressed_mint_account, Rpc, }; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::{CompressibleParams, CreateAssociatedTokenAccount}, +}; use light_token_client::{ actions::create_mint, instructions::mint_action::{MintActionType, MintToRecipient}, }; use light_token_interface::state::{extensions::AdditionalMetadata, Mint}; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::{CompressibleParams, CreateAssociatedTokenAccount}, -}; use serial_test::serial; use solana_sdk::{ instruction::{AccountMeta, Instruction}, @@ -468,7 +468,7 @@ async fn functional_and_failing_tests() { .unwrap(); let recipient_ata = - light_token_sdk::token::derive_token_ata(&recipient2.pubkey(), &spl_mint_pda).0; + light_token::instruction::derive_token_ata(&recipient2.pubkey(), &spl_mint_pda).0; // Try to mint with valid NEW authority (since we updated it) let result = light_token_client::actions::mint_action_comprehensive( @@ -811,6 +811,9 @@ async fn functional_and_failing_tests() { #[serial] async fn test_mint_to_ctoken_max_top_up_exceeded() { use light_compressed_account::instruction_data::traits::LightInstructionData; + use light_token::compressed_token::{ + create_compressed_mint::derive_mint_compressed_address, mint_action::MintActionMetaConfig, + }; use light_token_interface::{ instructions::mint_action::{ MintActionCompressedInstructionData, MintToAction, MintWithContext, @@ -818,9 +821,6 @@ async fn test_mint_to_ctoken_max_top_up_exceeded() { state::TokenDataVersion, LIGHT_TOKEN_PROGRAM_ID, }; - use light_token_sdk::compressed_token::{ - create_compressed_mint::derive_mint_compressed_address, mint_action::MintActionMetaConfig, - }; let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(false, None)) .await @@ -881,7 +881,8 @@ async fn test_mint_to_ctoken_max_top_up_exceeded() { .await .unwrap(); - let ctoken_ata = light_token_sdk::token::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; + let ctoken_ata = + light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; // 3. Build MintToCToken instruction with max_top_up = 1 (too low) // Get current compressed mint state @@ -1024,8 +1025,8 @@ async fn test_create_mint_non_signer_mint_signer() { async fn test_compress_and_close_mint_must_be_only_action() { use light_compressible::rent::SLOTS_PER_EPOCH; use light_program_test::program_test::TestRpc; + use light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address; use light_token_client::instructions::mint_action::DecompressMintParams; - use light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address; let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(false, None)) .await diff --git a/program-tests/compressed-token-test/tests/mint/functional.rs b/program-tests/compressed-token-test/tests/mint/functional.rs index 4b441cc1d1..86e9b961c5 100644 --- a/program-tests/compressed-token-test/tests/mint/functional.rs +++ b/program-tests/compressed-token-test/tests/mint/functional.rs @@ -13,6 +13,10 @@ use light_test_utils::{ mint_assert::assert_compressed_mint_account, Rpc, }; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, +}; use light_token_client::{ actions::{create_mint, mint_to_compressed, transfer, transfer2}, instructions::{ @@ -33,10 +37,6 @@ use light_token_interface::{ }, COMPRESSED_MINT_SEED, }; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, -}; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/mint/mint_to.rs b/program-tests/compressed-token-test/tests/mint/mint_to.rs index 987572eb9a..9af8c5296a 100644 --- a/program-tests/compressed-token-test/tests/mint/mint_to.rs +++ b/program-tests/compressed-token-test/tests/mint/mint_to.rs @@ -1,10 +1,10 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::{assert_ctoken_mint_to::assert_ctoken_mint_to, Rpc}; -use light_token_client::instructions::mint_action::DecompressMintParams; -use light_token_sdk::{ +use light_token::{ compressed_token::create_compressed_mint::find_mint_address, - token::{derive_token_ata, CreateAssociatedTokenAccount, MintTo}, + instruction::{derive_token_ata, CreateAssociatedTokenAccount, MintTo}, }; +use light_token_client::instructions::mint_action::DecompressMintParams; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; @@ -153,7 +153,7 @@ async fn test_ctoken_mint_to() { // MintTo Checked Tests // ============================================================================ -use light_token_sdk::token::MintToChecked; +use light_token::instruction::MintToChecked; #[tokio::test] #[serial] diff --git a/program-tests/compressed-token-test/tests/mint/random.rs b/program-tests/compressed-token-test/tests/mint/random.rs index 9a0d4bc943..688cfbc0de 100644 --- a/program-tests/compressed-token-test/tests/mint/random.rs +++ b/program-tests/compressed-token-test/tests/mint/random.rs @@ -5,15 +5,15 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::{ assert_mint_action::assert_mint_action, mint_assert::assert_compressed_mint_account, Rpc, }; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::CreateAssociatedTokenAccount, +}; use light_token_client::{ actions::create_mint, instructions::mint_action::{MintActionType, MintToRecipient}, }; use light_token_interface::state::{extensions::AdditionalMetadata, Mint}; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::CreateAssociatedTokenAccount, -}; use serial_test::serial; use solana_sdk::{signature::Keypair, signer::Signer}; @@ -137,7 +137,7 @@ async fn test_random_mint_action() { .await .unwrap(); - let ata = light_token_sdk::token::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; + let ata = light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; ctoken_atas.push(ata); } diff --git a/program-tests/compressed-token-test/tests/token_pool.rs b/program-tests/compressed-token-test/tests/token_pool.rs index 59b41cc46f..7b03ad3559 100644 --- a/program-tests/compressed-token-test/tests/token_pool.rs +++ b/program-tests/compressed-token-test/tests/token_pool.rs @@ -16,10 +16,10 @@ use light_test_utils::{ spl::{create_additional_token_pools, create_mint_22_helper, create_mint_helper}, Rpc, RpcError, }; +use light_token::spl_interface::CreateSplInterfacePda; use light_token_interface::{ find_spl_interface_pda, find_spl_interface_pda_with_index, has_restricted_extensions, }; -use light_token_sdk::spl_interface::CreateSplInterfacePda; use serial_test::serial; use solana_sdk::{ instruction::Instruction, diff --git a/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs b/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs index eda7457e4a..ff6b519dff 100644 --- a/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs @@ -40,10 +40,7 @@ use light_program_test::{ }; use light_sdk::instruction::PackedAccounts; use light_test_utils::RpcError; -use light_token_interface::{ - instructions::mint_action::Recipient, state::TokenDataVersion, TokenError, -}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ create_compressed_mint::find_mint_address, transfer2::{ @@ -52,9 +49,12 @@ use light_token_sdk::{ }, CTokenAccount2, }, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, ValidityProof, }; +use light_token_interface::{ + instructions::mint_action::Recipient, state::TokenDataVersion, TokenError, +}; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; // ============================================================================ // Test Setup diff --git a/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs b/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs index 5a1938d27b..f75d7d2242 100644 --- a/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs @@ -38,7 +38,7 @@ use light_test_utils::{ }, Rpc, RpcError, }; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer2::{ account_metas::Transfer2AccountsMetaConfig, create_transfer2_instruction, @@ -46,8 +46,8 @@ use light_token_sdk::{ }, CTokenAccount2, }, + instruction::{derive_token_ata, CreateAssociatedTokenAccount}, spl_interface::find_spl_interface_pda_with_index, - token::{derive_token_ata, CreateAssociatedTokenAccount}, ValidityProof, }; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; diff --git a/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs b/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs index 840313830a..7454f56117 100644 --- a/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs @@ -37,11 +37,7 @@ use light_program_test::{ }; use light_sdk::instruction::PackedAccounts; use light_test_utils::RpcError; -use light_token_interface::{ - instructions::{mint_action::Recipient, transfer2::MultiInputTokenDataWithContext}, - state::TokenDataVersion, -}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ create_compressed_mint::find_mint_address, transfer2::{ @@ -50,9 +46,13 @@ use light_token_sdk::{ }, CTokenAccount2, }, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, ValidityProof, }; +use light_token_interface::{ + instructions::{mint_action::Recipient, transfer2::MultiInputTokenDataWithContext}, + state::TokenDataVersion, +}; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; // ============================================================================ diff --git a/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs b/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs index 5672c525d3..e831406748 100644 --- a/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs @@ -48,12 +48,12 @@ use light_program_test::{ }; use light_sdk::instruction::PackedAccounts; use light_test_utils::{airdrop_lamports, RpcError}; -use light_token_interface::instructions::{mint_action::Recipient, transfer2::Compression}; -use light_token_sdk::{ +use light_token::{ compressed_token::create_compressed_mint::find_mint_address, - token::{derive_token_ata, CreateAssociatedTokenAccount}, + instruction::{derive_token_ata, CreateAssociatedTokenAccount}, ValidityProof, }; +use light_token_interface::instructions::{mint_action::Recipient, transfer2::Compression}; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; // ============================================================================ diff --git a/program-tests/compressed-token-test/tests/transfer2/shared.rs b/program-tests/compressed-token-test/tests/transfer2/shared.rs index e76d0bbb85..9f9a121c07 100644 --- a/program-tests/compressed-token-test/tests/transfer2/shared.rs +++ b/program-tests/compressed-token-test/tests/transfer2/shared.rs @@ -11,6 +11,10 @@ use light_test_utils::{ CREATE_MINT_HELPER_DECIMALS, }, }; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::{CompressibleParams, CreateAssociatedTokenAccount}, +}; use light_token_client::{ actions::{create_mint, mint_to_compressed}, instructions::{ @@ -25,10 +29,6 @@ use light_token_interface::{ instructions::{mint_action::Recipient, transfer2::CompressedTokenInstructionDataTransfer2}, state::TokenDataVersion, }; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::{CompressibleParams, CreateAssociatedTokenAccount}, -}; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction}; // ============================================================================ @@ -444,7 +444,7 @@ impl TestContext { .unwrap_or(&false); // Create Light Token ATA (compressible or regular based on requirements) - let (ata, bump) = light_token_sdk::token::derive_token_ata(&signer.pubkey(), &mint); + let (ata, bump) = light_token::instruction::derive_token_ata(&signer.pubkey(), &mint); let create_ata_ix = if is_compressible { println!( diff --git a/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs b/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs index 002fadadb7..6e835865d6 100644 --- a/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs +++ b/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs @@ -10,12 +10,10 @@ pub use light_test_utils::{ }, Rpc, RpcError, }; -pub use light_token_client::actions::transfer2::{self}; -use light_token_interface::instructions::transfer2::{Compression, MultiTokenTransferOutputData}; -pub use light_token_sdk::token::{ +pub use light_token::instruction::{ derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, }; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer2::{ create_transfer2_instruction, Transfer2AccountsMetaConfig, Transfer2Config, @@ -26,6 +24,8 @@ use light_token_sdk::{ spl_interface::find_spl_interface_pda_with_index, ValidityProof, }; +pub use light_token_client::actions::transfer2::{self}; +use light_token_interface::instructions::transfer2::{Compression, MultiTokenTransferOutputData}; use solana_sdk::pubkey::Pubkey; pub use solana_sdk::{instruction::Instruction, signature::Keypair, signer::Signer}; pub use spl_token_2022::pod::PodAccount; diff --git a/program-tests/compressed-token-test/tests/transfer2/transfer_failing.rs b/program-tests/compressed-token-test/tests/transfer2/transfer_failing.rs index 6468b434cf..d060166b7f 100644 --- a/program-tests/compressed-token-test/tests/transfer2/transfer_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/transfer_failing.rs @@ -10,12 +10,7 @@ use light_program_test::{ }; use light_sdk::instruction::PackedAccounts; use light_test_utils::{airdrop_lamports, RpcError}; -use light_token_client::actions::{create_mint, mint_to_compressed, transfer2::approve}; -use light_token_interface::{ - instructions::{mint_action::Recipient, transfer2::MultiInputTokenDataWithContext}, - state::TokenDataVersion, -}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer2::{ account_metas::Transfer2AccountsMetaConfig, create_transfer2_instruction, @@ -25,6 +20,11 @@ use light_token_sdk::{ }, ValidityProof, }; +use light_token_client::actions::{create_mint, mint_to_compressed, transfer2::approve}; +use light_token_interface::{ + instructions::{mint_action::Recipient, transfer2::MultiInputTokenDataWithContext}, + state::TokenDataVersion, +}; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer}; // ============================================================================ // Test Setup @@ -72,7 +72,7 @@ async fn setup_transfer_test( ) .await?; - let mint = light_token_sdk::compressed_token::create_compressed_mint::find_mint_address( + let mint = light_token::compressed_token::create_compressed_mint::find_mint_address( &mint_seed.pubkey(), ) .0; @@ -683,7 +683,7 @@ async fn setup_transfer_test_with_delegate( ) .await?; - let mint = light_token_sdk::compressed_token::create_compressed_mint::find_mint_address( + let mint = light_token::compressed_token::create_compressed_mint::find_mint_address( &mint_seed.pubkey(), ) .0; diff --git a/program-tests/compressed-token-test/tests/v1.rs b/program-tests/compressed-token-test/tests/v1.rs index 94ed30cfb2..3b0d33cf84 100644 --- a/program-tests/compressed-token-test/tests/v1.rs +++ b/program-tests/compressed-token-test/tests/v1.rs @@ -60,7 +60,7 @@ use light_test_utils::{ }, LightClient, Rpc, RpcError, }; -use light_token_sdk::compat::{AccountState, TokenDataWithMerkleContext}; +use light_token::compat::{AccountState, TokenDataWithMerkleContext}; use rand::{seq::SliceRandom, thread_rng, Rng}; use serial_test::serial; #[allow(deprecated)] @@ -5099,7 +5099,7 @@ async fn batch_compress_with_batched_tree() { .into(); assert_eq!(recipient_compressed_token_accounts.len(), 1); let recipient_compressed_token_account = &recipient_compressed_token_accounts[0]; - let expected_token_data = light_token_sdk::compat::TokenData { + let expected_token_data = light_token::compat::TokenData { mint, owner: recipients[i as usize], amount: (i + 1), @@ -5166,7 +5166,7 @@ async fn batch_compress_with_batched_tree() { .into(); assert_eq!(recipient_compressed_token_accounts.len(), 1); let recipient_compressed_token_account = &recipient_compressed_token_accounts[0]; - let expected_token_data = light_token_sdk::compat::TokenData { + let expected_token_data = light_token::compat::TokenData { mint, owner: *recipient, amount, diff --git a/program-tests/registry-test/Cargo.toml b/program-tests/registry-test/Cargo.toml index bddc0a4c2b..86ecef99e4 100644 --- a/program-tests/registry-test/Cargo.toml +++ b/program-tests/registry-test/Cargo.toml @@ -37,7 +37,7 @@ solana-sdk = { workspace = true } serial_test = { workspace = true } light-batched-merkle-tree = { workspace = true } light-account-checks = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-compressible = { workspace = true } light-token-client = { workspace = true } light-token-interface = { workspace = true } diff --git a/program-tests/registry-test/tests/compressible.rs b/program-tests/registry-test/tests/compressible.rs index 59a1b5af21..7bb35f33ae 100644 --- a/program-tests/registry-test/tests/compressible.rs +++ b/program-tests/registry-test/tests/compressible.rs @@ -27,6 +27,10 @@ use light_registry::accounts::{ use light_test_utils::{ airdrop_lamports, assert_claim::assert_claim, spl::create_mint_helper, Rpc, RpcError, }; +use light_token::{ + compressed_token::create_compressed_mint::find_mint_address, + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, MintTo}, +}; use light_token_client::{ actions::{ create_compressible_token_account, mint_action_comprehensive, transfer, @@ -34,10 +38,6 @@ use light_token_client::{ }, instructions::mint_action::{DecompressMintParams, NewMint}, }; -use light_token_sdk::{ - compressed_token::create_compressed_mint::find_mint_address, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, MintTo}, -}; use solana_sdk::{ instruction::Instruction, pubkey::Pubkey, diff --git a/program-tests/system-cpi-test/Cargo.toml b/program-tests/system-cpi-test/Cargo.toml index f470f74f97..1e3bd46621 100644 --- a/program-tests/system-cpi-test/Cargo.toml +++ b/program-tests/system-cpi-test/Cargo.toml @@ -24,7 +24,7 @@ default = ["custom-heap"] anchor-lang = { workspace = true } anchor-spl = { workspace = true } light-compressed-token = { workspace = true, features = ["cpi"] } -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-system-program-anchor = { workspace = true, features = ["cpi"] } light-registry = { workspace = true, features = ["cpi"] } account-compression = { workspace = true, features = ["cpi"] } diff --git a/program-tests/system-cpi-test/tests/test.rs b/program-tests/system-cpi-test/tests/test.rs index 9252a4cffc..ec6d61721f 100644 --- a/program-tests/system-cpi-test/tests/test.rs +++ b/program-tests/system-cpi-test/tests/test.rs @@ -38,7 +38,7 @@ use light_test_utils::{ }, Rpc, RpcError, }; -use light_token_sdk::compat::{AccountState, TokenDataWithMerkleContext}; +use light_token::compat::{AccountState, TokenDataWithMerkleContext}; use light_verifier::VerifierError; use serial_test::serial; use solana_sdk::{pubkey::Pubkey, signature::Keypair, signer::Signer, transaction::Transaction}; diff --git a/program-tests/utils/Cargo.toml b/program-tests/utils/Cargo.toml index f64af481e0..11cf7e4e50 100644 --- a/program-tests/utils/Cargo.toml +++ b/program-tests/utils/Cargo.toml @@ -51,6 +51,6 @@ light-sparse-merkle-tree = { workspace = true } solana-banks-client = { workspace = true } light-zero-copy = { workspace = true } base64 = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-token-client = { workspace = true } light-compressible = { workspace = true } diff --git a/program-tests/utils/src/assert_create_token_account.rs b/program-tests/utils/src/assert_create_token_account.rs index fa04a54cf1..d3452f66f7 100644 --- a/program-tests/utils/src/assert_create_token_account.rs +++ b/program-tests/utils/src/assert_create_token_account.rs @@ -1,6 +1,7 @@ use light_client::rpc::Rpc; use light_compressible::{compression_info::CompressionInfo, rent::RentConfig}; use light_program_test::LightProgramTest; +use light_token::instruction::derive_token_ata; use light_token_interface::{ state::{ extensions::CompressibleExtension, token::Token, AccountState, ExtensionStruct, @@ -9,7 +10,6 @@ use light_token_interface::{ }, BASE_TOKEN_ACCOUNT_SIZE, }; -use light_token_sdk::token::derive_token_ata; use light_zero_copy::traits::ZeroCopyAt; use solana_sdk::{program_pack::Pack, pubkey::Pubkey}; use spl_token_2022::{ diff --git a/program-tests/utils/src/assert_mint_to_compressed.rs b/program-tests/utils/src/assert_mint_to_compressed.rs index 1dac9a5eef..8825a8137a 100644 --- a/program-tests/utils/src/assert_mint_to_compressed.rs +++ b/program-tests/utils/src/assert_mint_to_compressed.rs @@ -5,10 +5,10 @@ use light_client::{ rpc::Rpc, }; use light_compressed_token::instructions::create_token_pool::find_token_pool_pda_with_index; +use light_token::compressed_token::create_compressed_mint::derive_mint_from_spl_mint; use light_token_interface::{ instructions::mint_action::Recipient, state::Mint, LIGHT_TOKEN_PROGRAM_ID, }; -use light_token_sdk::compressed_token::create_compressed_mint::derive_mint_from_spl_mint; use solana_sdk::{program_pack::Pack, pubkey::Pubkey}; pub async fn assert_mint_to_compressed( @@ -51,12 +51,12 @@ pub async fn assert_mint_to_compressed( }); // Create expected token data - let expected_token_data = light_token_sdk::compat::TokenData { + let expected_token_data = light_token::compat::TokenData { mint: spl_mint_pda, owner: recipient_pubkey, amount: recipient.amount, delegate: None, - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; diff --git a/program-tests/utils/src/assert_token_tx.rs b/program-tests/utils/src/assert_token_tx.rs index 0d13b2c1f2..dec0921dc7 100644 --- a/program-tests/utils/src/assert_token_tx.rs +++ b/program-tests/utils/src/assert_token_tx.rs @@ -4,7 +4,7 @@ use light_compressed_account::compressed_account::CompressedAccountWithMerkleCon use light_compressed_token::process_transfer::{get_cpi_authority_pda, TokenTransferOutputData}; use light_event::event::PublicTransactionEvent; use light_program_test::indexer::TestIndexerExtensions; -use light_token_sdk::compat::TokenDataWithMerkleContext; +use light_token::compat::TokenDataWithMerkleContext; use solana_sdk::{program_pack::Pack, pubkey::Pubkey}; use crate::assert_compressed_tx::{ diff --git a/program-tests/utils/src/assert_transfer2.rs b/program-tests/utils/src/assert_transfer2.rs index 96c08b044a..907e35673f 100644 --- a/program-tests/utils/src/assert_transfer2.rs +++ b/program-tests/utils/src/assert_transfer2.rs @@ -89,12 +89,12 @@ pub async fn assert_transfer2_with_delegate( }; // Get mint from the source compressed token account - let expected_recipient_token_data = light_token_sdk::compat::TokenData { + let expected_recipient_token_data = light_token::compat::TokenData { mint: source_mint, owner: transfer_input.to, amount: transfer_input.amount, delegate: None, - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; @@ -157,12 +157,12 @@ pub async fn assert_transfer2_with_delegate( None // No delegate to preserve }; - let expected_change_token = light_token_sdk::compat::TokenData { + let expected_change_token = light_token::compat::TokenData { mint: source_mint, owner: source_owner, amount: change_amount, delegate: expected_delegate, - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; @@ -216,12 +216,12 @@ pub async fn assert_transfer2_with_delegate( None // Default to None if no authority specified }; - let expected_change_token = light_token_sdk::compat::TokenData { + let expected_change_token = light_token::compat::TokenData { mint: source_mint, owner: source_owner, amount: change_amount, delegate: expected_delegate, - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; @@ -278,12 +278,12 @@ pub async fn assert_transfer2_with_delegate( .value .items; - let expected_change_token = light_token_sdk::compat::TokenData { + let expected_change_token = light_token::compat::TokenData { mint: source_mint, owner: source_owner, amount: change_amount, delegate: Some(approve_input.delegate), - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; @@ -336,12 +336,12 @@ pub async fn assert_transfer2_with_delegate( .map(|accounts| accounts.iter().map(|a| a.token.amount).sum::()) .unwrap_or(0); - let expected_recipient_token_data = light_token_sdk::compat::TokenData { + let expected_recipient_token_data = light_token::compat::TokenData { mint: compress_input.mint, owner: compress_input.to, amount: compress_input.amount + compressed_input_amount, delegate: None, - state: light_token_sdk::compat::AccountState::Initialized, + state: light_token::compat::AccountState::Initialized, tlv: None, }; recipient_accounts.iter().for_each(|account| { @@ -451,9 +451,9 @@ pub async fn assert_transfer2_with_delegate( let is_frozen = pre_token_account.state == spl_token_2022::state::AccountState::Frozen; let expected_state = if is_frozen { - light_token_sdk::compat::AccountState::Frozen + light_token::compat::AccountState::Frozen } else { - light_token_sdk::compat::AccountState::Initialized + light_token::compat::AccountState::Initialized }; // Delegate is preserved from the original account @@ -488,7 +488,7 @@ pub async fn assert_transfer2_with_delegate( }; // Build expected token data for single assert comparison - let expected_token = light_token_sdk::compat::TokenData { + let expected_token = light_token::compat::TokenData { mint: expected_mint, owner: expected_owner, amount: expected_amount, diff --git a/program-tests/utils/src/conversions.rs b/program-tests/utils/src/conversions.rs index 38d6195181..505b2c29b5 100644 --- a/program-tests/utils/src/conversions.rs +++ b/program-tests/utils/src/conversions.rs @@ -83,27 +83,23 @@ use light_token_interface::state::{CompressedTokenAccountState, TokenData as Pro // } pub fn sdk_to_program_account_state( - sdk_state: light_token_sdk::compat::AccountState, + sdk_state: light_token::compat::AccountState, ) -> CompressedTokenAccountState { match sdk_state { - light_token_sdk::compat::AccountState::Initialized => { - CompressedTokenAccountState::Initialized - } - light_token_sdk::compat::AccountState::Frozen => CompressedTokenAccountState::Frozen, + light_token::compat::AccountState::Initialized => CompressedTokenAccountState::Initialized, + light_token::compat::AccountState::Frozen => CompressedTokenAccountState::Frozen, } } -pub fn program_to_sdk_account_state(program_state: u8) -> light_token_sdk::compat::AccountState { +pub fn program_to_sdk_account_state(program_state: u8) -> light_token::compat::AccountState { match program_state { - 0 => light_token_sdk::compat::AccountState::Initialized, - 1 => light_token_sdk::compat::AccountState::Frozen, + 0 => light_token::compat::AccountState::Initialized, + 1 => light_token::compat::AccountState::Frozen, _ => panic!("program_to_sdk_account_state: invalid account state"), } } -pub fn sdk_to_program_token_data( - sdk_token: light_token_sdk::compat::TokenData, -) -> ProgramTokenData { +pub fn sdk_to_program_token_data(sdk_token: light_token::compat::TokenData) -> ProgramTokenData { ProgramTokenData { mint: sdk_token.mint.into(), owner: sdk_token.owner.into(), @@ -116,8 +112,8 @@ pub fn sdk_to_program_token_data( pub fn program_to_sdk_token_data( program_token: ProgramTokenData, -) -> light_token_sdk::compat::TokenData { - light_token_sdk::compat::TokenData { +) -> light_token::compat::TokenData { + light_token::compat::TokenData { mint: program_token.mint.into(), owner: program_token.owner.into(), amount: program_token.amount, diff --git a/program-tests/utils/src/e2e_test_env.rs b/program-tests/utils/src/e2e_test_env.rs index 6aefb38f94..98e557c3eb 100644 --- a/program-tests/utils/src/e2e_test_env.rs +++ b/program-tests/utils/src/e2e_test_env.rs @@ -134,6 +134,7 @@ use light_program_test::{ }, program_test::{LightProgramTest, TestRpc}, utils::register_test_forester::register_test_forester, + ForesterConfig, }; use light_prover_client::{ constants::{PROVE_PATH, SERVER_ADDRESS}, @@ -145,7 +146,6 @@ use light_registry::{ protocol_config::state::{ProtocolConfig, ProtocolConfigPda}, sdk::create_finalize_registration_instruction, utils::get_protocol_config_pda_address, - ForesterConfig, }; use light_sdk::{ address::NewAddressParamsAssignedPacked, @@ -154,7 +154,7 @@ use light_sdk::{ use light_sparse_merkle_tree::{ changelog::ChangelogEntry, indexed_changelog::IndexedChangelogEntry, SparseMerkleTree, }; -use light_token_sdk::compat::{AccountState, TokenDataWithMerkleContext}; +use light_token::compat::{AccountState, TokenDataWithMerkleContext}; use log::info; use num_bigint::{BigUint, RandBigInt}; use num_traits::Num; diff --git a/program-tests/utils/src/mint_2022.rs b/program-tests/utils/src/mint_2022.rs index 28d22ee040..8341480c1b 100644 --- a/program-tests/utils/src/mint_2022.rs +++ b/program-tests/utils/src/mint_2022.rs @@ -5,8 +5,8 @@ use forester_utils::instructions::create_account::create_account_instruction; use light_client::rpc::Rpc; +use light_token::spl_interface::{find_spl_interface_pda, CreateSplInterfacePda}; use light_token_interface::RESTRICTED_EXTENSION_TYPES; -use light_token_sdk::spl_interface::{find_spl_interface_pda, CreateSplInterfacePda}; use solana_sdk::{ instruction::Instruction, pubkey::Pubkey, diff --git a/program-tests/utils/src/setup_forester.rs b/program-tests/utils/src/setup_forester.rs index b82698212d..c6e2e718ce 100644 --- a/program-tests/utils/src/setup_forester.rs +++ b/program-tests/utils/src/setup_forester.rs @@ -3,11 +3,10 @@ use light_client::rpc::{Rpc, RpcError}; use light_compressed_account::TreeType; use light_program_test::{ accounts::test_keypairs::TestKeypairs, program_test::TestRpc, - utils::register_test_forester::register_test_forester, + utils::register_test_forester::register_test_forester, ForesterConfig, }; use light_registry::{ protocol_config::state::ProtocolConfig, sdk::create_finalize_registration_instruction, - ForesterConfig, }; use solana_sdk::signature::Signer; diff --git a/program-tests/utils/src/spl.rs b/program-tests/utils/src/spl.rs index a075c10cc3..a44ebc3374 100644 --- a/program-tests/utils/src/spl.rs +++ b/program-tests/utils/src/spl.rs @@ -30,8 +30,8 @@ use light_compressed_token::{ }; use light_hasher::Poseidon; use light_program_test::{indexer::TestIndexerExtensions, program_test::TestRpc}; +use light_token::compat::TokenDataWithMerkleContext; use light_token_interface::state::{CompressedTokenAccountState, TokenData}; -use light_token_sdk::compat::TokenDataWithMerkleContext; use solana_banks_client::BanksClientError; use solana_sdk::{ instruction::Instruction, diff --git a/programs/compressed-token/anchor/Cargo.toml b/programs/compressed-token/anchor/Cargo.toml index 4cde7e6faa..3683d6343a 100644 --- a/programs/compressed-token/anchor/Cargo.toml +++ b/programs/compressed-token/anchor/Cargo.toml @@ -25,7 +25,7 @@ cpi-without-program-ids = [] [dependencies] anchor-lang = { workspace = true } -anchor-spl = { workspace = true } +anchor-spl = { version = "0.31.1", features = ["idl-build"] } spl-token = { workspace = true, features = ["no-entrypoint"] } account-compression = { workspace = true, features = ["cpi", "no-idl"] } light-system-program-anchor = { workspace = true, features = ["cpi"] } diff --git a/programs/compressed-token/program/docs/compressed_token/ADD_TOKEN_POOL.md b/programs/compressed-token/program/docs/compressed_token/ADD_TOKEN_POOL.md index 4f810eddba..57206410e0 100644 --- a/programs/compressed-token/program/docs/compressed_token/ADD_TOKEN_POOL.md +++ b/programs/compressed-token/program/docs/compressed_token/ADD_TOKEN_POOL.md @@ -9,7 +9,7 @@ - Accounts struct: `programs/compressed-token/anchor/src/instructions/create_token_pool.rs:171-201` **description:** -Token pool pda is renamed to spl interface pda in the light-token-sdk. +Token pool pda is renamed to spl interface pda in the light-token. 1. Creates additional token pools for a mint (indexes 1-4) after the initial pool (index 0) exists 2. Requires the previous pool (index-1) to exist, enforcing sequential pool creation. This ensures mint extensions were already validated during `create_token_pool` for pool index 0 3. Maximum 5 pools per mint (NUM_MAX_POOL_ACCOUNTS = 5, defined in programs/compressed-token/anchor/src/constants.rs) diff --git a/programs/compressed-token/program/docs/compressed_token/CREATE_TOKEN_POOL.md b/programs/compressed-token/program/docs/compressed_token/CREATE_TOKEN_POOL.md index 770b96c5a3..c4b9bc5db4 100644 --- a/programs/compressed-token/program/docs/compressed_token/CREATE_TOKEN_POOL.md +++ b/programs/compressed-token/program/docs/compressed_token/CREATE_TOKEN_POOL.md @@ -9,7 +9,7 @@ - Accounts struct: `programs/compressed-token/anchor/src/instructions/create_token_pool.rs:45-72` **description:** -Token pool pda is renamed to spl interface pda in the light-token-sdk. +Token pool pda is renamed to spl interface pda in the light-token. 1. Creates a token pool PDA for a given SPL or Token-2022 mint 2. Token pools store underlying SPL/T22 tokens when users compress them into compressed tokens or convert them into ctokens. When tokens are compressed, they are transferred to the pool; when decompressed, tokens are transferred back from the pool to the user 3. Each mint can have up to 5 token pools (this instruction creates the first pool at index 0) diff --git a/rebase.md b/rebase.md index 8f1a57f45d..0088e9b809 100644 --- a/rebase.md +++ b/rebase.md @@ -9,7 +9,7 @@ Rebasing `swen/clean-decompress-base` onto `main`. ### 1. Package Renames - `ctoken-sdk` → `token-sdk` -- `light_token_sdk` → `light_token_sdk` +- `light_token` → `light_token` - `ctoken` module → `token` module in APIs - `sdk-ctoken-test` → `sdk-light-token-test` - `light_token_interface` → `light_token_interface` @@ -36,21 +36,21 @@ Main deleted these that HEAD modified: 1. **sdk-libs/macros/src/compressible/instructions.rs** - Keep user's Phase 8 changes (simplified API) - - Use main's naming (`light_token_sdk` not `light_token_sdk`) + - Use main's naming (`light_token` not `light_token`) - Resolution: Take HEAD's code, update package names to main's convention 2. **sdk-libs/macros/src/compressible/decompress_context.rs** - Keep user's `RentFreeAccountData` naming - - Use `light_token_sdk::compat::PackedCTokenData` (main's package name) + - Use `light_token::compat::PackedCTokenData` (main's package name) - Fix trait method naming to match 3. **sdk-libs/macros/src/compressible/seed_providers.rs** - Keep user's Phase 8 implementation (simpler trait) - - Update imports to `light_token_sdk` + - Update imports to `light_token` 4. **sdk-libs/macros/src/compressible/variant_enum.rs** - Keep user's variant structure with idx fields - - Use `light_token_sdk::compat::*` imports + - Use `light_token::compat::*` imports 5. **sdk-libs/sdk/src/compressible/decompress_runtime.rs** - Keep user's simplified `TokenSeedProvider` trait (no accounts struct) @@ -85,7 +85,7 @@ Main deleted these that HEAD modified: ### Test Files -- **csdk-anchor-full-derived-test** - Keep user's changes, update imports to `light_token_sdk` → `light_token_sdk` +- **csdk-anchor-full-derived-test** - Keep user's changes, update imports to `light_token` → `light_token` ## Confidence Level diff --git a/scripts/lint.sh b/scripts/lint.sh index d31acd7d4a..11ee8ee6db 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -33,7 +33,7 @@ NO_DEFAULT_CRATES=( "light-sdk-types" "light-sdk-pinocchio" "light-sdk-macros" - "light-token-sdk" + "light-token" "light-token-types" "light-sdk" "csdk-anchor-full-derived-test" @@ -98,7 +98,7 @@ ANCHOR_CRATES=( "light-compressible" "light-sdk-types" "light-sdk" - "light-token-sdk" + "light-token" "light-token-types" ) diff --git a/sdk-libs/client/Cargo.toml b/sdk-libs/client/Cargo.toml index adf849ec06..b06698093b 100644 --- a/sdk-libs/client/Cargo.toml +++ b/sdk-libs/client/Cargo.toml @@ -7,10 +7,11 @@ repository = "https://github.com/lightprotocol/light-protocol" description = "Client library for Light Protocol" [features] +default = ["v2"] devenv = ["v2"] v2 = [] program-test = ["solana-banks-client", "litesvm"] -anchor = ["anchor-lang", "light-sdk/anchor", "light-token-sdk/anchor"] +anchor = ["anchor-lang", "light-sdk/anchor", "light-token/anchor"] [dependencies] # Solana dependencies @@ -46,7 +47,7 @@ light-indexed-merkle-tree = { workspace = true } light-sdk = { workspace = true, features = ["v2", "cpi-context"] } light-hasher = { workspace = true, features = ["poseidon"] } light-compressed-account = { workspace = true, features = ["solana", "poseidon"] } -light-token-sdk = { workspace = true, features = ["cpi-context"] } +light-token = { workspace = true, features = ["cpi-context"] } light-token-interface = { workspace = true } light-event = { workspace = true } light-compressible = { workspace = true } diff --git a/sdk-libs/client/src/indexer/types.rs b/sdk-libs/client/src/indexer/types.rs index 2278dd3735..3f653db274 100644 --- a/sdk-libs/client/src/indexer/types.rs +++ b/sdk-libs/client/src/indexer/types.rs @@ -11,8 +11,8 @@ use light_indexed_merkle_tree::array::IndexedElement; use light_sdk::instruction::{ PackedAccounts, PackedAddressTreeInfo, PackedStateTreeInfo, ValidityProof, }; +use light_token::compat::{AccountState, TokenData}; use light_token_interface::state::ExtensionStruct; -use light_token_sdk::compat::{AccountState, TokenData}; use num_bigint::BigUint; use solana_pubkey::Pubkey; use tracing::warn; @@ -939,11 +939,11 @@ impl TryFrom<&photon_api::models::TokenAccountV2> for CompressedTokenAccount { } #[allow(clippy::from_over_into)] -impl Into for CompressedTokenAccount { - fn into(self) -> light_token_sdk::compat::TokenDataWithMerkleContext { +impl Into for CompressedTokenAccount { + fn into(self) -> light_token::compat::TokenDataWithMerkleContext { let compressed_account = CompressedAccountWithMerkleContext::from(self.account); - light_token_sdk::compat::TokenDataWithMerkleContext { + light_token::compat::TokenDataWithMerkleContext { token_data: self.token, compressed_account, } @@ -951,30 +951,30 @@ impl Into for CompressedTok } #[allow(clippy::from_over_into)] -impl Into> +impl Into> for super::response::Response> { - fn into(self) -> Vec { + fn into(self) -> Vec { self.value .items .into_iter() .map( - |token_account| light_token_sdk::compat::TokenDataWithMerkleContext { + |token_account| light_token::compat::TokenDataWithMerkleContext { token_data: token_account.token, compressed_account: CompressedAccountWithMerkleContext::from( token_account.account.clone(), ), }, ) - .collect::>() + .collect::>() } } -impl TryFrom for CompressedTokenAccount { +impl TryFrom for CompressedTokenAccount { type Error = IndexerError; fn try_from( - token_data_with_context: light_token_sdk::compat::TokenDataWithMerkleContext, + token_data_with_context: light_token::compat::TokenDataWithMerkleContext, ) -> Result { let account = CompressedAccount::try_from(token_data_with_context.compressed_account)?; diff --git a/sdk-libs/client/src/interface/account_interface.rs b/sdk-libs/client/src/interface/account_interface.rs index bc8b123bac..4c04469b7f 100644 --- a/sdk-libs/client/src/interface/account_interface.rs +++ b/sdk-libs/client/src/interface/account_interface.rs @@ -8,8 +8,8 @@ //! - `solana_account::Account` for raw account data //! - `spl_token_2022_interface::pod::PodAccount` for parsed token data +use light_token::instruction::derive_token_ata; use light_token_interface::state::ExtensionStruct; -use light_token_sdk::token::derive_token_ata; use solana_account::Account; use solana_pubkey::Pubkey; use spl_pod::{ @@ -94,7 +94,7 @@ impl AccountInterface { compressed: CompressedTokenAccount, wallet_owner: Pubkey, ) -> Self { - use light_token_sdk::compat::AccountState as LightAccountState; + use light_token::compat::AccountState as LightAccountState; let token = &compressed.token; let parsed = PodAccount { mint: token.mint, @@ -119,7 +119,7 @@ impl AccountInterface { account: Account { lamports: compressed.account.lamports, data, - owner: light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID, + owner: light_token::instruction::LIGHT_TOKEN_PROGRAM_ID, executable: false, rent_epoch: 0, }, @@ -265,7 +265,7 @@ impl TokenAccountInterface { owner_override: Pubkey, program_owner: Pubkey, ) -> Self { - use light_token_sdk::compat::AccountState as LightAccountState; + use light_token::compat::AccountState as LightAccountState; let token = &compressed.token; diff --git a/sdk-libs/client/src/interface/account_interface_ext.rs b/sdk-libs/client/src/interface/account_interface_ext.rs index 6812b9b64e..d6ae2237a5 100644 --- a/sdk-libs/client/src/interface/account_interface_ext.rs +++ b/sdk-libs/client/src/interface/account_interface_ext.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; use borsh::BorshDeserialize as _; use light_compressed_account::address::derive_address; +use light_token::instruction::derive_token_ata; use light_token_interface::{state::Mint, MINT_ADDRESS_TREE}; -use light_token_sdk::token::derive_token_ata; use solana_pubkey::Pubkey; use super::{AccountInterface, AccountToFetch, MintInterface, MintState, TokenAccountInterface}; diff --git a/sdk-libs/client/src/interface/create_accounts_proof.rs b/sdk-libs/client/src/interface/create_accounts_proof.rs index 7f572a2021..0d6a1ab7c4 100644 --- a/sdk-libs/client/src/interface/create_accounts_proof.rs +++ b/sdk-libs/client/src/interface/create_accounts_proof.rs @@ -3,8 +3,8 @@ use light_compressed_account::instruction_data::compressed_proof::ValidityProof; use light_sdk::instruction::PackedAddressTreeInfo; +use light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address; use light_token_interface::MINT_ADDRESS_TREE; -use light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address; use solana_instruction::AccountMeta; use solana_pubkey::Pubkey; use thiserror::Error; diff --git a/sdk-libs/client/src/interface/decompress_mint.rs b/sdk-libs/client/src/interface/decompress_mint.rs index 0bc740f788..d877c1ce71 100644 --- a/sdk-libs/client/src/interface/decompress_mint.rs +++ b/sdk-libs/client/src/interface/decompress_mint.rs @@ -2,12 +2,12 @@ use borsh::BorshDeserialize; use light_compressed_account::instruction_data::compressed_proof::ValidityProof; +use light_token::instruction::{derive_mint_compressed_address, DecompressMint}; use light_token_interface::{ instructions::mint_action::{MintInstructionData, MintWithContext}, state::Mint, MINT_ADDRESS_TREE, }; -use light_token_sdk::token::{derive_mint_compressed_address, DecompressMint}; use solana_account::Account; use solana_instruction::Instruction; use solana_pubkey::Pubkey; @@ -98,7 +98,7 @@ impl MintInterface { } pub const DEFAULT_RENT_PAYMENT: u8 = 2; -pub const DEFAULT_WRITE_TOP_UP: u32 = 766; +pub const DEFAULT_WRITE_TOP_UP: u32 = 0; /// Builds load instruction for a cold mint. Returns empty vec if already hot. pub fn build_decompress_mint( diff --git a/sdk-libs/client/src/interface/instructions.rs b/sdk-libs/client/src/interface/instructions.rs index 043f927dd1..91c2157f80 100644 --- a/sdk-libs/client/src/interface/instructions.rs +++ b/sdk-libs/client/src/interface/instructions.rs @@ -11,7 +11,7 @@ use light_sdk::{ SystemAccountMetaConfig, ValidityProof, }, }; -use light_token_sdk::token::{ +use light_token::instruction::{ COMPRESSIBLE_CONFIG_V1, LIGHT_TOKEN_CPI_AUTHORITY, LIGHT_TOKEN_PROGRAM_ID, RENT_SPONSOR, }; use solana_account::Account; diff --git a/sdk-libs/client/src/interface/light_program_interface.rs b/sdk-libs/client/src/interface/light_program_interface.rs index 8bda731080..7815037bc2 100644 --- a/sdk-libs/client/src/interface/light_program_interface.rs +++ b/sdk-libs/client/src/interface/light_program_interface.rs @@ -9,7 +9,7 @@ use std::fmt::Debug; use light_sdk::interface::Pack; -use light_token_sdk::token::derive_token_ata; +use light_token::instruction::derive_token_ata; use solana_pubkey::Pubkey; use super::{AccountInterface, TokenAccountInterface}; diff --git a/sdk-libs/client/src/interface/load_accounts.rs b/sdk-libs/client/src/interface/load_accounts.rs index bb5a8c518b..67d1bd7931 100644 --- a/sdk-libs/client/src/interface/load_accounts.rs +++ b/sdk-libs/client/src/interface/load_accounts.rs @@ -4,15 +4,7 @@ use light_compressed_account::{ compressed_account::PackedMerkleContext, instruction_data::compressed_proof::ValidityProof, }; use light_sdk::{compressible::Pack, instruction::PackedAccounts}; -use light_token_interface::{ - instructions::{ - extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, - mint_action::{MintInstructionData, MintWithContext}, - transfer2::MultiInputTokenDataWithContext, - }, - state::{ExtensionStruct, TokenDataVersion}, -}; -use light_token_sdk::{ +use light_token::{ compat::AccountState, compressed_token::{ transfer2::{ @@ -21,10 +13,18 @@ use light_token_sdk::{ }, CTokenAccount2, }, - token::{ + instruction::{ derive_token_ata, CreateAssociatedTokenAccount, DecompressMint, LIGHT_TOKEN_PROGRAM_ID, }, }; +use light_token_interface::{ + instructions::{ + extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, + mint_action::{MintInstructionData, MintWithContext}, + transfer2::MultiInputTokenDataWithContext, + }, + state::{ExtensionStruct, TokenDataVersion}, +}; use solana_instruction::Instruction; use solana_pubkey::Pubkey; use thiserror::Error; @@ -48,7 +48,7 @@ pub enum LoadAccountsError { BuildInstruction(String), #[error("Token SDK error: {0}")] - TokenSdk(#[from] light_token_sdk::error::TokenSdkError), + TokenSdk(#[from] light_token::error::TokenSdkError), #[error("Cold PDA at index {index} (pubkey {pubkey}) missing data")] MissingPdaCompressed { index: usize, pubkey: Pubkey }, diff --git a/sdk-libs/client/src/interface/mod.rs b/sdk-libs/client/src/interface/mod.rs index 519d12db9d..b8847c6e98 100644 --- a/sdk-libs/client/src/interface/mod.rs +++ b/sdk-libs/client/src/interface/mod.rs @@ -27,7 +27,7 @@ pub use light_program_interface::{ ColdContext, LightProgramInterface, PdaSpec, }; pub use light_sdk::interface::config::LightConfig; -pub use light_token_sdk::compat::TokenData; +pub use light_token::compat::TokenData; pub use load_accounts::{create_load_instructions, LoadAccountsError}; pub use pack::{pack_proof, PackError, PackedProofResult}; pub use solana_account::Account; diff --git a/sdk-libs/macros/docs/accounts/light_mint.md b/sdk-libs/macros/docs/accounts/light_mint.md index 4cf2952a1b..03557e28b2 100644 --- a/sdk-libs/macros/docs/accounts/light_mint.md +++ b/sdk-libs/macros/docs/accounts/light_mint.md @@ -118,7 +118,7 @@ pub mint: UncheckedAccount<'info>, The mint address is derived from the `mint_signer` field: ```rust -let (mint_pda, bump) = light_token_sdk::token::find_mint_address(mint_signer.key); +let (mint_pda, bump) = light_token::instruction::find_mint_address(mint_signer.key); ``` ### Signer Seeds (mint_seeds) diff --git a/sdk-libs/macros/docs/features/anchor-spl-features.md b/sdk-libs/macros/docs/features/anchor-spl-features.md index 97ef13bfa2..dca26a4fab 100644 --- a/sdk-libs/macros/docs/features/anchor-spl-features.md +++ b/sdk-libs/macros/docs/features/anchor-spl-features.md @@ -7,8 +7,8 @@ This document covers the 12 SPL-specific features available in Anchor through th Anchor SPL provides typed wrappers and constraints for SPL Token and Token-2022 programs. These features enable type-safe token account and mint initialization with validation. ```rust -use anchor_spl::token::{Token, TokenAccount, Mint}; -use anchor_spl::token_interface::{TokenInterface, TokenAccount as InterfaceTokenAccount}; +use light_anchor_spl::token::{Token, TokenAccount, Mint}; +use light_anchor_spl::token_interface::{TokenInterface, TokenAccount as InterfaceTokenAccount}; ``` --- @@ -229,7 +229,7 @@ pub associated_token_program: Program<'info, AssociatedToken>, **Example**: ```rust -use anchor_spl::token_interface::TokenAccount; +use light_anchor_spl::token_interface::TokenAccount; #[derive(Accounts)] pub struct TransferTokens<'info> { @@ -248,7 +248,7 @@ pub struct TransferTokens<'info> { **Example**: ```rust -use anchor_spl::token_interface::TokenInterface; +use light_anchor_spl::token_interface::TokenInterface; #[derive(Accounts)] pub struct TokenOp<'info> { @@ -290,8 +290,8 @@ Anchor SPL supports these Token-2022 extensions through the interface types: **Example with extensions**: ```rust -use anchor_spl::token_2022::Token2022; -use anchor_spl::token_interface::{ +use light_anchor_spl::token_2022::Token2022; +use light_anchor_spl::token_interface::{ Mint as InterfaceMint, TokenAccount as InterfaceTokenAccount, }; @@ -318,7 +318,7 @@ pub struct Token2022Op<'info> { ```rust use anchor_lang::prelude::*; -use anchor_spl::{ +use light_anchor_spl::{ associated_token::AssociatedToken, token_interface::{Mint, TokenAccount, TokenInterface}, }; @@ -392,7 +392,7 @@ pub mint: InterfaceAccount<'info, Mint>, Anchor SPL also provides CPI helpers for token operations: ```rust -use anchor_spl::token_interface::{transfer_checked, TransferChecked}; +use light_anchor_spl::token_interface::{transfer_checked, TransferChecked}; // Transfer tokens transfer_checked( diff --git a/sdk-libs/macros/src/light_pdas/account/decompress_context.rs b/sdk-libs/macros/src/light_pdas/account/decompress_context.rs index 6c619d0f3d..da5a460fed 100644 --- a/sdk-libs/macros/src/light_pdas/account/decompress_context.rs +++ b/sdk-libs/macros/src/light_pdas/account/decompress_context.rs @@ -106,7 +106,7 @@ pub fn generate_decompress_context_trait_impl( Ok(quote! { impl<#lifetime> light_sdk::interface::DecompressContext<#lifetime> for DecompressAccountsIdempotent<#lifetime> { type CompressedData = LightAccountData; - type PackedTokenData = light_token_sdk::compat::PackedCTokenData<#packed_token_variant_ident>; + type PackedTokenData = light_token::compat::PackedCTokenData<#packed_token_variant_ident>; type CompressedMeta = light_sdk::instruction::account_meta::CompressedAccountMetaNoLamportsNoAddress; type SeedParams = SeedParams; @@ -146,7 +146,7 @@ pub fn generate_decompress_context_trait_impl( solana_accounts: &[solana_account_info::AccountInfo<#lifetime>], seed_params: std::option::Option<&Self::SeedParams>, ) -> std::result::Result<( - Vec, + Vec<::light_sdk::compressed_account::CompressedAccountInfo>, Vec<(Self::PackedTokenData, Self::CompressedMeta)>, ), solana_program_error::ProgramError> { solana_msg::msg!("collect_pda_and_token: start, {} accounts", compressed_accounts.len()); @@ -201,7 +201,7 @@ pub fn generate_decompress_context_trait_impl( post_system_accounts: &[solana_account_info::AccountInfo<#lifetime>], has_prior_context: bool, ) -> std::result::Result<(), solana_program_error::ProgramError> { - light_token_sdk::compressible::process_decompress_tokens_runtime( + light_token::compressible::process_decompress_tokens_runtime( remaining_accounts, fee_payer, token_program, diff --git a/sdk-libs/macros/src/light_pdas/accounts/builder.rs b/sdk-libs/macros/src/light_pdas/accounts/builder.rs index 8c04881e16..4c01f9ebf2 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/builder.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/builder.rs @@ -236,7 +236,7 @@ impl LightAccountsBuilder { let cpi_accounts = light_sdk::cpi::v2::CpiAccounts::new_with_config( &self.#fee_payer, _remaining, - light_sdk_types::cpi_accounts::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER), + ::light_sdk::sdk_types::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER), ); // Load compression config @@ -251,7 +251,7 @@ impl LightAccountsBuilder { // Step 1: Write PDAs to CPI context let cpi_context_account = cpi_accounts.cpi_context()?; - let cpi_context_accounts = light_sdk_types::cpi_context_write::CpiContextWriteAccounts { + let cpi_context_accounts = ::light_sdk::sdk_types::CpiContextWriteAccounts { fee_payer: cpi_accounts.fee_payer(), authority: cpi_accounts.authority()?, cpi_context: cpi_context_account, diff --git a/sdk-libs/macros/src/light_pdas/accounts/mint.rs b/sdk-libs/macros/src/light_pdas/accounts/mint.rs index ec44c0f974..61b9375cdc 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/mint.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/mint.rs @@ -110,7 +110,7 @@ impl InfraRefs { /// Builder for generating code that creates multiple compressed mints using CreateMintsCpi. /// /// This replaces the previous single-mint LightMintBuilder with support for N mints. -/// Generated code uses `CreateMintsCpi` from light_token_sdk for optimal batching. +/// Generated code uses `CreateMintsCpi` from light_token for optimal batching. /// /// Usage: /// ```ignore @@ -236,8 +236,8 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { .unwrap_or_else(|| quote! { None }); quote! { - let #token_metadata_ident: Option = Some( - light_token_sdk::TokenMetadataInstructionData { + let #token_metadata_ident: Option = Some( + light_token::TokenMetadataInstructionData { update_authority: #update_authority_expr, name: #name_expr, symbol: #symbol_expr, @@ -248,14 +248,14 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { } } else { quote! { - let #token_metadata_ident: Option = None; + let #token_metadata_ident: Option = None; } }; quote! { // Mint #idx: derive PDA and build params let #signer_key_ident = *self.#mint_signer.to_account_info().key; - let (#pda_ident, #bump_ident) = light_token_sdk::token::find_mint_address(&#signer_key_ident); + let (#pda_ident, #bump_ident) = light_token::instruction::find_mint_address(&#signer_key_ident); let #mint_seeds_ident: &[&[u8]] = #mint_seeds; #authority_seeds_binding @@ -263,7 +263,7 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { let __tree_info = &#address_tree_info; - let #idx_ident = light_token_sdk::token::SingleMintParams { + let #idx_ident = light_token::instruction::SingleMintParams { decimals: #decimals, address_merkle_tree_root_index: __tree_info.root_index, mint_authority: *self.#authority.to_account_info().key, @@ -329,14 +329,14 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { #output_tree_setup // Extract proof from instruction params - let __proof: light_token_sdk::CompressedProof = #params_ident.create_accounts_proof.proof.0.clone() + let __proof: light_token::CompressedProof = #params_ident.create_accounts_proof.proof.0.clone() .expect("proof is required for mint creation"); // Build SingleMintParams for each mint #(#mint_params_builds)* // Array of mint params - let __mint_params: [light_token_sdk::token::SingleMintParams<'_>; #mint_count] = [ + let __mint_params: [light_token::instruction::SingleMintParams<'_>; #mint_count] = [ #(#param_idents),* ]; @@ -364,7 +364,7 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { let __address_tree = cpi_accounts.get_tree_account_info(__address_tree_index as usize)?; // Build CreateMintsParams with tree indices - let __create_mints_params = light_token_sdk::token::CreateMintsParams::new( + let __create_mints_params = light_token::instruction::CreateMintsParams::new( &__mint_params, __proof, ) @@ -380,7 +380,7 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { // Build and invoke CreateMintsCpi // Seeds are extracted from SingleMintParams internally - light_token_sdk::token::CreateMintsCpi { + light_token::instruction::CreateMintsCpi { mint_seed_accounts: &__mint_seed_accounts, payer: self.#fee_payer.to_account_info(), address_tree: __address_tree.clone(), @@ -389,7 +389,7 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { compressible_config: self.#light_token_config.to_account_info(), mints: &__mint_accounts, rent_sponsor: self.#light_token_rent_sponsor.to_account_info(), - system_accounts: light_token_sdk::token::SystemAccountInfos { + system_accounts: light_token::instruction::SystemAccountInfos { light_system_program: cpi_accounts.light_system_program()?.clone(), cpi_authority_pda: self.#light_token_cpi_authority.to_account_info(), registered_program_pda: cpi_accounts.registered_program_pda()?.clone(), diff --git a/sdk-libs/macros/src/light_pdas/accounts/pda.rs b/sdk-libs/macros/src/light_pdas/accounts/pda.rs index 402561c815..884aa073c2 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/pda.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/pda.rs @@ -82,8 +82,8 @@ impl<'a> PdaBlockBuilder<'a> { // Explicit type annotation ensures clear error if wrong type is provided. // Must be PackedAddressTreeInfo (with indices), not AddressTreeInfo (with Pubkeys). // If you have AddressTreeInfo, pack it client-side using pack_address_tree_info(). - let tree_info: &light_sdk_types::instruction::PackedAddressTreeInfo = &#addr_tree_info; - light_compressed_account::instruction_data::data::NewAddressParamsAssignedPacked { + let tree_info: &::light_sdk::sdk_types::PackedAddressTreeInfo = &#addr_tree_info; + ::light_sdk::compressed_account::NewAddressParamsAssignedPacked { seed: #account_key, address_merkle_tree_account_index: tree_info.address_merkle_tree_pubkey_index, address_queue_account_index: tree_info.address_queue_pubkey_index, @@ -101,7 +101,7 @@ impl<'a> PdaBlockBuilder<'a> { let new_addr_params = &self.idents.new_addr_params; quote! { - let #address = light_compressed_account::address::derive_address( + let #address = ::light_sdk::compressed_account::derive_address( &#new_addr_params.seed, &cpi_accounts .get_tree_account_info(#new_addr_params.address_merkle_tree_account_index as usize)? diff --git a/sdk-libs/macros/src/light_pdas/accounts/token.rs b/sdk-libs/macros/src/light_pdas/accounts/token.rs index f9583d2973..9fd2911da0 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/token.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/token.rs @@ -102,7 +102,7 @@ pub(super) fn generate_token_account_cpi( Some(quote! { // Create token account: #field_ident { - use light_token_sdk::token::CreateTokenAccountCpi; + use light_token::instruction::CreateTokenAccountCpi; // Bind seeds to local variables to extend temporary lifetimes #(#seed_bindings)* @@ -150,7 +150,7 @@ pub(super) fn generate_ata_cpi(field: &AtaField, infra: &InfraRefs) -> Option Option, compression_config: &light_sdk::interface::LightConfig, program_id: &solana_pubkey::Pubkey, - ) -> std::result::Result, solana_program_error::ProgramError> { + ) -> std::result::Result, solana_program_error::ProgramError> { let data = account_info.try_borrow_data().map_err(__anchor_to_program_error)?; let discriminator = &data[0..8]; diff --git a/sdk-libs/macros/src/light_pdas/program/instructions.rs b/sdk-libs/macros/src/light_pdas/program/instructions.rs index f5f7b4bfae..d4ce9d55ea 100644 --- a/sdk-libs/macros/src/light_pdas/program/instructions.rs +++ b/sdk-libs/macros/src/light_pdas/program/instructions.rs @@ -341,7 +341,7 @@ fn codegen( write_top_up: u32, rent_sponsor: Pubkey, compression_authority: Pubkey, - rent_config: light_compressible::rent::RentConfig, + rent_config: ::light_sdk::interface::rent::RentConfig, address_space: Vec, ) -> Result<()> { light_sdk::interface::process_initialize_light_config_checked( @@ -369,7 +369,7 @@ fn codegen( ctx: Context<'_, '_, '_, 'info, UpdateCompressionConfig<'info>>, new_rent_sponsor: Option, new_compression_authority: Option, - new_rent_config: Option, + new_rent_config: Option<::light_sdk::interface::rent::RentConfig>, new_write_top_up: Option, new_address_space: Option>, new_update_authority: Option, diff --git a/sdk-libs/macros/src/light_pdas/program/variant_enum.rs b/sdk-libs/macros/src/light_pdas/program/variant_enum.rs index a17ef881e3..e85eac0f7d 100644 --- a/sdk-libs/macros/src/light_pdas/program/variant_enum.rs +++ b/sdk-libs/macros/src/light_pdas/program/variant_enum.rs @@ -134,8 +134,8 @@ impl<'a> LightVariantBuilder<'a> { let ctoken_variants = if self.include_ctoken { quote! { - PackedCTokenData(light_token_sdk::compat::PackedCTokenData), - CTokenData(light_token_sdk::compat::CTokenData), + PackedCTokenData(light_token::compat::PackedCTokenData), + CTokenData(light_token::compat::CTokenData), } } else { quote! {} @@ -181,23 +181,23 @@ impl<'a> LightVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_hasher::DataHasher>::hash::(data), - LightAccountVariant::#packed_variant_name { .. } => Err(light_hasher::HasherError::EmptyInput), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as ::light_sdk::hasher::DataHasher>::hash::(data), + LightAccountVariant::#packed_variant_name { .. } => Err(::light_sdk::hasher::HasherError::EmptyInput), } }); let ctoken_arms = if self.include_ctoken { quote! { - Self::PackedCTokenData(_) => Err(light_hasher::HasherError::EmptyInput), - Self::CTokenData(_) => Err(light_hasher::HasherError::EmptyInput), + Self::PackedCTokenData(_) => Err(::light_sdk::hasher::HasherError::EmptyInput), + Self::CTokenData(_) => Err(::light_sdk::hasher::HasherError::EmptyInput), } } else { quote! {} }; quote! { - impl light_hasher::DataHasher for LightAccountVariant { - fn hash(&self) -> std::result::Result<[u8; 32], light_hasher::HasherError> { + impl ::light_sdk::hasher::DataHasher for LightAccountVariant { + fn hash(&self) -> std::result::Result<[u8; 32], ::light_sdk::hasher::HasherError> { match self { #(#hash_match_arms)* #ctoken_arms @@ -385,7 +385,7 @@ impl<'a> LightVariantBuilder<'a> { quote! { Self::PackedCTokenData(_) => Err(solana_program_error::ProgramError::InvalidAccountData), Self::CTokenData(data) => { - Ok(Self::PackedCTokenData(light_token_sdk::pack::Pack::pack(data, remaining_accounts)?)) + Ok(Self::PackedCTokenData(light_token::pack::Pack::pack(data, remaining_accounts)?)) } } } else { @@ -666,7 +666,7 @@ impl<'a> TokenVariantBuilder<'a> { }); quote! { - impl light_token_sdk::pack::Pack for TokenAccountVariant { + impl light_token::pack::Pack for TokenAccountVariant { type Packed = PackedTokenAccountVariant; fn pack(&self, remaining_accounts: &mut light_sdk::instruction::PackedAccounts) -> std::result::Result { @@ -717,7 +717,7 @@ impl<'a> TokenVariantBuilder<'a> { }); quote! { - impl light_token_sdk::pack::Unpack for PackedTokenAccountVariant { + impl light_token::pack::Unpack for PackedTokenAccountVariant { type Unpacked = TokenAccountVariant; fn unpack( @@ -735,9 +735,9 @@ impl<'a> TokenVariantBuilder<'a> { /// Generate the IntoCTokenVariant implementation. fn generate_into_ctoken_variant_impl(&self) -> TokenStream { quote! { - impl light_sdk::interface::IntoCTokenVariant for TokenAccountVariant { - fn into_ctoken_variant(self, token_data: light_token_sdk::compat::TokenData) -> LightAccountVariant { - LightAccountVariant::CTokenData(light_token_sdk::compat::CTokenData { + impl light_sdk::interface::IntoCTokenVariant for TokenAccountVariant { + fn into_ctoken_variant(self, token_data: light_token::compat::TokenData) -> LightAccountVariant { + LightAccountVariant::CTokenData(light_token::compat::CTokenData { variant: self, token_data, }) diff --git a/sdk-libs/macros/src/rent_sponsor.rs b/sdk-libs/macros/src/rent_sponsor.rs index 8fd37695e7..d851ca171a 100644 --- a/sdk-libs/macros/src/rent_sponsor.rs +++ b/sdk-libs/macros/src/rent_sponsor.rs @@ -125,10 +125,10 @@ pub fn derive_light_rent_sponsor_pda(input: TokenStream) -> TokenStream { /// Derives a Rent Sponsor configuration struct at compile time. /// -/// Returns `::light_sdk_types::RentSponsor { program_id, rent_sponsor, bump, version }`. +/// Returns `::light_sdk::sdk_types::RentSponsor { program_id, rent_sponsor, bump, version }`. /// /// Usage: -/// const RENT_SPONSOR: ::light_sdk_types::RentSponsor = +/// const RENT_SPONSOR: ::light_sdk::sdk_types::RentSponsor = /// derive_light_rent_sponsor!("Program1111111111111111111111111111111111", 1); pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { let args = parse_macro_input!(input as Args); @@ -175,7 +175,7 @@ pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { let version_lit = proc_macro2::Literal::u16_unsuffixed(version_u16); let output = quote! { { - ::light_sdk_types::RentSponsor { + ::light_sdk::sdk_types::RentSponsor { program_id: [#(#program_id_literals),*], rent_sponsor: [#(#pda_literals),*], bump: #bump, diff --git a/sdk-libs/program-test/Cargo.toml b/sdk-libs/program-test/Cargo.toml index 0be76fce8a..0b147de2bb 100644 --- a/sdk-libs/program-test/Cargo.toml +++ b/sdk-libs/program-test/Cargo.toml @@ -6,9 +6,9 @@ license = "MIT" edition = "2021" [features] -default = [] -devenv = ["v2","light-client/devenv", "light-prover-client/devenv", "dep:account-compression", "dep:light-compressed-token", "dep:light-compressible", "dep:light-registry", "dep:light-batched-merkle-tree", "dep:light-concurrent-merkle-tree"] -v2 = ["light-client/v2"] +default = ["v2"] +v2 = [] +devenv = ["v2", "light-client/devenv", "light-prover-client/devenv", "dep:account-compression", "dep:light-compressed-token", "dep:light-registry", "dep:light-batched-merkle-tree", "dep:light-concurrent-merkle-tree"] [dependencies] light-sdk = { workspace = true, features = ["anchor"] } @@ -19,8 +19,8 @@ light-merkle-tree-metadata = { workspace = true, features = ["anchor"] } light-concurrent-merkle-tree = { workspace = true, optional = true } light-hasher = { workspace = true, features = ["poseidon", "sha256", "keccak", "std"] } light-token-interface = { workspace = true } -light-compressible = { workspace = true, optional = true } -light-token-sdk = { workspace = true } +light-compressible = { workspace = true } +light-token = { workspace = true } light-compressed-account = { workspace = true, features = ["anchor", "poseidon"] } light-batched-merkle-tree = { workspace = true, features = ["test-only"], optional = true } light-event = { workspace = true } diff --git a/sdk-libs/program-test/src/compressible.rs b/sdk-libs/program-test/src/compressible.rs index a49e712369..10aac649c5 100644 --- a/sdk-libs/program-test/src/compressible.rs +++ b/sdk-libs/program-test/src/compressible.rs @@ -1,35 +1,27 @@ -#[cfg(feature = "devenv")] use std::collections::HashMap; -#[cfg(feature = "devenv")] -use anchor_lang::pubkey; -#[cfg(feature = "devenv")] use borsh::BorshDeserialize; -#[cfg(feature = "devenv")] use light_client::rpc::{Rpc, RpcError}; -#[cfg(feature = "devenv")] -use light_compressible::compression_info::CompressionInfo; -#[cfg(feature = "devenv")] -use light_compressible::config::CompressibleConfig as CtokenCompressibleConfig; -#[cfg(feature = "devenv")] -use light_compressible::rent::RentConfig; -#[cfg(feature = "devenv")] -use light_compressible::rent::SLOTS_PER_EPOCH; -#[cfg(feature = "devenv")] +use light_compressible::{ + compression_info::CompressionInfo, + config::CompressibleConfig as CtokenCompressibleConfig, + rent::{RentConfig, SLOTS_PER_EPOCH}, +}; use light_sdk::interface::LightConfig; -#[cfg(feature = "devenv")] -use light_token_interface::state::{Mint, Token, ACCOUNT_TYPE_MINT, ACCOUNT_TYPE_TOKEN_ACCOUNT}; -#[cfg(feature = "devenv")] +use light_token_interface::{ + state::{Mint, Token, ACCOUNT_TYPE_MINT, ACCOUNT_TYPE_TOKEN_ACCOUNT}, + LIGHT_TOKEN_PROGRAM_ID, +}; use solana_pubkey::Pubkey; -#[cfg(feature = "devenv")] -use crate::{litesvm_extensions::LiteSvmExtensions, LightProgramTest}; +use crate::{ + litesvm_extensions::LiteSvmExtensions, registry_sdk::REGISTRY_PROGRAM_ID, LightProgramTest, +}; /// Determines account type from account data. /// - If account is exactly 165 bytes: Token (legacy size without extensions) /// - If account is > 165 bytes: read byte 165 for discriminator /// - If account is < 165 bytes: invalid (returns None) -#[cfg(feature = "devenv")] fn determine_account_type(data: &[u8]) -> Option { const ACCOUNT_TYPE_OFFSET: usize = 165; @@ -42,7 +34,6 @@ fn determine_account_type(data: &[u8]) -> Option { /// Extracts CompressionInfo, account type, and compression_only from account data. /// Returns (CompressionInfo, account_type, compression_only) or None if parsing fails. -#[cfg(feature = "devenv")] fn extract_compression_info(data: &[u8]) -> Option<(CompressionInfo, u8, bool)> { use light_zero_copy::traits::ZeroCopyAt; @@ -83,10 +74,8 @@ fn extract_compression_info(data: &[u8]) -> Option<(CompressionInfo, u8, bool)> } } -#[cfg(feature = "devenv")] pub type CompressibleAccountStore = HashMap; -#[cfg(feature = "devenv")] #[derive(Eq, Hash, PartialEq)] pub struct StoredCompressibleAccount { pub pubkey: Pubkey, @@ -98,7 +87,6 @@ pub struct StoredCompressibleAccount { pub compression_only: bool, } -#[cfg(feature = "devenv")] #[derive(Debug, PartialEq, Copy, Clone)] pub struct FundingPoolConfig { pub compressible_config_pda: Pubkey, @@ -109,7 +97,6 @@ pub struct FundingPoolConfig { pub rent_sponsor_pda_bump: u8, } -#[cfg(feature = "devenv")] impl FundingPoolConfig { pub fn new(version: u16) -> Self { let config = CtokenCompressibleConfig::new_light_token( @@ -119,11 +106,8 @@ impl FundingPoolConfig { Pubkey::default(), RentConfig::default(), ); - let compressible_config = CtokenCompressibleConfig::derive_pda( - &pubkey!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX"), - version, - ) - .0; + let compressible_config = + CtokenCompressibleConfig::derive_pda(®ISTRY_PROGRAM_ID, version).0; Self { compressible_config_pda: compressible_config, rent_sponsor_pda: config.rent_sponsor, @@ -138,7 +122,6 @@ impl FundingPoolConfig { } } -#[cfg(feature = "devenv")] pub async fn claim_and_compress( rpc: &mut LightProgramTest, stored_compressible_accounts: &mut CompressibleAccountStore, @@ -151,7 +134,7 @@ pub async fn claim_and_compress( // Get all compressible token/mint accounts (both Token and Mint) let compressible_ctoken_accounts = rpc .context - .get_program_accounts(&light_compressed_token::ID); + .get_program_accounts(&Pubkey::from(LIGHT_TOKEN_PROGRAM_ID)); // CToken base accounts are 165 bytes, filter above that to exclude empty/minimal accounts for account in compressible_ctoken_accounts @@ -278,7 +261,6 @@ pub async fn claim_and_compress( Ok(()) } -#[cfg(feature = "devenv")] pub async fn auto_compress_program_pdas( rpc: &mut LightProgramTest, program_id: Pubkey, @@ -339,7 +321,6 @@ pub async fn auto_compress_program_pdas( Ok(()) } -#[cfg(feature = "devenv")] async fn try_compress_chunk( rpc: &mut LightProgramTest, program_id: &Pubkey, @@ -402,7 +383,6 @@ async fn try_compress_chunk( /// Compress and close a Mint account via mint_action instruction. /// Mint uses MintAction::CompressAndCloseMint flow instead of registry compress_and_close. -#[cfg(feature = "devenv")] async fn compress_mint_forester( rpc: &mut LightProgramTest, mint_pubkey: Pubkey, @@ -411,13 +391,10 @@ async fn compress_mint_forester( use light_client::indexer::Indexer; use light_compressed_account::instruction_data::traits::LightInstructionData; use light_compressible::config::CompressibleConfig; - use light_token_interface::{ - instructions::mint_action::{ - CompressAndCloseMintAction, MintActionCompressedInstructionData, MintWithContext, - }, - LIGHT_TOKEN_PROGRAM_ID, + use light_token::compressed_token::mint_action::MintActionMetaConfig; + use light_token_interface::instructions::mint_action::{ + CompressAndCloseMintAction, MintActionCompressedInstructionData, MintWithContext, }; - use light_token_sdk::compressed_token::mint_action::MintActionMetaConfig; use solana_sdk::signature::Signer; // Get Mint account data diff --git a/sdk-libs/program-test/src/forester/claim_forester.rs b/sdk-libs/program-test/src/forester/claim_forester.rs index 53f53bdd6b..bf9634ffe1 100644 --- a/sdk-libs/program-test/src/forester/claim_forester.rs +++ b/sdk-libs/program-test/src/forester/claim_forester.rs @@ -1,21 +1,18 @@ -use std::str::FromStr; - -use anchor_lang::{InstructionData, ToAccountMetas}; use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; use light_compressible::config::CompressibleConfig; -use light_registry::{ - accounts::ClaimContext as ClaimAccounts, utils::get_forester_epoch_pda_from_authority, -}; use solana_sdk::{ - instruction::Instruction, pubkey::Pubkey, signature::{Keypair, Signature}, signer::Signer, }; +use crate::registry_sdk::{ + build_claim_instruction, get_forester_epoch_pda_from_authority, REGISTRY_PROGRAM_ID, +}; + /// Claim rent from compressible token accounts via the registry program /// /// This function invokes the registry program's claim instruction, @@ -35,11 +32,9 @@ pub async fn claim_forester( authority: &Keypair, payer: &Keypair, ) -> Result { - // Registry and compressed token program IDs - let registry_program_id = - Pubkey::from_str("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX").unwrap(); + // Compressed token program ID let compressed_token_program_id = - Pubkey::from_str("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m").unwrap(); + Pubkey::from_str_const("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"); let current_epoch = 0; @@ -47,44 +42,20 @@ pub async fn claim_forester( let (registered_forester_pda, _) = get_forester_epoch_pda_from_authority(&authority.pubkey(), current_epoch); let config = CompressibleConfig::light_token_v1(Default::default(), Default::default()); - let compressible_config = CompressibleConfig::light_token_v1_config_pda(); + let compressible_config = CompressibleConfig::derive_v1_config_pda(®ISTRY_PROGRAM_ID).0; let rent_sponsor = config.rent_sponsor; let compression_authority = config.compression_authority; - // Build accounts using Anchor's account abstraction - let claim_accounts = ClaimAccounts { - authority: authority.pubkey(), + // Build the claim instruction using local SDK + let claim_ix = build_claim_instruction( + authority.pubkey(), registered_forester_pda, rent_sponsor, compression_authority, compressible_config, - compressed_token_program: compressed_token_program_id, - }; - - // Get account metas from Anchor accounts - let mut accounts = claim_accounts.to_account_metas(Some(true)); - - // Add token accounts as remaining accounts - for token_account in token_accounts { - accounts.push(solana_sdk::instruction::AccountMeta::new( - *token_account, - false, - )); - } - - // Create Anchor instruction with proper discriminator - // The registry program's claim function doesn't take any instruction data - // beyond the discriminator, so we just need to generate the discriminator - use light_registry::instruction::Claim; - let instruction = Claim {}; - let instruction_data = instruction.data(); - - // Create the instruction - let claim_ix = Instruction { - program_id: registry_program_id, - accounts, - data: instruction_data, - }; + compressed_token_program_id, + token_accounts, + ); // Prepare signers let mut signers = vec![payer]; diff --git a/sdk-libs/program-test/src/forester/compress_and_close_forester.rs b/sdk-libs/program-test/src/forester/compress_and_close_forester.rs index 60d17074aa..2c33ee7f87 100644 --- a/sdk-libs/program-test/src/forester/compress_and_close_forester.rs +++ b/sdk-libs/program-test/src/forester/compress_and_close_forester.rs @@ -1,25 +1,21 @@ -use std::str::FromStr; - -use anchor_lang::{InstructionData, ToAccountMetas}; use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; use light_compressible::config::CompressibleConfig; -use light_registry::{ - accounts::CompressAndCloseContext as CompressAndCloseAccounts, - compressible::compressed_token::CompressAndCloseIndices, instruction::CompressAndClose, - utils::get_forester_epoch_pda_from_authority, -}; use light_sdk::instruction::PackedAccounts; -use light_token_sdk::compressed_token::CompressAndCloseAccounts as CTokenCompressAndCloseAccounts; +use light_token::compressed_token::CompressAndCloseAccounts as CTokenCompressAndCloseAccounts; use solana_sdk::{ - instruction::Instruction, pubkey::Pubkey, signature::{Keypair, Signature}, signer::Signer, }; +use crate::registry_sdk::{ + build_compress_and_close_instruction, get_forester_epoch_pda_from_authority, + CompressAndCloseIndices, REGISTRY_PROGRAM_ID, +}; + /// Compress and close token accounts via the registry program /// /// This function invokes the registry program's compress_and_close instruction, @@ -41,11 +37,9 @@ pub async fn compress_and_close_forester( payer: &Keypair, destination: Option, ) -> Result { - // Registry and compressed token program IDs - let registry_program_id = - Pubkey::from_str("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX").unwrap(); + // Compressed token program ID let compressed_token_program_id = - Pubkey::from_str("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m").unwrap(); + Pubkey::from_str_const("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"); let current_epoch = 0; @@ -55,7 +49,7 @@ pub async fn compress_and_close_forester( let config = CompressibleConfig::light_token_v1(Pubkey::default(), Pubkey::default()); - let compressible_config = CompressibleConfig::derive_v1_config_pda(®istry_program_id).0; + let compressible_config = CompressibleConfig::derive_v1_config_pda(®ISTRY_PROGRAM_ID).0; // Derive compression_authority PDA (uses u16 version) let compression_authority = config.compression_authority; @@ -172,7 +166,7 @@ pub async fn compress_and_close_forester( let authority_index = packed_accounts.insert_or_get_config(compression_authority_pubkey, false, true); - let config = CTokenCompressAndCloseAccounts { + let ctoken_config = CTokenCompressAndCloseAccounts { compressed_token_program: compressed_token_program_id, cpi_authority_pda: Pubkey::find_program_address( &[b"cpi_authority"], @@ -183,37 +177,23 @@ pub async fn compress_and_close_forester( self_program: None, // Critical: None means no light_system_cpi_authority is added }; packed_accounts - .add_custom_system_accounts(config) + .add_custom_system_accounts(ctoken_config) .map_err(|e| RpcError::CustomError(format!("Failed to add system accounts: {:?}", e)))?; // Get account metas for remaining accounts let (remaining_account_metas, _, _) = packed_accounts.to_account_metas(); - // Build accounts using Anchor's account abstraction - let compress_and_close_accounts = CompressAndCloseAccounts { - authority: authority.pubkey(), + + // Build the compress_and_close instruction using local SDK + let compress_and_close_ix = build_compress_and_close_instruction( + authority.pubkey(), registered_forester_pda, compression_authority, compressible_config, - }; - - // Get account metas from Anchor accounts - let mut accounts = compress_and_close_accounts.to_account_metas(Some(true)); - - accounts.extend(remaining_account_metas); - - let instruction = CompressAndClose { authority_index, destination_index, - indices: indices_vec, - }; - let instruction_data = instruction.data(); - - // Create the instruction - let compress_and_close_ix = Instruction { - program_id: registry_program_id, - accounts, - data: instruction_data, - }; + indices_vec, + remaining_account_metas, + ); // Prepare signers let mut signers = vec![payer]; diff --git a/sdk-libs/program-test/src/forester/register_forester.rs b/sdk-libs/program-test/src/forester/register_forester.rs index 3009064fac..b33b4c08d9 100644 --- a/sdk-libs/program-test/src/forester/register_forester.rs +++ b/sdk-libs/program-test/src/forester/register_forester.rs @@ -1,14 +1,19 @@ use light_client::rpc::{Rpc, RpcError}; +// When devenv is enabled, use light_registry's SDK and types +#[cfg(feature = "devenv")] use light_registry::{ - protocol_config::state::ProtocolConfigPda, - sdk::{ - create_finalize_registration_instruction, create_register_forester_epoch_pda_instruction, - }, - utils::get_protocol_config_pda_address, + protocol_config::state::ProtocolConfigPda, sdk::create_finalize_registration_instruction, + sdk::create_register_forester_epoch_pda_instruction, utils::get_protocol_config_pda_address, ForesterConfig, }; use solana_sdk::signature::{Keypair, Signer}; +// When devenv is NOT enabled, use local registry_sdk +#[cfg(not(feature = "devenv"))] +use crate::registry_sdk::{ + create_finalize_registration_instruction, create_register_forester_epoch_pda_instruction, + deserialize_protocol_config_pda, get_protocol_config_pda_address, ForesterConfig, +}; use crate::{ accounts::test_keypairs::TestKeypairs, program_test::TestRpc, utils::register_test_forester::register_test_forester, @@ -33,17 +38,30 @@ pub async fn register_forester_for_compress_and_close( // 2. Get protocol config let (protocol_config_pda, _) = get_protocol_config_pda_address(); - let protocol_config = rpc - .get_anchor_account::(&protocol_config_pda) - .await? - .ok_or_else(|| RpcError::CustomError("Protocol config not found".to_string()))? - .config; - // 3. We're already in the active phase for epoch 0 due to protocol config - // (genesis_slot: 0, registration_phase_length: 2, active_phase_length: 1_000_000_000) - // So we just need to register for epoch 0 + #[cfg(feature = "devenv")] + let protocol_config = { + let protocol_config_pda_data = rpc + .get_anchor_account::(&protocol_config_pda) + .await? + .ok_or_else(|| RpcError::CustomError("Protocol config not found".to_string()))?; + protocol_config_pda_data.config + }; + + #[cfg(not(feature = "devenv"))] + let protocol_config = { + let protocol_config_account = rpc + .get_account(protocol_config_pda) + .await? + .ok_or_else(|| RpcError::CustomError("Protocol config not found".to_string()))?; + let protocol_config_pda_data = + deserialize_protocol_config_pda(&protocol_config_account.data).map_err(|e| { + RpcError::CustomError(format!("Failed to deserialize protocol config: {}", e)) + })?; + protocol_config_pda_data.config + }; - // Get current slot to determine if we need to advance past registration phase + // 3. Get current slot to determine if we need to advance past registration phase let current_slot = rpc.get_slot().await?; let epoch = 0; @@ -66,7 +84,7 @@ pub async fn register_forester_for_compress_and_close( rpc.warp_to_slot(protocol_config.registration_phase_length + 1)?; } - // 7. Finalize registration + // 4. Finalize registration let ix = create_finalize_registration_instruction( &forester_keypair.pubkey(), &forester_keypair.pubkey(), diff --git a/sdk-libs/program-test/src/indexer/extensions.rs b/sdk-libs/program-test/src/indexer/extensions.rs index 34356db9f3..8550723368 100644 --- a/sdk-libs/program-test/src/indexer/extensions.rs +++ b/sdk-libs/program-test/src/indexer/extensions.rs @@ -5,7 +5,7 @@ use light_client::indexer::{ }; use light_compressed_account::compressed_account::CompressedAccountWithMerkleContext; use light_event::event::PublicTransactionEvent; -use light_token_sdk::compat::TokenDataWithMerkleContext; +use light_token::compat::TokenDataWithMerkleContext; use solana_sdk::signature::Keypair; use super::{address_tree::AddressMerkleTreeBundle, state_tree::StateMerkleTreeBundle}; diff --git a/sdk-libs/program-test/src/indexer/test_indexer.rs b/sdk-libs/program-test/src/indexer/test_indexer.rs index 8cbab69efc..a0691279b7 100644 --- a/sdk-libs/program-test/src/indexer/test_indexer.rs +++ b/sdk-libs/program-test/src/indexer/test_indexer.rs @@ -65,7 +65,7 @@ use light_prover_client::{ }, }; use light_sdk::light_hasher::Hash; -use light_token_sdk::compat::{TokenData, TokenDataWithMerkleContext}; +use light_token::compat::{TokenData, TokenDataWithMerkleContext}; use log::info; use num_bigint::{BigInt, BigUint}; use num_traits::FromBytes; diff --git a/sdk-libs/program-test/src/lib.rs b/sdk-libs/program-test/src/lib.rs index 57f2c5fa9d..ddca5f3e5f 100644 --- a/sdk-libs/program-test/src/lib.rs +++ b/sdk-libs/program-test/src/lib.rs @@ -133,17 +133,28 @@ pub mod accounts; pub mod compressible; -#[cfg(feature = "devenv")] pub mod forester; pub mod indexer; pub mod litesvm_extensions; pub mod logging; pub mod program_test; +pub mod registry_sdk; pub mod utils; pub use light_client::{ indexer::{AddressWithTree, Indexer}, rpc::{Rpc, RpcError}, }; +// When devenv is enabled, re-export types from light_registry for compatibility +// with code that uses both light_registry and light_program_test +#[cfg(feature = "devenv")] +pub use light_registry::{ForesterConfig, ForesterPda}; pub use litesvm_extensions::LiteSvmExtensions; pub use program_test::{config::ProgramTestConfig, LightProgramTest}; +// Export setup function for external tests to set up protocol accounts +pub use registry_sdk::{ + protocol_config_for_tests, setup_test_protocol_accounts, ForesterEpochPda, ProtocolConfig, +}; +// When devenv is not enabled, use local definitions +#[cfg(not(feature = "devenv"))] +pub use registry_sdk::{ForesterConfig, ForesterPda}; diff --git a/sdk-libs/program-test/src/program_test/extensions.rs b/sdk-libs/program-test/src/program_test/extensions.rs index 63762b4613..8615d1b644 100644 --- a/sdk-libs/program-test/src/program_test/extensions.rs +++ b/sdk-libs/program-test/src/program_test/extensions.rs @@ -5,7 +5,7 @@ use light_client::indexer::{ }; use light_compressed_account::compressed_account::CompressedAccountWithMerkleContext; use light_event::event::PublicTransactionEvent; -use light_token_sdk::compat::TokenDataWithMerkleContext; +use light_token::compat::TokenDataWithMerkleContext; use solana_sdk::signature::Keypair; use crate::{ diff --git a/sdk-libs/program-test/src/program_test/light_program_test.rs b/sdk-libs/program-test/src/program_test/light_program_test.rs index 08b4680f26..2189fe32b1 100644 --- a/sdk-libs/program-test/src/program_test/light_program_test.rs +++ b/sdk-libs/program-test/src/program_test/light_program_test.rs @@ -33,7 +33,6 @@ pub struct LightProgramTest { pub test_accounts: TestAccounts, pub payer: Keypair, pub transaction_counter: usize, - #[cfg(feature = "devenv")] pub auto_mine_cold_state_programs: Vec, } @@ -79,7 +78,6 @@ impl LightProgramTest { payer, config: config.clone(), transaction_counter: 0, - #[cfg(feature = "devenv")] auto_mine_cold_state_programs: Vec::new(), }; let keypairs = TestKeypairs::program_test_default(); @@ -359,11 +357,29 @@ impl LightProgramTest { })?; } + // Set up protocol config and forester accounts for compress/close operations + // This must come AFTER loading JSON accounts to avoid being overwritten + crate::registry_sdk::setup_test_protocol_accounts( + &mut context.context, + &keypairs.forester.pubkey(), + ) + .map_err(|e| RpcError::CustomError(e))?; + // Initialize indexer with extracted batch size let test_accounts = context.test_accounts.clone(); context .add_indexer(&test_accounts, Some(batch_size)) .await?; + + // Register additional programs for auto-compression of their PDAs + // In non-devenv mode, always register since we can't configure otherwise + if let Some(programs) = context.config.additional_programs.clone() { + for (_, pid) in programs.into_iter() { + if !context.auto_mine_cold_state_programs.contains(&pid) { + context.auto_mine_cold_state_programs.push(pid); + } + } + } } // reset tx counter after program setup. diff --git a/sdk-libs/program-test/src/program_test/test_rpc.rs b/sdk-libs/program-test/src/program_test/test_rpc.rs index 392924aeb0..7797873882 100644 --- a/sdk-libs/program-test/src/program_test/test_rpc.rs +++ b/sdk-libs/program-test/src/program_test/test_rpc.rs @@ -1,24 +1,24 @@ use async_trait::async_trait; use light_client::rpc::{LightClient, Rpc, RpcError}; +use light_compressible::rent::SLOTS_PER_EPOCH; use solana_account::Account; -use solana_sdk::{clock::Slot, pubkey::Pubkey}; +use solana_sdk::{ + clock::{Clock, Slot}, + pubkey::Pubkey, +}; #[cfg(feature = "devenv")] use { borsh::BorshDeserialize, light_client::fee::{assert_transaction_params, TransactionParams}, - light_compressible::rent::SLOTS_PER_EPOCH, light_event::event::{BatchPublicTransactionEvent, PublicTransactionEvent}, solana_sdk::{ - clock::Clock, instruction::Instruction, signature::{Keypair, Signature}, }, std::{fmt::Debug, marker::Send}, }; -#[cfg(feature = "devenv")] -use crate::compressible::CompressibleAccountStore; -use crate::program_test::LightProgramTest; +use crate::{compressible::CompressibleAccountStore, program_test::LightProgramTest}; #[async_trait] pub trait TestRpc: Rpc + Sized { @@ -106,12 +106,10 @@ pub trait TestRpc: Rpc + Sized { /// Warps current slot forward by slots. /// Claims and compresses compressible ctoken accounts. - #[cfg(feature = "devenv")] async fn warp_slot_forward(&mut self, slot: Slot) -> Result<(), RpcError>; /// Warps forward by the specified number of epochs. /// Each epoch is SLOTS_PER_EPOCH slots. - #[cfg(feature = "devenv")] async fn warp_epoch_forward(&mut self, epochs: u64) -> Result<(), RpcError> { let slots_to_warp = epochs * SLOTS_PER_EPOCH; self.warp_slot_forward(slots_to_warp).await @@ -129,7 +127,6 @@ impl TestRpc for LightClient { unimplemented!() } - #[cfg(feature = "devenv")] async fn warp_slot_forward(&mut self, _slot: Slot) -> Result<(), RpcError> { unimplemented!() } @@ -150,7 +147,6 @@ impl TestRpc for LightProgramTest { /// Warps current slot forward by slots. /// Claims and compresses compressible ctoken accounts and program PDAs (auto compress). - #[cfg(feature = "devenv")] async fn warp_slot_forward(&mut self, slot: Slot) -> Result<(), RpcError> { let mut current_slot = self.context.get_sysvar::().slot; current_slot += slot; diff --git a/sdk-libs/program-test/src/registry_sdk.rs b/sdk-libs/program-test/src/registry_sdk.rs new file mode 100644 index 0000000000..4ca748774b --- /dev/null +++ b/sdk-libs/program-test/src/registry_sdk.rs @@ -0,0 +1,621 @@ +//! Local registry SDK for program-test. +//! +//! This module provides the minimal registry program SDK functionality needed +//! for forester and compressible modules without requiring the `devenv` feature. +//! It reimplements the necessary constants, PDA derivation, type definitions, +//! and instruction builders locally to avoid anchor program dependencies. + +use borsh::{BorshDeserialize, BorshSerialize}; +use solana_pubkey::Pubkey; +use solana_sdk::instruction::{AccountMeta, Instruction}; + +// ============================================================================ +// Program IDs +// ============================================================================ + +/// Registry program ID +pub const REGISTRY_PROGRAM_ID: Pubkey = + solana_pubkey::pubkey!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX"); + +// ============================================================================ +// PDA Seeds +// ============================================================================ + +pub const FORESTER_SEED: &[u8] = b"forester"; +pub const FORESTER_EPOCH_SEED: &[u8] = b"forester_epoch"; +pub const PROTOCOL_CONFIG_PDA_SEED: &[u8] = b"authority"; + +// ============================================================================ +// Instruction Discriminators (from discriminator test) +// ============================================================================ + +/// Claim instruction discriminator +pub const CLAIM_DISCRIMINATOR: [u8; 8] = [62, 198, 214, 193, 213, 159, 108, 210]; + +/// CompressAndClose instruction discriminator +pub const COMPRESS_AND_CLOSE_DISCRIMINATOR: [u8; 8] = [96, 94, 135, 18, 121, 42, 213, 117]; + +/// RegisterForester instruction discriminator +pub const REGISTER_FORESTER_DISCRIMINATOR: [u8; 8] = [62, 47, 240, 103, 84, 200, 226, 73]; + +/// RegisterForesterEpoch instruction discriminator +pub const REGISTER_FORESTER_EPOCH_DISCRIMINATOR: [u8; 8] = [43, 120, 253, 194, 109, 192, 101, 188]; + +/// FinalizeRegistration instruction discriminator +pub const FINALIZE_REGISTRATION_DISCRIMINATOR: [u8; 8] = [230, 188, 172, 96, 204, 247, 98, 227]; + +/// ReportWork instruction discriminator +#[allow(dead_code)] +pub const REPORT_WORK_DISCRIMINATOR: [u8; 8] = [170, 110, 232, 47, 145, 213, 138, 162]; + +// ============================================================================ +// Account Discriminators (for direct account serialization) +// ============================================================================ + +/// ProtocolConfigPda account discriminator +pub const PROTOCOL_CONFIG_PDA_DISCRIMINATOR: [u8; 8] = [96, 176, 239, 146, 1, 254, 99, 146]; + +/// ForesterPda account discriminator +pub const FORESTER_PDA_DISCRIMINATOR: [u8; 8] = [51, 47, 187, 86, 82, 153, 117, 5]; + +/// ForesterEpochPda account discriminator +pub const FORESTER_EPOCH_PDA_DISCRIMINATOR: [u8; 8] = [29, 117, 211, 141, 99, 143, 250, 114]; + +/// EpochPda account discriminator +pub const EPOCH_PDA_DISCRIMINATOR: [u8; 8] = [66, 224, 46, 2, 167, 137, 120, 107]; + +// ============================================================================ +// PDA Derivation Functions +// ============================================================================ + +/// Derives the protocol config PDA address. +pub fn get_protocol_config_pda_address() -> (Pubkey, u8) { + Pubkey::find_program_address(&[PROTOCOL_CONFIG_PDA_SEED], ®ISTRY_PROGRAM_ID) +} + +/// Derives the forester PDA for a given authority. +pub fn get_forester_pda(authority: &Pubkey) -> (Pubkey, u8) { + Pubkey::find_program_address(&[FORESTER_SEED, authority.as_ref()], ®ISTRY_PROGRAM_ID) +} + +/// Derives the forester epoch PDA from forester PDA and epoch. +pub fn get_forester_epoch_pda(forester_pda: &Pubkey, epoch: u64) -> (Pubkey, u8) { + Pubkey::find_program_address( + &[ + FORESTER_EPOCH_SEED, + forester_pda.as_ref(), + epoch.to_le_bytes().as_slice(), + ], + ®ISTRY_PROGRAM_ID, + ) +} + +/// Derives the forester epoch PDA from authority and epoch. +pub fn get_forester_epoch_pda_from_authority(authority: &Pubkey, epoch: u64) -> (Pubkey, u8) { + let forester_pda = get_forester_pda(authority); + get_forester_epoch_pda(&forester_pda.0, epoch) +} + +/// Derives the epoch PDA address for a given epoch. +pub fn get_epoch_pda_address(epoch: u64) -> Pubkey { + Pubkey::find_program_address(&[&epoch.to_le_bytes()], ®ISTRY_PROGRAM_ID).0 +} + +// ============================================================================ +// Type Definitions +// ============================================================================ + +/// Configuration for a forester. +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct ForesterConfig { + /// Fee in percentage points. + pub fee: u64, +} + +/// Forester PDA account structure. +#[derive(Debug, Default, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct ForesterPda { + pub authority: Pubkey, + pub config: ForesterConfig, + pub active_weight: u64, + /// Pending weight which will get active once the next epoch starts. + pub pending_weight: u64, + pub current_epoch: u64, + /// Link to previous compressed forester epoch account hash. + pub last_compressed_forester_epoch_pda_hash: [u8; 32], + pub last_registered_epoch: u64, +} + +/// Protocol configuration. +#[derive(Debug, Clone, Copy, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct ProtocolConfig { + /// Solana slot when the protocol starts operating. + pub genesis_slot: u64, + /// Minimum weight required for a forester to register to an epoch. + pub min_weight: u64, + /// Light protocol slot length + pub slot_length: u64, + /// Foresters can register for this phase. + pub registration_phase_length: u64, + /// Foresters can perform work in this phase. + pub active_phase_length: u64, + /// Foresters can report work to receive performance based rewards in this phase. + pub report_work_phase_length: u64, + pub network_fee: u64, + pub cpi_context_size: u64, + pub finalize_counter_limit: u64, + /// Placeholder for future protocol updates. + pub place_holder: Pubkey, + pub address_network_fee: u64, + pub place_holder_b: u64, + pub place_holder_c: u64, + pub place_holder_d: u64, + pub place_holder_e: u64, + pub place_holder_f: u64, +} + +impl Default for ProtocolConfig { + fn default() -> Self { + Self { + genesis_slot: 0, + min_weight: 1, + slot_length: 10, + registration_phase_length: 100, + active_phase_length: 1000, + report_work_phase_length: 100, + network_fee: 5000, + cpi_context_size: 20 * 1024 + 8, // DEFAULT_CPI_CONTEXT_ACCOUNT_SIZE_V2 + finalize_counter_limit: 100, + place_holder: Pubkey::default(), + address_network_fee: 10000, + place_holder_b: 0, + place_holder_c: 0, + place_holder_d: 0, + place_holder_e: 0, + place_holder_f: 0, + } + } +} + +/// Protocol config PDA account structure. +/// Includes Anchor's 8-byte discriminator at the start. +#[derive(Debug, BorshDeserialize)] +pub struct ProtocolConfigPda { + pub authority: Pubkey, + pub bump: u8, + pub config: ProtocolConfig, +} + +/// Indices for CompressAndClose operation (matches registry program's definition). +#[derive(Debug, Copy, Clone, BorshSerialize, BorshDeserialize)] +pub struct CompressAndCloseIndices { + pub source_index: u8, + pub mint_index: u8, + pub owner_index: u8, + pub rent_sponsor_index: u8, + pub delegate_index: u8, +} + +// ============================================================================ +// Instruction Builders +// ============================================================================ + +/// Builds the Claim instruction. +/// +/// # Accounts (in order) +/// - authority (signer, writable) +/// - registered_forester_pda (writable) +/// - rent_sponsor (writable) +/// - compression_authority (read-only) +/// - compressible_config (read-only) +/// - compressed_token_program (read-only) +/// - token_accounts (writable, remaining) +pub fn build_claim_instruction( + authority: Pubkey, + registered_forester_pda: Pubkey, + rent_sponsor: Pubkey, + compression_authority: Pubkey, + compressible_config: Pubkey, + compressed_token_program: Pubkey, + token_accounts: &[Pubkey], +) -> Instruction { + let mut accounts = vec![ + AccountMeta::new(authority, true), + AccountMeta::new(registered_forester_pda, false), + AccountMeta::new(rent_sponsor, false), + AccountMeta::new_readonly(compression_authority, false), + AccountMeta::new_readonly(compressible_config, false), + AccountMeta::new_readonly(compressed_token_program, false), + ]; + + for token_account in token_accounts { + accounts.push(AccountMeta::new(*token_account, false)); + } + + Instruction { + program_id: REGISTRY_PROGRAM_ID, + accounts, + data: CLAIM_DISCRIMINATOR.to_vec(), + } +} + +/// Builds the CompressAndClose instruction. +/// +/// # Accounts (in order) +/// - authority (signer, writable) +/// - registered_forester_pda (writable) +/// - compression_authority (writable) +/// - compressible_config (read-only) +/// - remaining_accounts +#[allow(clippy::too_many_arguments)] +pub fn build_compress_and_close_instruction( + authority: Pubkey, + registered_forester_pda: Pubkey, + compression_authority: Pubkey, + compressible_config: Pubkey, + authority_index: u8, + destination_index: u8, + indices: Vec, + remaining_accounts: Vec, +) -> Instruction { + let mut accounts = vec![ + AccountMeta::new(authority, true), + AccountMeta::new(registered_forester_pda, false), + AccountMeta::new(compression_authority, false), + AccountMeta::new_readonly(compressible_config, false), + ]; + accounts.extend(remaining_accounts); + + // Serialize instruction data: discriminator + authority_index + destination_index + indices vec + let mut data = COMPRESS_AND_CLOSE_DISCRIMINATOR.to_vec(); + data.push(authority_index); + data.push(destination_index); + // Borsh serialize the indices vector + indices.serialize(&mut data).unwrap(); + + Instruction { + program_id: REGISTRY_PROGRAM_ID, + accounts, + data, + } +} + +/// Builds the RegisterForester instruction. +/// +/// # Accounts (in order): +/// 1. fee_payer (signer, writable) +/// 2. authority (signer) +/// 3. protocol_config_pda (read-only) +/// 4. forester_pda (writable, init) +/// 5. system_program (read-only) +pub fn create_register_forester_instruction( + fee_payer: &Pubkey, + governance_authority: &Pubkey, + forester_authority: &Pubkey, + config: ForesterConfig, +) -> Instruction { + let (forester_pda, bump) = get_forester_pda(forester_authority); + let (protocol_config_pda, _) = get_protocol_config_pda_address(); + + let accounts = vec![ + AccountMeta::new(*fee_payer, true), + AccountMeta::new_readonly(*governance_authority, true), + AccountMeta::new_readonly(protocol_config_pda, false), + AccountMeta::new(forester_pda, false), + AccountMeta::new_readonly(solana_sdk::system_program::id(), false), + ]; + + // Instruction data: discriminator + bump + authority (pubkey) + config + weight (Option) + let mut data = REGISTER_FORESTER_DISCRIMINATOR.to_vec(); + data.push(bump); + data.extend_from_slice(forester_authority.as_ref()); + config.serialize(&mut data).unwrap(); + // weight: Some(1) encoded as Option + data.push(1u8); // Some variant + data.extend_from_slice(&1u64.to_le_bytes()); // weight = 1 + + Instruction { + program_id: REGISTRY_PROGRAM_ID, + accounts, + data, + } +} + +/// Builds the RegisterForesterEpoch instruction. +/// +/// # Accounts (in order): +/// 1. fee_payer (signer, writable) +/// 2. forester_epoch_pda (writable, init) +/// 3. forester_pda (read-only) +/// 4. authority (signer) +/// 5. epoch_pda (writable, init_if_needed) +/// 6. protocol_config (read-only) +/// 7. system_program (read-only) +pub fn create_register_forester_epoch_pda_instruction( + authority: &Pubkey, + derivation: &Pubkey, + epoch: u64, +) -> Instruction { + let (forester_epoch_pda, _bump) = get_forester_epoch_pda_from_authority(derivation, epoch); + let (forester_pda, _) = get_forester_pda(derivation); + let epoch_pda = get_epoch_pda_address(epoch); + let protocol_config_pda = get_protocol_config_pda_address().0; + + let accounts = vec![ + AccountMeta::new(*authority, true), // fee_payer + AccountMeta::new(forester_epoch_pda, false), // forester_epoch_pda + AccountMeta::new_readonly(forester_pda, false), // forester_pda + AccountMeta::new_readonly(*authority, true), // authority + AccountMeta::new(epoch_pda, false), // epoch_pda + AccountMeta::new_readonly(protocol_config_pda, false), // protocol_config + AccountMeta::new_readonly(solana_sdk::system_program::id(), false), // system_program + ]; + + // Instruction data: discriminator + epoch (u64) + let mut data = REGISTER_FORESTER_EPOCH_DISCRIMINATOR.to_vec(); + data.extend_from_slice(&epoch.to_le_bytes()); + + Instruction { + program_id: REGISTRY_PROGRAM_ID, + accounts, + data, + } +} + +/// Builds the FinalizeRegistration instruction. +/// +/// # Accounts (in order): +/// 1. forester_epoch_pda (writable) +/// 2. authority (signer) +/// 3. epoch_pda (read-only) +pub fn create_finalize_registration_instruction( + authority: &Pubkey, + derivation: &Pubkey, + epoch: u64, +) -> Instruction { + let (forester_epoch_pda, _bump) = get_forester_epoch_pda_from_authority(derivation, epoch); + let epoch_pda = get_epoch_pda_address(epoch); + + let accounts = vec![ + AccountMeta::new(forester_epoch_pda, false), + AccountMeta::new_readonly(*authority, true), + AccountMeta::new_readonly(epoch_pda, false), + ]; + + Instruction { + program_id: REGISTRY_PROGRAM_ID, + accounts, + data: FINALIZE_REGISTRATION_DISCRIMINATOR.to_vec(), + } +} + +// ============================================================================ +// Helper Functions +// ============================================================================ + +/// Deserializes a ProtocolConfigPda from account data. +/// Skips the 8-byte Anchor discriminator automatically. +pub fn deserialize_protocol_config_pda(data: &[u8]) -> Result { + // Skip 8-byte Anchor discriminator + if data.len() < 8 { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidData, + "Account data too short for discriminator", + )); + } + ProtocolConfigPda::deserialize(&mut &data[8..]) +} + +/// Deserializes a ForesterPda from account data. +/// Skips the 8-byte Anchor discriminator automatically. +pub fn deserialize_forester_pda(data: &[u8]) -> Result { + // Skip 8-byte Anchor discriminator + if data.len() < 8 { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidData, + "Account data too short for discriminator", + )); + } + ForesterPda::deserialize(&mut &data[8..]) +} + +// ============================================================================ +// ForesterEpochPda (for direct account serialization) +// ============================================================================ + +/// ForesterEpochPda account structure for serialization. +#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct ForesterEpochPda { + pub authority: Pubkey, + pub config: ForesterConfig, + pub epoch: u64, + pub weight: u64, + pub work_counter: u64, + pub has_reported_work: bool, + pub forester_index: u64, + pub epoch_active_phase_start_slot: u64, + pub total_epoch_weight: Option, + pub protocol_config: ProtocolConfig, + pub finalize_counter: u64, +} + +/// EpochPda account structure for serialization. +#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct EpochPda { + pub epoch: u64, + pub protocol_config: ProtocolConfig, + pub total_work: u64, + pub registered_weight: u64, +} + +// ============================================================================ +// Direct Account Serialization (for LiteSVM set_account) +// ============================================================================ + +/// Creates a ProtocolConfig with a very long active phase (effectively infinite). +/// This allows any slot to be in epoch 0's active phase. +pub fn protocol_config_for_tests() -> ProtocolConfig { + ProtocolConfig { + genesis_slot: 0, + min_weight: 1, + slot_length: 10, + registration_phase_length: 0, // No registration phase - always active + active_phase_length: u64::MAX / 2, // Very long active phase + report_work_phase_length: 0, + network_fee: 5000, + cpi_context_size: 20 * 1024 + 8, + finalize_counter_limit: u64::MAX, + place_holder: Pubkey::default(), + address_network_fee: 10000, + place_holder_b: 0, + place_holder_c: 0, + place_holder_d: 0, + place_holder_e: 0, + place_holder_f: 0, + } +} + +/// Serializes a ProtocolConfigPda to account data with Anchor discriminator. +pub fn serialize_protocol_config_pda( + authority: Pubkey, + bump: u8, + config: ProtocolConfig, +) -> Vec { + let mut data = PROTOCOL_CONFIG_PDA_DISCRIMINATOR.to_vec(); + authority.serialize(&mut data).unwrap(); + data.push(bump); + config.serialize(&mut data).unwrap(); + data +} + +/// Serializes a ForesterPda to account data with Anchor discriminator. +pub fn serialize_forester_pda(forester: &ForesterPda) -> Vec { + let mut data = FORESTER_PDA_DISCRIMINATOR.to_vec(); + forester.authority.serialize(&mut data).unwrap(); + forester.config.serialize(&mut data).unwrap(); + forester.active_weight.serialize(&mut data).unwrap(); + forester.pending_weight.serialize(&mut data).unwrap(); + forester.current_epoch.serialize(&mut data).unwrap(); + forester + .last_compressed_forester_epoch_pda_hash + .serialize(&mut data) + .unwrap(); + forester.last_registered_epoch.serialize(&mut data).unwrap(); + data +} + +/// Serializes a ForesterEpochPda to account data with Anchor discriminator. +pub fn serialize_forester_epoch_pda(epoch_pda: &ForesterEpochPda) -> Vec { + let mut data = FORESTER_EPOCH_PDA_DISCRIMINATOR.to_vec(); + epoch_pda.serialize(&mut data).unwrap(); + data +} + +/// Serializes an EpochPda to account data with Anchor discriminator. +pub fn serialize_epoch_pda(epoch_pda: &EpochPda) -> Vec { + let mut data = EPOCH_PDA_DISCRIMINATOR.to_vec(); + epoch_pda.serialize(&mut data).unwrap(); + data +} + +/// Sets up protocol config, forester, and forester epoch accounts for testing. +/// Uses a very long active phase so any slot is valid for epoch 0. +/// +/// This allows compress/close operations to work without the full devenv setup. +pub fn setup_test_protocol_accounts( + context: &mut litesvm::LiteSVM, + forester_authority: &Pubkey, +) -> Result<(), String> { + let protocol_config = protocol_config_for_tests(); + + // 1. Set up ProtocolConfigPda + let (protocol_config_pda, protocol_bump) = get_protocol_config_pda_address(); + let protocol_data = serialize_protocol_config_pda( + *forester_authority, // Use forester as governance authority for simplicity + protocol_bump, + protocol_config, + ); + let protocol_account = solana_account::Account { + lamports: 1_000_000_000, + data: protocol_data, + owner: REGISTRY_PROGRAM_ID, + executable: false, + rent_epoch: 0, + }; + context + .set_account(protocol_config_pda, protocol_account) + .map_err(|e| format!("Failed to set protocol config account: {}", e))?; + + // 2. Set up ForesterPda + let (forester_pda, _forester_bump) = get_forester_pda(forester_authority); + let forester = ForesterPda { + authority: *forester_authority, + config: ForesterConfig::default(), + active_weight: 1, + pending_weight: 0, + current_epoch: 0, + last_compressed_forester_epoch_pda_hash: [0u8; 32], + last_registered_epoch: 0, + }; + let forester_data = serialize_forester_pda(&forester); + let forester_account = solana_account::Account { + lamports: 1_000_000_000, + data: forester_data, + owner: REGISTRY_PROGRAM_ID, + executable: false, + rent_epoch: 0, + }; + context + .set_account(forester_pda, forester_account) + .map_err(|e| format!("Failed to set forester account: {}", e))?; + + // 3. Set up ForesterEpochPda for epoch 0 + let (forester_epoch_pda, _epoch_bump) = + get_forester_epoch_pda_from_authority(forester_authority, 0); + let forester_epoch = ForesterEpochPda { + authority: *forester_authority, + config: ForesterConfig::default(), + epoch: 0, + weight: 1, + work_counter: 0, + has_reported_work: false, + forester_index: 0, + epoch_active_phase_start_slot: 0, + total_epoch_weight: Some(1), // Must be Some for active phase + protocol_config, + finalize_counter: 1, // Already finalized + }; + let forester_epoch_data = serialize_forester_epoch_pda(&forester_epoch); + let forester_epoch_account = solana_account::Account { + lamports: 1_000_000_000, + data: forester_epoch_data, + owner: REGISTRY_PROGRAM_ID, + executable: false, + rent_epoch: 0, + }; + context + .set_account(forester_epoch_pda, forester_epoch_account) + .map_err(|e| format!("Failed to set forester epoch account: {}", e))?; + + // 4. Set up EpochPda for epoch 0 + let epoch_pda_address = get_epoch_pda_address(0); + let epoch_pda = EpochPda { + epoch: 0, + protocol_config, + total_work: 0, + registered_weight: 1, // Must match forester weight + }; + let epoch_pda_data = serialize_epoch_pda(&epoch_pda); + let epoch_pda_account = solana_account::Account { + lamports: 1_000_000_000, + data: epoch_pda_data, + owner: REGISTRY_PROGRAM_ID, + executable: false, + rent_epoch: 0, + }; + context + .set_account(epoch_pda_address, epoch_pda_account) + .map_err(|e| format!("Failed to set epoch pda account: {}", e))?; + + Ok(()) +} diff --git a/sdk-libs/program-test/src/utils/mod.rs b/sdk-libs/program-test/src/utils/mod.rs index 2309bd1055..0276eeb534 100644 --- a/sdk-libs/program-test/src/utils/mod.rs +++ b/sdk-libs/program-test/src/utils/mod.rs @@ -2,7 +2,6 @@ pub mod assert; pub mod create_account; pub mod find_light_bin; pub mod load_accounts; -#[cfg(feature = "devenv")] pub mod register_test_forester; pub mod setup_light_programs; pub mod tree_accounts; diff --git a/sdk-libs/program-test/src/utils/register_test_forester.rs b/sdk-libs/program-test/src/utils/register_test_forester.rs index 41cbe8a063..b2c9615d2e 100644 --- a/sdk-libs/program-test/src/utils/register_test_forester.rs +++ b/sdk-libs/program-test/src/utils/register_test_forester.rs @@ -1,4 +1,6 @@ use light_client::rpc::{Rpc, RpcError}; +// When devenv is enabled, use light_registry's types and SDK +#[cfg(feature = "devenv")] use light_registry::{ sdk::create_register_forester_instruction, utils::get_forester_pda, ForesterConfig, ForesterPda, }; @@ -7,6 +9,13 @@ use solana_sdk::{ signature::{Keypair, Signer}, }; +// When devenv is NOT enabled, use local registry_sdk +#[cfg(not(feature = "devenv"))] +use crate::registry_sdk::{ + create_register_forester_instruction, deserialize_forester_pda, get_forester_pda, + ForesterConfig, ForesterPda, +}; + /// Creates and asserts forester account creation. pub async fn register_test_forester( rpc: &mut R, @@ -39,6 +48,7 @@ pub async fn register_test_forester( .await } +#[cfg(feature = "devenv")] async fn assert_registered_forester( rpc: &mut R, forester: &Pubkey, @@ -54,3 +64,25 @@ async fn assert_registered_forester( } Ok(()) } + +#[cfg(not(feature = "devenv"))] +async fn assert_registered_forester( + rpc: &mut R, + forester: &Pubkey, + expected_account: ForesterPda, +) -> Result<(), RpcError> { + let pda = get_forester_pda(forester).0; + let account = rpc + .get_account(pda) + .await? + .ok_or_else(|| RpcError::CustomError(format!("Forester PDA account not found: {}", pda)))?; + let account_data = deserialize_forester_pda(&account.data) + .map_err(|e| RpcError::CustomError(format!("Failed to deserialize ForesterPda: {}", e)))?; + if account_data != expected_account { + return Err(RpcError::AssertRpcError(format!( + "Expected account data: {:?}, got: {:?}", + expected_account, account_data + ))); + } + Ok(()) +} diff --git a/sdk-libs/sdk-pinocchio/Cargo.toml b/sdk-libs/sdk-pinocchio/Cargo.toml index ca2abe9c07..f6079e9a72 100644 --- a/sdk-libs/sdk-pinocchio/Cargo.toml +++ b/sdk-libs/sdk-pinocchio/Cargo.toml @@ -7,7 +7,7 @@ license = "Apache-2.0" edition = "2021" [features] -default = ["alloc"] +default = ["alloc", "v2"] alloc = ["light-compressed-account/alloc"] std = ["alloc"] v2 = ["light-sdk-types/v2"] diff --git a/sdk-libs/sdk-types/Cargo.toml b/sdk-libs/sdk-types/Cargo.toml index bf803f0a75..fc3f065245 100644 --- a/sdk-libs/sdk-types/Cargo.toml +++ b/sdk-libs/sdk-types/Cargo.toml @@ -7,11 +7,12 @@ repository = "https://github.com/lightprotocol/light-protocol" description = "Core types for Light Protocol SDK" [features] -default = ["std"] +default = ["std", "v2"] std = ["alloc", "light-compressed-account/std", "solana-msg"] alloc = ["light-compressed-account/alloc"] keccak = ["light-hasher/keccak"] anchor = ["anchor-lang", "light-compressed-account/anchor"] +idl-build = ["anchor-lang/idl-build", "anchor"] v2 = [] cpi-context = [] poseidon = ["light-hasher/poseidon", "light-compressed-account/poseidon"] diff --git a/sdk-libs/sdk/Cargo.toml b/sdk-libs/sdk/Cargo.toml index 340e0cd6e8..3b85434a53 100644 --- a/sdk-libs/sdk/Cargo.toml +++ b/sdk-libs/sdk/Cargo.toml @@ -12,7 +12,7 @@ name = "light_sdk" [features] default = ["v2"] -idl-build = ["anchor-lang/idl-build", "anchor"] +idl-build = ["anchor-lang/idl-build", "anchor", "dep:solana-program"] anchor = [ "anchor-lang", "light-compressed-account/anchor", @@ -42,6 +42,7 @@ solana-system-interface = { workspace = true } solana-loader-v3-interface = { workspace = true, features = ["serde"] } anchor-lang = { workspace = true, optional = true } +solana-program = { workspace = true, optional = true } num-bigint = { workspace = true } borsh = { workspace = true } diff --git a/sdk-libs/sdk/src/interface/mod.rs b/sdk-libs/sdk/src/interface/mod.rs index 899755de67..f6111f1c73 100644 --- a/sdk-libs/sdk/src/interface/mod.rs +++ b/sdk-libs/sdk/src/interface/mod.rs @@ -43,3 +43,4 @@ pub use decompress_runtime::{ check_account_types, handle_packed_pda_variant, process_decompress_accounts_idempotent, DecompressContext, HasTokenVariant, PdaSeedDerivation, TokenSeedProvider, }; +pub use light_compressible::{rent, CreateAccountsProof}; diff --git a/sdk-libs/sdk/src/interface/traits.rs b/sdk-libs/sdk/src/interface/traits.rs index 093658b6a4..74653a7084 100644 --- a/sdk-libs/sdk/src/interface/traits.rs +++ b/sdk-libs/sdk/src/interface/traits.rs @@ -51,7 +51,7 @@ pub trait IntoVariant { /// } /// ``` /// -/// Type parameter `T` is typically `light_token_sdk::compat::TokenData`. +/// Type parameter `T` is typically `light_token::compat::TokenData`. pub trait IntoCTokenVariant { /// Construct variant from CToken variant and token data. /// diff --git a/sdk-libs/sdk/src/lib.rs b/sdk-libs/sdk/src/lib.rs index 97ee57567d..a04c3d4774 100644 --- a/sdk-libs/sdk/src/lib.rs +++ b/sdk-libs/sdk/src/lib.rs @@ -160,6 +160,33 @@ pub use interface as compressible; #[cfg(feature = "merkle-tree")] pub mod merkle_tree; +// Re-export hasher types for macro-generated code +pub mod hasher { + pub use light_hasher::{ + errors, hash_to_field_size, sha256, to_byte_array, DataHasher, Hasher, HasherError, + Poseidon, Sha256, + }; +} + +// Re-export compressed_account types for macro-generated code +pub mod compressed_account { + pub use light_compressed_account::{ + address::derive_address, + instruction_data::{ + data::NewAddressParamsAssignedPacked, with_account_info::CompressedAccountInfo, + }, + }; +} + +// Re-export sdk_types for macro-generated code +pub mod sdk_types { + #[cfg(feature = "cpi-context")] + pub use light_sdk_types::cpi_context_write::CpiContextWriteAccounts; + pub use light_sdk_types::{ + cpi_accounts::CpiAccountsConfig, instruction::PackedAddressTreeInfo, RentSponsor, + }; +} + #[cfg(feature = "anchor")] use anchor_lang::{AnchorDeserialize, AnchorSerialize}; #[cfg(not(feature = "anchor"))] @@ -171,7 +198,8 @@ pub use interface::{ MAX_ADDRESS_TREES_PER_SPACE, }; pub use light_account_checks::{self, discriminator::Discriminator as LightDiscriminator}; -pub use light_hasher; +// Re-export as extern crate so downstream crates can use `::light_hasher::` paths +pub extern crate light_hasher; #[cfg(feature = "poseidon")] use light_hasher::DataHasher; pub use light_macros::{derive_light_cpi_signer, derive_light_cpi_signer_pda}; diff --git a/sdk-libs/token-client/Cargo.toml b/sdk-libs/token-client/Cargo.toml index 5a2b2d3188..a5d876fa21 100644 --- a/sdk-libs/token-client/Cargo.toml +++ b/sdk-libs/token-client/Cargo.toml @@ -13,7 +13,7 @@ light-compressible = { workspace = true, features = ["anchor"] } light-token-interface = { workspace = true } light-sdk = { workspace = true } light-client = { workspace = true, features = ["v2"] } -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-zero-copy = { workspace = true } # Solana dependencies diff --git a/sdk-libs/token-client/src/actions/create_compressible_token_account.rs b/sdk-libs/token-client/src/actions/create_compressible_token_account.rs index c283803e77..57763bbe8e 100644 --- a/sdk-libs/token-client/src/actions/create_compressible_token_account.rs +++ b/sdk-libs/token-client/src/actions/create_compressible_token_account.rs @@ -1,6 +1,6 @@ use light_client::rpc::{Rpc, RpcError}; +use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::{has_restricted_extensions, state::TokenDataVersion}; -use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; use solana_keypair::Keypair; use solana_pubkey::Pubkey; use solana_signer::Signer; diff --git a/sdk-libs/token-client/src/actions/mint_action.rs b/sdk-libs/token-client/src/actions/mint_action.rs index 9f7d2c886f..4258f5a219 100644 --- a/sdk-libs/token-client/src/actions/mint_action.rs +++ b/sdk-libs/token-client/src/actions/mint_action.rs @@ -2,10 +2,10 @@ use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; -use light_token_interface::instructions::mint_action::Recipient; -use light_token_sdk::compressed_token::create_compressed_mint::{ +use light_token::compressed_token::create_compressed_mint::{ derive_mint_compressed_address, find_mint_address, }; +use light_token_interface::instructions::mint_action::Recipient; use solana_keypair::Keypair; use solana_pubkey::Pubkey; use solana_signature::Signature; @@ -105,7 +105,7 @@ pub async fn mint_action_comprehensive( } if !mint_to_decompressed_recipients.is_empty() { - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let (spl_mint_pda, _) = find_mint_address(&mint_seed.pubkey()); diff --git a/sdk-libs/token-client/src/actions/spl_interface.rs b/sdk-libs/token-client/src/actions/spl_interface.rs index 58052301da..de0d05f3b2 100644 --- a/sdk-libs/token-client/src/actions/spl_interface.rs +++ b/sdk-libs/token-client/src/actions/spl_interface.rs @@ -3,8 +3,8 @@ //! This module provides actions for working with SPL interface PDAs (token pools). use light_client::rpc::{Rpc, RpcError}; +use light_token::spl_interface::{find_spl_interface_pda, CreateSplInterfacePda}; use light_token_interface::has_restricted_extensions; -use light_token_sdk::spl_interface::{find_spl_interface_pda, CreateSplInterfacePda}; use solana_keypair::Keypair; use solana_pubkey::Pubkey; use solana_signature::Signature; diff --git a/sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs b/sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs index 90ca61ee88..df9aa4a177 100644 --- a/sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs +++ b/sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs @@ -2,8 +2,9 @@ use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; -use light_token_sdk::{ - constants::SPL_TOKEN_PROGRAM_ID, spl_interface::find_spl_interface_pda, token::TransferToSpl, +use light_token::{ + constants::SPL_TOKEN_PROGRAM_ID, instruction::TransferToSpl, + spl_interface::find_spl_interface_pda, }; use solana_keypair::Keypair; use solana_pubkey::Pubkey; diff --git a/sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs b/sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs index a50b64ed36..87617dd877 100644 --- a/sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs +++ b/sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs @@ -2,8 +2,9 @@ use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; -use light_token_sdk::{ - constants::SPL_TOKEN_PROGRAM_ID, spl_interface::find_spl_interface_pda, token::TransferFromSpl, +use light_token::{ + constants::SPL_TOKEN_PROGRAM_ID, instruction::TransferFromSpl, + spl_interface::find_spl_interface_pda, }; use solana_keypair::Keypair; use solana_pubkey::Pubkey; diff --git a/sdk-libs/token-client/src/instructions/create_mint.rs b/sdk-libs/token-client/src/instructions/create_mint.rs index e7a58225f9..ebdc8e0bfc 100644 --- a/sdk-libs/token-client/src/instructions/create_mint.rs +++ b/sdk-libs/token-client/src/instructions/create_mint.rs @@ -37,7 +37,7 @@ pub async fn create_compressed_mint_instruction( ) -> Result { // Get address tree for deriving compressed mint address let address_tree_pubkey = rpc.get_address_tree_v2().tree; - let compressed_mint_address = light_token_sdk::token::derive_mint_compressed_address( + let compressed_mint_address = light_token::instruction::derive_mint_compressed_address( &mint_seed.pubkey(), &address_tree_pubkey, ); diff --git a/sdk-libs/token-client/src/instructions/mint_action.rs b/sdk-libs/token-client/src/instructions/mint_action.rs index 376ae8dbe0..f8f3deeeeb 100644 --- a/sdk-libs/token-client/src/instructions/mint_action.rs +++ b/sdk-libs/token-client/src/instructions/mint_action.rs @@ -5,6 +5,10 @@ use light_client::{ }; use light_compressed_account::instruction_data::traits::LightInstructionData; use light_compressible::config::CompressibleConfig; +use light_token::compressed_token::{ + create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + mint_action::MintActionMetaConfig, +}; use light_token_interface::{ instructions::{ extensions::{token_metadata::TokenMetadataInstructionData, ExtensionInstructionData}, @@ -18,10 +22,6 @@ use light_token_interface::{ state::Mint, LIGHT_TOKEN_PROGRAM_ID, }; -use light_token_sdk::compressed_token::{ - create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - mint_action::MintActionMetaConfig, -}; use solana_instruction::Instruction; use solana_keypair::Keypair; use solana_pubkey::Pubkey; diff --git a/sdk-libs/token-client/src/instructions/mint_to_compressed.rs b/sdk-libs/token-client/src/instructions/mint_to_compressed.rs index 35491ae755..25d2a1b147 100644 --- a/sdk-libs/token-client/src/instructions/mint_to_compressed.rs +++ b/sdk-libs/token-client/src/instructions/mint_to_compressed.rs @@ -3,16 +3,16 @@ use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; -use light_token_interface::{ - instructions::mint_action::{MintWithContext, Recipient}, - state::{Mint, TokenDataVersion}, -}; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ create_compressed_mint::derive_mint_from_spl_mint, mint_to_compressed::{ create_mint_to_compressed_instruction, DecompressedMintConfig, MintToCompressedInputs, }, }; +use light_token_interface::{ + instructions::mint_action::{MintWithContext, Recipient}, + state::{Mint, TokenDataVersion}, +}; use solana_instruction::Instruction; use solana_pubkey::Pubkey; @@ -63,7 +63,7 @@ pub async fn mint_to_compressed_instruction( unimplemented!("SPL mint synchronization for decompressed Mint not yet implemented"); } let decompressed_mint_config: Option> = None; - let spl_interface_pda: Option = None; + let spl_interface_pda: Option = None; // Prepare compressed mint inputs let compressed_mint_inputs = MintWithContext { diff --git a/sdk-libs/token-client/src/instructions/transfer2.rs b/sdk-libs/token-client/src/instructions/transfer2.rs index 54ce908a68..312d037ba5 100644 --- a/sdk-libs/token-client/src/instructions/transfer2.rs +++ b/sdk-libs/token-client/src/instructions/transfer2.rs @@ -3,15 +3,7 @@ use light_client::{ rpc::Rpc, }; use light_sdk::instruction::{PackedAccounts, PackedStateTreeInfo}; -use light_token_interface::{ - instructions::{ - extensions::ExtensionInstructionData, - transfer2::{MultiInputTokenDataWithContext, MultiTokenTransferOutputData}, - }, - state::TokenDataVersion, - LIGHT_TOKEN_PROGRAM_ID, -}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer2::{ account_metas::Transfer2AccountsMetaConfig, create_transfer2_instruction, @@ -22,6 +14,14 @@ use light_token_sdk::{ error::TokenSdkError, spl_interface::find_spl_interface_pda_with_index, }; +use light_token_interface::{ + instructions::{ + extensions::ExtensionInstructionData, + transfer2::{MultiInputTokenDataWithContext, MultiTokenTransferOutputData}, + }, + state::TokenDataVersion, + LIGHT_TOKEN_PROGRAM_ID, +}; use solana_instruction::Instruction; use solana_pubkey::Pubkey; diff --git a/sdk-libs/token-client/src/instructions/update_compressed_mint.rs b/sdk-libs/token-client/src/instructions/update_compressed_mint.rs index 0b8f4e214a..dbf463503d 100644 --- a/sdk-libs/token-client/src/instructions/update_compressed_mint.rs +++ b/sdk-libs/token-client/src/instructions/update_compressed_mint.rs @@ -3,13 +3,13 @@ use light_client::{ indexer::Indexer, rpc::{Rpc, RpcError}, }; +use light_token::compressed_token::update_compressed_mint::{ + update_compressed_mint, UpdateMintInputs, +}; use light_token_interface::{ instructions::mint_action::{MintInstructionData, MintWithContext}, state::Mint, }; -use light_token_sdk::compressed_token::update_compressed_mint::{ - update_compressed_mint, UpdateMintInputs, -}; use light_token_types::MintAuthorityType; use solana_instruction::Instruction; use solana_keypair::Keypair; diff --git a/sdk-libs/token-client/src/lib.rs b/sdk-libs/token-client/src/lib.rs index 76dda47d75..e5e9399ef0 100644 --- a/sdk-libs/token-client/src/lib.rs +++ b/sdk-libs/token-client/src/lib.rs @@ -1,4 +1,4 @@ pub mod actions; pub mod instructions; // re-export -pub use light_token_sdk::token; +pub use light_token::instruction; diff --git a/sdk-libs/token-sdk/Cargo.toml b/sdk-libs/token-sdk/Cargo.toml index f959a411fc..08f86f0e9f 100644 --- a/sdk-libs/token-sdk/Cargo.toml +++ b/sdk-libs/token-sdk/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "light-token-sdk" +name = "light-token" version = "0.2.1" edition = { workspace = true } description = "SDK for compressed tokens on Light Protocol" @@ -7,12 +7,14 @@ license = "Apache-2.0" repository = "https://github.com/Lightprotocol/light-protocol" [features] -default = [] +default = ["anchor-discriminator"] v1 = [] -compressible = ["cpi-context"] - -anchor = ["anchor-lang", "light-token-types/anchor", "light-token-interface/anchor"] +anchor-discriminator = ["light-sdk/anchor-discriminator"] +anchor = ["anchor-lang", "light-token-types/anchor", "light-token-interface/anchor", "dep:light-sdk-macros"] +# idl-build feature enables IDL generation for client-side tooling and SDK generation +idl-build = ["anchor", "anchor-lang/idl-build", "light-sdk/idl-build"] cpi-context = ["light-sdk/cpi-context"] + profile-program = [ "light-program-profiler/profile-program", "light-compressed-account/profile-program", @@ -30,7 +32,7 @@ light-token-types = { workspace = true } light-compressed-account = { workspace = true, features = ["std", "solana"] } light-compressible = { workspace = true } light-token-interface = { workspace = true } -light-sdk = { workspace = true, features = ["v2"] } +light-sdk = { workspace = true, features = ["v2", "cpi-context"] } light-batched-merkle-tree = { workspace = true } light-macros = { workspace = true } thiserror = { workspace = true } @@ -52,6 +54,7 @@ light-program-profiler = { workspace = true } # Optional Anchor dependency anchor-lang = { workspace = true, optional = true } +light-sdk-macros = { workspace = true, optional = true } [dev-dependencies] light-account-checks = { workspace = true, features = ["test-only", "pinocchio", "std"] } diff --git a/sdk-libs/token-sdk/src/anchor.rs b/sdk-libs/token-sdk/src/anchor.rs new file mode 100644 index 0000000000..d067a5a80c --- /dev/null +++ b/sdk-libs/token-sdk/src/anchor.rs @@ -0,0 +1,40 @@ +//! Anchor integration module for Light Protocol compressed tokens. +//! +//! Provides a single import point for Anchor programs using Light Protocol. + +// Re-export Light SDK core types +pub use light_sdk::{ + account::LightAccount as LightAccountType, + address, + cpi::{v2::CpiAccounts, InvokeLightSystemProgram, LightCpiInstruction}, + derive_light_cpi_signer, derive_light_cpi_signer_pda, + error::LightSdkError, + instruction::{PackedAccounts, ValidityProof}, + interface::{ + CompressAs as CompressAsTrait, CompressedInitSpace, CompressionInfo, + HasCompressionInfo as HasCompressionInfoTrait, LightConfig, LightFinalize, LightPreInit, + Pack, Space, Unpack, + }, + CpiSigner, LightDiscriminator as LightDiscriminatorTrait, +}; +// Re-export Light SDK macros +pub use light_sdk_macros::{ + // Proc macros + derive_light_rent_sponsor, + derive_light_rent_sponsor_pda, + // Attribute macros + light_program, + // Derive macros + CompressAs, + Compressible, + CompressiblePack, + HasCompressionInfo, + LightAccount, + LightAccounts, + LightDiscriminator, + LightHasher, + LightHasherSha, +}; + +// Re-export token SDK types +pub use crate::{instruction::*, CompressedProof, ValidityProof as ValidityProofAlias}; diff --git a/sdk-libs/token-sdk/src/compressible/decompress_runtime.rs b/sdk-libs/token-sdk/src/compressible/decompress_runtime.rs index 2eee582086..c191e76d18 100644 --- a/sdk-libs/token-sdk/src/compressible/decompress_runtime.rs +++ b/sdk-libs/token-sdk/src/compressible/decompress_runtime.rs @@ -142,14 +142,14 @@ where } }); - crate::token::CreateTokenAccountCpi { + crate::instruction::CreateTokenAccountCpi { payer: fee_payer.clone(), account: (*owner_info).clone(), mint: (*mint_info).clone(), owner: derived_authority_pda, // Use derived authority PDA (like cp-swap's vault_authority) } .invoke_signed_with( - crate::token::CompressibleParamsCpi { + crate::instruction::CompressibleParamsCpi { compressible_config: token_config.clone(), rent_sponsor: token_rent_sponsor.clone(), system_program: cpi_accounts diff --git a/sdk-libs/token-sdk/src/compressible/mod.rs b/sdk-libs/token-sdk/src/compressible/mod.rs index 9e47dd867d..1b22739596 100644 --- a/sdk-libs/token-sdk/src/compressible/mod.rs +++ b/sdk-libs/token-sdk/src/compressible/mod.rs @@ -1,7 +1,5 @@ //! Compressible token utilities for runtime decompression. -#[cfg(feature = "compressible")] mod decompress_runtime; -#[cfg(feature = "compressible")] pub use decompress_runtime::*; diff --git a/sdk-libs/token-sdk/src/token/approve.rs b/sdk-libs/token-sdk/src/instruction/approve.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/approve.rs rename to sdk-libs/token-sdk/src/instruction/approve.rs index 8f3ed9cce1..b1c6a8cff1 100644 --- a/sdk-libs/token-sdk/src/token/approve.rs +++ b/sdk-libs/token-sdk/src/instruction/approve.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Approve a delegate for a Light Token account: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Approve; +/// # use light_token::instruction::Approve; /// # let token_account = Pubkey::new_unique(); /// # let delegate = Pubkey::new_unique(); /// # let owner = Pubkey::new_unique(); @@ -33,7 +33,7 @@ pub struct Approve { /// # Approve Light Token via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::ApproveCpi; +/// # use light_token::instruction::ApproveCpi; /// # use solana_account_info::AccountInfo; /// # let token_account: AccountInfo = todo!(); /// # let delegate: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/approve_checked.rs b/sdk-libs/token-sdk/src/instruction/approve_checked.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/approve_checked.rs rename to sdk-libs/token-sdk/src/instruction/approve_checked.rs index 87c467a41d..4b1939fe3a 100644 --- a/sdk-libs/token-sdk/src/token/approve_checked.rs +++ b/sdk-libs/token-sdk/src/instruction/approve_checked.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Approve a delegate for a Light Token account with decimals validation: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::ApproveChecked; +/// # use light_token::instruction::ApproveChecked; /// # let token_account = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let delegate = Pubkey::new_unique(); @@ -43,7 +43,7 @@ pub struct ApproveChecked { /// # Approve Light Token via CPI with decimals validation: /// ```rust,no_run -/// # use light_token_sdk::token::ApproveCheckedCpi; +/// # use light_token::instruction::ApproveCheckedCpi; /// # use solana_account_info::AccountInfo; /// # let token_account: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/burn.rs b/sdk-libs/token-sdk/src/instruction/burn.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/burn.rs rename to sdk-libs/token-sdk/src/instruction/burn.rs index 4961d6b855..1c99355ad1 100644 --- a/sdk-libs/token-sdk/src/token/burn.rs +++ b/sdk-libs/token-sdk/src/instruction/burn.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Burn tokens from a ctoken account: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Burn; +/// # use light_token::instruction::Burn; /// # let source = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -37,7 +37,7 @@ pub struct Burn { /// # Burn ctoken via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::BurnCpi; +/// # use light_token::instruction::BurnCpi; /// # use solana_account_info::AccountInfo; /// # let source: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/burn_checked.rs b/sdk-libs/token-sdk/src/instruction/burn_checked.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/burn_checked.rs rename to sdk-libs/token-sdk/src/instruction/burn_checked.rs index dce7594250..1c6ca045ba 100644 --- a/sdk-libs/token-sdk/src/token/burn_checked.rs +++ b/sdk-libs/token-sdk/src/instruction/burn_checked.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Burn tokens from a ctoken account with decimals validation: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::BurnChecked; +/// # use light_token::instruction::BurnChecked; /// # let source = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -40,7 +40,7 @@ pub struct BurnChecked { /// # Burn ctoken via CPI with decimals validation: /// ```rust,no_run -/// # use light_token_sdk::token::BurnCheckedCpi; +/// # use light_token::instruction::BurnCheckedCpi; /// # use solana_account_info::AccountInfo; /// # let source: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/close.rs b/sdk-libs/token-sdk/src/instruction/close.rs similarity index 95% rename from sdk-libs/token-sdk/src/token/close.rs rename to sdk-libs/token-sdk/src/instruction/close.rs index d27e157234..347ad307c8 100644 --- a/sdk-libs/token-sdk/src/token/close.rs +++ b/sdk-libs/token-sdk/src/instruction/close.rs @@ -4,12 +4,12 @@ use solana_instruction::{AccountMeta, Instruction}; use solana_program_error::ProgramError; use solana_pubkey::Pubkey; -use crate::token::RENT_SPONSOR; +use crate::instruction::RENT_SPONSOR; /// # Create a close ctoken account instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::{CloseAccount, LIGHT_TOKEN_PROGRAM_ID}; +/// # use light_token::instruction::{CloseAccount, LIGHT_TOKEN_PROGRAM_ID}; /// # let account = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let owner = Pubkey::new_unique(); @@ -63,7 +63,7 @@ impl CloseAccount { /// # Close a ctoken account via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::CloseAccountCpi; +/// # use light_token::instruction::CloseAccountCpi; /// # use solana_account_info::AccountInfo; /// # let token_program: AccountInfo = todo!(); /// # let account: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/compressible.rs b/sdk-libs/token-sdk/src/instruction/compressible.rs similarity index 96% rename from sdk-libs/token-sdk/src/token/compressible.rs rename to sdk-libs/token-sdk/src/instruction/compressible.rs index f168b0dc33..3fffd3b06f 100644 --- a/sdk-libs/token-sdk/src/token/compressible.rs +++ b/sdk-libs/token-sdk/src/instruction/compressible.rs @@ -2,7 +2,7 @@ use light_token_interface::{instructions::extensions::CompressToPubkey, state::T use solana_account_info::AccountInfo; use solana_pubkey::Pubkey; -use crate::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; +use crate::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; /// Parameters for creating compressible ctoken accounts. /// @@ -17,7 +17,7 @@ use crate::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; /// /// # Example /// ```rust -/// use light_token_sdk::token::CompressibleParams; +/// use light_token::instruction::CompressibleParams; /// /// let params = CompressibleParams::new(); /// ``` @@ -79,7 +79,7 @@ impl CompressibleParams { /// /// # Example /// ```rust,no_run -/// # use light_token_sdk::token::CompressibleParamsCpi; +/// # use light_token::instruction::CompressibleParamsCpi; /// # use solana_account_info::AccountInfo; /// // Use ctoken::COMPRESSIBLE_CONFIG_V1 or ctoken::config_pda() to get the protocol config. /// // Use ctoken::RENT_SPONSOR or ctoken::rent_sponsor_pda() to get the protocol rent sponsor. diff --git a/sdk-libs/token-sdk/src/token/create.rs b/sdk-libs/token-sdk/src/instruction/create.rs similarity index 98% rename from sdk-libs/token-sdk/src/token/create.rs rename to sdk-libs/token-sdk/src/instruction/create.rs index 4c08da4ac2..91e240e9b3 100644 --- a/sdk-libs/token-sdk/src/token/create.rs +++ b/sdk-libs/token-sdk/src/instruction/create.rs @@ -9,12 +9,12 @@ use solana_instruction::{AccountMeta, Instruction}; use solana_program_error::ProgramError; use solana_pubkey::Pubkey; -use crate::token::{compressible::CompressibleParamsCpi, CompressibleParams}; +use crate::instruction::{compressible::CompressibleParamsCpi, CompressibleParams}; /// # Create a create ctoken account instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::CreateTokenAccount; +/// # use light_token::instruction::CreateTokenAccount; /// # let payer = Pubkey::new_unique(); /// # let account = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); diff --git a/sdk-libs/token-sdk/src/token/create_associated_token_account.rs b/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/create_associated_token_account.rs rename to sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs index fae7d29a5d..c67954cdc2 100644 --- a/sdk-libs/token-sdk/src/token/create_associated_token_account.rs +++ b/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs @@ -59,7 +59,7 @@ pub fn create_compressible_associated_token_account_idempotent( pub fn create_compressible_associated_token_account_with_mode( inputs: CreateCompressibleAssociatedTokenAccountInputs, ) -> Result { - let (ata_pubkey, bump) = derive_token_ata(&inputs.owner, &inputs.mint); + let (ata_pubkey, bump) = derive_associated_token_account(&inputs.owner, &inputs.mint); create_compressible_associated_token_account_with_bump_and_mode::( inputs, ata_pubkey, bump, ) @@ -122,7 +122,7 @@ pub fn create_associated_token_account_with_mode( owner: Pubkey, mint: Pubkey, ) -> Result { - let (ata_pubkey, bump) = derive_token_ata(&owner, &mint); + let (ata_pubkey, bump) = derive_associated_token_account(&owner, &mint); create_associated_token_account_with_bump_and_mode::( payer, owner, mint, ata_pubkey, bump, ) @@ -227,7 +227,7 @@ fn create_ata_instruction_unified (Pubkey, u8) { +pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { Pubkey::find_program_address( &[ owner.as_ref(), @@ -262,7 +262,7 @@ pub fn create_compressible_associated_token_account2_idempotent( fn create_compressible_associated_token_account2_with_mode( inputs: CreateCompressibleAssociatedTokenAccountInputs, ) -> Result { - let (ata_pubkey, bump) = derive_token_ata(&inputs.owner, &inputs.mint); + let (ata_pubkey, bump) = derive_associated_token_account(&inputs.owner, &inputs.mint); create_compressible_associated_token_account2_with_bump_and_mode::( inputs, ata_pubkey, bump, ) @@ -316,7 +316,7 @@ fn create_associated_token_account2_with_mode( owner: Pubkey, mint: Pubkey, ) -> Result { - let (ata_pubkey, bump) = derive_token_ata(&owner, &mint); + let (ata_pubkey, bump) = derive_associated_token_account(&owner, &mint); create_associated_token_account2_with_bump_and_mode::( payer, owner, mint, ata_pubkey, bump, ) diff --git a/sdk-libs/token-sdk/src/token/create_ata.rs b/sdk-libs/token-sdk/src/instruction/create_ata.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/create_ata.rs rename to sdk-libs/token-sdk/src/instruction/create_ata.rs index f3334e82ee..669b84f526 100644 --- a/sdk-libs/token-sdk/src/token/create_ata.rs +++ b/sdk-libs/token-sdk/src/instruction/create_ata.rs @@ -9,12 +9,12 @@ use solana_instruction::{AccountMeta, Instruction}; use solana_program_error::ProgramError; use solana_pubkey::Pubkey; -use crate::token::{compressible::CompressibleParamsCpi, CompressibleParams}; +use crate::instruction::{compressible::CompressibleParamsCpi, CompressibleParams}; const CREATE_ATA_DISCRIMINATOR: u8 = 100; const CREATE_ATA_IDEMPOTENT_DISCRIMINATOR: u8 = 102; -pub fn derive_token_ata(owner: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { +pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { Pubkey::find_program_address( &[ owner.as_ref(), @@ -28,7 +28,7 @@ pub fn derive_token_ata(owner: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { /// # Create an associated ctoken account instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::CreateAssociatedTokenAccount; +/// # use light_token::instruction::CreateAssociatedTokenAccount; /// # let payer = Pubkey::new_unique(); /// # let owner = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); @@ -50,7 +50,7 @@ pub struct CreateAssociatedTokenAccount { impl CreateAssociatedTokenAccount { pub fn new(payer: Pubkey, owner: Pubkey, mint: Pubkey) -> Self { - let (ata, bump) = derive_token_ata(&owner, &mint); + let (ata, bump) = derive_associated_token_account(&owner, &mint); Self { payer, owner, diff --git a/sdk-libs/token-sdk/src/token/create_mint.rs b/sdk-libs/token-sdk/src/instruction/create_mint.rs similarity index 98% rename from sdk-libs/token-sdk/src/token/create_mint.rs rename to sdk-libs/token-sdk/src/instruction/create_mint.rs index 847de6fb32..6d7ec243ad 100644 --- a/sdk-libs/token-sdk/src/token/create_mint.rs +++ b/sdk-libs/token-sdk/src/instruction/create_mint.rs @@ -15,7 +15,7 @@ use solana_program_error::ProgramError; use solana_pubkey::Pubkey; use super::{config_pda, rent_sponsor_pda}; -use crate::{compressed_token::mint_action::MintActionMetaConfig, token::SystemAccountInfos}; +use crate::{compressed_token::mint_action::MintActionMetaConfig, instruction::SystemAccountInfos}; /// Parameters for creating a mint. /// /// Creates both a compressed mint AND a decompressed Mint Solana account @@ -44,10 +44,10 @@ pub struct CreateMintParams { /// # Example /// ```rust,no_run /// # use solana_pubkey::Pubkey; -/// use light_token_sdk::token::{ +/// use light_token::instruction::{ /// CreateMint, CreateMintParams, derive_mint_compressed_address, find_mint_address, /// }; -/// # use light_token_sdk::CompressedProof; +/// # use light_token::CompressedProof; /// # let mint_seed_pubkey = Pubkey::new_unique(); /// # let payer = Pubkey::new_unique(); /// # let address_tree = Pubkey::new_unique(); @@ -190,7 +190,7 @@ impl CreateMint { /// # Create a mint via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::{CreateMintCpi, CreateMintParams, SystemAccountInfos}; +/// # use light_token::instruction::{CreateMintCpi, CreateMintParams, SystemAccountInfos}; /// # use solana_account_info::AccountInfo; /// # let mint_seed: AccountInfo = todo!(); /// # let authority: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/create_mints.rs b/sdk-libs/token-sdk/src/instruction/create_mints.rs similarity index 99% rename from sdk-libs/token-sdk/src/token/create_mints.rs rename to sdk-libs/token-sdk/src/instruction/create_mints.rs index fcfd1a15f9..896c9a8240 100644 --- a/sdk-libs/token-sdk/src/token/create_mints.rs +++ b/sdk-libs/token-sdk/src/instruction/create_mints.rs @@ -157,7 +157,7 @@ impl<'a> CreateMintsParams<'a> { /// # Example /// /// ```rust,ignore -/// use light_token_sdk::token::{CreateMintsCpi, CreateMintsParams, SingleMintParams, SystemAccountInfos}; +/// use light_token::instruction::{CreateMintsCpi, CreateMintsParams, SingleMintParams, SystemAccountInfos}; /// /// let params = CreateMintsParams::new(vec![mint_params_1, mint_params_2], proof); /// @@ -664,7 +664,7 @@ pub fn create_mints<'a, 'info>( // /// # Example // /// // /// ```rust,ignore -// /// use light_token_sdk::token::{CreateMints, CreateMintsParams, SingleMintParams}; +// /// use light_token::instruction::{CreateMints, CreateMintsParams, SingleMintParams}; // /// // /// let params = CreateMintsParams::new(vec![mint1_params, mint2_params], proof); // /// diff --git a/sdk-libs/token-sdk/src/token/decompress.rs b/sdk-libs/token-sdk/src/instruction/decompress.rs similarity index 96% rename from sdk-libs/token-sdk/src/token/decompress.rs rename to sdk-libs/token-sdk/src/instruction/decompress.rs index d034ee8886..ffbaef17ac 100644 --- a/sdk-libs/token-sdk/src/token/decompress.rs +++ b/sdk-libs/token-sdk/src/instruction/decompress.rs @@ -18,15 +18,15 @@ use crate::{ }, CTokenAccount2, }, - token::derive_token_ata, + instruction::derive_associated_token_account, }; /// # Decompress compressed tokens to a cToken account /// /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Decompress; -/// # use light_token_sdk::compat::TokenData; +/// # use light_token::instruction::Decompress; +/// # use light_token::compat::TokenData; /// # use light_compressed_account::instruction_data::compressed_proof::ValidityProof; /// # let destination = Pubkey::new_unique(); /// # let payer = Pubkey::new_unique(); @@ -106,7 +106,7 @@ impl Decompress { // For ATA decompress, derive the bump from wallet owner + mint // The signer is the wallet owner for ATAs let ata_bump = if is_ata { - let (_, bump) = derive_token_ata(&self.signer, &self.token_data.mint); + let (_, bump) = derive_associated_token_account(&self.signer, &self.token_data.mint); bump } else { 0 diff --git a/sdk-libs/token-sdk/src/token/decompress_mint.rs b/sdk-libs/token-sdk/src/instruction/decompress_mint.rs similarity index 98% rename from sdk-libs/token-sdk/src/token/decompress_mint.rs rename to sdk-libs/token-sdk/src/instruction/decompress_mint.rs index e6e82726c0..da01359043 100644 --- a/sdk-libs/token-sdk/src/token/decompress_mint.rs +++ b/sdk-libs/token-sdk/src/instruction/decompress_mint.rs @@ -12,7 +12,7 @@ use solana_pubkey::Pubkey; use crate::{ compressed_token::mint_action::MintActionMetaConfig, - token::{config_pda, rent_sponsor_pda, SystemAccountInfos}, + instruction::{config_pda, rent_sponsor_pda, SystemAccountInfos}, }; /// Decompress a compressed mint to a Mint Solana account. @@ -271,7 +271,7 @@ pub struct DecompressCMintWithCpiContext { impl DecompressCMintWithCpiContext { pub fn instruction(self) -> Result { // Derive Mint PDA - let (mint_pda, _cmint_bump) = crate::token::find_mint_address(&self.mint_seed_pubkey); + let (mint_pda, _cmint_bump) = crate::instruction::find_mint_address(&self.mint_seed_pubkey); // Build DecompressMintAction let action = DecompressMintAction { diff --git a/sdk-libs/token-sdk/src/token/freeze.rs b/sdk-libs/token-sdk/src/instruction/freeze.rs similarity index 96% rename from sdk-libs/token-sdk/src/token/freeze.rs rename to sdk-libs/token-sdk/src/instruction/freeze.rs index eb729127bb..14e99a5da3 100644 --- a/sdk-libs/token-sdk/src/token/freeze.rs +++ b/sdk-libs/token-sdk/src/instruction/freeze.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Freeze a Light Token account: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Freeze; +/// # use light_token::instruction::Freeze; /// # let token_account = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let freeze_authority = Pubkey::new_unique(); @@ -30,7 +30,7 @@ pub struct Freeze { /// # Freeze Light Token via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::FreezeCpi; +/// # use light_token::instruction::FreezeCpi; /// # use solana_account_info::AccountInfo; /// # let token_account: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/mint_to.rs b/sdk-libs/token-sdk/src/instruction/mint_to.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/mint_to.rs rename to sdk-libs/token-sdk/src/instruction/mint_to.rs index bff3e42c87..4f5c4f02a3 100644 --- a/sdk-libs/token-sdk/src/token/mint_to.rs +++ b/sdk-libs/token-sdk/src/instruction/mint_to.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Mint tokens to a ctoken account (simple 3-account instruction): /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::MintTo; +/// # use light_token::instruction::MintTo; /// # let mint = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -37,7 +37,7 @@ pub struct MintTo { /// # Mint to ctoken via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::MintToCpi; +/// # use light_token::instruction::MintToCpi; /// # use solana_account_info::AccountInfo; /// # let mint: AccountInfo = todo!(); /// # let destination: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/mint_to_checked.rs b/sdk-libs/token-sdk/src/instruction/mint_to_checked.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/mint_to_checked.rs rename to sdk-libs/token-sdk/src/instruction/mint_to_checked.rs index 662ff7185c..71730b3cf6 100644 --- a/sdk-libs/token-sdk/src/token/mint_to_checked.rs +++ b/sdk-libs/token-sdk/src/instruction/mint_to_checked.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Mint tokens to a ctoken account with decimals validation: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::MintToChecked; +/// # use light_token::instruction::MintToChecked; /// # let mint = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -40,7 +40,7 @@ pub struct MintToChecked { /// # Mint to ctoken via CPI with decimals validation: /// ```rust,no_run -/// # use light_token_sdk::token::MintToCheckedCpi; +/// # use light_token::instruction::MintToCheckedCpi; /// # use solana_account_info::AccountInfo; /// # let mint: AccountInfo = todo!(); /// # let destination: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/mod.rs b/sdk-libs/token-sdk/src/instruction/mod.rs similarity index 82% rename from sdk-libs/token-sdk/src/token/mod.rs rename to sdk-libs/token-sdk/src/instruction/mod.rs index 82e3676d88..478e6151bb 100644 --- a/sdk-libs/token-sdk/src/token/mod.rs +++ b/sdk-libs/token-sdk/src/instruction/mod.rs @@ -1,12 +1,12 @@ -//! High-level builders for ctoken operations. +//! High-level builders for Light Token operations. //! //! //! ## Account Creation //! -//! - [`CreateAssociatedCTokenAccount`] - Create associated ctoken account (ATA) instruction -//! - [`CreateTokenAtaCpi`] - Create associated ctoken account (ATA) via CPI -//! - [`CreateCTokenAccount`] - Create ctoken account instruction -//! - [`CreateTokenAccountCpi`] - Create ctoken account via CPI +//! - [`CreateAssociatedTokenAccount`] - Create associated Light Token account (ATA) instruction +//! - [`CreateTokenAtaCpi`] - Create associated Light Token account (ATA) via CPI +//! - [`CreateTokenAccount`] - Create Light Token account instruction +//! - [`CreateTokenAccountCpi`] - Create Light Token account via CPI //! //! ## Transfers //! @@ -14,32 +14,32 @@ //! //! ## Decompress //! -//! - [`Decompress`] - Decompress compressed tokens to a cToken account +//! - [`Decompress`] - Decompress compressed tokens to a Light Token account //! //! ## Close //! -//! - [`CloseTokenAccount`] - Create close ctoken account instruction -//! - [`CloseTokenAccountCpi`] - Close ctoken account via CPI +//! - [`CloseAccount`] - Create close Light Token account instruction +//! - [`CloseAccountCpi`] - Close Light Token account via CPI //! //! //! ## Mint //! -//! - [`CreateMint`] - Create cMint -//! - [`CreateMints`] - Create multiple cMints in a batch -//! - [`MintTo`] - Mint tokens to ctoken accounts +//! - [`CreateMint`] - Create Light Mint +//! - [`create_mints`] - Create multiple Light Mints in a batch +//! - [`MintTo`] - Mint tokens to Light Token accounts //! //! ## Revoke and Thaw //! -//! - [`Revoke`] - Revoke delegation for a ctoken account +//! - [`Revoke`] - Revoke delegation for a Light Token account //! - [`RevokeCpi`] - Revoke delegation via CPI -//! - [`Thaw`] - Thaw a frozen ctoken account -//! - [`ThawCpi`] - Thaw a frozen ctoken account via CPI +//! - [`Thaw`] - Thaw a frozen Light Token account +//! - [`ThawCpi`] - Thaw a frozen Light Token account via CPI //! -//! # Example: Create cToken Account Instruction +//! # Example: Create Light Token Account Instruction //! //! ```rust //! # use solana_pubkey::Pubkey; -//! use light_token_sdk::token::CreateAssociatedTokenAccount; +//! use light_token::instruction::CreateAssociatedTokenAccount; //! # let payer = Pubkey::new_unique(); //! # let owner = Pubkey::new_unique(); //! # let mint = Pubkey::new_unique(); @@ -53,7 +53,7 @@ //! # Example: Create rent-free ATA via CPI //! //! ```rust,ignore -//! use light_token_sdk::token::CreateTokenAtaCpi; +//! use light_token::instruction::CreateTokenAtaCpi; //! //! CreateTokenAtaCpi { //! payer: ctx.accounts.payer.to_account_info(), @@ -64,7 +64,7 @@ //! } //! .idempotent() //! .rent_free( -//! ctx.accounts.ctoken_config.to_account_info(), +//! ctx.accounts.light_token_config.to_account_info(), //! ctx.accounts.rent_sponsor.to_account_info(), //! ctx.accounts.system_program.to_account_info(), //! ) @@ -74,7 +74,7 @@ //! # Example: Create rent-free vault via CPI (with PDA signing) //! //! ```rust,ignore -//! use light_token_sdk::token::CreateTokenAccountCpi; +//! use light_token::instruction::CreateTokenAccountCpi; //! //! CreateTokenAccountCpi { //! payer: ctx.accounts.payer.to_account_info(), @@ -83,7 +83,7 @@ //! owner: ctx.accounts.vault_authority.key(), //! } //! .rent_free( -//! ctx.accounts.ctoken_config.to_account_info(), +//! ctx.accounts.light_token_config.to_account_info(), //! ctx.accounts.rent_sponsor.to_account_info(), //! ctx.accounts.system_program.to_account_info(), //! &crate::ID, @@ -123,8 +123,9 @@ pub use close::{CloseAccount, CloseAccountCpi}; pub use compressible::{CompressibleParams, CompressibleParamsCpi}; pub use create::*; pub use create_ata::{ - derive_token_ata, CreateAssociatedTokenAccount, - CreateTokenAtaCpi as CreateAssociatedAccountCpi, CreateTokenAtaCpi, + derive_associated_token_account, derive_associated_token_account as derive_token_ata, + CreateAssociatedTokenAccount, CreateTokenAtaCpi as CreateAssociatedAccountCpi, + CreateTokenAtaCpi, }; pub use create_mint::*; pub use create_mints::*; @@ -179,7 +180,7 @@ pub struct SystemAccountInfos<'info> { /// System accounts with Pubkey references for instruction building. /// /// ```rust -/// # use light_token_sdk::token::SystemAccounts; +/// # use light_token::instruction::SystemAccounts; /// # use solana_instruction::AccountMeta; /// let system_accounts = SystemAccounts::default(); /// let accounts = vec![ diff --git a/sdk-libs/token-sdk/src/token/revoke.rs b/sdk-libs/token-sdk/src/instruction/revoke.rs similarity index 96% rename from sdk-libs/token-sdk/src/token/revoke.rs rename to sdk-libs/token-sdk/src/instruction/revoke.rs index 16e5c12f1a..d746dbe850 100644 --- a/sdk-libs/token-sdk/src/token/revoke.rs +++ b/sdk-libs/token-sdk/src/instruction/revoke.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Revoke delegation for a Light Token account: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Revoke; +/// # use light_token::instruction::Revoke; /// # let token_account = Pubkey::new_unique(); /// # let owner = Pubkey::new_unique(); /// let instruction = Revoke { @@ -26,7 +26,7 @@ pub struct Revoke { /// # Revoke Light Token via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::RevokeCpi; +/// # use light_token::instruction::RevokeCpi; /// # use solana_account_info::AccountInfo; /// # let token_account: AccountInfo = todo!(); /// # let owner: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/thaw.rs b/sdk-libs/token-sdk/src/instruction/thaw.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/thaw.rs rename to sdk-libs/token-sdk/src/instruction/thaw.rs index b0b4f5e974..eb859e73a2 100644 --- a/sdk-libs/token-sdk/src/token/thaw.rs +++ b/sdk-libs/token-sdk/src/instruction/thaw.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Thaw a frozen Light Token account: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Thaw; +/// # use light_token::instruction::Thaw; /// # let token_account = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let freeze_authority = Pubkey::new_unique(); @@ -30,7 +30,7 @@ pub struct Thaw { /// # Thaw Light Token via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::ThawCpi; +/// # use light_token::instruction::ThawCpi; /// # use solana_account_info::AccountInfo; /// # let token_account: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/transfer.rs b/sdk-libs/token-sdk/src/instruction/transfer.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/transfer.rs rename to sdk-libs/token-sdk/src/instruction/transfer.rs index d8af38c88d..551c1ea3e7 100644 --- a/sdk-libs/token-sdk/src/token/transfer.rs +++ b/sdk-libs/token-sdk/src/instruction/transfer.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Create a transfer ctoken instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::Transfer; +/// # use light_token::instruction::Transfer; /// # let source = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -33,7 +33,7 @@ pub struct Transfer { /// # Transfer ctoken via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::TransferCpi; +/// # use light_token::instruction::TransferCpi; /// # use solana_account_info::AccountInfo; /// # let source: AccountInfo = todo!(); /// # let destination: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/transfer_checked.rs b/sdk-libs/token-sdk/src/instruction/transfer_checked.rs similarity index 97% rename from sdk-libs/token-sdk/src/token/transfer_checked.rs rename to sdk-libs/token-sdk/src/instruction/transfer_checked.rs index ffcd6d52d9..e2916046de 100644 --- a/sdk-libs/token-sdk/src/token/transfer_checked.rs +++ b/sdk-libs/token-sdk/src/instruction/transfer_checked.rs @@ -8,7 +8,7 @@ use solana_pubkey::Pubkey; /// # Create a transfer ctoken checked instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::TransferChecked; +/// # use light_token::instruction::TransferChecked; /// # let source = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); @@ -38,7 +38,7 @@ pub struct TransferChecked { /// # Transfer ctoken checked via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::TransferCheckedCpi; +/// # use light_token::instruction::TransferCheckedCpi; /// # use solana_account_info::AccountInfo; /// # let source: AccountInfo = todo!(); /// # let mint: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/transfer_from_spl.rs b/sdk-libs/token-sdk/src/instruction/transfer_from_spl.rs similarity index 98% rename from sdk-libs/token-sdk/src/token/transfer_from_spl.rs rename to sdk-libs/token-sdk/src/instruction/transfer_from_spl.rs index fe8454283b..3391a28619 100644 --- a/sdk-libs/token-sdk/src/token/transfer_from_spl.rs +++ b/sdk-libs/token-sdk/src/instruction/transfer_from_spl.rs @@ -16,7 +16,7 @@ use crate::compressed_token::{ /// # Create a transfer SPL to cToken instruction /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::TransferFromSpl; +/// # use light_token::instruction::TransferFromSpl; /// # let source_spl_token_account = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -54,7 +54,7 @@ pub struct TransferFromSpl { /// # Transfer SPL to ctoken via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::TransferFromSplCpi; +/// # use light_token::instruction::TransferFromSplCpi; /// # use solana_account_info::AccountInfo; /// # let source_spl_token_account: AccountInfo = todo!(); /// # let destination: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/transfer_interface.rs b/sdk-libs/token-sdk/src/instruction/transfer_interface.rs similarity index 99% rename from sdk-libs/token-sdk/src/token/transfer_interface.rs rename to sdk-libs/token-sdk/src/instruction/transfer_interface.rs index 8d5a5ddfbb..88eec28d56 100644 --- a/sdk-libs/token-sdk/src/token/transfer_interface.rs +++ b/sdk-libs/token-sdk/src/instruction/transfer_interface.rs @@ -89,7 +89,7 @@ pub struct SplInterfaceCpi<'info> { /// # Create a transfer interface instruction that auto-routes based on account types: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::{TransferInterface, SplInterface, LIGHT_TOKEN_PROGRAM_ID}; +/// # use light_token::instruction::{TransferInterface, SplInterface, LIGHT_TOKEN_PROGRAM_ID}; /// # let source = Pubkey::new_unique(); /// # let destination = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -221,7 +221,7 @@ impl<'info> From<&TransferInterfaceCpi<'info>> for TransferInterface { /// # Transfer interface via CPI (auto-detects account types): /// ```rust,no_run -/// # use light_token_sdk::token::{TransferInterfaceCpi, SplInterfaceCpi}; +/// # use light_token::instruction::{TransferInterfaceCpi, SplInterfaceCpi}; /// # use solana_account_info::AccountInfo; /// # let source_account: AccountInfo = todo!(); /// # let destination_account: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/token/transfer_to_spl.rs b/sdk-libs/token-sdk/src/instruction/transfer_to_spl.rs similarity index 98% rename from sdk-libs/token-sdk/src/token/transfer_to_spl.rs rename to sdk-libs/token-sdk/src/instruction/transfer_to_spl.rs index b9c0465052..961bb9c558 100644 --- a/sdk-libs/token-sdk/src/token/transfer_to_spl.rs +++ b/sdk-libs/token-sdk/src/instruction/transfer_to_spl.rs @@ -17,7 +17,7 @@ use crate::compressed_token::{ /// # Create a transfer ctoken to SPL instruction: /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::token::TransferToSpl; +/// # use light_token::instruction::TransferToSpl; /// # let source = Pubkey::new_unique(); /// # let destination_spl_token_account = Pubkey::new_unique(); /// # let authority = Pubkey::new_unique(); @@ -54,7 +54,7 @@ pub struct TransferToSpl { /// # Transfer ctoken to SPL via CPI: /// ```rust,no_run -/// # use light_token_sdk::token::TransferToSplCpi; +/// # use light_token::instruction::TransferToSplCpi; /// # use solana_account_info::AccountInfo; /// # let source: AccountInfo = todo!(); /// # let destination_spl_token_account: AccountInfo = todo!(); diff --git a/sdk-libs/token-sdk/src/lib.rs b/sdk-libs/token-sdk/src/lib.rs index 4f36bb77c6..dd21335bca 100644 --- a/sdk-libs/token-sdk/src/lib.rs +++ b/sdk-libs/token-sdk/src/lib.rs @@ -1,34 +1,34 @@ -//! # cToken SDK +//! # Light Token SDK //! -//! The base library to use cToken Accounts, cMints, and compressed token accounts. +//! The base library to use Light Token Accounts, Light Mints, and compressed token accounts. //! -//! ## cToken Accounts +//! ## Light Token Accounts //! - are on Solana devnet. //! - are Solana accounts. -//! - can hold cMint and spl Mint tokens. +//! - can hold Light Mint and SPL Mint tokens. //! - cost 17,288 lamports to create with 24 hours rent. -//! - are compressible: +//! - are rentfree: //! - rent exemption is sponsored by the protocol. //! - rent is 388 lamports per rent epoch (1.5 hours). //! - once the account's lamports balance is insufficient, it is compressed to a compressed token account. -//! - compressed tokens can be decompressed to a cToken account. -//! - configurable lamports per write (eg transfer) keep the cToken account perpetually funded when used. So you don't have to worry about funding rent. +//! - compressed tokens can be decompressed to a Light Token account. +//! - configurable lamports per write (eg transfer) keep the Light Token account perpetually funded when used. So you don't have to worry about funding rent. //! //! ## Compressed Token Accounts //! - are on Solana mainnet. //! - are compressed accounts. -//! - can hold cMint and spl Mint tokens. +//! - can hold Light Mint and SPL Mint tokens. //! - cost 5,000 lamports to create. //! - are well suited for airdrops and reward distribution. //! -//! ## cMints: +//! ## Light Mints //! - are on Solana devnet. //! - are Compressed accounts. //! - cost 15,000 lamports to create. //! - support `TokenMetadata`. //! //! -//! For full program examples, see the [Program Examples](https://github.com/Lightprotocol/program-examples). +//! For full program examples, see the [Light Token Examples](https://github.com/Lightprotocol/examples-light-token). //! For detailed documentation, visit [zkcompression.com](https://www.zkcompression.com/). //! For rust client development see [`light-client`](https://docs.rs/light-client). //! For rust program testing see [`light-program-test`](https://docs.rs/light-program-test). @@ -45,24 +45,23 @@ //! //! | Operation | Instruction Builder | CPI Builder | //! |-----------|----------------|-------------| -//! | Create Associated Token Account | [`CreateAssociatedTokenAccount`](token::CreateAssociatedTokenAccount) | [`CreateAssociatedAccountCpi`](token::CreateAssociatedAccountCpi) | -//! | Create Token Account | [`CreateTokenAccount`](token::CreateTokenAccount) | [`CreateTokenAccountCpi`](token::CreateTokenAccountCpi) | -//! | Transfer | [`Transfer`](token::Transfer) | [`TransferCpi`](token::TransferCpi) | -//! | Transfer to SPL | [`TransferToSpl`](token::TransferToSpl) | [`TransferToSplCpi`](token::TransferToSplCpi) | -//! | Transfer from SPL | [`TransferFromSpl`](token::TransferFromSpl) | [`TransferFromSplCpi`](token::TransferFromSplCpi) | -//! | Transfer (auto-detect) | - | [`TransferInterfaceCpi`](token::TransferInterfaceCpi) | -//! | Decompress to Token account | [`Decompress`](token::Decompress) | - | -//! | Close Token account | [`CloseAccount`](token::CloseAccount) | [`CloseAccountCpi`](token::CloseAccountCpi) | -//! | Create Mint | [`CreateMint`](token::CreateMint) | [`CreateMintCpi`](token::CreateMintCpi) | -//! | MintTo | [`MintTo`](token::MintTo) | [`MintToCpi`](token::MintToCpi) | +//! | Create Associated Token Account | [`CreateAssociatedTokenAccount`](instruction::CreateAssociatedTokenAccount) | [`CreateAssociatedAccountCpi`](instruction::CreateAssociatedAccountCpi) | +//! | Create Token Account | [`CreateTokenAccount`](instruction::CreateTokenAccount) | [`CreateTokenAccountCpi`](instruction::CreateTokenAccountCpi) | +//! | Transfer | [`Transfer`](instruction::Transfer) | [`TransferCpi`](instruction::TransferCpi) | +//! | Transfer Interface (auto-detect) | [`TransferInterface`](instruction::TransferInterface) | [`TransferInterfaceCpi`](instruction::TransferInterfaceCpi) | +//! | Close Token account | [`CloseAccount`](instruction::CloseAccount) | [`CloseAccountCpi`](instruction::CloseAccountCpi) | +//! | Create Mint | [`CreateMint`](instruction::CreateMint) | [`CreateMintCpi`](instruction::CreateMintCpi) | +//! | MintTo | [`MintTo`](instruction::MintTo) | [`MintToCpi`](instruction::MintToCpi) | //! //! //! # Disclaimer //! This library is not audited and in a beta state. Use at your own risk and expect breaking changes. +#[cfg(feature = "anchor")] +pub mod anchor; pub mod compressed_token; pub mod compressible; -pub mod token; +pub mod instruction; pub mod constants; pub mod error; diff --git a/sdk-libs/token-sdk/src/pack.rs b/sdk-libs/token-sdk/src/pack.rs index 6ac07a55b0..4577ddaf4b 100644 --- a/sdk-libs/token-sdk/src/pack.rs +++ b/sdk-libs/token-sdk/src/pack.rs @@ -67,7 +67,7 @@ pub mod compat { /// TokenData using standard Solana pubkeys. /// - /// For zero-copy operations, use [`TokenData`](crate::types::TokenData) from the crate root. + /// For zero-copy operations, use `TokenData` from `light_token_interface`. #[derive(Debug, PartialEq, Eq, AnchorDeserialize, AnchorSerialize, Clone, Default)] pub struct TokenData { /// The mint associated with this account @@ -86,7 +86,7 @@ pub mod compat { impl TokenData { /// TokenDataVersion 3 - /// CompressedAccount Discriminator [0,0,0,0,0,0,0,4] + /// CompressedAccount Discriminator `[0,0,0,0,0,0,0,4]` #[inline(always)] pub fn hash_sha_flat(&self) -> Result<[u8; 32], HasherError> { use light_sdk::light_hasher::Hasher; diff --git a/sdk-libs/token-sdk/src/spl_interface.rs b/sdk-libs/token-sdk/src/spl_interface.rs index f3b7c958c6..3f50eb671c 100644 --- a/sdk-libs/token-sdk/src/spl_interface.rs +++ b/sdk-libs/token-sdk/src/spl_interface.rs @@ -40,8 +40,8 @@ pub fn derive_spl_interface_pda(mint: &Pubkey, index: u8, restricted: bool) -> S /// /// ```rust /// # use solana_pubkey::Pubkey; -/// # use light_token_sdk::spl_interface::CreateSplInterfacePda; -/// # use light_token_sdk::constants::SPL_TOKEN_PROGRAM_ID; +/// # use light_token::spl_interface::CreateSplInterfacePda; +/// # use light_token::constants::SPL_TOKEN_PROGRAM_ID; /// # let fee_payer = Pubkey::new_unique(); /// # let mint = Pubkey::new_unique(); /// # let token_program = SPL_TOKEN_PROGRAM_ID; diff --git a/sdk-libs/token-sdk/tests/account_metas_test.rs b/sdk-libs/token-sdk/tests/account_metas_test.rs index dd1c96f05b..c01ce91e76 100644 --- a/sdk-libs/token-sdk/tests/account_metas_test.rs +++ b/sdk-libs/token-sdk/tests/account_metas_test.rs @@ -1,7 +1,7 @@ #![cfg(feature = "v1")] use anchor_lang::ToAccountMetas; use light_sdk::constants::REGISTERED_PROGRAM_PDA; -use light_token_sdk::{ +use light_token::{ compressed_token::{ batch_compress::{get_batch_compress_instruction_account_metas, BatchCompressMetaConfig}, transfer::account_metas::{ diff --git a/sdk-libs/token-sdk/tests/create_associated_token_account.rs b/sdk-libs/token-sdk/tests/create_associated_token_account.rs index 73d40c5712..356f19edd7 100644 --- a/sdk-libs/token-sdk/tests/create_associated_token_account.rs +++ b/sdk-libs/token-sdk/tests/create_associated_token_account.rs @@ -1,4 +1,4 @@ -use light_token_sdk::token::{derive_token_ata, CreateAssociatedTokenAccount}; +use light_token::instruction::{derive_token_ata, CreateAssociatedTokenAccount}; use solana_pubkey::Pubkey; const CREATE_ATA_DISCRIMINATOR: u8 = 100; diff --git a/sdk-libs/token-sdk/tests/mint_action_cpi_accounts_tests.rs b/sdk-libs/token-sdk/tests/mint_action_cpi_accounts_tests.rs index ab1a5ee014..655ba86c3e 100644 --- a/sdk-libs/token-sdk/tests/mint_action_cpi_accounts_tests.rs +++ b/sdk-libs/token-sdk/tests/mint_action_cpi_accounts_tests.rs @@ -5,10 +5,10 @@ use light_sdk_types::{ ACCOUNT_COMPRESSION_AUTHORITY_PDA, ACCOUNT_COMPRESSION_PROGRAM_ID, LIGHT_SYSTEM_PROGRAM_ID, REGISTERED_PROGRAM_PDA, }; -use light_token_interface::LIGHT_TOKEN_PROGRAM_ID; -use light_token_sdk::compressed_token::mint_action::{ +use light_token::compressed_token::mint_action::{ cpi_accounts::MintActionCpiAccountsConfig, MintActionCpiAccounts, }; +use light_token_interface::LIGHT_TOKEN_PROGRAM_ID; use light_token_types::CPI_AUTHORITY_PDA; use pinocchio::account_info::AccountInfo; diff --git a/sdk-libs/token-sdk/tests/pack_test.rs b/sdk-libs/token-sdk/tests/pack_test.rs index 7bf8fb8d30..b2e98e58a5 100644 --- a/sdk-libs/token-sdk/tests/pack_test.rs +++ b/sdk-libs/token-sdk/tests/pack_test.rs @@ -1,7 +1,7 @@ #![cfg(feature = "compressible")] use light_sdk::instruction::PackedAccounts; -use light_token_sdk::{ +use light_token::{ compat::{PackedCompressibleTokenDataWithVariant, TokenData, TokenDataWithVariant}, pack::Pack, }; diff --git a/sdk-libs/token-types/Cargo.toml b/sdk-libs/token-types/Cargo.toml index e29b9fcccb..b1faf18196 100644 --- a/sdk-libs/token-types/Cargo.toml +++ b/sdk-libs/token-types/Cargo.toml @@ -12,6 +12,7 @@ anchor = [ "light-compressed-account/anchor", "light-sdk-types/anchor", ] +idl-build = ["anchor-lang/idl-build", "anchor", "light-sdk-types/idl-build"] [dependencies] borsh = { workspace = true } diff --git a/sdk-tests/CLAUDE.md b/sdk-tests/CLAUDE.md index e55e188874..075afd5aa4 100644 --- a/sdk-tests/CLAUDE.md +++ b/sdk-tests/CLAUDE.md @@ -94,7 +94,7 @@ cargo test -p light-program-test cargo test -p light-client cargo test -p light-sparse-merkle-tree cargo test -p light-token-types -cargo test -p light-token-sdk +cargo test -p light-token ``` ## Test Categories diff --git a/sdk-tests/client-test/Cargo.toml b/sdk-tests/client-test/Cargo.toml index 0709251ea2..aa16fa3b30 100644 --- a/sdk-tests/client-test/Cargo.toml +++ b/sdk-tests/client-test/Cargo.toml @@ -26,7 +26,7 @@ light-zero-copy = { workspace = true } light-hasher = { workspace = true, features = ["poseidon"] } light-compressed-account = { workspace = true, features = ["std"] } light-compressed-token = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-indexed-array = { workspace = true } light-merkle-tree-reference = { workspace = true } light-macros = { workspace = true } diff --git a/sdk-tests/client-test/tests/light_client.rs b/sdk-tests/client-test/tests/light_client.rs index 57d089f832..8d3b0e9c63 100644 --- a/sdk-tests/client-test/tests/light_client.rs +++ b/sdk-tests/client-test/tests/light_client.rs @@ -16,7 +16,7 @@ use light_merkle_tree_reference::{indexed::IndexedMerkleTree, MerkleTree}; use light_program_test::accounts::test_accounts::TestAccounts; use light_sdk::address::{v1::derive_address, NewAddressParams}; use light_test_utils::{system_program::create_invoke_instruction, Rpc, RpcError}; -use light_token_sdk::compat::{AccountState, TokenData}; +use light_token::compat::{AccountState, TokenData}; use solana_compute_budget_interface::ComputeBudgetInstruction; use solana_keypair::Keypair; use solana_pubkey::Pubkey; diff --git a/sdk-tests/client-test/tests/light_program_test.rs b/sdk-tests/client-test/tests/light_program_test.rs index 7cf11155f2..3bc531baf0 100644 --- a/sdk-tests/client-test/tests/light_program_test.rs +++ b/sdk-tests/client-test/tests/light_program_test.rs @@ -14,7 +14,7 @@ use light_program_test::{ }; use light_sdk::address::{v1::derive_address, NewAddressParams}; use light_test_utils::{system_program::create_invoke_instruction, RpcError}; -use light_token_sdk::compat::{AccountState, TokenData}; +use light_token::compat::{AccountState, TokenData}; use solana_sdk::{ compute_budget::ComputeBudgetInstruction, pubkey::Pubkey, diff --git a/sdk-tests/csdk-anchor-full-derived-test-sdk/Cargo.toml b/sdk-tests/csdk-anchor-full-derived-test-sdk/Cargo.toml index 39bd3bd005..1a48fbd251 100644 --- a/sdk-tests/csdk-anchor-full-derived-test-sdk/Cargo.toml +++ b/sdk-tests/csdk-anchor-full-derived-test-sdk/Cargo.toml @@ -11,7 +11,7 @@ csdk-anchor-full-derived-test = { path = "../csdk-anchor-full-derived-test", fea # SDK trait and types light-client = { workspace = true, features = ["v2", "anchor"] } light-sdk = { workspace = true, features = ["anchor", "v2"] } -light-token-sdk = { workspace = true, features = ["anchor"] } +light-token = { workspace = true, features = ["anchor"] } anchor-lang = { workspace = true } solana-pubkey = { workspace = true } diff --git a/sdk-tests/csdk-anchor-full-derived-test-sdk/src/lib.rs b/sdk-tests/csdk-anchor-full-derived-test-sdk/src/lib.rs index 1467d85dc5..f7687db7b7 100644 --- a/sdk-tests/csdk-anchor-full-derived-test-sdk/src/lib.rs +++ b/sdk-tests/csdk-anchor-full-derived-test-sdk/src/lib.rs @@ -187,7 +187,7 @@ impl AmmSdk { account: &AccountInterface, is_vault_0: bool, ) -> Result<(), AmmSdkError> { - use light_token_sdk::compat::TokenData; + use light_token::compat::TokenData; let pool_state = self .pool_state_pubkey @@ -200,7 +200,7 @@ impl AmmSdk { let token_0_mint = self .token_0_mint .ok_or(AmmSdkError::MissingField("token_0_mint"))?; - LightAccountVariant::CTokenData(light_token_sdk::compat::CTokenData { + LightAccountVariant::CTokenData(light_token::compat::CTokenData { variant: TokenAccountVariant::Token0Vault { pool_state, token_0_mint, @@ -211,7 +211,7 @@ impl AmmSdk { let token_1_mint = self .token_1_mint .ok_or(AmmSdkError::MissingField("token_1_mint"))?; - LightAccountVariant::CTokenData(light_token_sdk::compat::CTokenData { + LightAccountVariant::CTokenData(light_token::compat::CTokenData { variant: TokenAccountVariant::Token1Vault { pool_state, token_1_mint, @@ -279,7 +279,7 @@ impl AmmSdk { pub fn derive_lp_mint_compressed_address(&self, address_tree: &Pubkey) -> Option<[u8; 32]> { self.lp_mint_signer.map(|signer| { - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &signer, address_tree, ) diff --git a/sdk-tests/csdk-anchor-full-derived-test/Cargo.toml b/sdk-tests/csdk-anchor-full-derived-test/Cargo.toml index 44484c6954..86c328e24b 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/Cargo.toml +++ b/sdk-tests/csdk-anchor-full-derived-test/Cargo.toml @@ -33,16 +33,16 @@ light-sdk-macros = { workspace = true } borsh = { workspace = true } light-compressed-account = { workspace = true, features = ["solana"] } anchor-lang = { workspace = true, features = ["idl-build"] } -anchor-spl = { version = "=0.31.1", git = "https://github.com/lightprotocol/anchor", rev = "da005d7f", features = ["memo", "metadata", "idl-build"] } +light-anchor-spl = { workspace = true, features = ["metadata", "idl-build"] } light-token-interface = { workspace = true, features = ["anchor"] } -light-token-sdk = { workspace = true, features = ["anchor", "compressible"] } +light-token = { workspace = true, features = ["anchor"] } light-token-types = { workspace = true, features = ["anchor"] } light-compressible = { workspace = true, features = ["anchor"] } [dev-dependencies] csdk-anchor-full-derived-test-sdk = { path = "../csdk-anchor-full-derived-test-sdk" } light-token-client = { workspace = true } -light-program-test = { workspace = true, features = ["devenv", "v2"] } +light-program-test = { workspace = true, features = ["devenv"] } light-client = { workspace = true, features = ["v2", "anchor"] } light-test-utils = { workspace = true } tokio = { workspace = true } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/deposit.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/deposit.rs index 6d5f733314..c2b7b4b420 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/deposit.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/deposit.rs @@ -1,8 +1,8 @@ //! Deposit instruction with MintToCpi. use anchor_lang::prelude::*; -use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; -use light_token_sdk::token::MintToCpi; +use light_anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; +use light_token::instruction::MintToCpi; use super::states::*; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs index 1d0170f104..45ee1bef45 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs @@ -9,10 +9,10 @@ //! - MintToCpi use anchor_lang::prelude::*; -use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; +use light_anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{ +use light_token::instruction::{ CreateTokenAccountCpi, CreateTokenAtaCpi, MintToCpi, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/swap.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/swap.rs index ff7b13ce50..62ea324539 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/swap.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/swap.rs @@ -9,7 +9,7 @@ //! - output_vault.key() == pool_state.token_0_vault || output_vault.key() == pool_state.token_1_vault use anchor_lang::prelude::*; -use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; +use light_anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; use super::states::*; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/withdraw.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/withdraw.rs index 0ca248350f..72f7ff4e2f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/withdraw.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/withdraw.rs @@ -1,8 +1,8 @@ //! Withdraw instruction with BurnCpi. use anchor_lang::prelude::*; -use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; -use light_token_sdk::token::BurnCpi; +use light_anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; +use light_token::instruction::BurnCpi; use super::states::*; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs index 5d40e8da88..87d73b9290 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs @@ -299,7 +299,7 @@ pub struct CreateMintWithMetadataParams { pub name: Vec, pub symbol: Vec, pub uri: Vec, - pub additional_metadata: Option>, + pub additional_metadata: Option>, } /// Test instruction with #[light_account(init)] with metadata fields. diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs index 3356240161..5cc8171ce6 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs @@ -10,7 +10,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; #[derive(AnchorSerialize, AnchorDeserialize, Clone)] pub struct D10SingleAtaParams { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_vault.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_vault.rs index dce017f0cd..68a30313f2 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_vault.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_vault.rs @@ -9,7 +9,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; /// Seed for the vault authority PDA pub const D10_SINGLE_VAULT_AUTH_SEED: &[u8] = b"d10_single_vault_auth"; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs index 2655c33abc..79c0e4c27b 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs @@ -6,7 +6,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs index 04cf0180ef..75cad9494d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs @@ -6,7 +6,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; pub const D5_VAULT_AUTH_SEED: &[u8] = b"d5_vault_auth"; pub const D5_VAULT_SEED: &[u8] = b"d5_vault"; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs index 201349126f..ebb5e296d6 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs @@ -5,7 +5,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs index d88283732d..79903b0216 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs @@ -5,7 +5,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; use light_sdk_macros::LightAccounts; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; pub const D7_LIGHT_TOKEN_AUTH_SEED: &[u8] = b"d7_light_token_auth"; pub const D7_LIGHT_TOKEN_VAULT_SEED: &[u8] = b"d7_light_token_vault"; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs index d31a32fbb4..f20cd7120d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs @@ -276,7 +276,7 @@ pub mod csdk_anchor_full_derived_test { ctx: Context<'_, '_, '_, 'info, CreatePdasAndMintAuto<'info>>, params: FullAutoWithMintParams, ) -> Result<()> { - use light_token_sdk::token::{ + use light_token::instruction::{ CreateTokenAccountCpi, CreateTokenAtaCpi, MintToCpi as CTokenMintToCpi, }; @@ -578,7 +578,7 @@ pub mod csdk_anchor_full_derived_test { ctx: Context<'_, '_, '_, 'info, D7LightTokenConfig<'info>>, _params: D7LightTokenConfigParams, ) -> Result<()> { - use light_token_sdk::token::CreateTokenAccountCpi; + use light_token::instruction::CreateTokenAccountCpi; let mint_key = ctx.accounts.mint.key(); // Derive the vault bump at runtime @@ -617,7 +617,7 @@ pub mod csdk_anchor_full_derived_test { ctx: Context<'_, '_, '_, 'info, D7AllNames<'info>>, params: D7AllNamesParams, ) -> Result<()> { - use light_token_sdk::token::CreateTokenAccountCpi; + use light_token::instruction::CreateTokenAccountCpi; // Set up the PDA record ctx.accounts.d7_all_record.owner = params.owner; @@ -1318,7 +1318,7 @@ pub mod csdk_anchor_full_derived_test { ctx: Context<'_, '_, '_, 'info, D5LightToken<'info>>, params: D5LightTokenParams, ) -> Result<()> { - use light_token_sdk::token::CreateTokenAccountCpi; + use light_token::instruction::CreateTokenAccountCpi; let mint_key = ctx.accounts.mint.key(); CreateTokenAccountCpi { @@ -1348,7 +1348,7 @@ pub mod csdk_anchor_full_derived_test { ctx: Context<'_, '_, '_, 'info, D5AllMarkers<'info>>, params: D5AllMarkersParams, ) -> Result<()> { - use light_token_sdk::token::CreateTokenAccountCpi; + use light_token::instruction::CreateTokenAccountCpi; // Set up the PDA record ctx.accounts.d5_all_record.owner = params.owner; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs index 7e0e438bb4..e38cf7de3c 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs @@ -5,8 +5,8 @@ use light_sdk::{ compressible::CompressionInfo, instruction::PackedAddressTreeInfo, LightDiscriminator, }; use light_sdk_macros::LightAccount; +use light_token::ValidityProof; use light_token_interface::instructions::mint_action::MintWithContext; -use light_token_sdk::ValidityProof; // Test modules pub mod d1_field_types; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs index 4f93839670..2b30510766 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs @@ -26,11 +26,11 @@ use light_program_test::{ program_test::{setup_mock_program_data, LightProgramTest, TestRpc}, Indexer, ProgramTestConfig, Rpc, }; -use light_token_interface::state::Token; -use light_token_sdk::token::{ +use light_token::instruction::{ find_mint_address, get_associated_token_address_and_bump, COMPRESSIBLE_CONFIG_V1, LIGHT_TOKEN_CPI_AUTHORITY, LIGHT_TOKEN_PROGRAM_ID, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR, }; +use light_token_interface::state::Token; use solana_instruction::Instruction; use solana_keypair::Keypair; use solana_pubkey::Pubkey; @@ -524,7 +524,7 @@ async fn test_amm_full_lifecycle() { &ctx.program_id.to_bytes(), ); let mint_compressed_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &pdas.lp_mint_signer, &address_tree_pubkey, ); diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs index 75e3914316..c5a9926726 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs @@ -9,7 +9,7 @@ use light_program_test::{ Indexer, ProgramTestConfig, Rpc, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; -use light_token_sdk::token::find_mint_address as find_cmint_address; +use light_token::instruction::find_mint_address as find_cmint_address; use solana_instruction::Instruction; use solana_keypair::Keypair; use solana_pubkey::Pubkey; @@ -24,10 +24,10 @@ async fn test_create_pdas_and_mint_auto() { instruction_accounts::{LP_MINT_SIGNER_SEED, VAULT_SEED}, FullAutoWithMintParams, GameSession, }; - use light_token_interface::state::Token; - use light_token_sdk::token::{ + use light_token::instruction::{ get_associated_token_address_and_bump, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; + use light_token_interface::state::Token; // Helpers async fn assert_onchain_exists(rpc: &mut LightProgramTest, pda: &Pubkey) { @@ -158,7 +158,7 @@ async fn test_create_pdas_and_mint_auto() { &program_id.to_bytes(), ); let mint_compressed_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &mint_signer_pda, &address_tree_pubkey, ); @@ -308,7 +308,7 @@ async fn test_create_pdas_and_mint_auto() { use light_client::interface::{ create_load_instructions, AccountInterface, AccountSpec, ColdContext, PdaSpec, }; - use light_token_sdk::compat::{CTokenData, TokenData}; + use light_token::compat::{CTokenData, TokenData}; // Fetch unified interfaces (hot/cold transparent) let user_interface = rpc @@ -399,7 +399,7 @@ async fn test_create_pdas_and_mint_auto() { account: solana_account::Account { lamports: 0, data: vec![], - owner: light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID, + owner: light_token::instruction::LIGHT_TOKEN_PROGRAM_ID, executable: false, rent_epoch: 0, }, @@ -510,7 +510,7 @@ async fn test_create_two_mints() { use csdk_anchor_full_derived_test::instruction_accounts::{ CreateTwoMintsParams, MINT_SIGNER_A_SEED, MINT_SIGNER_B_SEED, }; - use light_token_sdk::token::{ + use light_token::instruction::{ find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; @@ -653,7 +653,7 @@ async fn test_create_two_mints() { let address_tree_pubkey = rpc.get_address_tree_v2().tree; let mint_a_compressed_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &mint_signer_a_pda, &address_tree_pubkey, ); @@ -670,7 +670,7 @@ async fn test_create_two_mints() { ); let mint_b_compressed_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &mint_signer_b_pda, &address_tree_pubkey, ); @@ -704,7 +704,7 @@ async fn test_create_multi_mints() { use csdk_anchor_full_derived_test::instruction_accounts::{ CreateThreeMintsParams, MINT_SIGNER_A_SEED, MINT_SIGNER_B_SEED, MINT_SIGNER_C_SEED, }; - use light_token_sdk::token::{ + use light_token::instruction::{ find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; @@ -860,7 +860,7 @@ async fn test_create_multi_mints() { /// Helper function to set up test context for D9 instruction data tests. /// Returns (rpc, payer, program_id, config_pda). async fn setup_d9_test_context() -> (LightProgramTest, Keypair, Pubkey, Pubkey) { - use light_token_sdk::token::RENT_SPONSOR; + use light_token::instruction::RENT_SPONSOR; let program_id = csdk_anchor_full_derived_test::ID; let mut config = ProgramTestConfig::new_v2( diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs index 06c5029af2..a5cd62a7c3 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs @@ -16,7 +16,7 @@ use light_program_test::{ ProgramTestConfig, Rpc, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; +use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; use solana_instruction::Instruction; use solana_keypair::Keypair; use solana_pubkey::Pubkey; @@ -162,7 +162,7 @@ async fn test_d10_single_ata() { let ata_owner = ctx.payer.pubkey(); // Derive the ATA address using Light Token SDK's derivation - let (d10_single_ata, ata_bump) = light_token_sdk::token::derive_token_ata(&ata_owner, &mint); + let (d10_single_ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof (no PDA accounts for ATA-only instruction) let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs index 8a777be828..7272f4d4a0 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs @@ -1463,7 +1463,7 @@ async fn test_d5_light_token() { D5LightTokenParams, D5_VAULT_AUTH_SEED, D5_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; + use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; @@ -1528,7 +1528,7 @@ async fn test_d5_all_markers() { D5AllMarkersParams, D5_ALL_AUTH_SEED, D5_ALL_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; + use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; let owner = Keypair::new().pubkey(); @@ -1612,7 +1612,7 @@ async fn test_d7_light_token_config() { D7LightTokenConfigParams, D7_LIGHT_TOKEN_AUTH_SEED, D7_LIGHT_TOKEN_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{ + use light_token::instruction::{ COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR, }; @@ -1679,7 +1679,7 @@ async fn test_d7_all_names() { D7AllNamesParams, D7_ALL_AUTH_SEED, D7_ALL_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; + use light_token::instruction::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; let owner = Keypair::new().pubkey(); diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs index fee1258b38..938500f4bb 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs @@ -25,7 +25,7 @@ async fn test_create_mint_with_metadata() { use csdk_anchor_full_derived_test::instruction_accounts::{ CreateMintWithMetadataParams, METADATA_MINT_SIGNER_SEED, }; - use light_token_sdk::token::{ + use light_token::instruction::{ find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; @@ -79,11 +79,11 @@ async fn test_create_mint_with_metadata() { let symbol = b"TEST".to_vec(); let uri = b"https://example.com/metadata.json".to_vec(); let additional_metadata = Some(vec![ - light_token_sdk::AdditionalMetadata { + light_token::AdditionalMetadata { key: b"author".to_vec(), value: b"Light Protocol".to_vec(), }, - light_token_sdk::AdditionalMetadata { + light_token::AdditionalMetadata { key: b"version".to_vec(), value: b"1.0.0".to_vec(), }, @@ -194,7 +194,7 @@ async fn test_create_mint_with_metadata() { use light_token_interface::MINT_ADDRESS_TREE; let mint_address_tree = solana_pubkey::Pubkey::new_from_array(MINT_ADDRESS_TREE); let mint_compressed_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &mint_signer_pda, &mint_address_tree, ); diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs index 200f6e4432..352d0b2ad8 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs @@ -15,7 +15,7 @@ pub async fn setup_create_mint( decimals: u8, recipients: Vec<(u64, Pubkey)>, ) -> (Pubkey, [u8; 32], Vec, Keypair) { - use light_token_sdk::token::{ + use light_token::instruction::{ CreateAssociatedTokenAccount, CreateMint, CreateMintParams, MintTo, }; @@ -24,12 +24,12 @@ pub async fn setup_create_mint( let output_queue = rpc.get_random_state_tree_info().unwrap().queue; // Derive compression address using SDK helpers - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_seed.pubkey(), &address_tree.tree, ); - let (mint, bump) = light_token_sdk::token::find_mint_address(&mint_seed.pubkey()); + let (mint, bump) = light_token::instruction::find_mint_address(&mint_seed.pubkey()); // Get validity proof for the address let rpc_result = rpc @@ -93,7 +93,7 @@ pub async fn setup_create_mint( } // Create ATAs for each recipient - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let mut ata_pubkeys = Vec::with_capacity(recipients.len()); diff --git a/sdk-tests/sdk-light-token-test/Cargo.toml b/sdk-tests/sdk-light-token-test/Cargo.toml index 1a6d3c242b..3b1fb24084 100644 --- a/sdk-tests/sdk-light-token-test/Cargo.toml +++ b/sdk-tests/sdk-light-token-test/Cargo.toml @@ -17,7 +17,7 @@ default = [] [dependencies] # Light Protocol SDK dependencies (workspace-based) -light-token-sdk = { workspace = true } +light-token = { workspace = true } light-token-types = { workspace = true } light-token-interface = { workspace = true } light-sdk = { workspace = true, features = ["v2"] } @@ -45,7 +45,7 @@ tokio = { version = "1.36.0", features = ["full"] } solana-sdk = "2.2" spl-token-2022 = { workspace = true } spl-pod = { workspace = true } -anchor-spl = { workspace = true } +anchor-spl = "0.31.1" [lints.rust.unexpected_cfgs] level = "allow" diff --git a/sdk-tests/sdk-light-token-test/README.md b/sdk-tests/sdk-light-token-test/README.md index 56ae03ca78..c8534c461d 100644 --- a/sdk-tests/sdk-light-token-test/README.md +++ b/sdk-tests/sdk-light-token-test/README.md @@ -17,7 +17,7 @@ The program showcases **8 different instructions** that cover the core compresse ## Implementation Pattern: Builder Pattern from `ctoken` Module -This implementation uses the **builder pattern** from the `light-token-sdk::ctoken` module. This pattern provides a clean, ergonomic API for CPI operations. +This implementation uses the **builder pattern** from the `light-token::ctoken` module. This pattern provides a clean, ergonomic API for CPI operations. ### Why Use the Builder Pattern? @@ -66,7 +66,7 @@ transfer_accounts.invoke_signed(&[signer_seeds])?; ### ✅ Fully Implemented (8/8 Instructions) -All instructions use the **builder pattern** from `light-token-sdk::ctoken`: +All instructions use the **builder pattern** from `light-token::ctoken`: - **create_cmint** (Instruction 0): Create compressed mint using `CreateCMintCpi::invoke()` - **mint_to_ctoken** (Instruction 1): Mint tokens to compressed accounts using `MintToCTokenCpi::invoke()` @@ -94,7 +94,7 @@ ctoken/native/ All dependencies use **path references** to `/Users/ananas/dev/light-protocol2/sdk-libs/`: -- `light-token-sdk` → Main SDK with ctoken builder pattern +- `light-token` → Main SDK with ctoken builder pattern - `light-token-types` → Type definitions - `light-sdk` → Core SDK - `light-sdk-types` → Common types diff --git a/sdk-tests/sdk-light-token-test/src/approve.rs b/sdk-tests/sdk-light-token-test/src/approve.rs index 9a51f82d26..0dda096b88 100644 --- a/sdk-tests/sdk-light-token-test/src/approve.rs +++ b/sdk-tests/sdk-light-token-test/src/approve.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::ApproveCpi; +use light_token::instruction::ApproveCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/burn.rs b/sdk-tests/sdk-light-token-test/src/burn.rs index 24763da24d..b7d9fad600 100644 --- a/sdk-tests/sdk-light-token-test/src/burn.rs +++ b/sdk-tests/sdk-light-token-test/src/burn.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::BurnCpi; +use light_token::instruction::BurnCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/close.rs b/sdk-tests/sdk-light-token-test/src/close.rs index 30d1d798d3..dfa6c63851 100644 --- a/sdk-tests/sdk-light-token-test/src/close.rs +++ b/sdk-tests/sdk-light-token-test/src/close.rs @@ -1,4 +1,4 @@ -use light_token_sdk::token::CloseAccountCpi; +use light_token::instruction::CloseAccountCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/create_ata.rs b/sdk-tests/sdk-light-token-test/src/create_ata.rs index a376725b6f..9dd7ba9358 100644 --- a/sdk-tests/sdk-light-token-test/src/create_ata.rs +++ b/sdk-tests/sdk-light-token-test/src/create_ata.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::CreateTokenAtaCpi; +use light_token::instruction::CreateTokenAtaCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ATA_SEED, ID}; diff --git a/sdk-tests/sdk-light-token-test/src/create_mint.rs b/sdk-tests/sdk-light-token-test/src/create_mint.rs index c7ffe75a9d..413bda93de 100644 --- a/sdk-tests/sdk-light-token-test/src/create_mint.rs +++ b/sdk-tests/sdk-light-token-test/src/create_mint.rs @@ -1,6 +1,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::{ - token::{CreateMintCpi, CreateMintParams, ExtensionInstructionData, SystemAccountInfos}, +use light_token::{ + instruction::{CreateMintCpi, CreateMintParams, ExtensionInstructionData, SystemAccountInfos}, CompressedProof, }; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; diff --git a/sdk-tests/sdk-light-token-test/src/create_token_account.rs b/sdk-tests/sdk-light-token-test/src/create_token_account.rs index 43c847386c..1efd80124c 100644 --- a/sdk-tests/sdk-light-token-test/src/create_token_account.rs +++ b/sdk-tests/sdk-light-token-test/src/create_token_account.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::{CompressibleParamsCpi, CreateTokenAccountCpi}; +use light_token::instruction::{CompressibleParamsCpi, CreateTokenAccountCpi}; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/ctoken_mint_to.rs b/sdk-tests/sdk-light-token-test/src/ctoken_mint_to.rs index 19dfaac507..0709bf2a12 100644 --- a/sdk-tests/sdk-light-token-test/src/ctoken_mint_to.rs +++ b/sdk-tests/sdk-light-token-test/src/ctoken_mint_to.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::MintToCpi; +use light_token::instruction::MintToCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, MINT_AUTHORITY_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/decompress_mint.rs b/sdk-tests/sdk-light-token-test/src/decompress_mint.rs index 8741e09beb..53c2bcdebb 100644 --- a/sdk-tests/sdk-light-token-test/src/decompress_mint.rs +++ b/sdk-tests/sdk-light-token-test/src/decompress_mint.rs @@ -1,6 +1,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::{ - token::{DecompressMintCpi, MintWithContext, SystemAccountInfos}, +use light_token::{ + instruction::{DecompressMintCpi, MintWithContext, SystemAccountInfos}, ValidityProof, }; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; diff --git a/sdk-tests/sdk-light-token-test/src/freeze.rs b/sdk-tests/sdk-light-token-test/src/freeze.rs index 249c804e01..e1b83af6f6 100644 --- a/sdk-tests/sdk-light-token-test/src/freeze.rs +++ b/sdk-tests/sdk-light-token-test/src/freeze.rs @@ -1,4 +1,4 @@ -use light_token_sdk::token::FreezeCpi; +use light_token::instruction::FreezeCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{FREEZE_AUTHORITY_SEED, ID}; diff --git a/sdk-tests/sdk-light-token-test/src/revoke.rs b/sdk-tests/sdk-light-token-test/src/revoke.rs index c3bc1d59a6..ff55fbecce 100644 --- a/sdk-tests/sdk-light-token-test/src/revoke.rs +++ b/sdk-tests/sdk-light-token-test/src/revoke.rs @@ -1,4 +1,4 @@ -use light_token_sdk::token::RevokeCpi; +use light_token::instruction::RevokeCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/thaw.rs b/sdk-tests/sdk-light-token-test/src/thaw.rs index 8ce5a57678..8c666168ad 100644 --- a/sdk-tests/sdk-light-token-test/src/thaw.rs +++ b/sdk-tests/sdk-light-token-test/src/thaw.rs @@ -1,4 +1,4 @@ -use light_token_sdk::token::ThawCpi; +use light_token::instruction::ThawCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{FREEZE_AUTHORITY_SEED, ID}; diff --git a/sdk-tests/sdk-light-token-test/src/transfer.rs b/sdk-tests/sdk-light-token-test/src/transfer.rs index 0acd3cc425..e75fb3475b 100644 --- a/sdk-tests/sdk-light-token-test/src/transfer.rs +++ b/sdk-tests/sdk-light-token-test/src/transfer.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::TransferCpi; +use light_token::instruction::TransferCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/transfer_checked.rs b/sdk-tests/sdk-light-token-test/src/transfer_checked.rs index 65c78fcd71..ffc0692a67 100644 --- a/sdk-tests/sdk-light-token-test/src/transfer_checked.rs +++ b/sdk-tests/sdk-light-token-test/src/transfer_checked.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::TransferCheckedCpi; +use light_token::instruction::TransferCheckedCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::{ID, TOKEN_ACCOUNT_SEED}; diff --git a/sdk-tests/sdk-light-token-test/src/transfer_interface.rs b/sdk-tests/sdk-light-token-test/src/transfer_interface.rs index 5758563f41..0a60819d17 100644 --- a/sdk-tests/sdk-light-token-test/src/transfer_interface.rs +++ b/sdk-tests/sdk-light-token-test/src/transfer_interface.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::TransferInterfaceCpi; +use light_token::instruction::TransferInterfaceCpi; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::ID; diff --git a/sdk-tests/sdk-light-token-test/src/transfer_spl_ctoken.rs b/sdk-tests/sdk-light-token-test/src/transfer_spl_ctoken.rs index 805f04eadb..29b3d50def 100644 --- a/sdk-tests/sdk-light-token-test/src/transfer_spl_ctoken.rs +++ b/sdk-tests/sdk-light-token-test/src/transfer_spl_ctoken.rs @@ -1,5 +1,5 @@ use borsh::{BorshDeserialize, BorshSerialize}; -use light_token_sdk::token::{TransferFromSplCpi, TransferToSplCpi}; +use light_token::instruction::{TransferFromSplCpi, TransferToSplCpi}; use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey}; use crate::ID; diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_light_mint.rs b/sdk-tests/sdk-light-token-test/tests/scenario_light_mint.rs index 9b460f1775..d5556c69b3 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_light_mint.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_light_mint.rs @@ -16,7 +16,7 @@ mod shared; use borsh::BorshDeserialize; use light_client::{indexer::Indexer, rpc::Rpc}; use light_program_test::{program_test::TestRpc, LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::{CreateAssociatedTokenAccount, Decompress, Token, Transfer}; +use light_token::instruction::{CreateAssociatedTokenAccount, Decompress, Token, Transfer}; use solana_sdk::{signature::Keypair, signer::Signer}; /// Test the complete cMint to cToken flow using direct SDK calls diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_light_mint_compression_only.rs b/sdk-tests/sdk-light-token-test/tests/scenario_light_mint_compression_only.rs index 17cf7e2ba1..c76d991fdc 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_light_mint_compression_only.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_light_mint_compression_only.rs @@ -16,7 +16,7 @@ mod shared; use borsh::BorshDeserialize; use light_client::{indexer::Indexer, rpc::Rpc}; use light_program_test::{program_test::TestRpc, LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::{ +use light_token::instruction::{ CompressibleParams, CreateAssociatedTokenAccount, Decompress, Token, Transfer, }; use solana_sdk::{signature::Keypair, signer::Signer}; diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs b/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs index 5f1eab4325..88148df51c 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs @@ -20,11 +20,11 @@ use anchor_spl::token::{spl_token, Mint}; use light_client::{indexer::Indexer, rpc::Rpc}; use light_program_test::{program_test::TestRpc, LightProgramTest, ProgramTestConfig}; use light_test_utils::spl::{create_token_account, mint_spl_tokens}; -use light_token_sdk::{ - spl_interface::{find_spl_interface_pda_with_index, CreateSplInterfacePda}, - token::{ +use light_token::{ + instruction::{ derive_token_ata, CreateAssociatedTokenAccount, Decompress, Freeze, Thaw, TransferFromSpl, }, + spl_interface::{find_spl_interface_pda_with_index, CreateSplInterfacePda}, }; use solana_sdk::{signature::Keypair, signer::Signer}; use spl_token_2022::pod::PodAccount; diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs b/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs index 60a3e2975a..60b9faaa72 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs @@ -18,12 +18,12 @@ use light_program_test::{program_test::TestRpc, LightProgramTest, ProgramTestCon use light_test_utils::mint_2022::{ create_mint_22_with_extensions, create_token_22_account, mint_spl_tokens_22, }; -use light_token_sdk::{ - spl_interface::find_spl_interface_pda_with_index, - token::{ +use light_token::{ + instruction::{ derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, Decompress, TransferFromSpl, }, + spl_interface::find_spl_interface_pda_with_index, }; use solana_sdk::{signature::Keypair, signer::Signer}; use spl_token_2022::pod::PodAccount; diff --git a/sdk-tests/sdk-light-token-test/tests/shared.rs b/sdk-tests/sdk-light-token-test/tests/shared.rs index 4d36af0f53..748d673ceb 100644 --- a/sdk-tests/sdk-light-token-test/tests/shared.rs +++ b/sdk-tests/sdk-light-token-test/tests/shared.rs @@ -15,7 +15,7 @@ pub async fn setup_create_mint( decimals: u8, recipients: Vec<(u64, Pubkey)>, ) -> (Pubkey, [u8; 32], Vec, Keypair) { - use light_token_sdk::token::{ + use light_token::instruction::{ CreateAssociatedTokenAccount, CreateMint, CreateMintParams, MintTo, }; @@ -24,12 +24,12 @@ pub async fn setup_create_mint( let output_queue = rpc.get_random_state_tree_info().unwrap().queue; // Derive compression address using SDK helpers - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_seed.pubkey(), &address_tree.tree, ); - let (mint, bump) = light_token_sdk::token::find_mint_address(&mint_seed.pubkey()); + let (mint, bump) = light_token::instruction::find_mint_address(&mint_seed.pubkey()); // Get validity proof for the address let rpc_result = rpc @@ -93,7 +93,7 @@ pub async fn setup_create_mint( } // Create ATAs for each recipient - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let mut ata_pubkeys = Vec::with_capacity(recipients.len()); @@ -147,7 +147,7 @@ pub async fn setup_create_mint_with_freeze_authority( decimals: u8, recipients: Vec<(u64, Pubkey)>, ) -> (Pubkey, [u8; 32], Vec) { - use light_token_sdk::token::{ + use light_token::instruction::{ CreateAssociatedTokenAccount, CreateMint, CreateMintParams, MintTo, }; @@ -156,12 +156,12 @@ pub async fn setup_create_mint_with_freeze_authority( let output_queue = rpc.get_random_state_tree_info().unwrap().queue; // Derive compression address using SDK helpers - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_seed.pubkey(), &address_tree.tree, ); - let (mint, bump) = light_token_sdk::token::find_mint_address(&mint_seed.pubkey()); + let (mint, bump) = light_token::instruction::find_mint_address(&mint_seed.pubkey()); // Get validity proof for the address let rpc_result = rpc @@ -213,7 +213,7 @@ pub async fn setup_create_mint_with_freeze_authority( } // Create ATAs for each recipient - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let mut ata_pubkeys = Vec::with_capacity(recipients.len()); @@ -267,7 +267,7 @@ pub async fn setup_create_mint_with_compression_only( recipients: Vec<(u64, Pubkey)>, compression_only: bool, ) -> (Pubkey, [u8; 32], Vec) { - use light_token_sdk::token::{ + use light_token::instruction::{ CompressibleParams, CreateAssociatedTokenAccount, CreateMint, CreateMintParams, MintTo, }; @@ -276,12 +276,12 @@ pub async fn setup_create_mint_with_compression_only( let output_queue = rpc.get_random_state_tree_info().unwrap().queue; // Derive compression address using SDK helpers - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_seed.pubkey(), &address_tree.tree, ); - let (mint, bump) = light_token_sdk::token::find_mint_address(&mint_seed.pubkey()); + let (mint, bump) = light_token::instruction::find_mint_address(&mint_seed.pubkey()); // Get validity proof for the address let rpc_result = rpc @@ -345,7 +345,7 @@ pub async fn setup_create_mint_with_compression_only( } // Create ATAs for each recipient with custom compression_only setting - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let mut ata_pubkeys = Vec::with_capacity(recipients.len()); @@ -406,10 +406,10 @@ pub async fn setup_create_compressed_only_mint( mint_authority: Pubkey, decimals: u8, ) -> (Pubkey, [u8; 32], Keypair) { + use light_token::instruction::{derive_mint_compressed_address, find_mint_address}; use light_token_client::instructions::mint_action::{ create_mint_action_instruction, MintActionParams, NewMint, }; - use light_token_sdk::token::{derive_mint_compressed_address, find_mint_address}; let mint_seed = Keypair::new(); let address_tree = rpc.get_address_tree_v2(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_close.rs b/sdk-tests/sdk-light-token-test/tests/test_close.rs index eee94559c2..6a12a24dc6 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_close.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_close.rs @@ -4,7 +4,7 @@ mod shared; use light_client::rpc::Rpc; use light_program_test::{LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::{rent_sponsor_pda, LIGHT_TOKEN_PROGRAM_ID}; +use light_token::instruction::{rent_sponsor_pda, LIGHT_TOKEN_PROGRAM_ID}; use native_ctoken_examples::{InstructionType, ID, TOKEN_ACCOUNT_SEED}; use shared::*; use solana_sdk::{ diff --git a/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs b/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs index 937b92ee15..99f02cba97 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs @@ -5,7 +5,7 @@ mod shared; use borsh::{BorshDeserialize, BorshSerialize}; use light_client::rpc::Rpc; use light_program_test::{LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; +use light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; use native_ctoken_examples::{CreateAtaData, ATA_SEED, ID}; use shared::setup_create_mint; use solana_sdk::{ @@ -33,7 +33,7 @@ async fn test_create_ata_invoke() { // Derive the ATA address let owner = payer.pubkey(); - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let (ata_address, bump) = derive_token_ata(&owner, &mint_pda); // Build CreateAtaData (owner and mint are passed as accounts) @@ -45,7 +45,7 @@ async fn test_create_ata_invoke() { // Discriminator 4 = CreateAtaInvoke let instruction_data = [vec![4u8], create_ata_data.try_to_vec().unwrap()].concat(); - use light_token_sdk::token::{config_pda, rent_sponsor_pda}; + use light_token::instruction::{config_pda, rent_sponsor_pda}; let config = config_pda(); let rent_sponsor = rent_sponsor_pda(); @@ -119,7 +119,7 @@ async fn test_create_ata_invoke_signed() { .unwrap(); // Derive the ATA address for the PDA owner - use light_token_sdk::token::derive_token_ata; + use light_token::instruction::derive_token_ata; let (ata_address, bump) = derive_token_ata(&pda_owner, &mint_pda); // Build CreateAtaData with PDA as owner (owner and mint are passed as accounts) @@ -131,7 +131,7 @@ async fn test_create_ata_invoke_signed() { // Discriminator 5 = CreateAtaInvokeSigned let instruction_data = [vec![5u8], create_ata_data.try_to_vec().unwrap()].concat(); - use light_token_sdk::token::{config_pda, rent_sponsor_pda}; + use light_token::instruction::{config_pda, rent_sponsor_pda}; let config = config_pda(); let rent_sponsor = rent_sponsor_pda(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_create_mint.rs b/sdk-tests/sdk-light-token-test/tests/test_create_mint.rs index 5d5be5628d..ef1d864935 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_create_mint.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_create_mint.rs @@ -5,16 +5,16 @@ mod shared; use borsh::BorshSerialize; use light_client::{indexer::Indexer, rpc::Rpc}; use light_program_test::{LightProgramTest, ProgramTestConfig}; +use light_token::{ + compressed_token::mint_action::MintActionMetaConfig, + instruction::{config_pda, rent_sponsor_pda}, +}; use light_token_interface::{ instructions::extensions::{ token_metadata::TokenMetadataInstructionData, ExtensionInstructionData, }, state::AdditionalMetadata, }; -use light_token_sdk::{ - compressed_token::mint_action::MintActionMetaConfig, - token::{config_pda, rent_sponsor_pda}, -}; use native_ctoken_examples::{CreateCmintData, ID, MINT_SIGNER_SEED}; use solana_sdk::{ instruction::{AccountMeta, Instruction}, @@ -45,12 +45,12 @@ async fn test_create_compressed_mint() { Pubkey::new_from_array(light_token_interface::LIGHT_TOKEN_PROGRAM_ID); // Use SDK helper to derive the compression address correctly - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_signer.pubkey(), &address_tree.tree, ); - let (mint_pda, mint_bump) = light_token_sdk::token::find_mint_address(&mint_signer.pubkey()); + let (mint_pda, mint_bump) = light_token::instruction::find_mint_address(&mint_signer.pubkey()); let rpc_result = rpc .get_validity_proof( @@ -153,12 +153,12 @@ async fn test_create_compressed_mint_invoke_signed() { Pubkey::new_from_array(light_token_interface::LIGHT_TOKEN_PROGRAM_ID); // Use SDK helper to derive the compression address correctly - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_signer_pda, &address_tree.tree, ); - let (mint_pda, mint_bump) = light_token_sdk::token::find_mint_address(&mint_signer_pda); + let (mint_pda, mint_bump) = light_token::instruction::find_mint_address(&mint_signer_pda); let rpc_result = rpc .get_validity_proof( @@ -193,7 +193,7 @@ async fn test_create_compressed_mint_invoke_signed() { // Build accounts manually since SDK marks mint_signer as signer, but we need it as non-signer // for invoke_signed (the wrapper program signs via CPI) // Account order matches MintActionMetaConfig::to_account_metas() with mint_signer as non-signer - let system_accounts = light_token_sdk::token::SystemAccounts::default(); + let system_accounts = light_token::instruction::SystemAccounts::default(); let wrapper_accounts = vec![ AccountMeta::new_readonly(compressed_token_program_id, false), // [0] compressed_token_program AccountMeta::new_readonly(system_accounts.light_system_program, false), // [1] light_system_program diff --git a/sdk-tests/sdk-light-token-test/tests/test_create_token_account.rs b/sdk-tests/sdk-light-token-test/tests/test_create_token_account.rs index fd220462c3..3748cb5000 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_create_token_account.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_create_token_account.rs @@ -5,7 +5,7 @@ mod shared; use borsh::{BorshDeserialize, BorshSerialize}; use light_client::rpc::Rpc; use light_program_test::{LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; +use light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; use native_ctoken_examples::{CreateTokenAccountData, ID}; use shared::setup_create_mint; use solana_sdk::{ @@ -43,7 +43,7 @@ async fn test_create_token_account_invoke() { }; let instruction_data = [vec![2u8], create_token_account_data.try_to_vec().unwrap()].concat(); - use light_token_sdk::token::{config_pda, rent_sponsor_pda}; + use light_token::instruction::{config_pda, rent_sponsor_pda}; let config = config_pda(); let rent_sponsor = rent_sponsor_pda(); @@ -119,7 +119,7 @@ async fn test_create_token_account_invoke_signed() { // Discriminator 3 = CreateTokenAccountInvokeSigned let instruction_data = [vec![3u8], create_token_account_data.try_to_vec().unwrap()].concat(); - use light_token_sdk::token::{config_pda, rent_sponsor_pda}; + use light_token::instruction::{config_pda, rent_sponsor_pda}; let config = config_pda(); let rent_sponsor = rent_sponsor_pda(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs b/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs index 47fa876a75..68d3c57460 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs @@ -88,7 +88,7 @@ async fn test_ctoken_mint_to_invoke() { #[tokio::test] async fn test_ctoken_mint_to_invoke_signed() { use light_client::indexer::Indexer; - use light_token_sdk::token::CreateAssociatedTokenAccount; + use light_token::instruction::CreateAssociatedTokenAccount; use native_ctoken_examples::{CreateCmintData, MINT_SIGNER_SEED}; let config = ProgramTestConfig::new_v2(true, Some(vec![("native_ctoken_examples", ID)])); @@ -104,12 +104,12 @@ async fn test_ctoken_mint_to_invoke_signed() { let output_queue = rpc.get_random_state_tree_info().unwrap().queue; // Derive compression address using the PDA mint_signer - let compression_address = light_token_sdk::token::derive_mint_compressed_address( + let compression_address = light_token::instruction::derive_mint_compressed_address( &mint_signer_pda, &address_tree.tree, ); - let (mint_pda, mint_bump) = light_token_sdk::token::find_mint_address(&mint_signer_pda); + let (mint_pda, mint_bump) = light_token::instruction::find_mint_address(&mint_signer_pda); // Step 1: Create compressed mint with PDA authority using wrapper program (discriminator 14) { @@ -128,9 +128,9 @@ async fn test_ctoken_mint_to_invoke_signed() { let compressed_token_program_id = Pubkey::new_from_array(light_token_interface::LIGHT_TOKEN_PROGRAM_ID); - let default_pubkeys = light_token_sdk::utils::TokenDefaultAccounts::default(); - let compressible_config = light_token_sdk::token::config_pda(); - let rent_sponsor = light_token_sdk::token::rent_sponsor_pda(); + let default_pubkeys = light_token::utils::TokenDefaultAccounts::default(); + let compressible_config = light_token::instruction::config_pda(); + let rent_sponsor = light_token::instruction::rent_sponsor_pda(); let create_mint_data = CreateCmintData { decimals, @@ -196,7 +196,8 @@ async fn test_ctoken_mint_to_invoke_signed() { // Step 2: Create ATA for payer (CreateMint now auto-decompresses) let ata = { - let (ata_address, _) = light_token_sdk::token::derive_token_ata(&payer.pubkey(), &mint_pda); + let (ata_address, _) = + light_token::instruction::derive_token_ata(&payer.pubkey(), &mint_pda); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint_pda); let ata_instruction = create_ata.instruction().unwrap(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_decompress_mint.rs b/sdk-tests/sdk-light-token-test/tests/test_decompress_mint.rs index 119bfdf667..e22111be8d 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_decompress_mint.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_decompress_mint.rs @@ -7,11 +7,11 @@ use borsh::BorshDeserialize; use light_client::{indexer::Indexer, rpc::Rpc}; use light_compressible::compression_info::CompressionInfo; use light_program_test::{LightProgramTest, ProgramTestConfig}; +use light_token::instruction::derive_mint_compressed_address; use light_token_client::instructions::mint_action::{ create_mint_action_instruction, MintActionParams, MintActionType, }; use light_token_interface::state::Mint; -use light_token_sdk::token::derive_mint_compressed_address; use solana_sdk::signer::Signer; /// Test decompressing a compressed-only mint diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer.rs index 88c9eb0f3b..a97960d43e 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer.rs @@ -5,7 +5,7 @@ mod shared; use borsh::{BorshDeserialize, BorshSerialize}; use light_client::rpc::Rpc; use light_program_test::{LightProgramTest, ProgramTestConfig}; -use light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; +use light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; use native_ctoken_examples::{InstructionType, TransferData, ID, TOKEN_ACCOUNT_SEED}; use shared::*; use solana_sdk::{ diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs index 147ffb880e..92ca87a232 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs @@ -9,11 +9,11 @@ use light_test_utils::{ mint_2022::{create_mint_22_with_extensions, create_token_22_account, mint_spl_tokens_22}, spl::{create_token_account, mint_spl_tokens}, }; -use light_token_interface::state::Token; -use light_token_sdk::{ +use light_token::{ + instruction::{derive_token_ata, CreateAssociatedTokenAccount, TransferFromSpl}, spl_interface::{find_spl_interface_pda_with_index, CreateSplInterfacePda}, - token::{derive_token_ata, CreateAssociatedTokenAccount, TransferFromSpl}, }; +use light_token_interface::state::Token; use native_ctoken_examples::{InstructionType, TransferCheckedData, ID}; use shared::*; use solana_sdk::{ @@ -144,7 +144,7 @@ async fn test_ctoken_transfer_checked_spl_mint() { let mut instruction_data = vec![InstructionType::CTokenTransferCheckedInvoke as u8]; transfer_data.serialize(&mut instruction_data).unwrap(); - let light_token_program = light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; + let light_token_program = light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; let instruction = Instruction { program_id: ID, accounts: vec![ @@ -196,7 +196,7 @@ async fn test_ctoken_transfer_checked_t22_mint() { let (source_ata, _) = derive_token_ata(&source_owner, &mint); let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); - use light_token_sdk::token::CompressibleParams; + use light_token::instruction::CompressibleParams; let compressible_params = CompressibleParams { compression_only: true, ..Default::default() @@ -249,7 +249,7 @@ async fn test_ctoken_transfer_checked_t22_mint() { let mut instruction_data = vec![InstructionType::CTokenTransferCheckedInvoke as u8]; transfer_data.serialize(&mut instruction_data).unwrap(); - let light_token_program = light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; + let light_token_program = light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; let instruction = Instruction { program_id: ID, accounts: vec![ @@ -309,7 +309,7 @@ async fn test_ctoken_transfer_checked_mint() { let mut instruction_data = vec![InstructionType::CTokenTransferCheckedInvoke as u8]; transfer_data.serialize(&mut instruction_data).unwrap(); - let light_token_program = light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; + let light_token_program = light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; let instruction = Instruction { program_id: ID, accounts: vec![ diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs index 489c656f81..68a68c1c1b 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs @@ -8,9 +8,9 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::spl::{ create_mint_helper, create_token_2022_account, mint_spl_tokens, CREATE_MINT_HELPER_DECIMALS, }; -use light_token_sdk::{ +use light_token::{ + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, spl_interface::find_spl_interface_pda_with_index, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, }; use light_token_types::CPI_AUTHORITY_PDA; use native_ctoken_examples::{TransferInterfaceData, ID, TRANSFER_INTERFACE_AUTHORITY_SEED}; diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs index b88a1a55c6..4719b7a93b 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs @@ -8,9 +8,9 @@ use light_program_test::{LightProgramTest, ProgramTestConfig}; use light_test_utils::spl::{ create_mint_helper, create_token_2022_account, mint_spl_tokens, CREATE_MINT_HELPER_DECIMALS, }; -use light_token_sdk::{ +use light_token::{ + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, spl_interface::find_spl_interface_pda_with_index, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, }; use light_token_types::CPI_AUTHORITY_PDA; use native_ctoken_examples::{ diff --git a/sdk-tests/sdk-token-test/CLAUDE.md b/sdk-tests/sdk-token-test/CLAUDE.md index 529305fa61..1e5069420f 100644 --- a/sdk-tests/sdk-token-test/CLAUDE.md +++ b/sdk-tests/sdk-token-test/CLAUDE.md @@ -1,6 +1,6 @@ ## TLDR -- this is a test program that tests ctoken instructions with light-token-sdk functions in integration tests -- light-token-sdk: sdk-libs/compressed-token-sdk +- this is a test program that tests ctoken instructions with light-token functions in integration tests +- light-token: sdk-libs/compressed-token-sdk - light-token-interface: program-libs/token-interface - light-compressed-token-program: programs/compressed-token/program/ diff --git a/sdk-tests/sdk-token-test/Cargo.toml b/sdk-tests/sdk-token-test/Cargo.toml index 41b64523e7..64c79b2562 100644 --- a/sdk-tests/sdk-token-test/Cargo.toml +++ b/sdk-tests/sdk-token-test/Cargo.toml @@ -18,20 +18,20 @@ cpi = ["no-entrypoint"] test-sbf = ["profile-program"] default = [] profile-program = [ - "light-token-sdk/profile-program", + "light-token/profile-program", "light-program-profiler/profile-program", "light-compressed-account/profile-program", "light-token-interface/profile-program", ] profile-heap = [ - "light-token-sdk/profile-heap", + "light-token/profile-heap", "light-program-profiler/profile-heap", "light-compressed-account/profile-heap", "light-token-interface/profile-heap", ] [dependencies] -light-token-sdk = { workspace = true, features = ["anchor", "cpi-context", "v1"] } +light-token = { workspace = true, features = ["anchor", "cpi-context", "v1"] } light-token-types = { workspace = true } anchor-lang = { workspace = true } solana-pubkey = { workspace = true } @@ -52,7 +52,7 @@ light-test-utils = { workspace = true } tokio = { workspace = true } serial_test = { workspace = true } solana-sdk = { workspace = true } -anchor-spl = { workspace = true } +anchor-spl = "0.31.1" light-sdk = { workspace = true } light-compressed-account = { workspace = true, features = ["anchor"] } light-client = { workspace = true, features = ["devenv"] } diff --git a/sdk-tests/sdk-token-test/src/ctoken_pda/create_pda.rs b/sdk-tests/sdk-token-test/src/ctoken_pda/create_pda.rs index baefbfc80c..df77601ff7 100644 --- a/sdk-tests/sdk-token-test/src/ctoken_pda/create_pda.rs +++ b/sdk-tests/sdk-token-test/src/ctoken_pda/create_pda.rs @@ -6,7 +6,7 @@ use light_sdk::{ InvokeLightSystemProgram, LightCpiInstruction, }, }; -use light_token_sdk::ValidityProof; +use light_token::ValidityProof; use crate::process_update_deposit::CompressedEscrowPda; diff --git a/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs b/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs index 530fa8b8da..4f1a73c257 100644 --- a/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs +++ b/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs @@ -1,11 +1,11 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; use light_sdk::cpi::v2::CpiAccounts; +use light_token::compressed_token::{ + ctoken_instruction::CTokenInstruction, mint_action::MintActionCpiWriteAccounts, +}; use light_token_interface::instructions::mint_action::{ MintActionCompressedInstructionData, MintToCompressedAction, UpdateAuthority, }; -use light_token_sdk::compressed_token::{ - ctoken_instruction::CTokenInstruction, mint_action::MintActionCpiWriteAccounts, -}; use super::CTokenPda; use crate::ChainedCtokenInstructionData; diff --git a/sdk-tests/sdk-token-test/src/ctoken_pda/processor.rs b/sdk-tests/sdk-token-test/src/ctoken_pda/processor.rs index 58a5a24851..9609f01858 100644 --- a/sdk-tests/sdk-token-test/src/ctoken_pda/processor.rs +++ b/sdk-tests/sdk-token-test/src/ctoken_pda/processor.rs @@ -1,5 +1,5 @@ use anchor_lang::prelude::*; -use light_token_sdk::ValidityProof; +use light_token::ValidityProof; use super::{create_pda::process_create_escrow_pda, mint::process_mint_action, CTokenPda}; use crate::ChainedCtokenInstructionData; diff --git a/sdk-tests/sdk-token-test/src/lib.rs b/sdk-tests/sdk-token-test/src/lib.rs index 245112a40d..9d5cac59bb 100644 --- a/sdk-tests/sdk-token-test/src/lib.rs +++ b/sdk-tests/sdk-token-test/src/lib.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_sdk::instruction::{PackedAddressTreeInfo, ValidityProof as LightValidityProof}; -use light_token_sdk::{ +use light_token::{ compressed_token::{batch_compress::Recipient, TokenAccountMeta}, ValidityProof, }; @@ -129,8 +129,8 @@ pub mod sdk_token_test { /// This decompresses the entire balance to destination ctoken accounts pub fn decompress_full_cpi<'info>( ctx: Context<'_, '_, '_, 'info, Generic<'info>>, - indices: Vec, - validity_proof: light_token_sdk::ValidityProof, + indices: Vec, + validity_proof: light_token::ValidityProof, ) -> Result<()> { process_decompress_full_cpi_context(ctx, indices, validity_proof, None) } @@ -139,8 +139,8 @@ pub mod sdk_token_test { /// This decompresses the entire balance to destination ctoken accounts pub fn decompress_full_cpi_with_cpi_context<'info>( ctx: Context<'_, '_, '_, 'info, Generic<'info>>, - indices: Vec, - validity_proof: light_token_sdk::ValidityProof, + indices: Vec, + validity_proof: light_token::ValidityProof, params: Option, ) -> Result<()> { process_decompress_full_cpi_context(ctx, indices, validity_proof, params) diff --git a/sdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rs b/sdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rs index e4d5eec534..968061a95b 100644 --- a/sdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rs +++ b/sdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rs @@ -1,11 +1,11 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_interface::instructions::mint_action::{ - MintActionCompressedInstructionData, MintToCompressedAction, MintWithContext, Recipient, -}; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ ctoken_instruction::CTokenInstruction, mint_action::MintActionCpiWriteAccounts, transfer2::Transfer2CpiAccounts, }; +use light_token_interface::instructions::mint_action::{ + MintActionCompressedInstructionData, MintToCompressedAction, MintWithContext, Recipient, +}; use crate::Generic; diff --git a/sdk-tests/sdk-token-test/src/pda_ctoken/create_pda.rs b/sdk-tests/sdk-token-test/src/pda_ctoken/create_pda.rs index 1a3f93d4ea..1fb2f75910 100644 --- a/sdk-tests/sdk-token-test/src/pda_ctoken/create_pda.rs +++ b/sdk-tests/sdk-token-test/src/pda_ctoken/create_pda.rs @@ -7,7 +7,7 @@ use light_sdk::{ }, }; use light_sdk_types::cpi_context_write::CpiContextWriteAccounts; -use light_token_sdk::ValidityProof; +use light_token::ValidityProof; use crate::{process_update_deposit::CompressedEscrowPda, LIGHT_CPI_SIGNER}; diff --git a/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs b/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs index 33798fae69..473ae6bfc8 100644 --- a/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs +++ b/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs @@ -1,11 +1,11 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; use light_sdk_types::cpi_accounts::v2::CpiAccounts; +use light_token::compressed_token::{ + ctoken_instruction::CTokenInstruction, mint_action::MintActionCpiAccounts, +}; use light_token_interface::instructions::mint_action::{ MintActionCompressedInstructionData, MintToAction, MintToCompressedAction, UpdateAuthority, }; -use light_token_sdk::compressed_token::{ - ctoken_instruction::CTokenInstruction, mint_action::MintActionCpiAccounts, -}; use super::{processor::ChainedCtokenInstructionData, PdaCToken}; diff --git a/sdk-tests/sdk-token-test/src/pda_ctoken/processor.rs b/sdk-tests/sdk-token-test/src/pda_ctoken/processor.rs index 4181a3240d..67d04f5b04 100644 --- a/sdk-tests/sdk-token-test/src/pda_ctoken/processor.rs +++ b/sdk-tests/sdk-token-test/src/pda_ctoken/processor.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; +use light_token::ValidityProof; use light_token_interface::instructions::mint_action::{MintWithContext, Recipient}; -use light_token_sdk::ValidityProof; use super::{ create_pda::process_create_escrow_pda_with_cpi_context, mint::process_mint_action, PdaCToken, diff --git a/sdk-tests/sdk-token-test/src/process_batch_compress_tokens.rs b/sdk-tests/sdk-token-test/src/process_batch_compress_tokens.rs index 2543e76b24..8845f2c34d 100644 --- a/sdk-tests/sdk-token-test/src/process_batch_compress_tokens.rs +++ b/sdk-tests/sdk-token-test/src/process_batch_compress_tokens.rs @@ -1,5 +1,5 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_sdk::compressed_token::batch_compress::{ +use light_token::compressed_token::batch_compress::{ create_batch_compress_instruction, BatchCompressInputs, Recipient, }; use light_token_types::account_infos::BatchCompressAccountInfos; diff --git a/sdk-tests/sdk-token-test/src/process_compress_full_and_close.rs b/sdk-tests/sdk-token-test/src/process_compress_full_and_close.rs index 6c64fbe75b..faa82191cb 100644 --- a/sdk-tests/sdk-token-test/src/process_compress_full_and_close.rs +++ b/sdk-tests/sdk-token-test/src/process_compress_full_and_close.rs @@ -1,6 +1,6 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; use light_sdk_types::cpi_accounts::{v2::CpiAccounts, CpiAccountsConfig}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer2::{ account_metas::Transfer2AccountsMetaConfig, create_transfer2_instruction, @@ -8,7 +8,7 @@ use light_token_sdk::{ }, CTokenAccount2, }, - token::CloseAccount, + instruction::CloseAccount, }; use crate::Generic; diff --git a/sdk-tests/sdk-token-test/src/process_compress_tokens.rs b/sdk-tests/sdk-token-test/src/process_compress_tokens.rs index a416cebaca..430823da47 100644 --- a/sdk-tests/sdk-token-test/src/process_compress_tokens.rs +++ b/sdk-tests/sdk-token-test/src/process_compress_tokens.rs @@ -1,5 +1,5 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_sdk::compressed_token::transfer::{ +use light_token::compressed_token::transfer::{ instruction::{compress, CompressInputs}, TransferAccountInfos, }; diff --git a/sdk-tests/sdk-token-test/src/process_create_compressed_account.rs b/sdk-tests/sdk-token-test/src/process_create_compressed_account.rs index 09bbfa8a1f..1df113b713 100644 --- a/sdk-tests/sdk-token-test/src/process_create_compressed_account.rs +++ b/sdk-tests/sdk-token-test/src/process_create_compressed_account.rs @@ -10,7 +10,7 @@ use light_sdk::{ light_account_checks::AccountInfoTrait, LightDiscriminator, LightHasher, }; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ transfer::instruction::{TransferConfig, TransferInputs}, CTokenAccount, TokenAccountMeta, }; @@ -96,8 +96,7 @@ pub fn deposit_tokens<'a, 'info>( amount, }; let instruction = - light_token_sdk::compressed_token::transfer::instruction::transfer(transfer_inputs) - .unwrap(); + light_token::compressed_token::transfer::instruction::transfer(transfer_inputs).unwrap(); // msg!("instruction {:?}", instruction); // We can use the property that account infos don't have to be in order if you use // solana program invoke. diff --git a/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs b/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs index 51548db252..865e9f0516 100644 --- a/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs +++ b/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs @@ -1,6 +1,6 @@ use anchor_lang::{prelude::*, solana_program::program::invoke_signed}; +use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use light_token_interface::instructions::extensions::CompressToPubkey; -use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; use crate::Generic; diff --git a/sdk-tests/sdk-token-test/src/process_create_two_mints.rs b/sdk-tests/sdk-token-test/src/process_create_two_mints.rs index 6c5e6d76c6..304974a224 100644 --- a/sdk-tests/sdk-token-test/src/process_create_two_mints.rs +++ b/sdk-tests/sdk-token-test/src/process_create_two_mints.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; -use light_token_sdk::{ - token::{create_mints, CreateMintsParams as SdkCreateMintsParams, SingleMintParams}, +use light_token::{ + instruction::{create_mints, CreateMintsParams as SdkCreateMintsParams, SingleMintParams}, CompressedProof, }; diff --git a/sdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rs b/sdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rs index ac0cfca0ce..b909d0a85a 100644 --- a/sdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rs +++ b/sdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rs @@ -1,5 +1,5 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ decompress_full::{decompress_full_token_accounts_with_indices, DecompressFullIndices}, transfer2::Transfer2CpiAccounts, }; @@ -16,7 +16,7 @@ use crate::{ pub fn process_decompress_full_cpi_context<'info>( ctx: Context<'_, '_, '_, 'info, Generic<'info>>, indices: Vec, - validity_proof: light_token_sdk::ValidityProof, + validity_proof: light_token::ValidityProof, params: Option, ) -> Result<()> { // Parse CPI accounts following the established pattern diff --git a/sdk-tests/sdk-token-test/src/process_decompress_tokens.rs b/sdk-tests/sdk-token-test/src/process_decompress_tokens.rs index 1afb82563b..312733b76b 100644 --- a/sdk-tests/sdk-token-test/src/process_decompress_tokens.rs +++ b/sdk-tests/sdk-token-test/src/process_decompress_tokens.rs @@ -1,5 +1,5 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer::{ instruction::{decompress, DecompressInputs}, diff --git a/sdk-tests/sdk-token-test/src/process_four_invokes.rs b/sdk-tests/sdk-token-test/src/process_four_invokes.rs index ab64db5865..0b4204ba76 100644 --- a/sdk-tests/sdk-token-test/src/process_four_invokes.rs +++ b/sdk-tests/sdk-token-test/src/process_four_invokes.rs @@ -5,7 +5,7 @@ use light_sdk::{ light_account_checks::AccountInfoTrait, }; use light_sdk_types::cpi_accounts::CpiAccountsConfig; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ transfer::instruction::{compress, transfer, CompressInputs, TransferConfig, TransferInputs}, CTokenAccount, TokenAccountMeta, }; diff --git a/sdk-tests/sdk-token-test/src/process_four_transfer2.rs b/sdk-tests/sdk-token-test/src/process_four_transfer2.rs index 1312e04126..29dd3cd58a 100644 --- a/sdk-tests/sdk-token-test/src/process_four_transfer2.rs +++ b/sdk-tests/sdk-token-test/src/process_four_transfer2.rs @@ -8,14 +8,14 @@ use light_sdk_types::{ cpi_accounts::{v2::CpiAccounts as CpiAccountsSmall, CpiAccountsConfig}, cpi_context_write::CpiContextWriteAccounts, }; -use light_token_interface::instructions::transfer2::MultiInputTokenDataWithContext; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ transfer2::{ account_metas::Transfer2AccountsMetaConfig, create_transfer2_instruction, Transfer2Config, Transfer2Inputs, }, CTokenAccount2, }; +use light_token_interface::instructions::transfer2::MultiInputTokenDataWithContext; use crate::{process_update_deposit::CompressedEscrowPda, PdaParams, LIGHT_CPI_SIGNER}; diff --git a/sdk-tests/sdk-token-test/src/process_transfer_tokens.rs b/sdk-tests/sdk-token-test/src/process_transfer_tokens.rs index 670c2793b5..e4f9c02eab 100644 --- a/sdk-tests/sdk-token-test/src/process_transfer_tokens.rs +++ b/sdk-tests/sdk-token-test/src/process_transfer_tokens.rs @@ -1,5 +1,5 @@ use anchor_lang::{prelude::*, solana_program::program::invoke}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer::{ instruction::{transfer, TransferInputs}, diff --git a/sdk-tests/sdk-token-test/src/process_update_deposit.rs b/sdk-tests/sdk-token-test/src/process_update_deposit.rs index 39d64bd816..fb5b8048ff 100644 --- a/sdk-tests/sdk-token-test/src/process_update_deposit.rs +++ b/sdk-tests/sdk-token-test/src/process_update_deposit.rs @@ -12,7 +12,7 @@ use light_sdk::{ LightDiscriminator, LightHasher, }; use light_sdk_types::cpi_accounts::CpiAccountsConfig; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ transfer::instruction::{TransferConfig, TransferInputs}, CTokenAccount, TokenAccountMeta, }; @@ -105,8 +105,7 @@ fn merge_escrow_token_accounts<'info>( amount: total_escrowed_amount, }; let instruction = - light_token_sdk::compressed_token::transfer::instruction::transfer(transfer_inputs) - .unwrap(); + light_token::compressed_token::transfer::instruction::transfer(transfer_inputs).unwrap(); let account_infos = [&[fee_payer, authority][..], remaining_accounts].concat(); @@ -195,8 +194,7 @@ pub fn transfer_tokens_to_escrow_pda<'a, 'info>( amount, }; let instruction = - light_token_sdk::compressed_token::transfer::instruction::transfer(transfer_inputs) - .unwrap(); + light_token::compressed_token::transfer::instruction::transfer(transfer_inputs).unwrap(); let account_infos = [&[cpi_accounts.fee_payer().clone()][..], remaining_accounts].concat(); diff --git a/sdk-tests/sdk-token-test/tests/ctoken_pda.rs b/sdk-tests/sdk-token-test/tests/ctoken_pda.rs index 5b2816ffcd..2dc4e717d1 100644 --- a/sdk-tests/sdk-token-test/tests/ctoken_pda.rs +++ b/sdk-tests/sdk-token-test/tests/ctoken_pda.rs @@ -3,6 +3,9 @@ use light_client::indexer::Indexer; use light_compressed_account::{address::derive_address, hash_to_bn254_field_size_be}; use light_program_test::{LightProgramTest, ProgramTestConfig, Rpc, RpcError}; use light_sdk::instruction::{PackedAccounts, SystemAccountMetaConfig}; +use light_token::compressed_token::create_compressed_mint::{ + derive_mint_compressed_address, find_mint_address, +}; use light_token_interface::{ instructions::{ extensions::token_metadata::TokenMetadataInstructionData, @@ -11,9 +14,6 @@ use light_token_interface::{ state::{extensions::AdditionalMetadata, MintMetadata}, LIGHT_TOKEN_PROGRAM_ID, }; -use light_token_sdk::compressed_token::create_compressed_mint::{ - derive_mint_compressed_address, find_mint_address, -}; use light_token_types::CPI_AUTHORITY_PDA; use sdk_token_test::{ChainedCtokenInstructionData, PdaCreationData, ID}; use solana_sdk::{ diff --git a/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs b/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs index b40056d2eb..a7d5883a51 100644 --- a/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs +++ b/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs @@ -7,11 +7,11 @@ const TEST_INPUT_RANGE: [usize; 4] = [1, 2, 3, 4]; use light_program_test::{Indexer, LightProgramTest, ProgramTestConfig, Rpc}; use light_sdk::instruction::PackedAccounts; use light_test_utils::airdrop_lamports; -use light_token_client::{actions::mint_action_comprehensive, instructions::mint_action::NewMint}; -use light_token_interface::instructions::mint_action::{MintWithContext, Recipient}; -use light_token_sdk::compressed_token::{ +use light_token::compressed_token::{ create_compressed_mint::find_mint_address, decompress_full::DecompressFullAccounts, }; +use light_token_client::{actions::mint_action_comprehensive, instructions::mint_action::NewMint}; +use light_token_interface::instructions::mint_action::{MintWithContext, Recipient}; use sdk_token_test::mint_compressed_tokens_cpi_write::MintCompressedTokensCpiWriteParams; use solana_sdk::{ instruction::{AccountMeta, Instruction}, @@ -54,7 +54,7 @@ async fn setup_decompress_full_test(num_inputs: usize) -> (LightProgramTest, Tes .await .unwrap(); - use light_token_sdk::token::{ + use light_token::instruction::{ derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, }; @@ -240,7 +240,7 @@ async fn test_decompress_full_cpi() { .zip(ctx.destination_accounts.iter()) .zip(versions.iter()) .map(|(((token, tree_info), &dest_pubkey), &version)| { - light_token_sdk::compressed_token::decompress_full::pack_for_decompress_full( + light_token::compressed_token::decompress_full::pack_for_decompress_full( token, tree_info, dest_pubkey, @@ -350,7 +350,7 @@ async fn test_decompress_full_cpi_with_context() { let address_tree_info = rpc.get_address_tree_v2(); let compressed_mint_address = - light_token_sdk::compressed_token::create_compressed_mint::derive_mint_compressed_address( + light_token::compressed_token::create_compressed_mint::derive_mint_compressed_address( &ctx.mint_seed.pubkey(), &address_tree_info.tree, ); @@ -446,7 +446,7 @@ async fn test_decompress_full_cpi_with_context() { .zip(ctx.destination_accounts.iter()) .zip(versions.iter()) .map(|(((token, tree_info), &dest_pubkey), &version)| { - light_token_sdk::compressed_token::decompress_full::pack_for_decompress_full( + light_token::compressed_token::decompress_full::pack_for_decompress_full( token, tree_info, dest_pubkey, diff --git a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs index b9cace9e17..e6abc50a64 100644 --- a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs +++ b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs @@ -6,6 +6,10 @@ use light_client::indexer::Indexer; use light_compressed_account::{address::derive_address, hash_to_bn254_field_size_be}; use light_program_test::{LightProgramTest, ProgramTestConfig, Rpc, RpcError}; use light_sdk::instruction::{PackedAccounts, SystemAccountMetaConfig}; +use light_token::{ + compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, + instruction::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, +}; use light_token_interface::{ instructions::{ extensions::token_metadata::TokenMetadataInstructionData, @@ -14,10 +18,6 @@ use light_token_interface::{ state::{extensions::AdditionalMetadata, MintMetadata}, LIGHT_TOKEN_PROGRAM_ID, }; -use light_token_sdk::{ - compressed_token::create_compressed_mint::{derive_mint_compressed_address, find_mint_address}, - token::{derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount}, -}; use light_token_types::CPI_AUTHORITY_PDA; use sdk_token_test::{ChainedCtokenInstructionData, PdaCreationData, ID}; use solana_sdk::{ diff --git a/sdk-tests/sdk-token-test/tests/test.rs b/sdk-tests/sdk-token-test/tests/test.rs index 4beff199fd..60614ae176 100644 --- a/sdk-tests/sdk-token-test/tests/test.rs +++ b/sdk-tests/sdk-token-test/tests/test.rs @@ -9,7 +9,7 @@ use light_test_utils::{ spl::{create_mint_helper, create_token_account, mint_spl_tokens}, RpcError, }; -use light_token_sdk::{ +use light_token::{ compressed_token::{ batch_compress::{ get_batch_compress_instruction_account_metas, BatchCompressMetaConfig, Recipient, diff --git a/sdk-tests/sdk-token-test/tests/test_4_invocations.rs b/sdk-tests/sdk-token-test/tests/test_4_invocations.rs index a8c2508101..56a98cc3c8 100644 --- a/sdk-tests/sdk-token-test/tests/test_4_invocations.rs +++ b/sdk-tests/sdk-token-test/tests/test_4_invocations.rs @@ -8,7 +8,7 @@ use light_test_utils::{ spl::{create_mint_helper, create_token_account, mint_spl_tokens}, RpcError, }; -use light_token_sdk::{ +use light_token::{ compressed_token::{ transfer::account_metas::{ get_transfer_instruction_account_metas, TokenAccountsMetaConfig, diff --git a/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs b/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs index f160b1fe87..7bef0f5749 100644 --- a/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs +++ b/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs @@ -5,6 +5,14 @@ use light_sdk::{ instruction::{PackedAccounts, PackedStateTreeInfo, SystemAccountMetaConfig}, }; use light_test_utils::RpcError; +use light_token::{ + compressed_token::{ + create_compressed_mint::{create_compressed_mint, CreateMintInputs}, + mint_to_compressed::{create_mint_to_compressed_instruction, MintToCompressedInputs}, + }, + instruction::CreateAssociatedTokenAccount, + utils::TokenDefaultAccounts, +}; use light_token_interface::{ instructions::{ mint_action::{MintWithContext, Recipient}, @@ -13,14 +21,6 @@ use light_token_interface::{ state::{BaseMint, MintMetadata, ACCOUNT_TYPE_MINT}, COMPRESSED_MINT_SEED, }; -use light_token_sdk::{ - compressed_token::{ - create_compressed_mint::{create_compressed_mint, CreateMintInputs}, - mint_to_compressed::{create_mint_to_compressed_instruction, MintToCompressedInputs}, - }, - token::CreateAssociatedTokenAccount, - utils::TokenDefaultAccounts, -}; use solana_sdk::{ instruction::Instruction, pubkey::Pubkey, @@ -95,7 +95,7 @@ async fn create_compressed_mints_and_tokens( // Create associated token account for mint1 decompression let (token_account1_pubkey, _bump) = - light_token_sdk::token::derive_token_ata(&payer.pubkey(), &mint1_pda); + light_token::instruction::derive_token_ata(&payer.pubkey(), &mint1_pda); let create_ata_instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint1_pda) .instruction() diff --git a/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs b/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs index 780479e05a..7ef13f96d0 100644 --- a/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs +++ b/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs @@ -4,22 +4,22 @@ use anchor_lang::{ }; use light_program_test::{Indexer, LightProgramTest, ProgramTestConfig, Rpc}; use light_sdk::instruction::{PackedAccounts, SystemAccountMetaConfig}; -use light_token_client::instructions::transfer2::create_decompress_instruction; -use light_token_interface::{ - instructions::mint_action::{MintWithContext, Recipient}, - state::{BaseMint, Mint, MintMetadata, TokenDataVersion, ACCOUNT_TYPE_MINT}, - COMPRESSED_MINT_SEED, LIGHT_TOKEN_PROGRAM_ID, -}; -use light_token_sdk::{ +use light_token::{ compressed_token::{ create_compressed_mint::{create_compressed_mint, CreateMintInputs}, mint_to_compressed::{create_mint_to_compressed_instruction, MintToCompressedInputs}, }, - token::{ + instruction::{ config_pda, derive_token_ata, rent_sponsor_pda, CompressibleParams, CreateAssociatedTokenAccount, }, }; +use light_token_client::instructions::transfer2::create_decompress_instruction; +use light_token_interface::{ + instructions::mint_action::{MintWithContext, Recipient}, + state::{BaseMint, Mint, MintMetadata, TokenDataVersion, ACCOUNT_TYPE_MINT}, + COMPRESSED_MINT_SEED, LIGHT_TOKEN_PROGRAM_ID, +}; use sdk_token_test::instruction; use serial_test::serial; use solana_sdk::{ diff --git a/sdk-tests/sdk-token-test/tests/test_compress_to_pubkey.rs b/sdk-tests/sdk-token-test/tests/test_compress_to_pubkey.rs index a861514e5d..4a3b8ccb4a 100644 --- a/sdk-tests/sdk-token-test/tests/test_compress_to_pubkey.rs +++ b/sdk-tests/sdk-token-test/tests/test_compress_to_pubkey.rs @@ -4,7 +4,7 @@ use light_program_test::{ }; use light_sdk::instruction::PackedAccounts; use light_test_utils::spl::create_mint_helper; -use light_token_sdk::token::LIGHT_TOKEN_PROGRAM_ID; +use light_token::instruction::LIGHT_TOKEN_PROGRAM_ID; use solana_sdk::{ instruction::{AccountMeta, Instruction}, pubkey::Pubkey, diff --git a/sdk-tests/sdk-token-test/tests/test_create_two_mints.rs b/sdk-tests/sdk-token-test/tests/test_create_two_mints.rs index 680327ce0e..8a7f23a014 100644 --- a/sdk-tests/sdk-token-test/tests/test_create_two_mints.rs +++ b/sdk-tests/sdk-token-test/tests/test_create_two_mints.rs @@ -1,6 +1,6 @@ use anchor_lang::InstructionData; use light_program_test::{AddressWithTree, Indexer, LightProgramTest, ProgramTestConfig, Rpc}; -use light_token_sdk::token::{ +use light_token::instruction::{ config_pda, derive_mint_compressed_address, find_mint_address, rent_sponsor_pda, SystemAccounts, LIGHT_TOKEN_PROGRAM_ID, }; diff --git a/sdk-tests/sdk-token-test/tests/test_deposit.rs b/sdk-tests/sdk-token-test/tests/test_deposit.rs index 396d2cfecc..9e651975e4 100644 --- a/sdk-tests/sdk-token-test/tests/test_deposit.rs +++ b/sdk-tests/sdk-token-test/tests/test_deposit.rs @@ -9,7 +9,7 @@ use light_test_utils::{ spl::{create_mint_helper, create_token_account, mint_spl_tokens}, RpcError, }; -use light_token_sdk::{ +use light_token::{ compressed_token::batch_compress::{ get_batch_compress_instruction_account_metas, BatchCompressMetaConfig, Recipient, }, diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 3c21e458b0..4e9e672f69 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -27,7 +27,7 @@ tabled = "0.20" light-test-utils = { workspace = true } tokio = { workspace = true } solana-sdk = { workspace = true } -light-program-test = { workspace = true, features = ["v2"] } +light-program-test = { workspace = true } light-client = { workspace = true } dirs = "6.0" serde_json = "1.0.140" @@ -37,5 +37,5 @@ light-batched-merkle-tree = { workspace = true } light-registry = { workspace = true } light-compressible = { workspace = true } anchor-lang = { workspace = true } -light-token-sdk = { workspace = true } +light-token = { workspace = true } chrono = "0.4" diff --git a/xtask/src/create_ctoken_account.rs b/xtask/src/create_ctoken_account.rs index 6aa3363ecd..4e03c7250d 100644 --- a/xtask/src/create_ctoken_account.rs +++ b/xtask/src/create_ctoken_account.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use clap::Parser; use dirs::home_dir; use light_client::rpc::{LightClient, LightClientConfig, Rpc}; -use light_token_sdk::token::{CompressibleParams, CreateTokenAccount}; +use light_token::instruction::{CompressibleParams, CreateTokenAccount}; use solana_sdk::{ signature::{read_keypair_file, Keypair, Signer}, transaction::Transaction,