feat: add native program examples #8
Conversation
dabdc4e to
2fffdbf
Compare
9d21014 to
59f9ff7
Compare
- Format account destructuring across multiple lines for readability - Remove program-keypair.json (should not be committed) - Remove AI index line from README - Use authority_seeds! macro consistently in create_token_account.rs and create_mint.rs
Replace manual proof fields (proof_a, proof_b, proof_c, address_merkle_tree_root_index) with CreateAccountsProof struct from light-compressible crate for cleaner serialization.
- Add transfer_checked CPI instruction with decimal validation - Add mint_to_checked CPI instruction with decimal validation - Update Cargo.toml to use public crates from crates.io - Refactor tests to use COMPRESSIBLE_CONFIG_V1 constant - Update README with new instructions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…lify test comments
| [workspace.dependencies] | ||
| # Pin to match light-protocol Cargo.lock | ||
| constant_time_eq = "=0.3.1" | ||
| blake3 = "=1.5.5" |
There was a problem hiding this comment.
| blake3 = "=1.5.5" | |
| blake3 = "=1.8.2" |
|
|
||
| - **create-mint** - Create a light-token mint via CPI | ||
| - [Instruction](program/src/instructions/create_mint.rs) | [Test](program/tests/create_mint.rs) | ||
| - **create-ata** - Create an associated light-token account via CPI |
There was a problem hiding this comment.
| - **create-ata** - Create an associated light-token account via CPI | |
| - **create-associated** - Create an associated light-token account via CPI |
| - **thaw** - Thaw token account via CPI | ||
| - [Instruction](program/src/instructions/thaw.rs) | [Test](program/tests/thaw.rs) | ||
| - **close** - Close token account via CPI | ||
| - [Instruction](program/src/instructions/close.rs) | [Test](program/tests/close.rs) |
| light-token-interface = "0.3.0" | ||
| light-compressible = "0.4.0" |
There was a problem hiding this comment.
we shouldn't depend on these crates directly light-token should reexport everything. If something is not reexported we should add it.
There was a problem hiding this comment.
light-sdk
light-token
light-client
light program test
There was a problem hiding this comment.
light token interface should be reexported out of light token interface
| return Err(ProgramError::NotEnoughAccountKeys); | ||
| }; | ||
|
|
||
| // Close token account. Must be empty (balance = 0) |
There was a problem hiding this comment.
| // Close token account. Must be empty (balance = 0) | |
| // Close token account. Must be empty (balance == 0) |
| } | ||
|
|
||
| #[derive(BorshDeserialize)] | ||
| struct CreateMintSignedData { |
There was a problem hiding this comment.
can't we use the same instruction data for both?
|
|
||
| #[tokio::test(flavor = "multi_thread")] | ||
| async fn approve_cpi() { | ||
| // Setup: create mint and ATA with tokens |
There was a problem hiding this comment.
atas -> associated_token_accounts pls
|
|
||
| // Build instruction data | ||
| #[derive(BorshSerialize)] | ||
| struct CreateMintDataTest { |
There was a problem hiding this comment.
why dont we import the program defined struct?
|
|
||
| // Build instruction data | ||
| #[derive(BorshSerialize)] | ||
| struct CreateMintSignedDataTest { |
There was a problem hiding this comment.
pls use the program defined struct
Summary
Test plan
cd native/program && cargo test-sbfcd native && pnpm test