Skip to content

feat: add native program examples #8

Closed
tilo-14 wants to merge 12 commits into
mainfrom
feat/native-program-examples
Closed

feat: add native program examples #8
tilo-14 wants to merge 12 commits into
mainfrom
feat/native-program-examples

Conversation

@tilo-14
Copy link
Copy Markdown
Member

@tilo-14 tilo-14 commented Jan 17, 2026

Summary

  • Native Solana program demonstrating compressed token operations using light-sdk
  • Instructions: mint, transfer, approve, revoke, burn, freeze, thaw, close
  • Rust SBF integration tests
  • TypeScript tests

Test plan

  • Run Rust tests: cd native/program && cargo test-sbf
  • Run TS tests: cd native && pnpm test

Open with Devin

@tilo-14 tilo-14 changed the title feat: add native program examples for compressed tokens feat: add native program examples Jan 17, 2026
Comment thread program-examples/native/program/src/instructions/create_ata.rs Outdated
@tilo-14 tilo-14 force-pushed the feat/native-program-examples branch from dabdc4e to 2fffdbf Compare January 17, 2026 17:55
Comment thread program-examples/native/program/program-keypair.json Outdated
@tilo-14 tilo-14 force-pushed the feat/native-program-examples branch from 9d21014 to 59f9ff7 Compare January 21, 2026 23:14
Comment thread program-examples/native/README.md Outdated
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

- 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
Comment thread program-examples/native-rust/program/src/instructions/create_ata.rs
Comment thread program-examples/native-rust/program/src/instructions/create_ata.rs
Comment thread program-examples/native-rust/program/src/instructions/create_ata.rs
Comment thread program-examples/native/program/src/instructions/create_mint.rs Outdated
tilo-14 added 4 commits January 23, 2026 12:50
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.
Comment thread program-examples/native-rust/program/src/instructions/approve.rs
Comment thread program-examples/native-rust/program/src/instructions/approve.rs
Comment thread program-examples/native-rust/program/src/instructions/create_ata.rs
Comment thread program-examples/native-rust/program/src/instructions/mod.rs
Comment thread program-examples/native-rust/program/tests/shared.rs
tilo-14 and others added 5 commits January 23, 2026 18:17
- 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>
Comment thread program-examples/native-rust/Cargo.toml Outdated
[workspace.dependencies]
# Pin to match light-protocol Cargo.lock
constant_time_eq = "=0.3.1"
blake3 = "=1.5.5"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
blake3 = "=1.5.5"
blake3 = "=1.8.2"

Comment thread program-examples/native-rust/README.md Outdated

- **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
Copy link
Copy Markdown
Contributor

@ananas-block ananas-block Jan 27, 2026

Choose a reason for hiding this comment

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

Suggested change
- **create-ata** - Create an associated light-token account via CPI
- **create-associated** - Create an associated light-token account via CPI

Comment thread program-examples/native-rust/README.md Outdated
- **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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alphabetic order pls

Comment on lines +16 to +17
light-token-interface = "0.3.0"
light-compressible = "0.4.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we shouldn't depend on these crates directly light-token should reexport everything. If something is not reexported we should add it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

light-sdk
light-token
light-client
light program test

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

light token interface should be reexported out of light token interface

return Err(ProgramError::NotEnoughAccountKeys);
};

// Close token account. Must be empty (balance = 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Close token account. Must be empty (balance = 0)
// Close token account. Must be empty (balance == 0)

}

#[derive(BorshDeserialize)]
struct CreateMintSignedData {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

atas -> associated_token_accounts pls


// Build instruction data
#[derive(BorshSerialize)]
struct CreateMintDataTest {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why dont we import the program defined struct?


// Build instruction data
#[derive(BorshSerialize)]
struct CreateMintSignedDataTest {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pls use the program defined struct

@tilo-14 tilo-14 closed this Jan 29, 2026
@tilo-14 tilo-14 deleted the feat/native-program-examples branch February 2, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants