Add TON case to contract_write executor#783
Conversation
ⓘ 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. |
WalkthroughAdds TON blockchain support to the contract write executor by importing TON, introducing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
|
Greptile SummaryThis PR adds a Confidence Score: 5/5Safe 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 No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
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
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], |
There was a problem hiding this comment.
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.
| chainProviders.ton[operation.subchain], | |
| operation.rpc || chainProviders.ton[operation.subchain], |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/features/multichain/routines/executors/contract_write.ts
| 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, | ||
| ) | ||
| } |
There was a problem hiding this comment.
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).



Summary by CodeRabbit