Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/dts-resolve-and-type-cleanup.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 6 additions & 3 deletions packages/adapter-evm-core/src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ export interface EvmCompatibleNetworkConfig<E extends string = string>
}

/**
* 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;
}
1 change: 1 addition & 0 deletions packages/adapter-evm/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
74 changes: 28 additions & 46 deletions packages/adapter-polkadot/src/types.ts
Original file line number Diff line number Diff line change
@@ -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
*
Expand All @@ -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<TypedEvmNetworkConfig, 'ecosystem'> {
/**
* 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;
}
1 change: 1 addition & 0 deletions packages/adapter-polkadot/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading