Skip to content

[#244] Fix MetaMask gas estimation for createStoryline and chainPlot#245

Merged
realproject7 merged 1 commit intomainfrom
task/244-gas-estimation-fix
Mar 17, 2026
Merged

[#244] Fix MetaMask gas estimation for createStoryline and chainPlot#245
realproject7 merged 1 commit intomainfrom
task/244-gas-estimation-fix

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Added gas?: bigint to WriteCall interface in usePublish.ts
  • createStoryline: explicit gas limit of 5M (deploys 500-step bonding curve token via MCV2_Bond)
  • chainPlot: explicit gas limit of 500K (lighter write operation)
  • Same pattern as existing fixes in DonateWidget (150K) and TradingWidget (2M)

Test plan

  • Create storyline → MetaMask shows reasonable gas, tx submits successfully
  • Chain plot → MetaMask shows reasonable gas, tx submits successfully

Fixes #244

🤖 Generated with Claude Code

- Add gas?: bigint to WriteCall interface in usePublish
- createStoryline: gas 5M (deploys bonding curve token)
- chainPlot: gas 500K (lighter write operation)

Fixes #244

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The shared WriteCall type now supports an optional gas override, and both createStoryline and chainPlot supply explicit gas limits that are forwarded through writeContractAsync.

Findings

  • None. The gas override wiring is consistent with the existing write flow and covers both paths called out in issue #244.

Decision

Approving because the transaction requests now carry explicit gas limits for the two affected StoryFactory writes. CI was still pending at the time of review.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

Reviewed the full diff, usePublish.ts pass-through mechanism, and existing gas patterns in DonateWidget (150K) and TradingWidget (2M).

  • gas?: bigint on WriteCall is correctly optional and type-safe — no breaking changes to existing callers
  • Pass-through works: usePublish passes the writeCall object directly to wagmi's writeContractAsync, which accepts gas as a top-level property
  • Gas values are reasonable: 5M for createStoryline (factory + bonding curve token deployment), 500K for chainPlot (lighter storage write)
  • Follows established codebase patterns; unused gas is refunded so generous limits are safe

Minor note (non-blocking): RatingWidget may also benefit from an explicit gas limit if it hits the same estimation issue.

@realproject7 realproject7 merged commit 66e6c4c into main Mar 17, 2026
1 check passed
realproject7 added a commit that referenced this pull request Mar 17, 2026
500-step bonding curve creation requires ~14.4M gas. The 5M limit from
PR #245 caused OutOfGas reverts. 16M provides safe headroom.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Mar 22, 2026
#245: Rewrite lib/zap.ts for ZapPlotLinkV2 multi-token ABI:
- New ABI: mint(fromToken, storylineToken, ...), mintReverse(...),
  estimateMint(...), estimateMintReverse(...)
- getZapQuote calls contract estimates via simulateContract (non-view)
- buildZapMintTx handles ETH (payable) vs ERC-20 (approval) paths
- Removed V4 Quoter calls — contract handles full path internally
- 3% slippage buffer on bonding curve execution

Update constants.ts:
- ZAP_PLOTLINK mainnet: 0xEF6a8640c836b16Eb8cCD8016Ead4C8517aC3033
- Added USDC, HUNT, ETH_ADDRESS constants
- Added SUPPORTED_ZAP_TOKENS list for frontend selector

#244: Multi-token selector on TradingWidget buy tab:
- 4 options: ETH, USDC, HUNT, PLOT (default: ETH)
- ETH: payable zap tx, no approval, balance via useBalance
- USDC/HUNT: approve to ZAP_PLOTLINK → zap tx, balance via balanceOf
- PLOT: existing direct MCV2_Bond.mint flow unchanged
- USDC handled as 6 decimals for balance display
- Sell tab: unchanged
- Trade indexing fires for all modes
- isZapAvailable hides selector when zap address is zero

Fixes #244, Fixes #245

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Mar 22, 2026
…2 ABI

Set testnet ZAP_PLOTLINK to zero address until a V2 contract is
deployed to Base Sepolia. This prevents the V2 frontend from calling
V2 ABI functions against the old V1 Sepolia deployment.

The isZapAvailable check in TradingWidget already hides the token
selector when ZAP_PLOTLINK is zero, so testnet users fall back to
direct PLOT mode only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] createStoryline fails: MetaMask gas estimation exceeds limit

2 participants