chore: update docs to new JS beta#25
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis PR updates docs and examples to reflect an API reshaping: unified compressed-token exports, renamed functions (e.g., createMint→createMintInterface, mintTo→mintToCompressed, createTokenPool→createSplInterface, CompressedTokenProgram→LightTokenProgram), and instruction shapes changing from single TransactionInstruction[] to TransactionInstruction[][] to support multi-transaction batching (load-then-transfer patterns). Changes
Sequence Diagram(s)sequenceDiagram
participant App as App / Client
participant Wallet as Wallet (Signer)
participant RPC as RPC Node
participant LightProg as LightTokenProgram
participant SPL as SPL Token Program
App->>LightProg: createLoadAtaInstructions(...) -> returns TransactionInstruction[][]
App->>App: sliceLast / partition into load vs transfer chunks
loop per instruction chunk
App->>Wallet: request signature for tx built from chunk
Wallet-->>App: signed transaction
App->>RPC: sendSignedTransaction(signed tx)
RPC->>LightProg: deliver instructions
LightProg->>SPL: call into SPL program as needed
RPC-->>App: returns tx signature / confirmation
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
light-token/toolkits/for-payments.mdx (1)
421-433:⚠️ Potential issue | 🟠 Major
decimalsis used but never declared in the Wrap Instruction example.Line 429 references
decimals, but the code block doesn't show how to obtain it. The Unwrap example (line 499) demonstrates fetchingdecimalsviagetMint(...), but the Wrap example is missing this step. Readers copying this snippet will get aReferenceError.Suggested fix — add `getMint` usage before the wrap instruction
import { Transaction } from "@solana/web3.js"; -import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { getAssociatedTokenAddressSync, getMint } from "@solana/spl-token"; import { createWrapInstruction, getAssociatedTokenAddressInterface, } from "@lightprotocol/compressed-token/unified"; import { getSplInterfaceInfos } from "@lightprotocol/compressed-token"; const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey); const tokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint); const splInterfaceInfo = splInterfaceInfos.find((i) => i.isInitialized); +const { decimals } = await getMint(rpc, mint, undefined, splInterfaceInfo?.tokenProgram);snippets/code-snippets/light-token/transfer-interface/action.mdx (1)
5-11:⚠️ Potential issue | 🟡 MinorImport path inconsistency: this file uses
@lightprotocol/compressed-tokenwhile other light-token snippets use@lightprotocol/compressed-token/unified.This file imports
createMintInterface,createAtaInterface,mintToInterface,transferInterface, andgetAssociatedTokenAddressInterfacefrom the non-unified path, whileload-ata/action.mdx,unwrap/action.mdx,for-wallets.mdx, andfor-payments.mdxconsistently import from the/unifiedvariant. This inconsistency may confuse readers or indicate a missed update if these symbols have been consolidated under the unified API surface.
🤖 Fix all issues with AI agents
In `@light-token/toolkits/for-payments.mdx`:
- Around line 200-214: The commented-out example after
wallet.signAllTransactions incorrectly shows await
sendAndConfirmTransaction(rpc, tx) without signers; update that line to either
call sendAndConfirmTransaction with the proper signers parameter or, since the
wallet already signed all transactions via wallet.signAllTransactions, use
connection.sendRawTransaction(tx.serialize()) (and optionally await
connection.confirmTransaction) — modify the example near
wallet.signAllTransactions/signed to show one of these correct usages
(reference: wallet.signAllTransactions, sendAndConfirmTransaction,
connection.sendRawTransaction, tx.serialize()).
- Around line 238-249: The sendAndConfirmTransaction calls for the batched load
and the transfer omit the required signers array; update the two calls to
include the signer lists matching the tx.sign calls — for the Promise.all map
where you create tx from loadInstructions and call tx.sign(payer, owner), pass
[payer, owner] into sendAndConfirmTransaction(rpc, tx, [payer, owner]); and for
the transferTx where you call transferTx.sign(payer, owner) (or if only payer
signed, pass [payer] accordingly) call sendAndConfirmTransaction(rpc,
transferTx, [payer, owner]) so the signers argument is provided consistently.
In `@light-token/toolkits/for-wallets.mdx`:
- Around line 147-165: The code block declares const ata twice causing a
copy-paste syntax error; fix it by splitting the examples into two separate
fenced code blocks (one showing getAssociatedTokenAddressSync +
createAssociatedTokenAccountInstruction + Transaction, and a second showing
getOrCreateAssociatedTokenAccount) or by renaming the second variable (e.g.,
ataAccount) and adjusting references; ensure imports are grouped per block so
getAssociatedTokenAddressSync/createAssociatedTokenAccountInstruction are only
in the "Instruction" block and getOrCreateAssociatedTokenAccount is only in the
"Action" block, and keep the variable names consistent with
createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync,
getOrCreateAssociatedTokenAccount, and Transaction.
In `@snippets/code-snippets/light-token/transfer-interface/action.mdx`:
- Around line 37-38: The amount literal passed to transferInterface should use a
BigInt to match other snippets and the API expectations; change the numeric
literal 500_000_000 to a BigInt (e.g., 500_000_000n or the equivalent scaled
bigint consistent with other examples like 500n/1000n) where
transferInterface(rpc, payer, senderAta, mint, recipient.publicKey, sender,
500_000_000) is called so the last argument is a bigint value and the snippet
style matches load-ata/action.mdx and unwrap/instruction.mdx.
In `@snippets/code-snippets/light-token/unwrap/instruction.mdx`:
- Line 9: The import of bn is unused—remove the unused symbol bn from the import
statement (leave createRpc) so the top-level import becomes only createRpc;
search for any remaining bn(...) usages (e.g., prior pre-BigInt code) and
replace them with BigInt literals (like 500n) if any remain before committing.
| await Promise.all( | ||
| loadInstructions.map((ixs) => { | ||
| const tx = new Transaction().add(...ixs); | ||
| tx.sign(payer, owner); | ||
| return sendAndConfirmTransaction(rpc, tx); | ||
| }) | ||
| ); | ||
|
|
||
| // Send transfer. | ||
| const transferTx = new Transaction().add(...transferInstructions); | ||
| transferTx.sign(payer, owner); | ||
| await sendAndConfirmTransaction(rpc, transferTx); |
There was a problem hiding this comment.
sendAndConfirmTransaction calls are missing the signers parameter.
Lines 242 and 249 call sendAndConfirmTransaction(rpc, tx) without a signers array, but the standard @solana/web3.js signature is sendAndConfirmTransaction(connection, transaction, signers). Every other example in this PR passes signers (e.g., [payer, owner] or [payer]). Even though tx.sign(payer, owner) is called beforehand, the function still requires the signers argument.
Suggested fix
return sendAndConfirmTransaction(rpc, tx);
+ return sendAndConfirmTransaction(rpc, tx, [payer, owner]);-await sendAndConfirmTransaction(rpc, transferTx);
+await sendAndConfirmTransaction(rpc, transferTx, [payer, owner]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| await Promise.all( | |
| loadInstructions.map((ixs) => { | |
| const tx = new Transaction().add(...ixs); | |
| tx.sign(payer, owner); | |
| return sendAndConfirmTransaction(rpc, tx); | |
| }) | |
| ); | |
| // Send transfer. | |
| const transferTx = new Transaction().add(...transferInstructions); | |
| transferTx.sign(payer, owner); | |
| await sendAndConfirmTransaction(rpc, transferTx); | |
| await Promise.all( | |
| loadInstructions.map((ixs) => { | |
| const tx = new Transaction().add(...ixs); | |
| tx.sign(payer, owner); | |
| return sendAndConfirmTransaction(rpc, tx, [payer, owner]); | |
| }) | |
| ); | |
| // Send transfer. | |
| const transferTx = new Transaction().add(...transferInstructions); | |
| transferTx.sign(payer, owner); | |
| await sendAndConfirmTransaction(rpc, transferTx, [payer, owner]); |
🤖 Prompt for AI Agents
In `@light-token/toolkits/for-payments.mdx` around lines 238 - 249, The
sendAndConfirmTransaction calls for the batched load and the transfer omit the
required signers array; update the two calls to include the signer lists
matching the tx.sign calls — for the Promise.all map where you create tx from
loadInstructions and call tx.sign(payer, owner), pass [payer, owner] into
sendAndConfirmTransaction(rpc, tx, [payer, owner]); and for the transferTx where
you call transferTx.sign(payer, owner) (or if only payer signed, pass [payer]
accordingly) call sendAndConfirmTransaction(rpc, transferTx, [payer, owner]) so
the signers argument is provided consistently.
| // destination is a wallet pubkey; the action creates the recipient ATA. | ||
| const tx = await transferInterface(rpc, payer, senderAta, mint, recipient.publicKey, sender, 500_000_000); |
There was a problem hiding this comment.
Amount literal type inconsistency: number (500_000_000) vs BigInt (500n, 1000n) used elsewhere.
Other snippets in this PR use BigInt literals (e.g., 1000n in load-ata/action.mdx line 30, 500n in unwrap/instruction.mdx line 76). This file passes a plain number. If the new API expects bigint, this example will fail at runtime. Even if both are accepted, mixing styles across docs is confusing for readers.
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/transfer-interface/action.mdx` around
lines 37 - 38, The amount literal passed to transferInterface should use a
BigInt to match other snippets and the API expectations; change the numeric
literal 500_000_000 to a BigInt (e.g., 500_000_000n or the equivalent scaled
bigint consistent with other examples like 500n/1000n) where
transferInterface(rpc, payer, senderAta, mint, recipient.publicKey, sender,
500_000_000) is called so the last argument is a bigint value and the snippet
style matches load-ata/action.mdx and unwrap/instruction.mdx.
| Transaction, | ||
| sendAndConfirmTransaction, | ||
| } from "@solana/web3.js"; | ||
| import { createRpc, bn } from "@lightprotocol/stateless.js"; |
There was a problem hiding this comment.
Unused bn import — leftover from pre-BigInt migration.
bn is imported from @lightprotocol/stateless.js but never used. The amount on line 76 now uses a BigInt literal (500n) instead of bn(500).
Suggested fix
-import { createRpc, bn } from "@lightprotocol/stateless.js";
+import { createRpc } from "@lightprotocol/stateless.js";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { createRpc, bn } from "@lightprotocol/stateless.js"; | |
| import { createRpc } from "@lightprotocol/stateless.js"; |
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/unwrap/instruction.mdx` at line 9, The
import of bn is unused—remove the unused symbol bn from the import statement
(leave createRpc) so the top-level import becomes only createRpc; search for any
remaining bn(...) usages (e.g., prior pre-BigInt code) and replace them with
BigInt literals (like 500n) if any remain before committing.
| Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/send-and-receive.ts). | ||
| </Note> | ||
|
|
||
| Load creates the ATA if needed and pulls any cold state to hot. Share the ATA address with the sender. |
There was a problem hiding this comment.
| Load creates the ATA if needed and pulls any cold state to hot. Share the ATA address with the sender. | |
| Load creates the associated token account for the recipient <Tooltip tip="Inactive Light Tokens are cryptographically preserved on the Solana ledger as compressed tokens (cold storage) and are automatically loaded with this instruction to an associated token account.">if needed</Tooltip> and unifies the token balance of cold (compressed) Light Tokens in an associated token account. Share the associated token account address with the sender. | |
light-token/toolkits/for-wallets.mdx
Outdated
| Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/send-and-receive.ts). | ||
| </Note> | ||
|
|
||
| Load creates the ATA if needed and pulls any cold state to hot. Share the ATA address with the sender. |
There was a problem hiding this comment.
| Load creates the ATA if needed and pulls any cold state to hot. Share the ATA address with the sender. | |
| Load creates the associated token account for the recipient <Tooltip tip="Inactive Light Tokens are cryptographically preserved on the Solana ledger as compressed tokens (cold storage) and are automatically loaded with this instruction to an associated token account.">if needed</Tooltip> and unifies the token balance of cold (compressed) Light Tokens in an associated token account. Share the associated token account address with the sender. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
compressed-tokens/advanced-guides/use-token-2022-with-compression.mdx (1)
42-44:⚠️ Potential issue | 🟡 MinorConsider updating minimum SDK version requirements.
The prerequisite versions still reference
≥ 0.21.0, but ifcreateSplInterface(replacingcreateTokenPool) is introduced in a newer version, these minimums should be bumped to match the release that includes the renamed API.compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction.mdx (1)
162-162:⚠️ Potential issue | 🟡 MinorStale terminology: "Token pool created" not updated.
Line 162 still says
"Token pool created and tokens compressed"— should be updated to reference "SPL interface" for consistency with the rest of the guide.Suggested fix
- console.log("Token pool created and tokens compressed"); + console.log("SPL interface created and tokens compressed");
🤖 Fix all issues with AI agents
In `@compressed-tokens/for-privy.mdx`:
- Line 99: Fix the grammar in the sentence within
compressed-tokens/for-privy.mdx: change the phrase "a interface PDA for
compression" to "an interface PDA for compression" (locate the exact sentence
starting "* An SPL mint with a interface PDA for compression..." and update "a"
to "an").
In `@compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx`:
- Line 28: The text references a non-existent function addTokenPools(); update
the documentation to use the correct API function createSplInterface()
instead—replace addTokenPools() with createSplInterface() in the sentence about
creating additional interfaces and increasing per-block write-lock capacity so
it matches actual usage and other examples.
🧹 Nitpick comments (3)
snippets/overview-tables/compressed-tokens-guides-table.mdx (1)
8-9: Table content updated correctly; URL slugs still reference old terminology.The display text and descriptions are properly updated to "SPL interface" / "SPL Interface PDA", but the link slugs (
create-mint-with-token-pool,add-token-pools-to-mint-accounts) still use the old "token pool" naming. This is fine to avoid breaking existing bookmarks/external links, but consider adding redirects or updating slugs in a follow-up if you want full consistency.compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx (1)
17-17: Stale code block filename:function-create-token-pool.ts.The code block title still references "token-pool" terminology. Consider renaming to something like
function-create-spl-interface.tsfor consistency with the SPL interface rename.Suggested rename
-```typescript function-create-token-pool.ts +```typescript function-create-spl-interface.tscompressed-tokens/advanced-guides/airdrop.mdx (1)
768-768: Minor: parenthetical(SPL interface infos)in comment could be clearer.The comment on line 768 reads
getTokenPoolInfos() (SPL interface infos)— the parenthetical clarification is helpful but slightly awkward alongside the un-renamed function name. This is a minor style nit.
| Before we call compress or decompresss, we need: | ||
|
|
||
| * An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createTokenPool()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). | ||
| * An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). |
There was a problem hiding this comment.
Grammar: "a interface" → "an interface"
📝 Proposed fix
-* An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts).
+* An SPL mint with an interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts).📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| * An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). | |
| * An SPL mint with an interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). |
🤖 Prompt for AI Agents
In `@compressed-tokens/for-privy.mdx` at line 99, Fix the grammar in the sentence
within compressed-tokens/for-privy.mdx: change the phrase "a interface PDA for
compression" to "an interface PDA for compression" (locate the exact sentence
starting "* An SPL mint with a interface PDA for compression..." and update "a"
to "an").
|
|
||
| <Check> | ||
| **Best Practice:** Each mint supports a maximum of 4 token pools total. During compression/decompression operations, token pools get write-locked. Use `addTokenPools()` to create additional pools that increase per-block write-lock capacity. | ||
| **Best Practice:** Each mint supports up to 4 SPL interfaces. During compression/decompression, SPL Interface PDAs get write-locked. Use `addTokenPools()` to create additional interfaces and increase per-block write-lock capacity. |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# First, find and examine the file at the specified location
echo "=== Examining the file ==="
fd "add-token-pools-to-mint-accounts.mdx" -x cat -n {}
echo ""
echo "=== Searching for addTokenPools in the codebase ==="
rg "addTokenPools" -n --type-add 'md:*.mdx' --type md
echo ""
echo "=== Searching for any SPL interface function names ==="
rg "addSplInterface|createSplInterface" -n --type-add 'md:*.mdx' --type mdRepository: Lightprotocol/docs-v2
Length of output: 9305
🏁 Script executed:
#!/bin/bash
# Search for function definitions and exports of both functions
echo "=== Searching for addTokenPools function definition ==="
rg "addTokenPools" -n -A 5 -B 2
echo ""
echo "=== Checking TypeScript/JavaScript files for exports ==="
fd "\.(ts|js|tsx|jsx)$" -x grep -l "addTokenPools\|export.*createSplInterface" {}
echo ""
echo "=== Looking for package.json or SDK type definitions ==="
fd "package.json|index.ts|index.d.ts" -x grep -l "addTokenPools\|createSplInterface" {}Repository: Lightprotocol/docs-v2
Length of output: 1783
Replace addTokenPools() with createSplInterface()—the function does not exist.
The function addTokenPools() does not exist anywhere in the codebase. All examples and actual API usage reference createSplInterface(). Update line 28 to use the correct function name.
🤖 Prompt for AI Agents
In `@compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx` at line 28,
The text references a non-existent function addTokenPools(); update the
documentation to use the correct API function createSplInterface()
instead—replace addTokenPools() with createSplInterface() in the sentence about
creating additional interfaces and increasing per-block write-lock capacity so
it matches actual usage and other examples.
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx (1)
286-296:⚠️ Potential issue | 🔴 CriticalUpdate imports and function names to match the current API:
createMint→createMintInterface,mintTo→mintToCompressed.The imports at line 289 use outdated function names. Throughout the codebase, all other code snippets use
createMintInterfaceandmintToCompressedfrom@lightprotocol/compressed-token. Line 311 and 322 which callcreateMint()andmintTo()also need to be updated to use the new function names.compressed-tokens/advanced-guides/airdrop.mdx (1)
291-292:⚠️ Potential issue | 🔴 CriticalUpdate imports to use the new compressed-token API names.
The file imports
createMintfrom@lightprotocol/compressed-token, but this export has been renamed tocreateMintInterface. Additionally,mintToshould bemintToCompressed. Other sections of the documentation (light-token snippets) already use the new names, confirming this is the current API.References to updated names in codebase
Multiple files import the new names:
snippets/code-snippets/light-token/create-spl-mint/action.mdx:createMintInterfacesnippets/code-snippets/light-token/unwrap/instruction.mdx:createMintInterface,mintToCompressedsnippets/code-snippets/light-token/load-ata/instruction.mdx:createMintInterface,mintToCompressedsnippets/code-snippets/light-token/create-token-pool/instruction.mdx (1)
30-36:⚠️ Potential issue | 🔴 CriticalReplace
LightTokenProgram.createSplInterface()with the correct API:CompressedTokenProgram.createTokenPool().
LightTokenProgramandcreateSplInterfacedo not exist in@lightprotocol/compressed-token. The correct import and method are:import { CompressedTokenProgram } from "@lightprotocol/compressed-token"; const ix = await CompressedTokenProgram.createTokenPool({ feePayer: payer.publicKey, mint: existingMint, tokenProgramId: TOKEN_PROGRAM_ID, }); const tx = new Transaction().add(ix);The
createTokenPool()method returns a singleTransactionInstruction, which is fully compatible withTransaction.add().
🤖 Fix all issues with AI agents
In
`@compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx`:
- Line 457: The backticks around method references include trailing punctuation,
making them render like chained property access; update occurrences of
`LightTokenProgram.decompress().` and `LightTokenProgram.compress().` so the
trailing period is outside the backticks (e.g.,
`LightTokenProgram.decompress()`.). Locate the two instances (one at the example
that says "This example converts compressed tokens..." and the other on the line
that references compress) and move the period outside the inline code span for
correct rendering.
- Line 481: The createRpc call for the connection contains a stray semicolon
inside the parentheses causing a syntax error; update the Rpc initialization
(variable connection and the createRpc(...) invocation) to remove the extra
semicolon so the string argument ends with the closing quote and then the
closing parenthesis — ensure
createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>") is used (keeping
the API key placeholder intact).
In `@light-token/toolkits/for-payments.mdx`:
- Around line 224-242: The code block declares const ata twice (using
getAssociatedTokenAddressSync and then getOrCreateAssociatedTokenAccount) which
will cause a duplicate-declaration error; fix by splitting the examples into two
separate fenced code blocks (one showing the "Instruction" example using
getAssociatedTokenAddressSync and createAssociatedTokenAccountInstruction with
variable ata1 or just its own block) and a second fenced block for the "Action"
example using getOrCreateAssociatedTokenAccount (or rename the second variable
to ataAccount/ata2) so getAssociatedTokenAddressSync,
createAssociatedTokenAccountInstruction, Transaction, and
getOrCreateAssociatedTokenAccount examples do not reuse the same const name in
the same scope.
In `@light-token/toolkits/for-wallets.mdx`:
- Around line 71-72: The documentation lists assumed variables (rpc, payer,
mint, owner, recipient, amount) but uses decimals in the "Wrap" snippet; update
the examples to either add decimals to the assumed-variables list or modify the
Wrap code to derive decimals at runtime (for example call getMint(rpc, mint) and
read mintInfo.decimals) and update the same omission in the for-payments.mdx
file; adjust any references in the Wrap snippet to use the derived decimals
variable (or the newly documented assumed variable) so the snippet is
self-contained and consistent.
- Around line 111-132: The code uses sendAndConfirmTransaction but only imports
Transaction; update the import list from "@solana/web3.js" to include
sendAndConfirmTransaction (or consolidate imports so both Transaction and
sendAndConfirmTransaction are imported together) so the
createLoadAtaInstructions usage and subsequent send loop works; apply the same
fix to the other examples (Send Payments and Unwrap) that call
sendAndConfirmTransaction to make each snippet self-contained and
copy-pasteable.
| <Accordion title="Decompress to Regular SPL"> | ||
|
|
||
| This example converts compressed tokens to regular SPL format using `CompressedTokenProgram.decompress().` | ||
| This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().` |
There was a problem hiding this comment.
Punctuation inside backtick makes method reference look like a chained property access.
The trailing period is inside the backtick: `LightTokenProgram.decompress().` which renders as a property access. Move the period outside.
Same issue on line 543 with `LightTokenProgram.compress().`.
Proposed fix
-This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().`
+This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress()`.Line 543:
-This example converts regular SPL tokens to compressed format using `LightTokenProgram.compress().`
+This example converts regular SPL tokens to compressed format using `LightTokenProgram.compress()`.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().` | |
| This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress()`. |
🤖 Prompt for AI Agents
In
`@compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx`
at line 457, The backticks around method references include trailing
punctuation, making them render like chained property access; update occurrences
of `LightTokenProgram.decompress().` and `LightTokenProgram.compress().` so the
trailing period is outside the backticks (e.g.,
`LightTokenProgram.decompress()`.). Locate the two instances (one at the example
that says "This example converts compressed tokens..." and the other on the line
that references compress) and move the period outside the inline code span for
correct rendering.
| // 3. Create decompress instruction with LightTokenProgram.decompress() and submit transaction | ||
|
|
||
| // Step 1: Setup RPC connection and define decompression parameters | ||
| const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";); |
There was a problem hiding this comment.
Pre-existing syntax error: stray semicolon inside createRpc() call.
createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";);
The ; between the closing quote and ) is invalid JavaScript. Users copying this snippet will get a syntax error.
Proposed fix
-const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";);
+const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";); | |
| const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>"); |
🤖 Prompt for AI Agents
In
`@compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx`
at line 481, The createRpc call for the connection contains a stray semicolon
inside the parentheses causing a syntax error; update the Rpc initialization
(variable connection and the createRpc(...) invocation) to remove the extra
semicolon so the string argument ends with the closing quote and then the
closing parenthesis — ensure
createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>") is used (keeping
the API key placeholder intact).
| ```typescript | ||
| import { | ||
| createAssociatedTokenAccountInstruction, | ||
| getAssociatedTokenAddressSync, | ||
| createTransferInstruction, | ||
| getOrCreateAssociatedTokenAccount, | ||
| } from "@solana/spl-token"; | ||
|
|
||
| const sourceAta = getAssociatedTokenAddressSync(mint, owner.publicKey); | ||
| const destinationAta = getAssociatedTokenAddressSync(mint, recipient); | ||
| const ata = getAssociatedTokenAddressSync(mint, recipient); | ||
|
|
||
| // Instruction: | ||
| const tx = new Transaction().add( | ||
| createTransferInstruction(sourceAta, destinationAta, owner.publicKey, amount) | ||
| createAssociatedTokenAccountInstruction(payer.publicKey, ata, recipient, mint) | ||
| ); | ||
|
|
||
| // Action: | ||
| const ata = await getOrCreateAssociatedTokenAccount( | ||
| connection, payer, mint, recipient | ||
| ); | ||
| ``` |
There was a problem hiding this comment.
Duplicate const ata declaration in the same code block.
Lines 231 and 239 both declare const ata within a single code fence. A reader copying this block would get a syntax error. Split into two separate code blocks (one for instruction, one for action) or use different variable names.
const ata = getAssociatedTokenAddressSync(mint, recipient);
// Instruction:
const tx = new Transaction().add(
createAssociatedTokenAccountInstruction(payer.publicKey, ata, recipient, mint)
);
// Action:
-const ata = await getOrCreateAssociatedTokenAccount(
+const ataAccount = await getOrCreateAssociatedTokenAccount(
connection, payer, mint, recipient
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ```typescript | |
| import { | |
| createAssociatedTokenAccountInstruction, | |
| getAssociatedTokenAddressSync, | |
| createTransferInstruction, | |
| getOrCreateAssociatedTokenAccount, | |
| } from "@solana/spl-token"; | |
| const sourceAta = getAssociatedTokenAddressSync(mint, owner.publicKey); | |
| const destinationAta = getAssociatedTokenAddressSync(mint, recipient); | |
| const ata = getAssociatedTokenAddressSync(mint, recipient); | |
| // Instruction: | |
| const tx = new Transaction().add( | |
| createTransferInstruction(sourceAta, destinationAta, owner.publicKey, amount) | |
| createAssociatedTokenAccountInstruction(payer.publicKey, ata, recipient, mint) | |
| ); | |
| // Action: | |
| const ata = await getOrCreateAssociatedTokenAccount( | |
| connection, payer, mint, recipient | |
| ); | |
| ``` |
🤖 Prompt for AI Agents
In `@light-token/toolkits/for-payments.mdx` around lines 224 - 242, The code block
declares const ata twice (using getAssociatedTokenAddressSync and then
getOrCreateAssociatedTokenAccount) which will cause a duplicate-declaration
error; fix by splitting the examples into two separate fenced code blocks (one
showing the "Instruction" example using getAssociatedTokenAddressSync and
createAssociatedTokenAccountInstruction with variable ata1 or just its own
block) and a second fenced block for the "Action" example using
getOrCreateAssociatedTokenAccount (or rename the second variable to
ataAccount/ata2) so getAssociatedTokenAddressSync,
createAssociatedTokenAccountInstruction, Transaction, and
getOrCreateAssociatedTokenAccount examples do not reuse the same const name in
the same scope.
| Snippets below assume `rpc`, `payer`, `mint`, `owner`, `recipient`, and `amount` are defined. | ||
| See the [full examples](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets) for runnable setup. |
There was a problem hiding this comment.
decimals is not listed among assumed variables but is used in the Wrap section.
Line 71 lists rpc, payer, mint, owner, recipient, and amount as assumed variables, but the Wrap instruction code block (line 352) also uses decimals. Either add decimals to this list or derive it in the wrap snippet (e.g., from getMint).
The same omission exists in for-payments.mdx (line 71 and line 474).
🤖 Prompt for AI Agents
In `@light-token/toolkits/for-wallets.mdx` around lines 71 - 72, The documentation
lists assumed variables (rpc, payer, mint, owner, recipient, amount) but uses
decimals in the "Wrap" snippet; update the examples to either add decimals to
the assumed-variables list or modify the Wrap code to derive decimals at runtime
(for example call getMint(rpc, mint) and read mintInfo.decimals) and update the
same omission in the for-payments.mdx file; adjust any references in the Wrap
snippet to use the derived decimals variable (or the newly documented assumed
variable) so the snippet is self-contained and consistent.
| ```typescript | ||
| import { Transaction } from "@solana/web3.js"; | ||
| import { | ||
| createAssociatedTokenAccountInterfaceIdempotentInstruction, | ||
| createLoadAtaInstructions, | ||
| getAssociatedTokenAddressInterface, | ||
| } from "@lightprotocol/compressed-token"; | ||
| import { LIGHT_TOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; | ||
| } from "@lightprotocol/compressed-token/unified"; | ||
|
|
||
| const ata = getAssociatedTokenAddressInterface(mint, recipient); | ||
|
|
||
| const tx = new Transaction().add( | ||
| createAssociatedTokenAccountInterfaceIdempotentInstruction( | ||
| payer.publicKey, | ||
| ata, | ||
| recipient, | ||
| mint, | ||
| LIGHT_TOKEN_PROGRAM_ID | ||
| ), | ||
| ...(await createLoadAtaInstructions( | ||
| rpc, | ||
| ata, | ||
| recipient, | ||
| mint, | ||
| payer.publicKey | ||
| )) | ||
| // Each inner array = one transaction. Usually just one. Empty = nothing to load. | ||
| const instructions = await createLoadAtaInstructions( | ||
| rpc, | ||
| ata, | ||
| recipient, | ||
| mint, | ||
| payer.publicKey | ||
| ); | ||
|
|
||
| for (const ixs of instructions) { | ||
| const tx = new Transaction().add(...ixs); | ||
| await sendAndConfirmTransaction(rpc, tx, [payer]); | ||
| } |
There was a problem hiding this comment.
sendAndConfirmTransaction used but not imported in this code block.
Line 131 calls sendAndConfirmTransaction but only Transaction is imported on line 112. The same omission occurs in the Send Payments (line 202) and Unwrap (line 408) instruction blocks. For-payments.mdx is more consistent, importing it in most instruction blocks (e.g., lines 120, 256, 512).
Add the import for self-contained, copy-pasteable snippets:
import { Transaction } from "@solana/web3.js";
+import { sendAndConfirmTransaction } from "@solana/web3.js";Or combine:
-import { Transaction } from "@solana/web3.js";
+import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ```typescript | |
| import { Transaction } from "@solana/web3.js"; | |
| import { | |
| createAssociatedTokenAccountInterfaceIdempotentInstruction, | |
| createLoadAtaInstructions, | |
| getAssociatedTokenAddressInterface, | |
| } from "@lightprotocol/compressed-token"; | |
| import { LIGHT_TOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; | |
| } from "@lightprotocol/compressed-token/unified"; | |
| const ata = getAssociatedTokenAddressInterface(mint, recipient); | |
| const tx = new Transaction().add( | |
| createAssociatedTokenAccountInterfaceIdempotentInstruction( | |
| payer.publicKey, | |
| ata, | |
| recipient, | |
| mint, | |
| LIGHT_TOKEN_PROGRAM_ID | |
| ), | |
| ...(await createLoadAtaInstructions( | |
| rpc, | |
| ata, | |
| recipient, | |
| mint, | |
| payer.publicKey | |
| )) | |
| // Each inner array = one transaction. Usually just one. Empty = nothing to load. | |
| const instructions = await createLoadAtaInstructions( | |
| rpc, | |
| ata, | |
| recipient, | |
| mint, | |
| payer.publicKey | |
| ); | |
| for (const ixs of instructions) { | |
| const tx = new Transaction().add(...ixs); | |
| await sendAndConfirmTransaction(rpc, tx, [payer]); | |
| } |
🤖 Prompt for AI Agents
In `@light-token/toolkits/for-wallets.mdx` around lines 111 - 132, The code uses
sendAndConfirmTransaction but only imports Transaction; update the import list
from "@solana/web3.js" to include sendAndConfirmTransaction (or consolidate
imports so both Transaction and sendAndConfirmTransaction are imported together)
so the createLoadAtaInstructions usage and subsequent send loop works; apply the
same fix to the other examples (Send Payments and Unwrap) that call
sendAndConfirmTransaction to make each snippet self-contained and
copy-pasteable.
Summary by CodeRabbit
Documentation
API Updates
Code Samples