Skip to content

Add TON case to contract_write executor#783

Merged
HaykK-Solicy merged 2 commits into
testnetfrom
feature/add-ton-contract-write-executor
May 22, 2026
Merged

Add TON case to contract_write executor#783
HaykK-Solicy merged 2 commits into
testnetfrom
feature/add-ton-contract-write-executor

Conversation

@HaykK-Solicy
Copy link
Copy Markdown
Contributor

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

Summary by CodeRabbit

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

Review Change Stack

@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

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba8c30ff-9a1b-4561-92e4-8c3df280a61c

📥 Commits

Reviewing files that changed from the base of the PR and between 87345f1 and 1c752f4.

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

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

Adds TON blockchain support to the contract write executor by importing TON, adding a handleTonContractWrite helper that calls genericJsonRpcPay with the TON subchain provider, and extending the chain dispatch to route "ton" operations to that helper.

Changes

TON Contract Write Support

Layer / File(s) Summary
Import TON SDK
src/features/multichain/routines/executors/contract_write.ts
Updates the @kynesyslabs/demosdk/xm-localsdk import to include TON.
handleTonContractWrite implementation
src/features/multichain/routines/executors/contract_write.ts
Adds handleTonContractWrite which forwards TON contract-write ops to genericJsonRpcPay using chainProviders.ton[operation.subchain].
Dispatch routing for TON
src/features/multichain/routines/executors/contract_write.ts
Extends the handleContractWrite chain switch to handle case "ton" and call the new handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • kynesyslabs/node#779: Also adds a new chain-specific handler and updates the contract_write executor dispatch (egld handler in that PR).

Suggested reviewers

  • Shitikyan

Poem

🐰 A hop, a skip, across chains we go,
TON support now steals the show!
A tiny handler, routing clear and bright,
genericJsonRpcPay sends calls just right.
Hop on, little rabbit — ledger dreams take flight!

🚥 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

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 TON blockchain support to the contract_write executor by introducing a handleTonContractWrite function that delegates to the shared genericJsonRpcPay helper, mirroring how the existing Solana and MultiversX contract-write paths are implemented.

  • New handler: handleTonContractWrite calls genericJsonRpcPay(TON, chainProviders.ton[operation.subchain], operation) — structurally identical to handleSolanaContractWrite and handleMultiversxContractWrite.
  • Switch case added: case "ton" wired into handleContractWrite between Solana and egld.
  • Import updated: TON is imported alongside the existing EVM, MULTIVERSX, and SOLANA SDK entries.

Confidence Score: 4/5

Safe to merge with a known gap around custom RPC support that has already been called out in a prior review thread.

The TON handler is a straightforward, low-risk addition that mirrors the Solana and MultiversX contract-write paths exactly. The one meaningful gap — passing chainProviders.ton[operation.subchain] directly without checking operation.rpc — is already under discussion in a previous thread on this PR, so there are no new blocking issues to gate on.

src/features/multichain/routines/executors/contract_write.ts — the RPC resolution logic warrants a second look once the prior thread on custom-RPC support is resolved.

Important Files Changed

Filename Overview
src/features/multichain/routines/executors/contract_write.ts Adds TON contract-write support via a new handleTonContractWrite function and a corresponding switch case; follows existing Solana/EGLD patterns but does not honour operation.rpc (already flagged in prior review thread).

Sequence Diagram

sequenceDiagram
    participant Caller
    participant handleContractWrite
    participant handleTonContractWrite
    participant genericJsonRpcPay
    participant TON_SDK as TON SDK

    Caller->>handleContractWrite: "operation (chain="ton")"
    handleContractWrite->>handleTonContractWrite: operation
    handleTonContractWrite->>genericJsonRpcPay: TON, chainProviders.ton[subchain], operation
    genericJsonRpcPay->>TON_SDK: TON.create(rpcUrl)
    TON_SDK-->>genericJsonRpcPay: instance
    genericJsonRpcPay->>TON_SDK: instance.sendTransaction(signedPayloads[0])
    TON_SDK-->>genericJsonRpcPay: result
    genericJsonRpcPay-->>handleTonContractWrite: result
    handleTonContractWrite-->>handleContractWrite: result
    handleContractWrite-->>Caller: result
Loading

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/tes..." | 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).

…ntract-write-executor

# Conflicts:
#	src/features/multichain/routines/executors/contract_write.ts
@HaykK-Solicy HaykK-Solicy merged commit 6269667 into testnet May 22, 2026
8 of 9 checks passed
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