Skip to content

fix: add delegate to packed accounts in decompress, chunk proofs#2284

Open
SwenSchaeferjohann wants to merge 19 commits intomainfrom
swen/pub-beta-cov
Open

fix: add delegate to packed accounts in decompress, chunk proofs#2284
SwenSchaeferjohann wants to merge 19 commits intomainfrom
swen/pub-beta-cov

Conversation

@SwenSchaeferjohann
Copy link
Contributor

@SwenSchaeferjohann SwenSchaeferjohann commented Feb 13, 2026

Summary by CodeRabbit

  • Documentation

    • Updated c-token transfer and unwrap docs to describe the new batch-based processing flow.
  • Refactor

    • Reworked transfer and unwrap flows to use batched operations and to execute loading batches in parallel for improved efficiency.
  • Breaking Change

    • Public API adjusted: one transfer-related export was renamed and a new batching helper was added—update integrations accordingly.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (30)
  • cli/package.json is excluded by none and included by none
  • cli/src/commands/create-token-pool/index.ts is excluded by none and included by none
  • js/compressed-token/CHANGELOG.md is excluded by none and included by none
  • js/compressed-token/package.json is excluded by none and included by none
  • js/compressed-token/src/actions/create-token-pool.ts is excluded by none and included by none
  • js/compressed-token/src/index.ts is excluded by none and included by none
  • js/compressed-token/src/program.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/decompress-mint.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/load-ata.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/transfer-interface.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/unwrap.ts is excluded by none and included by none
  • js/compressed-token/src/v3/instructions/create-mint.ts is excluded by none and included by none
  • js/compressed-token/src/v3/instructions/mint-to-compressed.ts is excluded by none and included by none
  • js/compressed-token/src/v3/unified/index.ts is excluded by none and included by none
  • js/compressed-token/src/v3/utils/estimate-tx-size.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/approve-and-mint-to.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/create-associated-ctoken.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/create-ata-interface.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/create-token-pool.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/get-or-create-ata-interface.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/input-selection.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-to-ctoken.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-to-interface.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/mint-workflow.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/multi-cold-inputs.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/multi-pool.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/unwrap.test.ts is excluded by none and included by none
  • js/compressed-token/tests/unit/estimate-tx-size.test.ts is excluded by none and included by none
  • js/compressed-token/tests/unit/select-inputs.test.ts is excluded by none and included by none
  • js/stateless.js/package.json is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Reworks instruction-level c-token flows in ctoken_for_payments.md to use batched instruction creation and parallel loading. Renames createTransferInterfaceInstructioncreateTransferInterfaceInstructions, adds sliceLast export, and introduces Transaction/sendAndConfirmTransaction usage for unwrap batching.

Changes

Cohort / File(s) Summary
C-token instruction-level changes
ctoken_for_payments.md
Replaces per-call transfer interface with createTransferInterfaceInstructions returning batches; adds sliceLast to separate load vs transfer batches; runs load batches in parallel and executes transfer/unwrap as separate transactions. Adds Transaction/sendAndConfirmTransaction imports and getMint use for unwrap decimals; public API rename/export updated.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant InstrCreator
    participant BatchAggregator
    participant RPC

    rect rgba(100,150,200,0.5)
    Note over Client,RPC: Batch-Based Transfer Flow
    Client->>InstrCreator: createTransferInterfaceInstructions(...)
    InstrCreator-->>Client: [batch1, batch2, ..., transferBatch]
    Client->>BatchAggregator: sliceLast(batches)
    BatchAggregator-->>Client: [loadBatches, transferBatch]
    par Execute loads
      Client->>RPC: sendAndConfirmTransaction(loadBatch1)
      Client->>RPC: sendAndConfirmTransaction(loadBatch2)
    end
    Client->>RPC: sendAndConfirmTransaction(transferBatch)
    RPC-->>Client: confirmed
    end
Loading
sequenceDiagram
    participant Client
    participant MintService
    participant InstrCreator
    participant RPC

    rect rgba(100,200,100,0.5)
    Note over Client,RPC: Parallel Unwrap Flow
    Client->>InstrCreator: createLoadAtaInstructions(...)
    Client->>MintService: getMint(mintAddr)
    MintService-->>Client: decimals
    Client->>InstrCreator: createUnwrapInstruction(decimals)
    par Parallel load RPCs
      Client->>RPC: sendAndConfirmTransaction(loadBatch1)
      Client->>RPC: sendAndConfirmTransaction(loadBatch2)
    end
    Client->>RPC: sendAndConfirmTransaction(unwrapTransaction)
    RPC-->>Client: unwrap confirmed
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • sergeytimoshin
  • ananas-block

Poem

🔄 Batches gather, split, then dance in line,
Loads fly parallel while transfers wait their time,
Functions renamed to carry plural cheer,
Transactions sent — confirmations near! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references 'delegate to packed accounts in decompress, chunk proofs' but the changeset implements batched c-token payment flows and unwrap instruction batching with API renaming, which are unrelated changes. Update the PR title to accurately reflect the main changes: something like 'refactor: batch c-token transfers and unwrap instructions with parallel loading' to match the actual implementation.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (113 files):

⚔️ Cargo.lock (content)
⚔️ ctoken_for_payments.md (content)
⚔️ js/compressed-token/CHANGELOG.md (content)
⚔️ js/compressed-token/src/index.ts (content)
⚔️ js/compressed-token/src/v3/actions/create-ata-interface.ts (content)
⚔️ js/compressed-token/src/v3/actions/create-mint-interface.ts (content)
⚔️ js/compressed-token/src/v3/actions/decompress-interface.ts (content)
⚔️ js/compressed-token/src/v3/actions/decompress-mint.ts (content)
⚔️ js/compressed-token/src/v3/actions/get-or-create-ata-interface.ts (content)
⚔️ js/compressed-token/src/v3/actions/load-ata.ts (content)
⚔️ js/compressed-token/src/v3/actions/mint-to-compressed.ts (content)
⚔️ js/compressed-token/src/v3/actions/transfer-interface.ts (content)
⚔️ js/compressed-token/src/v3/actions/update-metadata.ts (content)
⚔️ js/compressed-token/src/v3/actions/update-mint.ts (content)
⚔️ js/compressed-token/src/v3/ata-utils.ts (content)
⚔️ js/compressed-token/src/v3/derivation.ts (content)
⚔️ js/compressed-token/src/v3/get-account-interface.ts (content)
⚔️ js/compressed-token/src/v3/get-associated-token-address-interface.ts (content)
⚔️ js/compressed-token/src/v3/get-mint-interface.ts (content)
⚔️ js/compressed-token/src/v3/instructions/create-associated-ctoken.ts (content)
⚔️ js/compressed-token/src/v3/instructions/create-ata-interface.ts (content)
⚔️ js/compressed-token/src/v3/instructions/create-decompress-interface-instruction.ts (content)
⚔️ js/compressed-token/src/v3/instructions/create-load-accounts-params.ts (content)
⚔️ js/compressed-token/src/v3/instructions/create-mint.ts (content)
⚔️ js/compressed-token/src/v3/instructions/decompress-mint.ts (content)
⚔️ js/compressed-token/src/v3/instructions/mint-to-compressed.ts (content)
⚔️ js/compressed-token/src/v3/instructions/mint-to.ts (content)
⚔️ js/compressed-token/src/v3/instructions/transfer-interface.ts (content)
⚔️ js/compressed-token/src/v3/instructions/unwrap.ts (content)
⚔️ js/compressed-token/src/v3/instructions/update-metadata.ts (content)
⚔️ js/compressed-token/src/v3/instructions/update-mint.ts (content)
⚔️ js/compressed-token/src/v3/instructions/wrap.ts (content)
⚔️ js/compressed-token/src/v3/unified/index.ts (content)
⚔️ js/compressed-token/tests/e2e/compressible-load.test.ts (content)
⚔️ js/compressed-token/tests/e2e/create-ata-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/create-compressed-mint.test.ts (content)
⚔️ js/compressed-token/tests/e2e/create-mint-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/get-account-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/get-mint-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/get-or-create-ata-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/layout.test.ts (content)
⚔️ js/compressed-token/tests/e2e/load-ata-spl-t22.test.ts (content)
⚔️ js/compressed-token/tests/e2e/load-ata-standard.test.ts (content)
⚔️ js/compressed-token/tests/e2e/load-ata-unified.test.ts (content)
⚔️ js/compressed-token/tests/e2e/mint-to-compressed.test.ts (content)
⚔️ js/compressed-token/tests/e2e/mint-to-ctoken.test.ts (content)
⚔️ js/compressed-token/tests/e2e/mint-to-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/mint-workflow.test.ts (content)
⚔️ js/compressed-token/tests/e2e/multi-cold-inputs.test.ts (content)
⚔️ js/compressed-token/tests/e2e/payment-flows.test.ts (content)
⚔️ js/compressed-token/tests/e2e/transfer-interface.test.ts (content)
⚔️ js/compressed-token/tests/e2e/update-metadata.test.ts (content)
⚔️ js/compressed-token/tests/e2e/update-mint.test.ts (content)
⚔️ js/compressed-token/tests/e2e/v3-interface-migration.test.ts (content)
⚔️ js/compressed-token/tests/e2e/wrap.test.ts (content)
⚔️ js/compressed-token/tests/unit/get-associated-token-address-interface.test.ts (content)
⚔️ js/compressed-token/tests/unit/mint-action-layout.test.ts (content)
⚔️ js/compressed-token/tests/unit/unified-guards.test.ts (content)
⚔️ js/stateless.js/src/constants.ts (content)
⚔️ js/stateless.js/src/rpc.ts (content)
⚔️ js/stateless.js/src/utils/validation.ts (content)
⚔️ js/stateless.js/tests/unit/utils/validation.test.ts (content)
⚔️ program-libs/compressed-account/src/instruction_data/zero_copy.rs (content)
⚔️ program-libs/token-interface/src/instructions/mint_action/builder.rs (content)
⚔️ program-libs/token-interface/src/instructions/mint_action/instruction_data.rs (content)
⚔️ program-libs/token-interface/src/instructions/transfer2/instruction_data.rs (content)
⚔️ program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs (content)
⚔️ program-tests/compressed-token-test/tests/light_token/transfer_checked.rs (content)
⚔️ program-tests/compressed-token-test/tests/token_pool.rs (content)
⚔️ program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs (content)
⚔️ program-tests/system-test/Cargo.toml (content)
⚔️ programs/compressed-token/program/docs/compressed_token/MINT_ACTION.md (content)
⚔️ programs/compressed-token/program/docs/compressed_token/TRANSFER2.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/APPROVE.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/BURN.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/BURN_CHECKED.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/MINT_TO.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/MINT_TO_CHECKED.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/REVOKE.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/TRANSFER.md (content)
⚔️ programs/compressed-token/program/docs/ctoken/TRANSFER_CHECKED.md (content)
⚔️ programs/compressed-token/program/src/compressed_token/mint_action/actions/process_actions.rs (content)
⚔️ programs/compressed-token/program/src/compressed_token/transfer2/compression/ctoken/compress_and_close.rs (content)
⚔️ programs/compressed-token/program/src/compressed_token/transfer2/compression/mod.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/approve_revoke.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/burn.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/mint_to.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/transfer/checked.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/transfer/default.rs (content)
⚔️ programs/compressed-token/program/src/ctoken/transfer/shared.rs (content)
⚔️ programs/compressed-token/program/src/shared/compressible_top_up.rs (content)
⚔️ programs/compressed-token/program/tests/check_extensions.rs (content)
⚔️ programs/compressed-token/program/tests/extensions_metadata.rs (content)
⚔️ programs/compressed-token/program/tests/mint.rs (content)
⚔️ programs/registry/src/compressible/compressed_token/compress_and_close.rs (content)
⚔️ programs/system/src/cpi_context/process_cpi_context.rs (content)
⚔️ programs/system/src/cpi_context/state.rs (content)
⚔️ programs/system/src/invoke_cpi/processor.rs (content)
⚔️ programs/system/tests/cpi_context.rs (content)
⚔️ sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (content)
⚔️ sdk-libs/event/tests/parse_test.rs (content)
⚔️ sdk-libs/instruction-decoder/src/programs/ctoken.rs (content)
⚔️ sdk-libs/sdk-types/src/interface/cpi/create_mints.rs (content)
⚔️ sdk-libs/sdk-types/src/interface/program/decompression/processor.rs (content)
⚔️ sdk-libs/token-pinocchio/src/instruction/transfer_from_spl.rs (content)
⚔️ sdk-libs/token-pinocchio/src/instruction/transfer_to_spl.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/burn.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/burn_checked.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/create_mints.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/mint_to.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/mint_to_checked.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/transfer.rs (content)
⚔️ sdk-libs/token-sdk/src/instruction/transfer_checked.rs (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch swen/pub-beta-cov

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.

@SwenSchaeferjohann SwenSchaeferjohann changed the title fix(js): add delegate to packed accounts in decompress, chunk proofs fix: add delegate to packed accounts in decompress, chunk proofs Feb 13, 2026
Copy link
Contributor

@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: 1

Caution

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

⚠️ Outside diff range comments (1)
ctoken_for_payments.md (1)

268-311: ⚠️ Potential issue | 🟡 Minor

Fix the misleading "parallel" comment and surface the new decimals requirement.

The example has three issues worth addressing:

  1. Misleading parallel execution: The comment says "in parallel, if any" but the code uses sequential for-loop with await on each iteration. Either execute truly in parallel using Promise.all() or correct the comment to reflect sequential execution.

  2. New decimals parameter is required: The createUnwrapInstruction now requires the mint's decimals (for transfer_checked validation). The example correctly fetches this via getMint, but this change should be called out since it differs from previous API versions.

  3. Missing error handling: In production, both the load batches loop and the unwrap transaction should be wrapped in try-catch blocks with appropriate failure handling (retries, user notifications, etc.).

Example: Fix parallel execution or comment

For truly parallel execution:

-// Send load batches first (in parallel, if any), then unwrap tx
-for (const batch of loadBatches) {
-  await sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
-    payer,
-    owner,
-  ]);
-}
+// Send load batches in parallel (if any), then unwrap tx
+if (loadBatches.length > 0) {
+  await Promise.all(
+    loadBatches.map(batch =>
+      sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [payer, owner])
+    )
+  );
+}

Or, for sequential (fix comment):

-// Send load batches first (in parallel, if any), then unwrap tx
+// Send load batches first (if any), then unwrap tx
 for (const batch of loadBatches) {
🤖 Fix all issues with AI agents
In `@ctoken_for_payments.md`:
- Around line 144-159: Add a cross-reference to the official
js/compressed-token/docs/payment-integration.md and a brief note next to the
createTransferInterfaceInstructions example: mention the hot/cold sender pattern
and the rule "For a hot sender or <=8 cold inputs, the result is a
single-element array", and instruct readers to run loadBatches (the rest
returned by sliceLast) in parallel and then submit transferBatch sequentially;
reference the symbols createTransferInterfaceInstructions, sliceLast,
loadBatches, and transferBatch and add a link to the payment-integration.md
which contains the full usage example and the table describing contents of each
transaction.

Comment on lines 144 to 159
createTransferInterfaceInstructions,
sliceLast,
} from "@lightprotocol/compressed-token/unified";

const sourceAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);
const destinationAta = getAssociatedTokenAddressInterface(mint, recipient);

const tx = new Transaction().add(
...(await createLoadAtaInstructions(
rpc,
sourceAta,
owner.publicKey,
mint,
payer.publicKey
)),
createTransferInterfaceInstruction(
sourceAta,
destinationAta,
owner.publicKey,
amount
)
const batches = await createTransferInterfaceInstructions(
rpc,
payer.publicKey,
mint,
amount,
owner.publicKey,
recipient
);
const { rest: loadBatches, last: transferBatch } = sliceLast(batches);
// For hot sender: one batch. For cold: run loadBatches in parallel, then transferBatch
const tx = new Transaction().add(...transferBatch);
```
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

🧩 Analysis chain

🏁 Script executed:

# Find the file and check its location
find . -name "ctoken_for_payments.md" -type f

Repository: Lightprotocol/light-protocol

Length of output: 96


🏁 Script executed:

# Search for createTransferInterfaceInstructions export (plural)
rg -n "export.*createTransferInterfaceInstructions" --type=ts --type=js

Repository: Lightprotocol/light-protocol

Length of output: 298


🏁 Script executed:

# Search for sliceLast export
rg -n "export.*sliceLast" --type=ts --type=js

Repository: Lightprotocol/light-protocol

Length of output: 324


🏁 Script executed:

# Check for old singular API references
rg -n "createTransferInterfaceInstruction[^s]" --type=ts --type=js -g '!*.md'

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Find CLAUDE.md files for compressed token documentation guidance
find . -path "*/compressed-token/*" -name "CLAUDE.md" -o -path "*/compressed-token/*" -name "*.md" | head -20

Repository: Lightprotocol/light-protocol

Length of output: 1176


🏁 Script executed:

# Look at the unified module structure
find . -path "*/compressed-token/unified*" -type f | grep -E "\.(ts|js|md)$"

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Get the full path and first 200 lines of ctoken_for_payments.md
find . -name "ctoken_for_payments.md" -exec wc -l {} \;

Repository: Lightprotocol/light-protocol

Length of output: 100


🏁 Script executed:

# Check the directory containing ctoken_for_payments.md
find . -name "ctoken_for_payments.md" -exec dirname {} \;

Repository: Lightprotocol/light-protocol

Length of output: 73


🏁 Script executed:

# Read the relevant section of the file (around lines 144-159)
sed -n '130,170p' ./ctoken_for_payments.md | cat -n

Repository: Lightprotocol/light-protocol

Length of output: 1345


🏁 Script executed:

# Check for hot/cold sender pattern documentation elsewhere
rg -n "hot\s+sender|cold\s+sender" --type=md --type=ts

Repository: Lightprotocol/light-protocol

Length of output: 1159


🏁 Script executed:

# Look for CLAUDE.md guidance in js/compressed-token
find ./js/compressed-token -name "CLAUDE.md" -o -name "*.md" | grep -i claude

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Check docs directory in js/compressed-token for standards
ls -la ./js/compressed-token/docs/ 2>/dev/null || echo "No docs dir"

Repository: Lightprotocol/light-protocol

Length of output: 321


🏁 Script executed:

# Read payment-integration.md to see existing hot/cold sender documentation
cat ./js/compressed-token/docs/payment-integration.md

Repository: Lightprotocol/light-protocol

Length of output: 3120


🏁 Script executed:

# Check the JSDoc for createTransferInterfaceInstructions in transfer-interface.ts
sed -n '200,225p' ./js/compressed-token/src/v3/actions/transfer-interface.ts | cat -n

Repository: Lightprotocol/light-protocol

Length of output: 1335


🏁 Script executed:

# Check if there are any references from ctoken_for_payments.md to payment-integration.md
rg -n "payment-integration" ./ctoken_for_payments.md

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Check if ctoken_for_payments.md should be elsewhere or if this is the intended location
cat -n ./ctoken_for_payments.md | head -30

Repository: Lightprotocol/light-protocol

Length of output: 865


🏁 Script executed:

# Check for any references to ctoken_for_payments.md in docs or READMEs
rg -n "ctoken_for_payments" --type=md --type=ts

Repository: Lightprotocol/light-protocol

Length of output: 54


🏁 Script executed:

# Understand the file structure - is ctoken_for_payments.md a payment flow guide?
head -50 ./ctoken_for_payments.md

Repository: Lightprotocol/light-protocol

Length of output: 993


Reference the official payment-integration.md documentation for batching details.

The hot/cold sender pattern and batching guidance already exist in the official js/compressed-token/docs/payment-integration.md. Consider adding a link or cross-reference to that documentation, which explains:

  • "For a hot sender or <=8 cold inputs, the result is a single-element array"
  • Complete usage showing parallel load transactions followed by sequential transfer
  • A table describing what each transaction contains

The APIs (createTransferInterfaceInstructions, sliceLast) are correct and properly exported from the unified module. The code example is accurate; it just needs to point readers to the comprehensive documentation that already covers the concepts in detail.

🤖 Prompt for AI Agents
In `@ctoken_for_payments.md` around lines 144 - 159, Add a cross-reference to the
official js/compressed-token/docs/payment-integration.md and a brief note next
to the createTransferInterfaceInstructions example: mention the hot/cold sender
pattern and the rule "For a hot sender or <=8 cold inputs, the result is a
single-element array", and instruct readers to run loadBatches (the rest
returned by sliceLast) in parallel and then submit transferBatch sequentially;
reference the symbols createTransferInterfaceInstructions, sliceLast,
loadBatches, and transferBatch and add a link to the payment-integration.md
which contains the full usage example and the table describing contents of each
transaction.

Copy link
Contributor

@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: 1

🤖 Fix all issues with AI agents
In `@ctoken_for_payments.md`:
- Around line 312-318: The comment says "Send load batches first (in
parallel...)" but the for-loop over loadBatches runs sequentially; update to
actually send in parallel by mapping loadBatches to an array of
sendAndConfirmTransaction promises using sendAndConfirmTransaction(rpc, new
Transaction().add(...batch), [payer, owner]) and await Promise.all(...) (or,
alternatively, change the comment to remove "in parallel" if sequential behavior
is intended). Ensure you reference loadBatches, sendAndConfirmTransaction, rpc,
Transaction, payer, and owner when making the change so the behavior and intent
remain clear.

Comment on lines +312 to +318
// Send load batches first (in parallel, if any), then unwrap tx
for (const batch of loadBatches) {
await sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
payer,
owner,
]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Fix mismatch: comment says parallel, code runs sequentially.

The text says “Send load batches first (in parallel, if any)” but the loop sends them sequentially. Either update the comment or send in parallel to match the guidance.

♻️ Suggested fix (parallelize loads)
-// Send load batches first (in parallel, if any), then unwrap tx
-for (const batch of loadBatches) {
-  await sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
-    payer,
-    owner,
-  ]);
-}
+// Send load batches first (in parallel, if any), then unwrap tx
+await Promise.all(
+  loadBatches.map((batch) =>
+    sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
+      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.

Suggested change
// Send load batches first (in parallel, if any), then unwrap tx
for (const batch of loadBatches) {
await sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
payer,
owner,
]);
}
// Send load batches first (in parallel, if any), then unwrap tx
await Promise.all(
loadBatches.map((batch) =>
sendAndConfirmTransaction(rpc, new Transaction().add(...batch), [
payer,
owner,
])
)
);
🤖 Prompt for AI Agents
In `@ctoken_for_payments.md` around lines 312 - 318, The comment says "Send load
batches first (in parallel...)" but the for-loop over loadBatches runs
sequentially; update to actually send in parallel by mapping loadBatches to an
array of sendAndConfirmTransaction promises using sendAndConfirmTransaction(rpc,
new Transaction().add(...batch), [payer, owner]) and await Promise.all(...) (or,
alternatively, change the comment to remove "in parallel" if sequential behavior
is intended). Ensure you reference loadBatches, sendAndConfirmTransaction, rpc,
Transaction, payer, and owner when making the change so the behavior and intent
remain clear.

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