Skip to content

Add TON case to contract_write executor#783

Open
HaykK-Solicy wants to merge 1 commit intotestnetfrom
feature/add-ton-contract-write-executor
Open

Add TON case to contract_write executor#783
HaykK-Solicy wants to merge 1 commit intotestnetfrom
feature/add-ton-contract-write-executor

Conversation

@HaykK-Solicy
Copy link
Copy Markdown

@HaykK-Solicy HaykK-Solicy commented Apr 30, 2026

Summary by CodeRabbit

  • New Features
    • Added TON blockchain support for contract write operations, enabling users to execute and interact with smart contracts on the TON network.

@qodo-code-review
Copy link
Copy Markdown
Contributor

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Walkthrough

Adds TON blockchain support to the contract write executor by importing TON, introducing a handleTonContractWrite helper function that routes TON contract-write operations through genericJsonRpcPay using the TON subchain provider, and extending the existing chain dispatcher to handle TON requests.

Changes

Cohort / File(s) Summary
TON Contract Write Support
src/features/multichain/routines/executors/contract_write.ts
Added TON import, created handleTonContractWrite helper function to process TON contract-write operations via genericJsonRpcPay, and extended the chain switch statement to route operation.chain === "ton" to the new handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A hop, a skip, across chains we go,
TON support now steals the show!
From Ethereum's realm to blockchains anew,
The executor knows just what to do.
With genericJsonRpc and routing so neat,
Another chain conquest—oh, how sweet! 🪙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and accurately describes the main change: adding TON case handling to the contract_write executor. The title is clear, concise, and specific to the primary modification in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-ton-contract-write-executor

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@sonarqubecloud
Copy link
Copy Markdown

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR adds a ton case to the contract_write executor, introducing a handleTonContractWrite helper that reuses the existing genericJsonRpcPay utility and the pre-configured chainProviders.ton URLs — following the same pattern already used by handleSolanaContractWrite. The implementation is minimal, consistent, and leverages existing modular infrastructure correctly.

Confidence Score: 5/5

Safe to merge — the change is a clean copy of the Solana contract-write pattern with no logic gaps beyond an existing P2 style inconsistency.

All findings are P2 (style/best-practice). The new handler correctly reuses genericJsonRpcPay, TON providers are already configured, and error handling is inherited from the shared helper.

No files require special attention.

Important Files Changed

Filename Overview
src/features/multichain/routines/executors/contract_write.ts Adds TON case to contract_write dispatcher by introducing a thin handleTonContractWrite helper that correctly reuses genericJsonRpcPay with the existing chainProviders.ton config — mirrors the Solana contract-write pattern exactly; minor: no operation.rpc fallback.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant handleContractWrite
    participant handleTonContractWrite
    participant genericJsonRpcPay
    participant TON SDK
    participant TonCenter

    Caller->>handleContractWrite: operation (chain="ton")
    handleContractWrite->>handleTonContractWrite: operation
    handleTonContractWrite->>genericJsonRpcPay: TON, chainProviders.ton[subchain], operation
    genericJsonRpcPay->>TON SDK: create(rpcUrl)
    TON SDK-->>genericJsonRpcPay: instance
    genericJsonRpcPay->>TON SDK: instance.sendTransaction(signedPayload)
    TON SDK->>TonCenter: broadcast BoC
    TonCenter-->>TON SDK: tx hash / error
    TON SDK-->>genericJsonRpcPay: result
    genericJsonRpcPay-->>handleTonContractWrite: result
    handleTonContractWrite-->>handleContractWrite: result
    handleContractWrite-->>Caller: result
Loading

Reviews (1): Last reviewed commit: "Add TON case to contract_write executor" | Re-trigger Greptile

// TON.sendTransaction parses it and broadcasts via TonCenter.
return await genericJsonRpcPay(
TON,
chainProviders.ton[operation.subchain],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Missing operation.rpc fallback

chainProviders.ton[operation.subchain] is used directly without honoring a caller-supplied operation.rpc. The sibling handlePayOperation in pay.ts (line 52) uses operation.rpc || chainProviders[operation.chain][operation.subchain] for the same chain, so a custom RPC passed through a TON contract-write operation will be silently ignored. The same gap exists in handleSolanaContractWrite, but it's worth aligning both here.

Suggested change
chainProviders.ton[operation.subchain],
operation.rpc || chainProviders.ton[operation.subchain],

Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/multichain/routines/executors/contract_write.ts`:
- Around line 35-43: The TON contract write handler handleTonContractWrite
currently always uses chainProviders.ton[operation.subchain], ignoring an
explicit operation.rpc override; update the provider selection so it prefers
operation.rpc when present (falling back to
chainProviders.ton[operation.subchain]) and pass that chosen provider into
genericJsonRpcPay (referencing handleTonContractWrite, operation.rpc,
chainProviders.ton, and genericJsonRpcPay to locate the change).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42565c6c-7f90-4625-a716-062b115ab595

📥 Commits

Reviewing files that changed from the base of the PR and between 50ab546 and 87345f1.

📒 Files selected for processing (1)
  • src/features/multichain/routines/executors/contract_write.ts

Comment on lines +35 to +43
async function handleTonContractWrite(operation: IOperation) {
// Signed payload is a hex-encoded BoC of the wallet's external message; the localSDK's
// TON.sendTransaction parses it and broadcasts via TonCenter.
return await genericJsonRpcPay(
TON,
chainProviders.ton[operation.subchain],
operation,
)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Honor operation.rpc in TON contract writes.

Line 40 always uses chainProviders.ton[operation.subchain], so explicit RPC overrides are ignored for TON writes. This can send transactions to the wrong endpoint/network in multi-env setups.

Suggested fix
 async function handleTonContractWrite(operation: IOperation) {
     // Signed payload is a hex-encoded BoC of the wallet's external message; the localSDK's
     // TON.sendTransaction parses it and broadcasts via TonCenter.
+    const rpcUrl = operation.rpc || chainProviders.ton[operation.subchain]
     return await genericJsonRpcPay(
         TON,
-        chainProviders.ton[operation.subchain],
+        rpcUrl,
         operation,
     )
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/multichain/routines/executors/contract_write.ts` around lines 35
- 43, The TON contract write handler handleTonContractWrite currently always
uses chainProviders.ton[operation.subchain], ignoring an explicit operation.rpc
override; update the provider selection so it prefers operation.rpc when present
(falling back to chainProviders.ton[operation.subchain]) and pass that chosen
provider into genericJsonRpcPay (referencing handleTonContractWrite,
operation.rpc, chainProviders.ton, and genericJsonRpcPay to locate the change).

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