You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#1971 closed via #2054 which is a different layer than the options @cryptomotifs sketched. Reopening as a fresh issue since the close didn't address this design layer.
The dependencies bug
The visible symptom was Mezo (eip155:31611) missing from published bundles. The real bug surfaced by @cryptomotifs:
x402 can't distinguish "chain exists in viem ≥ N but we're pinned on < N"
(freshness gap; throws Unsupported chain ID when the chain is in fact
supported) from "chain truly doesn't exist" (correct error).
A lockfile bump postpones the first case until the next new chain. A runtime registry fixes the distinction.
Three options (per @cryptomotifs, ordered by effort vs. robustness)
Runtime fetch + minimal local fallback — small x402-chains package lazy-fetches chain metadata from a CDN JSON endpoint, with compiled-in fallback for the offline-must-work subset. Decouples downstream SDKs from viem's release cadence entirely, but introduces infrastructure requirements.
defineChain by ID, per-chain literals committed here — viem for types only. Scoped variant I floated:
paywall sources from x402's existing per-chain registries (e.g. DEFAULT_STABLECOINS in @x402/evm).
@phdargen — looking for guidance on which of options 1 or 2 is the direction we should consider for a robust fix, as I don't have context to pick between them. Merging #2002 seems to be a fine mitigation step in the meantime.
Background
#1971 closed via #2054 which is a different layer than the options @cryptomotifs sketched. Reopening as a fresh issue since the close didn't address this design layer.
The dependencies bug
The visible symptom was Mezo (
eip155:31611) missing from published bundles. The real bug surfaced by @cryptomotifs:x402 can't distinguish "chain exists in viem ≥ N but we're pinned on < N"
(freshness gap; throws
Unsupported chain IDwhen the chain is in factsupported) from "chain truly doesn't exist" (correct error).
A lockfile bump postpones the first case until the next new chain. A runtime registry fixes the distinction.
Three options (per @cryptomotifs, ordered by effort vs. robustness)
x402-chainspackage lazy-fetches chain metadata from a CDN JSON endpoint, with compiled-in fallback for the offline-must-work subset. Decouples downstream SDKs from viem's release cadence entirely, but introduces infrastructure requirements.defineChainby ID, per-chain literals committed here — viem for types only. Scoped variant I floated:paywall sources from x402's existing per-chain registries (e.g.
DEFAULT_STABLECOINSin@x402/evm).Status
pnpmfrom re-resolving downward when sub-packages land with looser pins.resolveViemChain(caip2)walking viem's chain DB withdefineChainfallback, sourced fromDEFAULT_STABLECOINS. SDK-runtime application would be a separate step. Adjacent design notes with @phdargen on a related pattern in PR #2238.Ask
@phdargen — looking for guidance on which of options 1 or 2 is the direction we should consider for a robust fix, as I don't have context to pick between them. Merging #2002 seems to be a fine mitigation step in the meantime.