Skip to content

Commit 3aae061

Browse files
committed
stash
1 parent 0c50564 commit 3aae061

File tree

14 files changed

+297
-0
lines changed

14 files changed

+297
-0
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ members = [
2525
"sdk-libs/sdk-types",
2626
"sdk-libs/photon-api",
2727
"sdk-libs/program-test",
28+
"sdk-libs/compressed-token-types",
2829
"xtask",
2930
"examples/anchor/token-escrow",
3031
# "examples/anchor/name-service-without-macros",
@@ -60,6 +61,10 @@ strip = "none"
6061
[profile.release]
6162
overflow-checks = true
6263

64+
[workspace.package]
65+
version = "0.1.0"
66+
edition = "2021"
67+
6368
[workspace.dependencies]
6469
solana-banks-client = { version = "2.2" }
6570
solana-banks-interface = { version = "2.2" }
@@ -175,6 +180,7 @@ account-compression = { path = "programs/account-compression", version = "1.2.0"
175180
light-compressed-token = { path = "programs/compressed-token", version = "1.2.0", features = [
176181
"cpi",
177182
] }
183+
light-compressed-token-types = { path = "sdk-libs/compressed-token-types", name = "light-compressed-token-types" }
178184
light-system-program-anchor = { path = "anchor-programs/system", version = "1.2.0", features = [
179185
"cpi",
180186
] }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "light-compressed-token-types"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
borsh = { workspace = true }
8+
light-macros = { workspace = true }
9+
10+
[dev-dependencies]
11+
solana-pubkey = { workspace = true }
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use light_macros::pubkey_array;
2+
3+
// Program ID for light-compressed-token
4+
pub const PROGRAM_ID: [u8; 32] = pubkey_array!("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");
5+
6+
// SPL Token Program ID
7+
pub const SPL_TOKEN_PROGRAM_ID: [u8; 32] =
8+
pubkey_array!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
9+
10+
// SPL Token 2022 Program ID
11+
pub const SPL_TOKEN_2022_PROGRAM_ID: [u8; 32] =
12+
pubkey_array!("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
13+
14+
// Light System Program ID
15+
pub const LIGHT_SYSTEM_PROGRAM_ID: [u8; 32] =
16+
pubkey_array!("SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7");
17+
18+
// Account Compression Program ID
19+
pub const ACCOUNT_COMPRESSION_PROGRAM_ID: [u8; 32] =
20+
pubkey_array!("compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq");
21+
22+
// Noop Program ID
23+
pub const NOOP_PROGRAM_ID: [u8; 32] = pubkey_array!("noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV");
24+
25+
// CPI Authority PDA seed
26+
pub const CPI_AUTHORITY_PDA_SEED: &[u8] = b"cpi_authority";
27+
28+
pub const CPI_AUTHORITY_PDA: [u8; 32] =
29+
pubkey_array!("GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy");
30+
31+
// 2 in little endian
32+
pub const TOKEN_COMPRESSED_ACCOUNT_DISCRIMINATOR: [u8; 8] = [2, 0, 0, 0, 0, 0, 0, 0];
33+
pub const BUMP_CPI_AUTHORITY: u8 = 254;
34+
pub const NOT_FROZEN: bool = false;
35+
pub const POOL_SEED: &[u8] = b"pool";
36+
37+
/// Maximum number of pool accounts that can be created for each mint.
38+
pub const NUM_MAX_POOL_ACCOUNTS: u8 = 5;
39+
pub const MINT_TO: [u8; 8] = [241, 34, 48, 186, 37, 179, 123, 192];
40+
pub const TRANSFER: [u8; 8] = [163, 52, 200, 231, 140, 3, 69, 186];
41+
pub const BATCH_COMPRESS: [u8; 8] = [65, 206, 101, 37, 147, 42, 221, 144];
42+
pub const APPROVE: [u8; 8] = [69, 74, 217, 36, 115, 117, 97, 76];
43+
pub const REVOKE: [u8; 8] = [170, 23, 31, 34, 133, 173, 93, 242];
44+
pub const FREEZE: [u8; 8] = [255, 91, 207, 84, 251, 194, 254, 63];
45+
pub const THAW: [u8; 8] = [226, 249, 34, 57, 189, 21, 177, 101];
46+
pub const CREATE_TOKEN_POOL: [u8; 8] = [23, 169, 27, 122, 147, 169, 209, 152];
47+
pub const CREATE_ADDITIONAL_TOKEN_POOL: [u8; 8] = [114, 143, 210, 73, 96, 115, 1, 228];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
3+
#[derive(Debug, Default, Clone, PartialEq, BorshSerialize, BorshDeserialize)]
4+
pub struct BatchCompressInstructionData {
5+
pub pubkeys: Vec<[u8; 32]>,
6+
// Some if one amount per pubkey.
7+
pub amounts: Option<Vec<u64>>,
8+
pub lamports: Option<u64>,
9+
// Some if one amount across all pubkeys.
10+
pub amount: Option<u64>,
11+
pub index: u8,
12+
pub bump: u8,
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
use crate::instruction::transfer::{CompressedProof, InputTokenDataWithContext, CompressedCpiContext, DelegatedTransfer};
3+
4+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
5+
pub struct CompressedTokenInstructionDataBurn {
6+
pub proof: CompressedProof,
7+
pub input_token_data_with_context: Vec<InputTokenDataWithContext>,
8+
pub cpi_context: Option<CompressedCpiContext>,
9+
pub burn_amount: u64,
10+
pub change_account_merkle_tree_index: u8,
11+
pub delegated_transfer: Option<DelegatedTransfer>,
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
use crate::instruction::transfer::{CompressedProof, InputTokenDataWithContext, CompressedCpiContext};
3+
4+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
5+
pub struct CompressedTokenInstructionDataApprove {
6+
pub proof: CompressedProof,
7+
pub mint: [u8; 32],
8+
pub input_token_data_with_context: Vec<InputTokenDataWithContext>,
9+
pub cpi_context: Option<CompressedCpiContext>,
10+
pub delegate: [u8; 32],
11+
pub delegated_amount: u64,
12+
/// Index in remaining accounts.
13+
pub delegate_merkle_tree_index: u8,
14+
/// Index in remaining accounts.
15+
pub change_account_merkle_tree_index: u8,
16+
pub delegate_lamports: Option<u64>,
17+
}
18+
19+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
20+
pub struct CompressedTokenInstructionDataRevoke {
21+
pub proof: CompressedProof,
22+
pub mint: [u8; 32],
23+
pub input_token_data_with_context: Vec<InputTokenDataWithContext>,
24+
pub cpi_context: Option<CompressedCpiContext>,
25+
pub output_account_merkle_tree_index: u8,
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
use crate::instruction::transfer::{CompressedProof, InputTokenDataWithContext, CompressedCpiContext};
3+
4+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
5+
pub struct CompressedTokenInstructionDataFreeze {
6+
pub proof: CompressedProof,
7+
pub owner: [u8; 32],
8+
pub input_token_data_with_context: Vec<InputTokenDataWithContext>,
9+
pub cpi_context: Option<CompressedCpiContext>,
10+
pub outputs_merkle_tree_index: u8,
11+
}
12+
13+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
14+
pub struct CompressedTokenInstructionDataThaw {
15+
pub proof: CompressedProof,
16+
pub owner: [u8; 32],
17+
pub input_token_data_with_context: Vec<InputTokenDataWithContext>,
18+
pub cpi_context: Option<CompressedCpiContext>,
19+
pub outputs_merkle_tree_index: u8,
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
3+
// Generic instruction data wrapper that can hold any instruction data as bytes
4+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
5+
pub struct GenericInstructionData {
6+
pub instruction_data: Vec<u8>,
7+
}
8+
9+
// Type alias for the main generic instruction data type
10+
pub type CompressedTokenInstructionData = GenericInstructionData;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use borsh::{BorshDeserialize, BorshSerialize};
2+
3+
// Note: MintToInstruction is an Anchor account struct, not an instruction data struct
4+
// This file is for completeness but there's no specific MintToInstructionData type
5+
// The mint_to instruction uses pubkeys and amounts directly as parameters
6+
7+
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
8+
pub struct MintToParams {
9+
pub public_keys: Vec<[u8; 32]>,
10+
pub amounts: Vec<u64>,
11+
pub lamports: Option<u64>,
12+
}

0 commit comments

Comments
 (0)