Skip to content

Commit 016b6b4

Browse files
author
tilo-14
committed
Reorganize anchor/ examples into standalone projects
- Convert monorepo to 5 independent Anchor projects - Each operation (create, update, close, reinit, burn) is now standalone - Add setup helpers in each test file - Replace sleep() with confirmTransactionIndexed() for reliable test synchronization - Add comprehensive README with technical descriptions - Update counter example with confirmTransactionIndexed() Each project contains: - Complete workspace configuration - Program with single operation instruction - Rust tests in programs/{name}/tests/test.rs - TypeScript tests in tests/{name}.ts - Independent build and test capability
1 parent b3b167c commit 016b6b4

71 files changed

Lines changed: 49245 additions & 2015 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎basic-operations/anchor/Anchor.toml‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎basic-operations/anchor/README.md‎

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
# Basic Operations - Anchor Programs
22

3-
Programs built with the Anchor framework with basic compressed account operations.
3+
Standalone Anchor programs for compressed accounts.
44

5-
## Programs
5+
## Structure
66

7-
- **create** - Initialize a new compressed account
8-
- **update** - Modify data in an existing compressed account
9-
- **close** - Close a compressed account and reclaim rent
10-
- **reinit** - Reinitialize a previously closed compressed account
11-
- **burn** - Permanently destroy a compressed account (cannot be reinitialized)
7+
Each operation is an independent Anchor project:
8+
9+
- **create** - Initialize a new compressed account with `new_init()`
10+
- **update** - Modify data in an existing compressed account with `new_mut()`
11+
- **close** - Clear account data while preserving address with `new_close()`
12+
- **reinit** - Reinitialize a closed account with `new_empty()`
13+
- **burn** - Permanently delete a compressed account with `new_burn()`
14+
15+
Each project contains its own workspace, program, and tests.
1216

1317
## Build
1418

15-
Build all programs in the workspace:
19+
Navigate to a specific project directory and build:
1620

1721
```bash
22+
cd create/ # or update/, close/, reinit/, burn/
1823
anchor build
1924
```
2025

@@ -32,39 +37,35 @@ anchor build
3237
#### Rust Tests
3338

3439
```bash
40+
cd create/ # or update/, close/, reinit/, burn/
3541
cargo test-sbf
3642
```
3743

3844
#### TypeScript Tests
3945

40-
1. Build the programs and sync program IDs:
46+
1. Build the program and sync the program ID:
4147

4248
```bash
49+
cd create/ # or update/, close/, reinit/, burn/
4350
anchor build && anchor keys sync && anchor build
4451
```
4552

46-
2. Start the test validator with deployed programs:
53+
2. Start the test validator with the program deployed:
4754

4855
```bash
49-
light test-validator \
50-
--sbf-program "<PROGRAM_ID_CREATE>" ./target/deploy/create.so \
51-
--sbf-program "<PROGRAM_ID_UPDATE>" ./target/deploy/update.so \
52-
--sbf-program "<PROGRAM_ID_CLOSE>" ./target/deploy/close.so \
53-
--sbf-program "<PROGRAM_ID_REINIT>" ./target/deploy/reinit.so \
54-
--sbf-program "<PROGRAM_ID_BURN>" ./target/deploy/burn.so
56+
light test-validator --sbf-program "<PROGRAM_ID>" ./target/deploy/<program_name>.so
5557
```
5658

57-
NOTE: Replace program IDs with those in your `Anchor.toml` file.
59+
NOTE: Replace `<PROGRAM_ID>` with the ID from `Anchor.toml` and `<program_name>` with `create`, `update`, `close`, `reinit`, or `burn`.
5860

5961
3. Install dependencies and run tests:
6062

6163
```bash
6264
npm install
63-
6465
anchor test --skip-local-validator --skip-build --skip-deploy
6566
```
6667

67-
The TypeScript tests demonstrate client-side interaction with compressed accounts using `@lightprotocol/stateless.js` and `@lightprotocol/zk-compression-cli`.
68+
The TypeScript tests demonstrate client-side interaction with compressed accounts using `@lightprotocol/stateless.js`.
6869

6970
`light test-validator` spawns the following background processes:
7071

@@ -78,4 +79,4 @@ You can kill these background processes with `lsof -i:<port>` and `kill <pid>`.
7879

7980
This reference implementation is not audited.
8081

81-
The Light Protocol programs are audited and deployed on Solana devnet and mainnet.
82+
The Light Protocol programs are audited and deployed on Solana devnet and mainnet.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.anchor
2+
.DS_Store
3+
target
4+
**/*.rs.bk
5+
node_modules
6+
test-ledger
7+
.yarn
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[toolchain]
2+
3+
[features]
4+
resolution = true
5+
skip-lint = false
6+
7+
[programs.localnet]
8+
burn = "A1KqLAv8emDMsoGTUcf5r9hxrC1PXQ5rtr8EnBnBY6hR"
9+
10+
[registry]
11+
url = "https://api.apr.dev"
12+
13+
[provider]
14+
cluster = "localnet"
15+
wallet = "~/.config/solana/id.json"
16+
17+
[scripts]
18+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

0 commit comments

Comments
 (0)