diff --git a/.changeset/dts-resolve-and-type-cleanup.md b/.changeset/dts-resolve-and-type-cleanup.md new file mode 100644 index 00000000..f75deb71 --- /dev/null +++ b/.changeset/dts-resolve-and-type-cleanup.md @@ -0,0 +1,15 @@ +--- +'@openzeppelin/ui-builder-adapter-evm': patch +'@openzeppelin/ui-builder-adapter-polkadot': patch +--- + +fix(adapter): resolve type declarations for internal evm-core package + +Add `dts.resolve` for `adapter-evm-core` in tsup configs so type declarations +are bundled alongside runtime JS. This fixes exported apps failing to compile +because `.d.ts` files referenced the unpublished `adapter-evm-core` package. + +Also cleans up the type hierarchy: `TypedPolkadotNetworkConfig` now extends +`PolkadotNetworkConfig` from `@openzeppelin/ui-types` directly (with narrowed +`viemChain` typing), eliminating its type-level dependency on `adapter-evm-core`. +`TypedEvmNetworkConfig` similarly extends `EvmNetworkConfig` directly. diff --git a/packages/adapter-evm-core/src/types/network.ts b/packages/adapter-evm-core/src/types/network.ts index 0d6ec091..94b2b1d1 100644 --- a/packages/adapter-evm-core/src/types/network.ts +++ b/packages/adapter-evm-core/src/types/network.ts @@ -46,10 +46,13 @@ export interface EvmCompatibleNetworkConfig } /** - * EVM-specific network configuration with strict `ecosystem: 'evm'` constraint. - * Use this type in EVM-only contexts where you want strict ecosystem typing. + * EVM-specific network configuration with strict `ecosystem: 'evm'` constraint + * and strongly-typed viem `Chain` (narrowed from `unknown` in `EvmNetworkConfig`). * + * Use this type in EVM-only contexts where you want strict ecosystem typing. * For function signatures that should accept configs from multiple adapters * (EVM, Polkadot, etc.), use `EvmCompatibleNetworkConfig` instead. */ -export type TypedEvmNetworkConfig = EvmCompatibleNetworkConfig<'evm'>; +export interface TypedEvmNetworkConfig extends EvmNetworkConfig { + viemChain?: Chain; +} diff --git a/packages/adapter-evm/tsup.config.ts b/packages/adapter-evm/tsup.config.ts index 56ad0312..bddad38e 100644 --- a/packages/adapter-evm/tsup.config.ts +++ b/packages/adapter-evm/tsup.config.ts @@ -4,6 +4,7 @@ export default defineConfig({ entry: ['src/index.ts', 'src/metadata.ts', 'src/vite-config.ts'], format: ['cjs', 'esm'], dts: { + resolve: ['@openzeppelin/ui-builder-adapter-evm-core'], compilerOptions: { composite: false, incremental: false, diff --git a/packages/adapter-polkadot/src/types.ts b/packages/adapter-polkadot/src/types.ts index 78a9b01d..8f67f9b4 100644 --- a/packages/adapter-polkadot/src/types.ts +++ b/packages/adapter-polkadot/src/types.ts @@ -1,6 +1,7 @@ /** * @fileoverview Core type definitions for the Polkadot adapter. - * These types extend the EVM core types with Polkadot-specific fields. + * These types extend the base types from `@openzeppelin/ui-types` with + * adapter-level refinements (e.g. strongly-typed viem Chain). * * ## Developer Notes: Future Substrate Extension * @@ -22,57 +23,38 @@ * 3. **Runtime Detection**: Use executionType to discriminate at runtime */ -import type { TypedEvmNetworkConfig } from '@openzeppelin/ui-builder-adapter-evm-core'; +import type { Chain } from 'viem'; -/** - * Polkadot network execution types. - * - 'evm': Networks using EVM via PolkaVM/REVM or native EVM (Moonbeam) - * - 'substrate': Future - Native Substrate/Wasm chains (not implemented) - * - * [SUBSTRATE TODO]: When adding Substrate support, the adapter will route - * operations based on this type. Networks with executionType: 'substrate' - * will use polkadot-api for queries and transactions instead of viem/wagmi. - */ -export type PolkadotExecutionType = 'evm' | 'substrate'; +import type { PolkadotNetworkConfig } from '@openzeppelin/ui-types'; /** - * Network category for UI grouping. - * - 'hub': Official Polkadot/Kusama system chains (displayed first) - * - 'parachain': Independent parachains (displayed after hub networks) - */ -export type PolkadotNetworkCategory = 'hub' | 'parachain'; - -/** - * The Polkadot/Kusama relay chain this network connects to. + * Re-exported from `@openzeppelin/ui-types` for convenience. + * + * - `PolkadotExecutionType`: `'evm' | 'substrate'` + * [SUBSTRATE TODO]: When adding Substrate support, the adapter will route + * operations based on this type. Networks with executionType: 'substrate' + * will use polkadot-api for queries and transactions instead of viem/wagmi. + * + * - `PolkadotNetworkCategory`: `'hub' | 'parachain'` + * 'hub' = Official Polkadot/Kusama system chains (displayed first) + * 'parachain' = Independent parachains (displayed after hub networks) + * + * - `PolkadotRelayChain`: `'polkadot' | 'kusama'` */ -export type PolkadotRelayChain = 'polkadot' | 'kusama'; +export type { + PolkadotExecutionType, + PolkadotNetworkCategory, + PolkadotRelayChain, +} from '@openzeppelin/ui-types'; /** * Extended network configuration for Polkadot ecosystem. - * Inherits all EVM fields for EVM-compatible networks. - * Overrides the ecosystem field to 'polkadot'. + * + * Extends {@link PolkadotNetworkConfig} from `@openzeppelin/ui-types` + * (which already defines ecosystem, executionType, networkCategory, relayChain, + * and all inherited EVM fields) with a strongly-typed `viemChain` field + * (narrowed from `unknown` to viem {@link Chain}). */ -export interface TypedPolkadotNetworkConfig extends Omit { - /** - * Ecosystem identifier - always 'polkadot' for this adapter. - */ - ecosystem: 'polkadot'; - - /** - * Execution type determines which handler processes requests. - * Currently only 'evm' is implemented; 'substrate' reserved for future. - */ - executionType: PolkadotExecutionType; - - /** - * Network category for UI grouping. - * Hub networks appear before parachain networks in selectors. - */ - networkCategory: PolkadotNetworkCategory; - - /** - * Optional: The relay chain this network is connected to. - * Used for display purposes and filtering. - */ - relayChain?: PolkadotRelayChain; +export interface TypedPolkadotNetworkConfig extends PolkadotNetworkConfig { + viemChain?: Chain; } diff --git a/packages/adapter-polkadot/tsup.config.ts b/packages/adapter-polkadot/tsup.config.ts index 56ad0312..bddad38e 100644 --- a/packages/adapter-polkadot/tsup.config.ts +++ b/packages/adapter-polkadot/tsup.config.ts @@ -4,6 +4,7 @@ export default defineConfig({ entry: ['src/index.ts', 'src/metadata.ts', 'src/vite-config.ts'], format: ['cjs', 'esm'], dts: { + resolve: ['@openzeppelin/ui-builder-adapter-evm-core'], compilerOptions: { composite: false, incremental: false,