Repository navigation
fix: replace hardcoded gas 21000 - #115
Conversation
WalkthroughReorders client action composition to ensure transaction actions are available before contract actions; adds eth_estimateGas and exposes estimateTransactionGas in client types; uses it in contract transaction sending with a fallback on failure; consolidates imports in transaction decoders. No removed public signatures; one method added. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as App
participant Contract as ContractActions
participant Client as GenLayerClient (tx+chain+wallet)
participant Node as RPC Node
App->>Contract: sendTransaction(params)
Note over Contract: prepare encoded data & params
Contract->>Client: estimateTransactionGas(txParams)
Client->>Node: eth_estimateGas(txParams)
alt estimate succeeds
Node-->>Client: gas (hex)
Client-->>Contract: gas (bigint)
else estimate fails
Node-->>Client: error
Client-->>Contract: warning + fallback gas (200_000n)
end
Contract->>Client: eth_sendTransaction / sign+send (with gas)
Client->>Node: sendTransaction RPC
Node-->>Client: tx hash / receipt
Client-->>App: result / receipt
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing touches
🧪 Generate unit tests
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 |
Fixes #DXP-653
What
createClientfunction insrc/client/client.tsto first add transaction actions before contract actions, ensuring that contract actions can access transaction actions because estimateTransactionGas was not available._sendTransactionfunction insrc/contracts/actions.tsto dynamically calculate gas, with a fallback to a default value if estimation fails.estimateTransactionGasinsrc/transactions/actions.tsto estimate gas using theeth_estimateGasmethod.GenLayerClienttype insrc/types/clients.tsto include the newestimateTransactionGasmethod.Why
To provide a more accurate gas estimation for transactions.
Testing done
Tested the gas estimation feature to ensure it calculates gas correctly and falls back to a default value when necessary.
Decisions made
Decided to name method estimateTransactionGas because Viem has estimateGas already.
Checks
Reviewing tips
Review the implementation if the gas estimation method has the correct eth input params.
User facing release notes
Added dynamic gas estimation for transactions.
Summary by CodeRabbit
New Features
Refactor