Skip to content

Commit bd37cbd

Browse files
author
tilo-14
committed
Bump compressed PDA docs to program-examples 0.23.0
- Update light-sdk from 0.16.0/0.19.0 to 0.23.0 across all compressed PDA guides, setup snippets, and client guide - Fix Rust imports: light_sdk_types::ADDRESS_TREE_V2 → light_sdk::constants::ADDRESS_TREE_V2, add PackedAddressTreeInfoExt - Update TS client snippets: replace deprecated defaultTestStateTreeAccounts with selectStateTreeInfo/TreeInfo pattern, use stateTreeInfo.queue for output tree, set proveByIndex: true - Bump CLI prereqs: Rust 1.90.0, Solana CLI 2.3.11, Node.js 22+ - All snippets verified identical to program-examples source
1 parent f265a66 commit bd37cbd

20 files changed

Lines changed: 84 additions & 69 deletions

pda/compressed-pdas/guides/client-guide.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ light test-validator
201201

202202
```toml
203203
[dependencies]
204-
light-client = "0.16.0"
205-
light-sdk = "0.16.0"
204+
light-client = "0.23.0"
205+
light-sdk = "0.23.0"
206206
```
207207

208208
### 2. RPC Connection

pda/compressed-pdas/guides/how-to-create-compressed-accounts.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ Add dependencies to your program.
4848
<CodeGroup>
4949
```toml Anchor
5050
[dependencies]
51-
light-sdk = "0.16.0"
51+
light-sdk = "0.23.0"
5252
anchor_lang = "0.31.1"
5353
```
5454

5555
```toml Native Rust
5656
[dependencies]
57-
light-sdk = "0.16.0"
58-
borsh = "0.10.0"
57+
light-sdk = "0.23.0"
58+
borsh = "0.10.4"
5959
solana-program = "2.2"
6060
```
6161
</CodeGroup>

pda/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ For the usage example source code, see here: [create_nullifier.rs](https://githu
4242
```toml
4343
[dependencies]
4444
light-nullifier-program = "0.1.2"
45-
light-client = "0.19.0"
45+
light-client = "0.23.0"
4646
```
4747

4848
</Tab>

pda/compressed-pdas/overview.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ For DeFi pools, vaults, shared state, pool accounts, or config accounts, use [Li
102102
<Info>
103103
Required versions:
104104

105-
* **Rust**: 1.86.0 or later
106-
* **Solana CLI**: 2.2.15
105+
* **Rust**: 1.90.0 or later
106+
* **Solana CLI**: 2.3.11 or later
107107
* **Anchor CLI**: 0.31.1
108108
* **Zk compression CLI**: 0.27.0 or later
109-
* **Node.js**: 23.5.0 or later
109+
* **Node.js**: 22 or later
110110
</Info>
111111
<DevelopmentEnvironmentSetup />
112112

snippets/code-snippets/burn/anchor-program.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use light_sdk::{
99
cpi::{v2::CpiAccounts, CpiSigner},
1010
derive_light_cpi_signer,
1111
instruction::{account_meta::CompressedAccountMetaBurn, PackedAddressTreeInfo, ValidityProof},
12-
LightDiscriminator,
12+
LightDiscriminator, PackedAddressTreeInfoExt,
1313
};
14-
use light_sdk_types::ADDRESS_TREE_V2;
14+
use light_sdk::constants::ADDRESS_TREE_V2;
1515

1616
declare_id!("BJhPWQnD31mdo6739Mac1gLuSsbbwTmpgjHsW6shf6WA");
1717

snippets/code-snippets/burn/native-program.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use light_sdk::{
1818
instruction::{account_meta::CompressedAccountMetaBurn, PackedAddressTreeInfo, ValidityProof},
1919
LightDiscriminator,
2020
};
21-
use light_sdk_types::ADDRESS_TREE_V2;
21+
use light_sdk::constants::ADDRESS_TREE_V2;
22+
use light_sdk::PackedAddressTreeInfoExt;
2223
use solana_program::{
2324
account_info::AccountInfo, entrypoint, program_error::ProgramError, pubkey::Pubkey,
2425
};

snippets/code-snippets/burn/typescript-client.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
CompressedAccountWithMerkleContext,
99
confirmTx,
1010
createRpc,
11-
defaultTestStateTreeAccounts,
1211
deriveAddressV2,
1312
deriveAddressSeedV2,
1413
batchAddressTree,
@@ -18,6 +17,8 @@ import {
1817
SystemAccountMetaConfig,
1918
featureFlags,
2019
VERSION,
20+
selectStateTreeInfo,
21+
TreeInfo,
2122
} from "@lightprotocol/stateless.js";
2223
import * as assert from "assert";
2324

@@ -49,7 +50,8 @@ describe("test-anchor-burn", () => {
4950
await rpc.requestAirdrop(signer.publicKey, lamports);
5051
await sleep(2000);
5152

52-
const outputStateTree = defaultTestStateTreeAccounts().merkleTree;
53+
const stateTreeInfos = await rpc.getStateTreeInfos();
54+
const stateTreeInfo = selectStateTreeInfo(stateTreeInfos);
5355
const addressTree = new web3.PublicKey(batchAddressTree);
5456

5557
const messageSeed = new TextEncoder().encode("message");
@@ -66,7 +68,7 @@ describe("test-anchor-burn", () => {
6668
addressTree,
6769
address,
6870
burnProgram,
69-
outputStateTree,
71+
stateTreeInfo,
7072
signer,
7173
"Hello, compressed world!",
7274
);
@@ -116,7 +118,7 @@ async function createCompressedAccount(
116118
addressTree: anchor.web3.PublicKey,
117119
address: anchor.web3.PublicKey,
118120
program: anchor.Program<Burn>,
119-
outputStateTree: anchor.web3.PublicKey,
121+
stateTreeInfo: TreeInfo,
120122
signer: anchor.web3.Keypair,
121123
message: string,
122124
) {
@@ -143,7 +145,7 @@ async function createCompressedAccount(
143145
addressQueuePubkeyIndex,
144146
};
145147
const outputStateTreeIndex =
146-
remainingAccounts.insertOrGet(outputStateTree);
148+
remainingAccounts.insertOrGet(stateTreeInfo.queue);
147149

148150
let proof = {
149151
0: proofRpcResult.compressedProof,
@@ -203,7 +205,7 @@ async function burnCompressedAccount(
203205
merkleTreePubkeyIndex,
204206
queuePubkeyIndex,
205207
leafIndex: compressedAccount.leafIndex,
206-
proveByIndex: false,
208+
proveByIndex: true,
207209
rootIndex: proofRpcResult.rootIndices[0],
208210
},
209211
address: compressedAccount.address,

snippets/code-snippets/close/anchor-program.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use light_sdk::{
99
cpi::{v2::CpiAccounts, CpiSigner},
1010
derive_light_cpi_signer,
1111
instruction::{account_meta::CompressedAccountMeta, PackedAddressTreeInfo, ValidityProof},
12-
LightDiscriminator,
12+
LightDiscriminator, PackedAddressTreeInfoExt,
1313
};
14-
use light_sdk_types::ADDRESS_TREE_V2;
14+
use light_sdk::constants::ADDRESS_TREE_V2;
1515

1616
declare_id!("DzQ3za3DVCpXkXhmZVSrNchwbbSsJXmi9MBc8v5tvZuQ");
1717

snippets/code-snippets/close/native-program.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use light_sdk::{
1818
instruction::{account_meta::CompressedAccountMeta, PackedAddressTreeInfo, ValidityProof},
1919
LightDiscriminator,
2020
};
21-
use light_sdk_types::ADDRESS_TREE_V2;
21+
use light_sdk::constants::ADDRESS_TREE_V2;
22+
use light_sdk::PackedAddressTreeInfoExt;
2223
use solana_program::{
2324
account_info::AccountInfo, entrypoint, program_error::ProgramError, pubkey::Pubkey,
2425
};

snippets/code-snippets/close/typescript-client.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
CompressedAccountWithMerkleContext,
99
confirmTx,
1010
createRpc,
11-
defaultTestStateTreeAccounts,
1211
deriveAddressV2,
1312
deriveAddressSeedV2,
1413
batchAddressTree,
@@ -18,6 +17,8 @@ import {
1817
SystemAccountMetaConfig,
1918
featureFlags,
2019
VERSION,
20+
selectStateTreeInfo,
21+
TreeInfo,
2122
} from "@lightprotocol/stateless.js";
2223
import * as assert from "assert";
2324

@@ -49,7 +50,8 @@ describe("test-anchor-close", () => {
4950
await rpc.requestAirdrop(signer.publicKey, lamports);
5051
await sleep(2000);
5152

52-
const outputStateTree = defaultTestStateTreeAccounts().merkleTree;
53+
const stateTreeInfos = await rpc.getStateTreeInfos();
54+
const stateTreeInfo = selectStateTreeInfo(stateTreeInfos);
5355
const addressTree = new web3.PublicKey(batchAddressTree);
5456

5557
const messageSeed = new TextEncoder().encode("message");
@@ -65,7 +67,7 @@ describe("test-anchor-close", () => {
6567
addressTree,
6668
address,
6769
closeProgram,
68-
outputStateTree,
70+
stateTreeInfo,
6971
signer,
7072
"Hello, compressed world!",
7173
);
@@ -88,7 +90,7 @@ describe("test-anchor-close", () => {
8890
rpc,
8991
compressedAccount,
9092
closeProgram,
91-
outputStateTree,
93+
stateTreeInfo,
9294
signer,
9395
"Hello, compressed world!",
9496
);
@@ -115,7 +117,7 @@ async function createCompressedAccount(
115117
addressTree: anchor.web3.PublicKey,
116118
address: anchor.web3.PublicKey,
117119
program: anchor.Program<Close>,
118-
outputStateTree: anchor.web3.PublicKey,
120+
stateTreeInfo: TreeInfo,
119121
signer: anchor.web3.Keypair,
120122
message: string,
121123
) {
@@ -142,7 +144,7 @@ async function createCompressedAccount(
142144
addressQueuePubkeyIndex,
143145
};
144146
const outputStateTreeIndex =
145-
remainingAccounts.insertOrGet(outputStateTree);
147+
remainingAccounts.insertOrGet(stateTreeInfo.queue);
146148

147149
let proof = {
148150
0: proofRpcResult.compressedProof,
@@ -171,7 +173,7 @@ async function closeCompressedAccount(
171173
rpc: Rpc,
172174
compressedAccount: CompressedAccountWithMerkleContext,
173175
program: anchor.Program<Close>,
174-
outputStateTree: anchor.web3.PublicKey,
176+
stateTreeInfo: TreeInfo,
175177
signer: anchor.web3.Keypair,
176178
message: string,
177179
) {
@@ -197,7 +199,7 @@ async function closeCompressedAccount(
197199
compressedAccount.treeInfo.queue,
198200
);
199201
const outputStateTreeIndex =
200-
remainingAccounts.insertOrGet(outputStateTree);
202+
remainingAccounts.insertOrGet(stateTreeInfo.queue);
201203

202204
const coder = new anchor.BorshCoder(closeIdl as anchor.Idl);
203205
const currentAccount = coder.types.decode(
@@ -210,7 +212,7 @@ async function closeCompressedAccount(
210212
merkleTreePubkeyIndex,
211213
queuePubkeyIndex,
212214
leafIndex: compressedAccount.leafIndex,
213-
proveByIndex: false,
215+
proveByIndex: true,
214216
rootIndex: proofRpcResult.rootIndices[0],
215217
},
216218
address: compressedAccount.address,

0 commit comments

Comments
 (0)