fix(sdk-coin-flrp): compute Flare C-chain import fee from real gas usage - #9385
fix(sdk-coin-flrp): compute Flare C-chain import fee from real gas usage#9385ArunBala-Bitgo wants to merge 1 commit into
Conversation
|
@claude review this PR |
|
Claude finished @ArunBala-Bitgo's task —— View job Code Review for Flare C-chain Import Fee FixTodo List:
Overall AssessmentThis PR successfully addresses a critical issue in Flare C-chain atomic import transactions where underestimated gas fees were causing broadcast failures. The implementation is well-architected, maintains backward compatibility, and includes comprehensive test coverage. ✅ Strengths1. Excellent Problem Analysis & Solution Design
2. Robust Implementation Architecture
3. Comprehensive Test CoverageThe new test suite (
4. Backward Compatibility
🔍 Detailed Code AnalysisInterface Changes (
|
026a411 to
f3f0716
Compare
Import-to-C-chain transactions built a fee from a caller-supplied literal amount, bypassing flarejs's actual gas accounting (which includes the ~10,000 AtomicTxBaseCost). When the caller priced the import using a naive gas estimate, the resulting fee was too low and the network rejected the transaction with insufficient funds, independent of transfer amount. Add an opt-in baseFee() builder method that computes the fee via newImportTxFromBaseFee (mirroring the export builder's existing pattern), with a 10% padding buffer to absorb base-fee volatility between signing and broadcast. The legacy fee() literal-amount path is unchanged for backward compatibility. Ticket: CECHO-1821 fix(sdk-coin-flrp): use assert for bigint comparisons in import fee tests should.above() coerces to number and fails on bigint values, breaking the build. Compare with native > via assert instead. Ticket: CECHO-1821
f3f0716 to
27ca6a4
Compare
Summary
evm.newImportTx(fee), treating the caller-supplied fee as a literal amount and never accounting for the ~10,000 gasAtomicTxBaseCostthat flarejs's gas estimator applies internally.baseFee()builder method that instead callsevm.newImportTxFromBaseFee(...), letting flarejs compute the real gas cost (includingAtomicTxBaseCost) from the actual tx, and applies a 10% padding buffer on the supplied base fee to absorb volatility between signing and broadcast. This mirrors the pattern the export builder (ExportInCTxBuilder) already uses vianewExportTxFromBaseFee.fee()path is untouched for backward compatibility with existing (on-chain verified) test vectors.Test plan
npx mocha --exclude test/unit/flrp.ts 'test/unit/**/*.ts'inmodules/sdk-coin-flrp— 275 passingtsc --noEmitandeslintclean (no new warnings)Ticket: CECHO-1821
🤖 Generated with Claude Code