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 substantially restructures Light Token documentation by removing pre-release package tags, reorganizing cookbook guides to use component-based code examples instead of inline code blocks, adding comprehensive Rust-language code examples alongside TypeScript ones, enhancing the CodeCompare component with copy-to-clipboard and language support, introducing new toolkit pages, and updating Rust dependencies to version 0.19.0. Changes
Sequence Diagram(s)sequenceDiagram
participant User as Developer
participant App as TypeScript/Rust Client
participant RPC as Light Protocol RPC
participant Chain as Solana Blockchain
User->>App: Initialize mint interface with decimals
App->>RPC: Create Mint transaction
RPC->>Chain: Submit CreateMint instruction
Chain-->>RPC: Mint account created
User->>App: Create Associated Token Account (ATA)
App->>RPC: CreateAta with idempotent flag
RPC->>Chain: Submit CreateAta instruction
Chain-->>RPC: ATA created/verified
User->>App: Mint tokens to ATA
App->>RPC: MintTo with amount and authority
RPC->>Chain: Submit MintTo instruction
Chain-->>RPC: Tokens minted, balance updated
User->>App: Approve delegate for amount
App->>RPC: Approve instruction with delegate and amount
RPC->>Chain: Submit Approve instruction
Chain-->>RPC: Delegate authorized
User->>App: Transfer tokens with decimal check
App->>RPC: TransferChecked with decimals validation
RPC->>Chain: Submit TransferChecked instruction
Chain-->>RPC: Tokens transferred, balance updated
App->>RPC: Fetch updated account data
RPC->>Chain: Query account state
Chain-->>RPC: Return deserialized Token state
RPC-->>App: Account data with balance/delegate
App-->>User: Display operation result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~65 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3fcb3c2 to
f909958
Compare
There was a problem hiding this comment.
Actionable comments posted: 20
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
docs.json (1)
54-87:⚠️ Potential issue | 🔴 CriticalFix broken navigation links: 11 referenced pages do not exist.
All newly added page references in the navigation are missing from the repository and will result in 404 errors:
light-token/toolkits/for-streaming-mintslight-token/toolkits/for-streaming-tokenslight-token/examples/clientlight-token/cookbook/create-mintlight-token/cookbook/create-atalight-token/cookbook/create-token-accountlight-token/cookbook/mint-tolight-token/cookbook/close-token-accountlight-token/cookbook/transfer-interfacelight-token/cookbook/wrap-unwraplight-token/cookbook/load-ataEither create these MDX files or remove the corresponding nav entries.
snippets/jsx/code-compare.jsx (1)
1-370:⚠️ Potential issue | 🟠 MajorCI is failing Prettier on this file.
The pipeline reports a Prettier formatting failure for
snippets/jsx/code-compare.jsx. Please runprettier --writeon this file and re-check CI.snippets/code-samples/code-compare-snippets.jsx (1)
1-3:⚠️ Potential issue | 🟠 MajorFix Prettier formatting failure for this file.
CI reports a Prettier check failure; please run Prettier on this file before merge.
🤖 Fix all issues with AI agents
In @.mintignore:
- Line 1: Update the `.mintignore` entry for the node_modules directory to
explicitly include a trailing slash: replace the current "node_modules" pattern
with "node_modules/" so the file unambiguously matches a directory (follow the
same convention used in `.mintlifyignore`).
In @.mintlifyignore:
- Line 1: Delete the stray `.mintlifyignore` file—Mintlify uses `.mintignore`
(already present), so remove the unused `.mintlifyignore` to avoid confusion and
duplication in repository configuration.
In `@light-token/cookbook/approve-revoke.mdx`:
- Around line 8-12: Remove the stray YAML delimiter line between the frontmatter
and imports by deleting the extra '---' that appears before the import block;
ensure the import statements (TokenClientPrerequisites, FullSetup, and
CodeCompare) come immediately after the closed frontmatter so the MDX parser
sees the imports directly following the frontmatter closure.
In `@light-token/cookbook/close-token-account.mdx`:
- Around line 19-20: The second bullet uses inconsistent capitalization ("Light
token"); update the text so both bullets use "Light Token" with capital T in
"Token" to match the rest of the page—specifically change the phrase "Light
token accounts can be closed by the owner." to "Light Token accounts can be
closed by the owner."
In `@light-token/cookbook/create-ata.mdx`:
- Around line 31-32: The sentence "Light-ATAs are on-chain accounts like SPL
ATA's, but the light token program sponsors the rent-exemption cost for you."
uses incorrect possessive/apostrophe pluralization; update the phrase "SPL
ATA's" to the plural form "SPL ATAs" so it reads "Light-ATAs are on-chain
accounts like SPL ATAs, but the light token program sponsors the rent-exemption
cost for you." to fix the grammar.
In `@light-token/cookbook/create-token-account.mdx`:
- Around line 24-25: Replace the lowercase mentions in the two lines shown:
change "Light token accounts" to "Light Token accounts" and change "light token
program" to "Light Token program" so the product name is capitalized
consistently (leave other terms like "SPL" and "Token 2022" unchanged); update
the exact phrases "Light token accounts" and "light token program" in the file
to "Light Token accounts" and "Light Token program".
In `@light-token/cookbook/transfer-checked.mdx`:
- Around line 8-12: Remove the extraneous '---' that appears immediately before
the import block so MDX imports (TokenClientPrerequisites, RustActionCode,
RustInstructionCode) come first; delete the standalone '---' after the
frontmatter (lines following the existing frontmatter) so the imports are the
first non-frontmatter content in transfer-checked.mdx.
In `@light-token/cookbook/wrap-unwrap.mdx`:
- Around line 77-129: The Rust tabs currently only include Action examples
(components WrapRustActionCode and UnwrapRustActionCode) but the PR requires
both Action and Instruction examples; add an "Instruction" Tab alongside the
existing "Action" Tab for both the Wrap and Unwrap Tabs, using the corresponding
instruction snippet components (e.g., WrapRustInstructionCode and
UnwrapRustInstructionCode) or the existing instruction content if available, and
keep TokenClientPrerequisites intact; if no instruction snippets exist, update
the PR description to state the objective changed instead of adding empty
Instruction tabs.
In `@light-token/toolkits/for-streaming-tokens.mdx`:
- Around line 11-19: Fix two text issues in the paragraph: replace the
misspelled word "autoatically" with "automatically" (occurring in the phrase
"its token accounts and related PDAs will be compressed autoatically") and
change the compound adjective "warm up" to the hyphenated form "warm-up" when
modifying "instruction" (in the phrase "prepend an idempotent decompress warm up
instruction" → "prepend an idempotent decompress warm-up instruction").
In `@scripts/copy-light-token-snippets.sh`:
- Around line 6-7: Replace the hardcoded absolute paths assigned to EXAMPLES and
SNIPPETS_DIR with portable values: derive defaults relative to the script
location using the script directory (e.g., based on dirname "$0") and/or allow
overriding via environment variables or command-line arguments (e.g., honor
EXAMPLES and SNIPPETS_DIR env vars if set, otherwise fall back to relative
defaults); update the assignments for EXAMPLES and SNIPPETS_DIR in
copy-light-token-snippets.sh and adjust any downstream uses to rely on these
variables.
In `@scripts/copy-rust-snippets.sh`:
- Around line 6-8: Replace the hard-coded absolute paths by reading optional env
overrides and falling back to repo-relative defaults: use EXAMPLES_DIR and
SNIPPETS_DIR env vars if set, otherwise compute defaults relative to the
repository root (e.g., using the script's directory via dirname "$0" or git
rev-parse --show-toplevel) and assign those to EXAMPLES_DIR and SNIPPETS_DIR;
then validate both directories exist and exit with a clear error if missing
(fail fast). Update the top of scripts/copy-rust-snippets.sh to set EXAMPLES_DIR
and SNIPPETS_DIR from env or computed repo-relative paths and add checks that
call echo + exit 1 when the paths are not directories.
In `@snippets/code-snippets/light-token/approve-revoke/approve-action.mdx`:
- Around line 26-37: The approve call uses a number literal (500) while
mintToCompressed used a bigint (1000n); update the approve invocation (function
approve) to use a bigint amount (e.g., 500n) so types are consistent with
createMintInterface/mintToCompressed and other token operations involving
BigInt; locate the approve(...) call near where Keypair.generate() creates
delegate and replace the numeric literal with a BigInt literal.
In `@snippets/code-snippets/light-token/burn/rust-client/instruction.mdx`:
- Around line 2-6: Add the missing import for the token state by adding a use
statement for light_token_interface::state::Token at the top of the file so
Token::deserialize() can be resolved; update the imports near the existing use
lines (e.g., alongside use light_token::instruction::Burn and use
rust_client::{setup, SetupContext}) to include Token so the call on
Token::deserialize(...) on the later line compiles.
In
`@snippets/code-snippets/light-token/create-mint/anchor-macro/full-example.mdx`:
- Around line 154-168: The test is missing the import of light_token_types so
references to light_token_types::CPI_AUTHORITY_PDA will fail to compile; add an
import for the module (e.g., bring CPI_AUTHORITY_PDA into scope) near the other
use/import lines and then simplify the two references (previously
light_token_types::CPI_AUTHORITY_PDA) to just CPI_AUTHORITY_PDA in the test
where find_mint_address, COMPRESSIBLE_CONFIG_V1, and RENT_SPONSOR are used.
In `@snippets/code-snippets/light-token/create-mint/rust-client/instruction.mdx`:
- Around line 31-58: Replace the three unwrap() calls with proper error
propagation using the function's Result return: call
rpc.get_random_state_tree_info()? instead of .unwrap(), await and propagate the
Result from rpc.get_validity_proof(...).await? (or map_err to a descriptive
error) instead of .await.unwrap(), and handle rpc_result.proof.0 as an Option by
using .ok_or_else(|| /* descriptive error */)? to convert it into a Result for
propagation; update references around get_random_state_tree_info,
get_validity_proof, and rpc_result.proof so CreateMintParams is built only after
these fallible calls have been converted to ?-propagated Results.
In
`@snippets/code-snippets/light-token/create-token-account/anchor-macro/full-example.mdx`:
- Around line 224-229: The test currently only logs the transaction outcome, so
failures are ignored; replace the println!("Transaction result: {:?}", result)
with a check that fails the test on error by asserting the Result returned by
rpc.create_and_send_transaction is Ok (or propagating the error) and include the
error details in the assertion message—locate the call to
rpc.create_and_send_transaction (assigned to result) and update the code to
assert/result-handling so the test fails when the transaction fails.
In `@snippets/code-snippets/light-token/transfer-interface/instruction.mdx`:
- Line 50: Fix the typo in the inline comment that reads "Transfer tokens
between light-token associate token accounts" by changing "associate" to
"associated" so the comment reads "Transfer tokens between light-token
associated token accounts"; locate and update this exact comment string in the
instruction.mdx snippet.
In `@snippets/code-snippets/light-token/unwrap/instruction.mdx`:
- Around line 17-21: The snippet references an undefined RPC_URL when calling
createRpc(RPC_URL) which causes a runtime ReferenceError; fix by either
restoring the devnet constant RPC_URL (uncomment the line that defines RPC_URL)
so createRpc(RPC_URL) has a valid value, or switch to the localnet form by
calling createRpc() with no argument; look for the RPC_URL constant and the
createRpc(...) call to update accordingly.
In `@snippets/code-snippets/light-token/wrap/instruction.mdx`:
- Around line 18-22: The snippet references RPC_URL when calling createRpc (rpc
= createRpc(RPC_URL)) but RPC_URL is currently commented out, causing a
ReferenceError; fix by either uncommenting/defining RPC_URL (e.g., set const
RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`)
before calling createRpc, or change the call to createRpc() for localnet
usage—update the line that initializes rpc (the createRpc invocation) so it
matches the intended example (devnet with RPC_URL defined or localnet using
createRpc()).
In `@snippets/jsx/code-compare.jsx`:
- Around line 11-26: The handleCopy function should guard against missing
Clipboard API and failures and should store/clear the copy timeout to avoid
state updates after unmount: update handleCopy to first check
navigator.clipboard and wrap navigator.clipboard.writeText(codeToCopy) in
try/catch (handle failures gracefully, e.g., early return or fallback), save the
setTimeout id into a ref (e.g., copyTimeoutRef) instead of ignoring it, and add
a useEffect cleanup that clears copyTimeoutRef.current (and any other related
timers) on unmount; refer to handleCopy, copied/setCopied, and create a
copyTimeoutRef to locate where to change code.
🧹 Nitpick comments (2)
snippets/code-snippets/light-token/create-token-account/rust-client/instruction.mdx (1)
23-25: Consider breaking long line for readability.Line 24 exceeds typical line length limits. Consider formatting for better readability in documentation.
📝 Suggested formatting
let sig = rpc - .create_and_send_transaction(&[create_token_account_instruction], &payer.pubkey(), &[&payer, &account]) + .create_and_send_transaction( + &[create_token_account_instruction], + &payer.pubkey(), + &[&payer, &account], + ) .await?;light-token/cookbook/freeze-thaw.mdx (1)
73-85: Single-tab containers could be simplified.The inner
<Tabs>wrappers on lines 73-77 and 80-84 each contain only one tab ("Instruction"). If Action tabs aren't planned for this release, consider removing the extra nesting for cleaner structure.If this is a placeholder for future Action tabs, consider leaving a comment to clarify the intent.
| @@ -0,0 +1 @@ | |||
| node_modules | |||
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
.mintignore file format Mint documentation trailing slash
💡 Result:
Mintlify’s .mintignore is a plain-text file (placed in the root of your docs directory) that uses the same pattern syntax as .gitignore—one pattern per line, # for comments, glob patterns like *.draft.mdx, **/internal/**, and negation with !pattern. [1]
Trailing slash rule: because it follows .gitignore semantics, a pattern ending in / matches directories only (and everything under them). Without the trailing /, the pattern can match both files and directories. Example: drafts/ ignores the drafts directory; drafts could match a file or directory named drafts. [2]
Add trailing slash to match .gitignore conventions.
The .mintignore file uses .gitignore pattern syntax. For directories like node_modules, the trailing slash should be included—change node_modules to node_modules/ to explicitly indicate it's a directory match. This aligns with .gitignore best practices and the existing convention in .mintlifyignore.
🤖 Prompt for AI Agents
In @.mintignore at line 1, Update the `.mintignore` entry for the node_modules
directory to explicitly include a trailing slash: replace the current
"node_modules" pattern with "node_modules/" so the file unambiguously matches a
directory (follow the same convention used in `.mintlifyignore`).
| @@ -0,0 +1 @@ | |||
| node_modules/ | |||
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
.mintlifyignore file format documentation trailing slash
💡 Result:
Mintlify’s ignore file is .mintignore (not .mintlifyignore). It uses the same pattern syntax as .gitignore. (mintlify.com)
Trailing slash meaning: a pattern ending in / matches a directory (and everything under it). Example from Mintlify’s docs: drafts/ excludes the entire drafts folder. (mintlify.com)
Citations:
- 1: https://www.mintlify.com/docs/organize/mintignore?utm_source=openai
- 2: https://www.mintlify.com/docs/organize/mintignore?utm_source=openai
🏁 Script executed:
# Check if .mintignore exists in the repository
find . -name ".mintignore" -o -name ".mintlifyignore" | head -20Repository: Lightprotocol/docs-v2
Length of output: 96
🏁 Script executed:
# Search for any references to mintify or mintignore in the codebase
rg -i "mintify|mintignore" --type json --type md --type txt | head -30Repository: Lightprotocol/docs-v2
Length of output: 47
🏁 Script executed:
echo "=== .mintignore ===" && cat -n .mintignore && echo -e "\n=== .mintlifyignore ===" && cat -n .mintlifyignoreRepository: Lightprotocol/docs-v2
Length of output: 150
Remove .mintlifyignore — the correct filename for Mintlify is .mintignore.
Mintlify only recognizes .mintignore (not .mintlifyignore). The repository already has .mintignore configured correctly. The .mintlifyignore file will not be used by Mintlify and should be deleted to avoid confusion.
🤖 Prompt for AI Agents
In @.mintlifyignore at line 1, Delete the stray `.mintlifyignore` file—Mintlify
uses `.mintignore` (already present), so remove the unused `.mintlifyignore` to
avoid confusion and duplication in repository configuration.
| --- | ||
|
|
||
| import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx"; | ||
| import FullSetup from "/snippets/setup/full-setup.mdx"; | ||
| import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's locate and examine the file
fd "approve-revoke.mdx" -x cat -n {}Repository: Lightprotocol/docs-v2
Length of output: 5380
🌐 Web query:
MDX import statements frontmatter horizontal rule syntax
💡 Result:
- MDX “core” (mdxjs) doesn’t support YAML frontmatter by default. If you want metadata, the built-in/portable approach is ESM exports instead of frontmatter (e.g.,
export const title = ...). (mdxjs.com) - If your toolchain does support YAML frontmatter (via plugins), the delimiter is the same as Markdown frontmatter: a fenced block at the very top of the file using
---lines (this looks like a horizontal rule, but in this position it’s parsed as frontmatter). (github.com)
Import vs frontmatter ordering (common gotcha):
- In Gatsby (gatsby-plugin-mdx), frontmatter must come first, and
importstatements go after the frontmatter block. (v3.gatsbyjs.com)
Example (Gatsby-style):
---
title: Hello
date: 2026-02-02
---
import Callout from "../components/Callout.mdx"
# Hello
<Callout />Citations:
- 1: https://mdxjs.com/guides/frontmatter/?utm_source=openai
- 2: https://github.com/remarkjs/remark-frontmatter?utm_source=openai
- 3: https://v3.gatsbyjs.com/docs/how-to/routing/mdx/?utm_source=openai
Remove the extraneous horizontal rule before imports.
The file has valid YAML frontmatter (lines 1–6) correctly closed with ---, followed by a blank line. The extra --- on line 8 before imports is invalid—MDX syntax expects imports to come immediately after frontmatter closure, not preceded by another --- delimiter. This stray delimiter can confuse MDX parsers and break document processing.
✅ Proposed fix
---
----
-
import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx";🤖 Prompt for AI Agents
In `@light-token/cookbook/approve-revoke.mdx` around lines 8 - 12, Remove the
stray YAML delimiter line between the frontmatter and imports by deleting the
extra '---' that appears before the import block; ensure the import statements
(TokenClientPrerequisites, FullSetup, and CodeCompare) come immediately after
the closed frontmatter so the MDX parser sees the imports directly following the
frontmatter closure.
| 1. Closing a Light Token account transfers remaining lamports to a destination account and the rent sponsor can reclaim sponsored rent. | ||
| 2. Light token accounts can be closed by the owner. |
There was a problem hiding this comment.
Use consistent “Light Token” capitalization in the bullet list.
The second bullet uses “Light token” (lowercase). Align with the rest of the page’s terminology.
✍️ Suggested tweak
-2. Light token accounts can be closed by the owner.
+2. Light Token accounts can be closed by the 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.
| 1. Closing a Light Token account transfers remaining lamports to a destination account and the rent sponsor can reclaim sponsored rent. | |
| 2. Light token accounts can be closed by the owner. | |
| 1. Closing a Light Token account transfers remaining lamports to a destination account and the rent sponsor can reclaim sponsored rent. | |
| 2. Light Token accounts can be closed by the owner. |
🤖 Prompt for AI Agents
In `@light-token/cookbook/close-token-account.mdx` around lines 19 - 20, The
second bullet uses inconsistent capitalization ("Light token"); update the text
so both bullets use "Light Token" with capital T in "Token" to match the rest of
the page—specifically change the phrase "Light token accounts can be closed by
the owner." to "Light Token accounts can be closed by the owner."
| 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. | ||
| 2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. |
There was a problem hiding this comment.
Fix pluralization in “ATA's.”
Use “ATAs” without an apostrophe.
✏️ Suggested edit
-2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you.
+2. Light-ATAs are on-chain accounts like SPL ATAs, but the light token program sponsors the rent-exemption cost for you.📝 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.
| 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. | |
| 2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. | |
| 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. | |
| 2. Light-ATAs are on-chain accounts like SPL ATAs, but the light token program sponsors the rent-exemption cost for you. |
🤖 Prompt for AI Agents
In `@light-token/cookbook/create-ata.mdx` around lines 31 - 32, The sentence
"Light-ATAs are on-chain accounts like SPL ATA's, but the light token program
sponsors the rent-exemption cost for you." uses incorrect possessive/apostrophe
pluralization; update the phrase "SPL ATA's" to the plural form "SPL ATAs" so it
reads "Light-ATAs are on-chain accounts like SPL ATAs, but the light token
program sponsors the rent-exemption cost for you." to fix the grammar.
| let result = rpc | ||
| .create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) | ||
| .await; | ||
|
|
||
| println!("Transaction result: {:?}", result); | ||
| } |
There was a problem hiding this comment.
Make the test fail on transaction errors.
The result is only logged, so the test can pass even if the transaction fails.
✅ Suggested fix
- let result = rpc
- .create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer])
- .await;
-
- println!("Transaction result: {:?}", result);
+ rpc
+ .create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer])
+ .await
+ .unwrap();📝 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.
| let result = rpc | |
| .create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) | |
| .await; | |
| println!("Transaction result: {:?}", result); | |
| } | |
| rpc | |
| .create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) | |
| .await | |
| .unwrap(); | |
| } |
🤖 Prompt for AI Agents
In
`@snippets/code-snippets/light-token/create-token-account/anchor-macro/full-example.mdx`
around lines 224 - 229, The test currently only logs the transaction outcome, so
failures are ignored; replace the println!("Transaction result: {:?}", result)
with a check that fails the test on error by asserting the Result returned by
rpc.create_and_send_transaction is Ok (or propagating the error) and include the
error details in the assertion message—locate the call to
rpc.create_and_send_transaction (assigned to result) and update the code to
assert/result-handling so the test fails when the transaction fails.
| recipient.publicKey, | ||
| ); | ||
|
|
||
| // Transfer tokens between light-token associate token accounts |
There was a problem hiding this comment.
Typo in comment.
"associate" should be "associated".
- // Transfer tokens between light-token associate token accounts
+ // Transfer tokens between light-token associated token 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.
| // Transfer tokens between light-token associate token accounts | |
| // Transfer tokens between light-token associated token accounts |
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/transfer-interface/instruction.mdx` at
line 50, Fix the typo in the inline comment that reads "Transfer tokens between
light-token associate token accounts" by changing "associate" to "associated" so
the comment reads "Transfer tokens between light-token associated token
accounts"; locate and update this exact comment string in the instruction.mdx
snippet.
| // devnet: | ||
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | ||
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | ||
| const rpc = createRpc(RPC_URL); | ||
| // localnet: | ||
| // const rpc = createRpc(); |
There was a problem hiding this comment.
Undefined RPC_URL variable will cause runtime error.
The RPC_URL constant on line 18 is commented out, but it's still referenced on line 19 in createRpc(RPC_URL). This will cause a ReferenceError when the snippet is executed.
Either uncomment the devnet URL or switch to the localnet configuration:
🐛 Option 1: Uncomment the devnet URL
// devnet:
-// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
+const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
const rpc = createRpc(RPC_URL);
// localnet:
// const rpc = createRpc();🐛 Option 2: Switch to localnet (no URL required)
// devnet:
// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
-const rpc = createRpc(RPC_URL);
// localnet:
-// const rpc = createRpc();
+const rpc = createRpc();📝 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.
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); | |
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); |
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); | |
| // devnet: | |
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| // localnet: | |
| const rpc = createRpc(); |
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/unwrap/instruction.mdx` around lines 17 -
21, The snippet references an undefined RPC_URL when calling createRpc(RPC_URL)
which causes a runtime ReferenceError; fix by either restoring the devnet
constant RPC_URL (uncomment the line that defines RPC_URL) so createRpc(RPC_URL)
has a valid value, or switch to the localnet form by calling createRpc() with no
argument; look for the RPC_URL constant and the createRpc(...) call to update
accordingly.
| // devnet: | ||
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | ||
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | ||
| const rpc = createRpc(RPC_URL); | ||
| // localnet: | ||
| // const rpc = createRpc(); |
There was a problem hiding this comment.
RPC_URL is undefined — this code snippet will not run.
Line 19 comments out the RPC_URL definition, but line 20 still references it. This will throw a ReferenceError when developers copy and run this example.
Proposed fix
Either uncomment the definition:
// devnet:
-// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
+const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
const rpc = createRpc(RPC_URL);Or if the intent is to show a placeholder for users to fill in:
// devnet:
-// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
-const rpc = createRpc(RPC_URL);
+const RPC_URL = `https://devnet.helius-rpc.com?api-key=<YOUR_API_KEY>`;
+const rpc = createRpc(RPC_URL);📝 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.
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); | |
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); |
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); | |
| // devnet: | |
| const RPC_URL = `https://devnet.helius-rpc.com?api-key=<YOUR_API_KEY>`; | |
| const rpc = createRpc(RPC_URL); | |
| // localnet: | |
| // const rpc = createRpc(); |
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/wrap/instruction.mdx` around lines 18 -
22, The snippet references RPC_URL when calling createRpc (rpc =
createRpc(RPC_URL)) but RPC_URL is currently commented out, causing a
ReferenceError; fix by either uncommenting/defining RPC_URL (e.g., set const
RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`)
before calling createRpc, or change the call to createRpc() for localnet
usage—update the line that initializes rpc (the createRpc invocation) so it
matches the intended example (devnet with RPC_URL defined or localnet using
createRpc()).
| const [copied, setCopied] = useState(false); | ||
| const containerRef = useRef(null); | ||
| const animationRef = useRef(null); | ||
| const firstPreRef = useRef(null); | ||
| const secondPreRef = useRef(null); | ||
| const [containerHeight, setContainerHeight] = useState(null); | ||
|
|
||
| const isLightMode = sliderPercent > 50; | ||
| // When slider is on the right (100%), show first code; on left (0%), show second code | ||
| const showingFirst = sliderPercent > 50; | ||
|
|
||
| const handleCopy = async () => { | ||
| const codeToCopy = showingFirst ? firstCode : secondCode; | ||
| await navigator.clipboard.writeText(codeToCopy); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
navigator.clipboard.writeText secure context requirements browser support Safari iOS
💡 Result:
Secure-context + security requirements for navigator.clipboard.writeText()
- Must be a secure context: your page needs to be served over HTTPS (and “secure-context” equivalents such as
localhostin many browsers). Otherwise the call will fail (often withNotAllowedError). [1][2] - Must be triggered by a user gesture (transient activation) in Safari (macOS + iOS) (and Firefox): call it directly inside a click/tap/pointer handler (e.g.,
pointerdown,pointerup,click). [2][3] - Permissions model differences:
- Safari / Firefox: do not support the
clipboard-read/clipboard-writePermissions API model; they rely on user activation (and Safari may show native UI for clipboard access). [2][3] - Chromium: can also be affected by Permissions-Policy when used in iframes (e.g., requiring
clipboard-writeto be allowed). [2]
- Safari / Firefox: do not support the
Browser support (Safari iOS)
- Safari on iOS: support for the async Clipboard API (
navigator.clipboard/writeText) is reported as supported starting iOS Safari 13.4+. [4] - Safari (macOS): reported as supported starting Safari 13.1+. [4]
- WebKit’s Safari 13.1 announcement notes the API is available via
navigator.clipboard, requires user-gesture handlers, and requires a secure context (https://) (and uses native UI rather than a permissions prompt). [3]
Sources:
[1] MDN – Clipboard.writeText() secure context requirement https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText
[2] MDN – Clipboard API security/permission model notes https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API
[3] WebKit – Safari 13.1 “Async Clipboard API” notes https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/
[4] Can I use – Clipboard API (write) support table (Safari / iOS Safari versions) https://caniuse.com/mdn-api_clipboard_write
🏁 Script executed:
# Find and examine the actual code file
fd "code-compare.jsx" --type fRepository: Lightprotocol/docs-v2
Length of output: 94
🏁 Script executed:
# Read the code-compare.jsx file to verify the concerns
cat -n "snippets/jsx/code-compare.jsx" | head -160Repository: Lightprotocol/docs-v2
Length of output: 7096
Guard clipboard usage and clean up the copy timer.
navigator.clipboard.writeText requires a secure context (HTTPS or localhost) and can fail if the API is unavailable or the clipboard access is denied. Additionally, the setTimeout on line 25 is not stored in a ref, so it cannot be cleaned up on component unmount, risking a state update after teardown.
♻️ Suggested change
- const [copied, setCopied] = useState(false);
+ const [copied, setCopied] = useState(false);
+ const copyTimeoutRef = useRef(null);
...
- const handleCopy = async () => {
- const codeToCopy = showingFirst ? firstCode : secondCode;
- await navigator.clipboard.writeText(codeToCopy);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- };
+ const handleCopy = async () => {
+ const codeToCopy = showingFirst ? firstCode : secondCode;
+ try {
+ if (!navigator.clipboard?.writeText) {
+ throw new Error("Clipboard API unavailable");
+ }
+ await navigator.clipboard.writeText(codeToCopy);
+ setCopied(true);
+ if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
+ copyTimeoutRef.current = setTimeout(() => setCopied(false), 2000);
+ } catch (err) {
+ console.error("Copy failed", err);
+ }
+ };
...
- return () => {
- if (animationRef.current) cancelAnimationFrame(animationRef.current);
- };
+ return () => {
+ if (animationRef.current) cancelAnimationFrame(animationRef.current);
+ if (copyTimeoutRef.current) clearTimeout(copyTimeoutRef.current);
+ };Also applies to: 150-155
🤖 Prompt for AI Agents
In `@snippets/jsx/code-compare.jsx` around lines 11 - 26, The handleCopy function
should guard against missing Clipboard API and failures and should store/clear
the copy timeout to avoid state updates after unmount: update handleCopy to
first check navigator.clipboard and wrap
navigator.clipboard.writeText(codeToCopy) in try/catch (handle failures
gracefully, e.g., early return or fallback), save the setTimeout id into a ref
(e.g., copyTimeoutRef) instead of ignoring it, and add a useEffect cleanup that
clears copyTimeoutRef.current (and any other related timers) on unmount; refer
to handleCopy, copied/setCopied, and create a copyTimeoutRef to locate where to
change code.
Summary
Test plan
Summary by CodeRabbit
New Features
Documentation
Chores