Skip to content

fix(chat template): unblock next build (write narrowing + build-safe registry default)#88

Merged
rajkaria merged 1 commit into
mainfrom
fix/chat-build-config-and-write
Jul 2, 2026
Merged

fix(chat template): unblock next build (write narrowing + build-safe registry default)#88
rajkaria merged 1 commit into
mainfrom
fix/chat-build-config-and-write

Conversation

@rajkaria

@rajkaria rajkaria commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Follow-up to #87. With the BodyInit fix in, chat's next build progressed and hit two more latent errors (verified by a fresh npm create 0gkit-app --template chat against published 1.12.x):

  1. route.ts:95contract.write.post is a Record<string,…> access → possibly-undefined under noUncheckedIndexedAccess. Assert the method, then narrow the Receipt | DryRunResult<Receipt> union before reading .txHash.
  2. 0g.config.tsNEXT_PUBLIC_MESSAGE_REGISTRY_ADDRESS was required and read at module load in lib/contract.ts, so next build with no env threw during page-data collection. Default it to the zero address (fresh-dev/CI build path); 0g dev prints the real address for .env.

Verified locally: fresh chat scaffold now compiles, collects page data, and generates all routes cleanly. Template-only; no package publish.

🤖 Generated with Claude Code

…ld-safe registry default

Two latent errors that only surfaced once the earlier smoke blockers were cleared:

- app/api/post/route.ts:95 — `contract.write.post` is a `Record<string,…>`
  access, so under `noUncheckedIndexedAccess` it's possibly-undefined ("cannot
  invoke"). Assert the method exists, then narrow the returned
  `Receipt | DryRunResult<Receipt>` union before reading `.txHash`.

- 0g.config.ts — `NEXT_PUBLIC_MESSAGE_REGISTRY_ADDRESS` was required, and
  `lib/contract.ts` reads it via `config.client()` at module load, so `next build`
  with no env (the fresh-dev / CI path) threw ConfigError during page-data
  collection. Default it to the zero address so the build succeeds out of the box;
  `0g dev` prints the real address to paste into .env.

Verified: a fresh `npm create 0gkit-app --template chat` (published 1.12.x deps)
now compiles + collects page data + generates all routes cleanly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
0gkit Ready Ready Preview, Comment Jul 2, 2026 12:07pm
0gkit-docs Ready Ready Preview, Comment Jul 2, 2026 12:07pm
0gkit-playground Ready Ready Preview, Comment Jul 2, 2026 12:07pm

Request Review

@rajkaria rajkaria merged commit 10c53ec into main Jul 2, 2026
8 checks passed
@rajkaria rajkaria deleted the fix/chat-build-config-and-write branch July 2, 2026 12:15
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