feat: transaction simulation via viem + Solana simulateTransaction#210
feat: transaction simulation via viem + Solana simulateTransaction#210premiumjibles merged 11 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughThe changes implement pre-transaction simulation for EVM and Solana blockchains. A new SimulationError utility class and helper functions detect reverts and extract error reasons. Chain-specific simulators (EVM and Solana) catch failures early with descriptive error handling. The EVM simulator applies a 20% gas buffer. Both chain integrations now invoke simulation before sending transactions. Error mapping utilities are enhanced to handle "transaction will revert" messages directly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing Touches
🧪 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. Comment |
…on helpers Foundation for transaction simulation — SimulationError distinguishes predicted reverts from RPC failures, isRevertError classifies viem errors, and extractRevertReason pulls human-readable messages from viem error objects. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Call simulateEvmTransaction before wallet interaction to detect reverts early and use the estimated gas. SimulationError propagates to prevent wallet popup; RPC failures degrade gracefully. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-sign simulation using connection.simulateTransaction with sigVerify:false, extracting meaningful error logs on failure and throwing SimulationError. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Simulate transactions before prompting wallet signing to catch reverts early without bothering the user. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add check for 'transaction will revert' in getUserFriendlyError so simulation revert messages like "Transaction will revert: INSUFFICIENT_OUTPUT_AMOUNT" are not truncated to 120 chars. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Cover success, error with matching log, error with no matching log, and null logs scenarios. Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Preserve caller-provided gasLimit instead of overriding with simulation estimate - Use `gas !== undefined` to avoid falsy bigint 0n being dropped - Make Solana error log matching case-insensitive - Skip redundant Solana preflight since we already simulate explicitly Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
3390d64 to
8a292e8
Compare
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
publicClient.call()+estimateGas()for EVM andconnection.simulateTransaction()for SolanaChanges
SimulationErrorclass +isRevertError/extractRevertReasonhelperssimulateEvmTransaction— eth_call revert detection + estimateGas with buffersimulateSolanaTransaction— preflight simulation with log extractionsendEvmTransactionandsendSolanaTransactiongetUserFriendlyErrorTest Plan
isRevertErrorclassification (revert vs RPC failure)extractRevertReason(shortMessage preference)simulateEvmTransaction(revert, non-revert, gas buffer)simulateSolanaTransaction(success, error log extraction, fallback)🤖 Generated with Claude Code
Closes sg-rzht
Summary by CodeRabbit
New Features
Bug Fixes
Tests