Skip to content

[codex] Add viem-free common core entrypoint - #2544

Draft
blakecduncan wants to merge 1 commit into
mainfrom
codex/common-core-entrypoint
Draft

[codex] Add viem-free common core entrypoint#2544
blakecduncan wants to merge 1 commit into
mainfrom
codex/common-core-entrypoint

Conversation

@blakecduncan

@blakecduncan blakecduncan commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Description

Add a viem-free @alchemy/common/core entrypoint for shared Alchemy SDK infrastructure. This lets packages such as Data APIs reuse REST/JSON-RPC transport, normalized API errors, retries/timeouts/abort handling, request IDs, redaction, and network resolution without depending on viem or wallet-client types.

The root @alchemy/common barrel stays wallet-facing: existing viem transport utilities and BaseError-based errors remain available there, while chain-library-free consumers can import only from the new /core subpath.

Summary

  • Add @alchemy/common/core package export and core barrel.
  • Add viem-free AlchemyError / AlchemyApiError family plus fetch/server subclasses for shared HTTP clients.
  • Add shared HTTP engine support for query params, retries, timeouts, abort signals, request IDs, retry-after parsing, and credential redaction.
  • Add typed REST and JSON-RPC clients over the shared HTTP engine.
  • Add network slug / CAIP-2 resolution helpers and a chain ID bridge for adapters.
  • Keep root @alchemy/common focused on wallet/viem-facing exports and mark viem as an optional peer.
  • Add tests for error shape, redaction, network resolution, REST/JSON-RPC retry/error behavior, and a small logger timing deflake.

Test Plan

  • pnpm --filter @alchemy/common test:run
  • pnpm --filter @alchemy/common build
  • pnpm --filter @alchemy/wallet-apis build
  • pnpm --filter @alchemy/smart-accounts exec tsc --project tsconfig.build.json --noEmit
  • pnpm --filter @alchemy/aa-infra exec tsc --project tsconfig.build.json --noEmit
  • no-viem temp consumer proof importing @alchemy/common/core
  • git diff --check

Breaking Changes

None expected. Existing root @alchemy/common wallet-facing exports remain available; the new core entrypoint is additive.

Deployment Notes

No service deployment or migration required. This is a package surface addition for downstream SDK work.

LINEAR TASK: N/A - Data SDK Foundation follow-up; no Linear issue provided.


PR-Codex overview

This PR primarily focuses on enhancing error handling, introducing new error classes, and refining the AlchemyRestClient for better request management. It also adds utility functions for redacting sensitive information in URLs and improves query serialization.

Detailed summary

  • Updated documentation for ServerError and FetchError.
  • Added AlchemyFetchError and AlchemyServerError classes for better error handling.
  • Introduced redactUrlCredentials function to mask sensitive data in URLs.
  • Enhanced AlchemyRestClient with request ID and improved retry logic.
  • Implemented query serialization in AlchemyRestClient.
  • Added tests for error handling and request functionality in both AlchemyRestClient and AlchemyJsonRpcClient.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@jakehobbs jakehobbs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

don't love that we are copying things from viem again, which v5 undid a lot of from v4. this seems fairly small though.

might be worth adding eslint rules to block importing viem from places that could get us in trouble, since we're making it optional now.

"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
},
"./core": {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

don't love the name core for this, but sure i have any better suggestions.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah that's fair, we could do something like runtime or primatives but I don't really have anything better than that

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.

2 participants