fix(frontend): writeContractWithGasBuffer helper with +30% buffer + soft caps (GitLab #176) #378
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega!378
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/glab-176-estimate-gas-buffer-helper"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
closes #176.
what changed
new helper
frontend/src/lib/writeContractWithGasBuffer.ts(148 lines) that pre-flightsestimateContractGas, multiplies by configurablebufferNumerator/bufferDenominator(default130/100= +30%), optionally enforces a per-sitesoftCapGas(throwsGasSoftCapExceededError), then submits viawriteContractAsyncwith the buffered gas units. integer bigint arithmetic only — no Number coercion.onEstimateRevert: "submit-without-override" | "rethrow"controls behavior when estimation itself reverts.adopted at all 22 wagmi
writeContractAsyncsites in the frontend across 6 files. HIGH-risk sites useonEstimateRevert: "rethrow"+ per-sitesoftCapGasto fail fast on pathological calldata; MEDIUM/LOW sites use defaults.sites adopted
frontend/src/pages/timecurve/TimeCurveProtocolWarbowRefreshSection.tsx— 1 site (C4 refreshWarbowPodium, HIGH, rethrow + 12M cap)frontend/src/pages/timeCurveArena/useTimeCurveArenaModel.tsx— 13 sites (A1-A13: weth deposit, weth approve, usdm approve, kumbaya exactOutput HIGH+6M, CL8Y approve x2, buy, claimWarBowFlag, warbowSteal, warbowActivateGuard, warbowRevenge, refreshWarbowPodium HIGH+12M, runVoid w/ distributePrizes HIGH+18M)frontend/src/lib/timeCurveKumbayaSingleTx.ts— 2 sites (C12 usdm approve, C13 buyViaKumbaya HIGH+8M)frontend/src/pages/timecurve/useTimeCurveSaleSession.ts— 7 sites (C5-C11: weth deposit, weth approve, usdm approve, exactOutput HIGH+6M, acceptedAsset approve, buy, redeemCharms)frontend/src/pages/referrals/ReferralRegisterSection.tsx— 2 sites (C2 CL8Y approve, C3 registerCode)frontend/src/pages/PresaleVestingPage.tsx— 1 site (C1 claim, sync→async conversion)structural changes
WalletWriteAsynctype attimeCurveKumbayaSingleTx.ts:34extended withgas?: bigintfield. all callers compatible (verified at HEAD).submitKumbayaSingleTxBuygains achainId: numberparameter (threaded through to the helper). both callers (useTimeCurveSaleSession.ts:962,useTimeCurveArenaModel.tsx:2319) updated.friendlyRevertFromUnknownatrevertMessage.ts:115gets a newinstanceof GasSoftCapExceededErrorbranch that surfaces a clear safety-cap message before falling through to viemBaseErrorhandling.PresaleVestingPage.tsxC1 converted from syncwriteContractto asyncwriteContractAsyncso it can thread through the helper.claimErrorrendering still wired through the wagmi error path; helper-thrown errors surface viaclaimGateError.risk-class tradeoffs (per #176 audit narrative)
onEstimateRevert: "rethrow"— surfaces estimation reverts immediately rather than falling through to wallet-side estimation. tradeoff: cleaner error UX vs slightly less retry-tolerant under transient state drift (e.g. competing wallet plant-flag interrupting our refresh by one block). recommendation: ship as-is, downgrade specific sites to default if telemetry shows excessive false-positive blocks.onEstimateRevert: "submit-without-override", no softCapGas) — strict superset of pre-patch behavior, no regression vs status quo.verification
npm run typecheckclean.npm test -- --run— 51 files / 307 passed (up from 50/295 — added 11 helper tests + 1 revertMessage case).npm run lint— 0 errors. one pre-existing fast-refresh warning inIndexerConnectivityContext.tsxuntouched.known limitations
useTimeCurveSaleSession.tsanduseTimeCurveArenaModel.tsxstill have no dedicated unit tests — out of scope for this MR (separate@testing-library/reactprovider-mock harness needed; see #175 for the broader frontend coverage gap).gasfield. the helper sets the dapp-preferred ceiling, not a hard wallet-side override.cc @PlasticDigits
mentioned in commit
8eb5f34cfbmentioned in issue #175