Skip to content

Add indexing tokens warm-up examples#19

Open
tilo-14 wants to merge 1 commit intomainfrom
indexing-tokens
Open

Add indexing tokens warm-up examples#19
tilo-14 wants to merge 1 commit intomainfrom
indexing-tokens

Conversation

@tilo-14
Copy link
Collaborator

@tilo-14 tilo-14 commented Feb 1, 2026

Summary

  • Replace inline load-ata code on the "For Indexing Tokens" toolkit page with warm-up snippets sourced from examples-light-token
  • Add snippet copy script support for toolkits/indexing-tokens/ warm-up examples
  • Show the detect cold → decompress → trade pattern that indexers need

Test plan

  • warm-up-action.ts passes against localnet
  • warm-up-instruction.ts passes against localnet
  • Verify page renders with npm run dev

Summary by CodeRabbit

  • Documentation
    • Clarified market inactivity behavior: automatic compression to cold storage and on-ledger cryptographic preservation; on-chain lookups return uninitialized.
    • Added concise tabbed examples (WarmUpAction / WarmUpInstruction) showing an idempotent "warm up a cold market" pattern before trading.
    • Updated resource link and refreshed snippet publishing so new examples appear in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Walkthrough

Refactors the Light Protocol token toolkit docs to replace inline TypeScript examples with two new MDX snippets (WarmUpAction, WarmUpInstruction), updates prose about market compression and on-chain lookup semantics, and adds script changes to copy/process these snippets during the build.

Changes

Cohort / File(s) Summary
Documentation
light-token/toolkits/for-streaming-tokens.mdx
Replaced inline TypeScript examples and previous toolkit setup with a Tabs block referencing WarmUpAction and WarmUpInstruction MDX components; updated wording on market inactivity, automatic compression (cold storage), is_initialized/is_compressed semantics, and on-chain lookup behavior.
Build Script
scripts/copy-light-token-snippets.sh
Ensure destination directory exists before writing; add indexing workflow to process warm-up variants (warm-up-action, warm-up-instruction) from indexing-tokens, wrap and save snippets to SNIPPETS_DIR/warm-up, warn when missing, and list created files after processing.
New Snippets
snippets/code-snippets/light-token/warm-up/warm-up-action.mdx, snippets/code-snippets/light-token/warm-up/warm-up-instruction.mdx
Add two TypeScript MDX examples: warm-up-action shows loading a payer ATA (no-op if already hot) and using transferInterface to move tokens; warm-up-instruction demonstrates createLoadAtaInstructions, conditional transaction assembly when load is required, then a transfer instruction.
Navigation / MDX formatting
(same file) light-token/toolkits/for-streaming-tokens.mdx
Minor MDX formatting adjustments to close blocks consistently and preserve downstream Card linking to streaming mints.

Sequence Diagram(s)

(omitted — changes are documentation and snippet additions without a cross-component control-flow change requiring a diagram)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • chore: update docs #17 — Related docs clarifying cold-market compression behavior and idempotent/no-op semantics for load/createLoadAtaInstructions.
  • chore: rename ctoken to light-token #11 — Related updates to light-token toolkit docs and ATA usage semantics that overlap with these snippet changes.
  • chore: update #15 — Related documentation edits about prepping/loading cold accounts and prepending load/warm-up instructions.

Poem

🐰 I hopped through snippets, tidy and bright,

Warmed tokens gently before the trade's flight.
Scripts stacked the snippets, neat in a row,
Docs now whisper how cold markets go,
A rabbit's small cheer for the code's warm glow.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding warm-up code examples for indexing tokens, which is reflected across all four modified/created files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch indexing-tokens

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/copy-light-token-snippets.sh (1)

6-7: ⚠️ Potential issue | 🔴 Critical

Hardcoded absolute paths break portability.

The script uses absolute paths tied to a specific developer's machine (/home/tilo/Workspace/...). This will fail for other contributors and in CI environments.

Consider using relative paths from the repository root or environment variables:

🔧 Proposed fix using relative paths
-EXAMPLES="/home/tilo/Workspace/examples-light-token/cookbook"
-SNIPPETS_DIR="/home/tilo/Workspace/docs/snippets/code-snippets/light-token"
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+
+# Configure external examples repo path (override via environment variable)
+EXAMPLES="${EXAMPLES_LIGHT_TOKEN:-$REPO_ROOT/../examples-light-token/cookbook}"
+SNIPPETS_DIR="$REPO_ROOT/snippets/code-snippets/light-token"

And for line 45:

-INDEXING_DIR="/home/tilo/Workspace/examples-light-token/toolkits/indexing-tokens"
+INDEXING_DIR="${EXAMPLES_LIGHT_TOKEN:-$REPO_ROOT/../examples-light-token}/toolkits/indexing-tokens"

Also applies to: 45-45

🤖 Fix all issues with AI agents
In `@light-token/toolkits/for-streaming-tokens.mdx`:
- Around line 18-19: The phrase "warm up" used as a compound modifier in the
sentence containing idempotent decompress "warm up" instruction should be
hyphenated; update the text so it reads idempotent decompress "warm-up"
instruction (or idempotent decompress warm-up instruction) to use the compound
modifier form, leaving the rest of the sentence unchanged.

In `@snippets/code-snippets/light-token/warm-up/warm-up-action.mdx`:
- Around line 56-57: The code block ends without a blank line before the closing
fence causing markdown rendering issues; edit the snippet containing the IIFE
that logs the transaction (the line with console.log("Tx:", tx); and the
trailing IIFE end `})();`) and insert a newline after `})();` so the closing
triple-backtick is on its own line (i.e., add a blank line/newline between
`})();` and the closing ``` fence).

In `@snippets/code-snippets/light-token/warm-up/warm-up-instruction.mdx`:
- Around line 76-77: The closing Markdown code fence is missing a preceding
newline in the warm-up snippet—locate the snippet containing console.log("Tx:",
signature);})(); and add a newline (blank line) before the final ``` fence so
the code block closes properly; ensure the sequence ends with the code line, a
newline, then ``` to fix rendering.
🧹 Nitpick comments (1)
scripts/copy-light-token-snippets.sh (1)

44-55: Indexing toolkit processing looks correct.

The new section follows the established pattern. One minor observation: the source directory name (indexing-tokens) differs from the output directory name (warm-up). This is intentional per the PR description but worth documenting in a comment for clarity.

💡 Optional: Add clarifying comment
 # Indexing toolkit snippets
+# Note: Source files are in indexing-tokens/, but output to warm-up/ to match documentation structure
 INDEXING_DIR="/home/tilo/Workspace/examples-light-token/toolkits/indexing-tokens"

Comment on lines +18 to +19
To trade a cold market, the first client must prepend an
idempotent decompress "warm up" instruction.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Hyphenate "warm up" when used as a compound modifier.

Per static analysis, "warm up" should be hyphenated as "warm-up" when used as an adjective modifying "instruction".

📝 Proposed fix
 To trade a cold market, the first client must prepend an
-idempotent decompress "warm up" instruction.
+idempotent decompress "warm-up" instruction.
📝 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.

Suggested change
To trade a cold market, the first client must prepend an
idempotent decompress "warm up" instruction.
To trade a cold market, the first client must prepend an
idempotent decompress "warm-up" instruction.
🧰 Tools
🪛 LanguageTool

[grammar] ~19-~19: Use a hyphen to join words.
Context: ...t prepend an idempotent decompress "warm up" instruction. Find the sour...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In `@light-token/toolkits/for-streaming-tokens.mdx` around lines 18 - 19, The
phrase "warm up" used as a compound modifier in the sentence containing
idempotent decompress "warm up" instruction should be hyphenated; update the
text so it reads idempotent decompress "warm-up" instruction (or idempotent
decompress warm-up instruction) to use the compound modifier form, leaving the
rest of the sentence unchanged.

Comment on lines +56 to +57
console.log("Tx:", tx);
})();```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing newline before closing code fence.

The closing `)();``` should have a newline before the fence for proper markdown rendering.

📝 Proposed fix
     console.log("Tx:", tx);
-})();```
+})();
+```
📝 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.

Suggested change
console.log("Tx:", tx);
})();```
console.log("Tx:", tx);
})();
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/warm-up/warm-up-action.mdx` around lines
56 - 57, The code block ends without a blank line before the closing fence
causing markdown rendering issues; edit the snippet containing the IIFE that
logs the transaction (the line with console.log("Tx:", tx); and the trailing
IIFE end `})();`) and insert a newline after `})();` so the closing
triple-backtick is on its own line (i.e., add a blank line/newline between
`})();` and the closing ``` fence).

Comment on lines +76 to +77
console.log("Tx:", signature);
})();```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing newline before closing code fence.

Same issue as the action snippet - the closing fence needs a preceding newline for proper markdown rendering.

📝 Proposed fix
     console.log("Tx:", signature);
-})();```
+})();
+```
🤖 Prompt for AI Agents
In `@snippets/code-snippets/light-token/warm-up/warm-up-instruction.mdx` around
lines 76 - 77, The closing Markdown code fence is missing a preceding newline in
the warm-up snippet—locate the snippet containing console.log("Tx:",
signature);})(); and add a newline (blank line) before the final ``` fence so
the code block closes properly; ensure the sequence ends with the code line, a
newline, then ``` to fix rendering.

Replace inline load-ata code on for-streaming-tokens page with
warm-up snippets sourced from examples-light-token. Shows detect
cold + decompress + trade pattern for indexers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant