@openzeppelin/ui-types 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # @openzeppelin/ui-types
2
+
3
+ Shared TypeScript type definitions for the OpenZeppelin UI ecosystem.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@openzeppelin/ui-types.svg)](https://www.npmjs.com/package/@openzeppelin/ui-types)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Using npm
11
+ npm install @openzeppelin/ui-types
12
+
13
+ # Using yarn
14
+ yarn add @openzeppelin/ui-types
15
+
16
+ # Using pnpm
17
+ pnpm add @openzeppelin/ui-types
18
+ ```
19
+
20
+ ## Purpose
21
+
22
+ This package serves as the single source of truth for all shared types used across the OpenZeppelin UI packages, including:
23
+
24
+ - Contract and blockchain related types
25
+ - Form field and layout definitions
26
+ - Adapter interfaces
27
+
28
+ By centralizing type definitions, we ensure consistency across all packages and eliminate type duplication.
29
+
30
+ ## Usage
31
+
32
+ The package is organized into namespaces for better organization and to prevent naming collisions.
33
+
34
+ ```typescript
35
+ // Import everything
36
+ import { adapters, contracts, forms } from '@openzeppelin/ui-types';
37
+
38
+ // Import specific namespaces
39
+ import * as contracts from '@openzeppelin/ui-types';
40
+ import * as adapters from '@openzeppelin/ui-types';
41
+ import * as forms from '@openzeppelin/ui-types';
42
+
43
+ // Import specific types from their respective namespaces
44
+ import { ContractAdapter } from '@openzeppelin/ui-types';
45
+ import { FieldType, FormFieldType } from '@openzeppelin/ui-types';
46
+
47
+ // Example usage in a function
48
+ function validateField(field: forms.FormFieldType): boolean {
49
+ // Implementation
50
+ return true;
51
+ }
52
+ ```
53
+
54
+ ## Package Structure
55
+
56
+ ```text
57
+ types/
58
+ ├── src/
59
+ │ ├── adapters/ # Contract adapter interfaces
60
+ │ │ ├── base.ts # Core ContractAdapter interface
61
+ │ │ ├── contract-state.ts # Contract state querying capabilities
62
+ │ │ └── index.ts # Re-exports all adapter types
63
+ │ ├── common/ # Common types shared across namespaces
64
+ │ │ ├── ecosystem.ts # NetworkEcosystem enum/type
65
+ │ │ └── index.ts # Re-exports common types
66
+ │ ├── config/ # Types for runtime application configuration
67
+ │ │ └── app-config.ts # Defines AppRuntimeConfig and related types
68
+ │ ├── contracts/ # Contract schema related types
69
+ │ │ ├── schema.ts # ContractSchema, ContractFunction etc.
70
+ │ │ └── index.ts # Re-exports contract types
71
+ │ ├── execution/ # Types for transaction execution methods
72
+ │ │ ├── eoa.ts
73
+ │ │ ├── relayer.ts
74
+ │ │ └── ...
75
+ │ ├── forms/ # Form field, layout, schema, and validation definitions
76
+ │ │ ├── fields.ts # Base FieldType definitions
77
+ │ │ ├── form-field.ts # FormField definition
78
+ │ │ ├── layout.ts # FormLayout definitions
79
+ │ │ ├── schema.ts # RenderFormSchema, BuilderFormConfig definitions
80
+ │ │ ├── validation.ts # FieldValidation definitions
81
+ │ │ ├── values.ts # FormValues type
82
+ │ │ └── index.ts # Re-exports all form types
83
+ │ ├── networks/ # Network configuration types
84
+ │ │ ├── config.ts # Network config interfaces and type guards
85
+ │ │ ├── validation.ts # Network configuration validation utilities
86
+ │ │ └── index.ts # Re-exports all network types
87
+ │ ├── transactions/ # Types related to transaction submission status
88
+ │ │ ├── status.ts # TransactionStatus types
89
+ │ │ └── index.ts # Re-exports transaction types
90
+ │ └── index.ts # Main entry point that re-exports all modules
91
+ ├── package.json
92
+ └── tsconfig.json
93
+ ```
94
+
95
+ ## Type Definitions
96
+
97
+ ### Adapter Types (`./src/adapters`)
98
+
99
+ Interfaces for blockchain-specific adapters:
100
+
101
+ - `ContractAdapter`: The core interface defining methods for loading contracts, mapping types, querying state, formatting data, validating addresses, handling transactions, and interacting with wallets.
102
+ - `AccessControlService`: Interface for access control and ownership management operations on contracts.
103
+
104
+ ### Config Types (`./src/config`)
105
+
106
+ - `AppRuntimeConfig`: Defines the shape of the `app.config.json` file used by exported applications.
107
+
108
+ ### Common Types (`./src/common`)
109
+
110
+ - `NetworkEcosystem`: Enum or type defining supported blockchain ecosystems (e.g., 'evm', 'solana').
111
+
112
+ ### Contract Types (`./src/contracts`)
113
+
114
+ - `ContractSchema`: Interface for contract schema definitions (ABI in EVM).
115
+ - `ContractFunction`: Interface for function definitions within a contract.
116
+ - `ContractParameter`: Interface for function parameter definitions.
117
+
118
+ ### Form Types (`./src/forms`)
119
+
120
+ - `FieldType`: Types of form fields (text, number, boolean, address, select, etc.).
121
+ - `FormField`: Complete definition of a form field including ID, type, label, validation, etc.
122
+ - `RenderFormSchema`: The schema used by the renderer package.
123
+ - `BuilderFormConfig`: The configuration used by builder applications.
124
+ - `FieldValidation`: Validation rules for form fields.
125
+ - `FormValues`: Type representing the collected data from a form submission.
126
+
127
+ ### Network Types (`./src/networks`)
128
+
129
+ - Interfaces for common properties (`BaseNetworkConfig`) and ecosystem-specific details.
130
+ - The discriminated union type `NetworkConfig` representing any valid network configuration.
131
+ - Type guard functions (e.g., `isEvmNetworkConfig(config)`) to safely narrow down the `NetworkConfig` union type.
132
+
133
+ ### Execution Types (`./src/execution`)
134
+
135
+ - Types related to transaction execution strategies, such as `EoaExecutionConfig`, `RelayerExecutionConfig`, and `RelayerDetails`.
136
+
137
+ ### Transaction Types (`./src/transactions`)
138
+
139
+ - `TransactionStatus`: Enum or type defining possible states (Idle, Signing, Broadcasting, PendingConfirmation, Success, Error).
140
+ - `TransactionProgress`: Interface holding details like transaction hash, error messages, explorer links.
141
+
142
+ ## Integration with Other Packages
143
+
144
+ This package is a dependency for multiple packages in the ecosystem:
145
+
146
+ - **@openzeppelin/ui-components**: Uses types for form field rendering
147
+ - **@openzeppelin/ui-renderer**: Uses types for form rendering and validation
148
+ - **@openzeppelin/ui-utils**: Uses types for utility functions
149
+
150
+ ## Development
151
+
152
+ ### Building
153
+
154
+ ```bash
155
+ # From the monorepo root
156
+ pnpm --filter @openzeppelin/ui-types build
157
+
158
+ # Or from within the types package directory
159
+ pnpm build
160
+ ```
161
+
162
+ ### Testing
163
+
164
+ ```bash
165
+ # From the monorepo root
166
+ pnpm --filter @openzeppelin/ui-types test
167
+
168
+ # Or from within the types package directory
169
+ pnpm test
170
+ ```
171
+
172
+ ## License
173
+
174
+ [AGPL-3.0](https://github.com/OpenZeppelin/openzeppelin-ui/blob/main/LICENSE)