Skip to content

[PLAN] Prepare AI Credits Widget for GoodWallet integration #133

Description

@L03TJ3

[PLAN] Prepare AI Credits Widget for GoodWallet integration

Parent: #132

Required states, flows, and behaviors

  • Preserve the React host contract: an injected EIP-1193 provider and optional themeOverrides must reach AiCreditsWidget without selecting window.ethereum.
  • Give the Custom Element the equivalent provider and theming handoff, including its existing events, while keeping all AI Credits configuration, transaction, success, and error UI widget-owned.
  • Keep production backend, RPC, and contract defaults internal to AI Credits. Development/test overrides remain optional only.
  • If required production configuration is unavailable, display a clear disabled/error state; never fall back to mock backend or chain clients.
  • Make @goodwidget/ai-credits-widget/register a no-op during Node/Next.js module evaluation and register the element normally in browsers.
  • Publish typed ESM and CommonJS entries for ., ./element, and ./register; the packed tarball must include their built artifacts.
  • Document the exact EIP-1193 request methods used by the widget so GoodWallet can grant only the required capabilities.
  • Do not add GoodWallet repository changes, release automation, integration manifests, or publishing work.

Execution plan

  1. Compare only the Web Component, SSR-safety, export, and packaging portions of PR add: automated release flow for widgets/packages, and event dispatch for automated wallet integration trigger #131 with the listed AI Credits package references; exclude its workflow, release, dispatch, CODEOWNERS, and manifest work.
  2. Trace AiCreditsWidget.tsx, widgetRuntimeContract.ts, element.ts, and createMiniAppElement.tsx to map the React and Custom Element provider/theme handoffs and identify the smallest bridge changes needed.
  3. Audit backendClient.ts and chainClient.ts configuration selection so production defaults remain widget-owned and unavailable production configuration fails closed rather than choosing mock clients.
  4. Update the guarded register.ts, package export map, tsup build entries, and package files configuration only as required for SSR-safe React, element, and register consumer imports.
  5. Add focused AI Credits unit/integration coverage for provider and theme propagation, element events, SSR registration behavior, production configuration failures, EIP-1193 requests, package artifacts, and a clean packed-package Next.js production build.
  6. Update AI Credits documentation with the minimum EIP-1193 methods used and any consumer-facing installation/import expectations.
  7. Run the issue-required build, lint, SSR import check, and relevant AI Credits tests; capture Storybook/Playwright evidence where the widget behavior changes.

Acceptance criteria

  • React and Custom Element integrations pass injected provider and optional theme overrides to AiCreditsWidget without accessing GoodWallet signer or session internals.
  • AI Credits owns production backend, RPC, and contract defaults; missing production configuration produces a clear disabled/error state and never chooses mock clients.
  • Server evaluation of @goodwidget/ai-credits-widget/register is harmless, and browser evaluation registers the Custom Element.
  • Typed ESM and CommonJS exports exist for ., ./element, and ./register, and their built consumer entries are included in the packed tarball.
  • A clean Next.js consumer can install the tarball and complete a production build.
  • Tests cover configuration/provider/theming handoff, Custom Element events, missing production configuration, and the exact EIP-1193 request methods.
  • pnpm build, pnpm lint, an SSR import check, and relevant AI Credits tests pass.
  • No GoodWallet repository changes, release automation, integration manifests, or publishing changes are included.

Human-reviewer checklist

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status
Prepare AI Task

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions