Skip to content

feat: integrate @genlayer/transaction-kit fee approval flow - #63

Merged
MuncleUscles merged 3 commits into
v2-devfrom
feat/transaction-kit-showcase
Jun 11, 2026
Merged

MuncleUscles merged 3 commits into
v2-devfrom
feat/transaction-kit-showcase

Conversation

@MuncleUscles

Copy link
Copy Markdown
Member

What

Integrates the new @genlayer/transaction-kit as the showcase fee-approval flow for the boilerplate frontend, replacing the ad-hoc fee integration from the v0.6 sweep.

Replaced

  • lib/genlayer/fees.ts (manual low/standard/high preset estimation via estimateTransactionFees + simulation) — deleted
  • Hand-rolled "Fee Preset" button grid in CreateBetModal — replaced by the panel's built-in preset selector + fee receipt
  • confirm() popup + fire-and-forget mutation for resolve_bet in BetsTable — replaced by a dialog hosting the panel
  • createBet/resolveBet write methods (estimate -> writeContract({fees}) -> waitForTransactionReceipt) in FootballBets — the kit now owns estimate/submit/track; the class keeps reads only
  • useCreateBet/useResolveBet mutations — replaced by a useInvalidateBetsData() helper invoked from the panel's onDone

Added

  • lib/genlayer/kit.ts — useTransactionKit(address) wiring createTransactionKit to the existing studionet chain config and the MetaMask EIP-1193 provider
  • GenLayerTransactionPanel for both writes (create_bet, resolve_bet): estimate -> fee receipt review -> hold-to-sign -> timeline -> outcome, trackUntil="decided"
  • Kit styles imported in app/layout.tsx
  • Vitest + RTL setup (vitest.config.ts, vitest.setup.ts, npm test) with panel tests backed by createMockKit: quote renders + hold-to-sign enabled, and approve drives the flow to done
  • tx props are memoized — useTransactionFlow re-estimates on tx identity change, so inline literals would reset the flow mid-signing on unrelated re-renders

Dependency note

Installed as github branch refs (github:genlayerlabs/genlayer-transaction-kit#pkg/core / #pkg/react) because npm github deps can't reach monorepo subpackages — packed branches exist for this. Will be moved to the npm rc once published.

Verification

  • npm run lint (tsc --noEmit) — pass
  • npm test — 2/2 pass
  • npm run build (Next 16 production build) — pass

Replace the hand-rolled fee preset estimation and approval UI with the
GenLayerTransactionPanel from @genlayer/transaction-kit-react for both
contract writes (create_bet, resolve_bet). The panel handles the full
flow: estimate -> fee receipt review -> hold-to-sign -> timeline ->
outcome.

- add useTransactionKit hook wiring createTransactionKit to the
  existing studionet chain config and MetaMask EIP-1193 provider
- swap CreateBetModal fee preset grid + mutation for a review step
  hosting the panel; swap BetsTable confirm() flow for a panel dialog
- drop lib/genlayer/fees.ts and the write/estimate methods from
  FootballBets (reads stay); replace write mutations with a
  useInvalidateBetsData helper
- add vitest + RTL setup and panel tests backed by createMockKit
- deps installed as github branch refs (#pkg/core, #pkg/react) until
  the npm rc is published
@coderabbitai

coderabbitai Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 905b9ea8-3e34-491e-b8ca-39fd84eb3e51

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transaction-kit-showcase

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- frontend/fee-profile.json: committed developer fee profile (decimal
  strings, measured shape produced by 'gltest --fee-profile'); seeded with
  plausible deploy/create_bet/resolve_bet values
- useTransactionKit passes it verbatim as 'suggestions' to
  createTransactionKit; the panel then quotes with PolicyQuote.source
  'developer' and renders the measured-profile source line
- npm run test:fees regenerates the profile via gltest over
  tests/integration (requires a running Studio; not wired into CI)
- package-lock: re-resolved the kit git deps to pick up the force-refreshed
  pkg/core and pkg/react branches with the suggestions API
- vitest: assert both source lines (network defaults vs developer profile
  via createMockKit({ suggestions: true }))
@MuncleUscles

Copy link
Copy Markdown
Member Author

Added the developer fee-suggestions flow on top of the panel integration:

  • frontend/fee-profile.json — committed fee profile in the shape produced by gltest --fee-profile (genlayer-testing-suite PR #94): {version, network, measuredAt, deploy, methods} with executionBudgetPerRound / totalMessageFees as decimal strings (max observed × 1.25 headroom). Time-unit allocation keys are intentionally absent — the backend doesn't report time-unit usage, so the kit falls back to preset/network defaults for those.
  • useTransactionKit now passes the profile verbatim as suggestions to createTransactionKit. When a suggestion matches the call, PolicyQuote.source is 'developer' and the panel renders "Sized from the developer's measured fee profile" instead of "Sized from network defaults" — no panel changes needed, the source line renders automatically.
  • npm run test:fees regenerates the profile by running the contract integration suite against a local Studio (gltest tests/integration --fee-profile frontend/fee-profile.json). Deliberately not in CI (needs a live Studio).
  • Re-resolved the #pkg/core / #pkg/react git deps so the lockfile picks up the force-refreshed suggestions API (verified PolicyQuote.source in the installed .d.ts).
  • Vitest covers both provenance lines via createMockKit({ suggestions: true }).

Frontend verification: tsc --noEmit clean, vitest 3/3, next build succeeds.

@MuncleUscles

Copy link
Copy Markdown
Member Author

Flow screenshots committed under docs/screenshots/:

create bet form
fee approval panel
flow complete

Captured with createMockKit (no wallet/studio needed); the panel shows the developer fee-profile provenance line.

@MuncleUscles
MuncleUscles merged commit e37e2db into v2-dev Jun 11, 2026
5 of 6 checks passed
@MuncleUscles
MuncleUscles deleted the feat/transaction-kit-showcase branch June 11, 2026 21:45
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.

1 participant