Skip to content

Add @goodwidget/goodreserve-widget with reserve swap runtime contract, quote/tx state machine, and Storybook/demo coverage#39

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/build-goodreserve-widget
Draft

Add @goodwidget/goodreserve-widget with reserve swap runtime contract, quote/tx state machine, and Storybook/demo coverage#39
Copilot wants to merge 4 commits into
mainfrom
copilot/build-goodreserve-widget

Conversation

Copy link
Copy Markdown

Copilot AI commented May 27, 2026

This PR introduces the first packages/goodreserve-widget package to prove GoodWidget supports a quote-driven reserve swap flow (buy/sell) with reserve-specific state handling and reusable widget packaging.
It maps the swap UX structure from GoodWalletV2 into a widget-local implementation and adds deterministic story/demo coverage for all required states.

  • Widget package scaffold + runtime contract

    • Added @goodwidget/goodreserve-widget package scaffold (package.json, tsconfig/tsup, React + element/register entrypoints).
    • Added widgetRuntimeContract.ts + integration.ts defining reserve states/events/dependencies (no_provider, unsupported_chain, quote_*, confirm_dialog, swap_*, etc.).
    • Exported widget runtime/integration surface from src/index.ts.
  • Reserve swap UI + local adapter/state

    • Implemented GoodReserveWidget, ReserveSwapView, and useGoodReserveAdapter.
    • Added widget-local state/actions for:
      • direction toggle (buy/sell),
      • amount editing + quote debounce,
      • slippage selection,
      • confirm dialog,
      • pending/success/error tx lifecycle,
      • insufficient balance and reserve warning/error presentation.
    • Wired provider/runtime through existing GoodWidgetProvider path and chain gating for Celo (42220) + XDC (50).
  • SDK wiring and explicit reserve dependency handling

    • Added reserve error mapping utilities and SDK initialization path inside widget-local adapter.
    • Added explicit user-facing state when @goodsdks/good-reserve is unavailable at runtime (reported as a blocker condition, not silently ignored).
  • Storybook coverage (widget-scoped, deterministic)

    • Added examples/storybook/src/stories/goodreserve-widget/GoodReserveWidget.stories.tsx.
    • Added reserve-specific deterministic fixtures in examples/storybook/src/fixtures/goodReserveWidgetMock.ts.
    • Included required visual states: disconnected, unsupported chain, quote loading/success/error, insufficient balance, slippage sheet, confirm, pending/success/error, buy+sell ready states.
  • Demo verification coverage

    • Added tests/widgets/goodreserve-widget/states.spec.ts with deterministic Playwright checks mapped to widget stories.
  • Workspace/docs wiring

    • Added Storybook dependency on @goodwidget/goodreserve-widget.
    • Updated top-level package listings/architecture docs to include goodreserve-widget.
// packages/goodreserve-widget/src/integration.ts
export const goodReserveWidgetIntegration = {
  id: 'goodreserve-swap',
  sdk: '@goodsdks/good-reserve',
  chains: [42220, 50],
  states: [
    'no_provider',
    'unsupported_chain',
    'sdk_initializing',
    'quote_ready',
    'confirm_dialog',
    'swap_pending',
    'swap_success',
    'swap_error',
  ],
  events: ['swap-success', 'swap-error'],
} as const

Copilot AI changed the title [WIP] Build GoodReserve widget backed by GoodReserve SDK Add @goodwidget/goodreserve-widget with reserve swap runtime contract, quote/tx state machine, and Storybook/demo coverage May 27, 2026
Copilot AI requested a review from L03TJ3 May 27, 2026 15:17
Copilot finished work on behalf of L03TJ3 May 27, 2026 15:17
@L03TJ3
Copy link
Copy Markdown
Contributor

L03TJ3 commented May 28, 2026

@copilot the skills folder should not be committed so can be removed.

can you also produce initial screenshots of the story examples

Copy link
Copy Markdown
Author

Copilot AI commented May 28, 2026

@copilot the skills folder should not be committed so can be removed.

can you also produce initial screenshots of the story examples

Implemented in commit f31eb12.

  • Removed committed skills artifacts (.agents/skills/** and skills-lock.json).
  • Added initial GoodReserve Storybook screenshots under:
    examples/storybook/src/stories/goodreserve-widget/screenshots/

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.

[Plan]: Build GoodReserve Widget — Reserve swap UI backed by GoodReserve SDK

2 participants