@openzeppelin/ui-utils 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/LICENSE +661 -0
- package/README.md +106 -0
- package/dist/index-DNIN-Squ.d.cts +1205 -0
- package/dist/index-DNIN-Squ.d.cts.map +1 -0
- package/dist/index-qy1AQMhr.d.ts +1205 -0
- package/dist/index-qy1AQMhr.d.ts.map +1 -0
- package/dist/index.cjs +2167 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1205 -0
- package/dist/index.d.ts +1205 -0
- package/dist/index.js +2079 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,1205 @@
|
|
|
1
|
+
import { ClassValue } from "clsx";
|
|
2
|
+
import { AccessSnapshot, AppRuntimeConfig, ContractAdapter, FieldType, FieldValidation, FieldValue, FormValues, IndexerEndpointConfig, RoleAssignment, RoleIdentifier, RpcEndpointConfig, ServiceParameterConfig, UiKitName, UserExplorerConfig, UserRpcProviderConfig } from "@openzeppelin/ui-types";
|
|
3
|
+
|
|
4
|
+
//#region src/contractInputs.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns names of adapter-declared required inputs that are missing/empty in values.
|
|
7
|
+
*/
|
|
8
|
+
declare function getMissingRequiredContractInputs(adapter: ContractAdapter, values: FormValues): string[];
|
|
9
|
+
/**
|
|
10
|
+
* True if any adapter-declared required inputs are missing/empty.
|
|
11
|
+
*/
|
|
12
|
+
declare function hasMissingRequiredContractInputs(adapter: ContractAdapter | null | undefined, values: FormValues): boolean;
|
|
13
|
+
//# sourceMappingURL=contractInputs.d.ts.map
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/requiredInputs.d.ts
|
|
16
|
+
type RequiredInputSnapshot = Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Builds a snapshot of required form input values.
|
|
19
|
+
* @param adapter - Contract adapter to get field definitions from
|
|
20
|
+
* @param formValues - Current form values
|
|
21
|
+
* @returns Snapshot of required field values, or null if no required fields
|
|
22
|
+
*/
|
|
23
|
+
declare function buildRequiredInputSnapshot(adapter: ContractAdapter | null, formValues: FormValues | null | undefined): RequiredInputSnapshot | null;
|
|
24
|
+
/**
|
|
25
|
+
* Compares two required input snapshots for equality.
|
|
26
|
+
* @param a - First snapshot to compare
|
|
27
|
+
* @param b - Second snapshot to compare
|
|
28
|
+
* @returns True if snapshots are equal, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
declare function requiredSnapshotsEqual(a: RequiredInputSnapshot | null, b: RequiredInputSnapshot | null): boolean;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/addressNormalization.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes a contract address by trimming whitespace and converting to lowercase.
|
|
35
|
+
* This is useful for case-insensitive and whitespace-insensitive address comparison.
|
|
36
|
+
*
|
|
37
|
+
* @param address - The address to normalize (string, null, or undefined)
|
|
38
|
+
* @returns The normalized address string, or empty string if input is falsy
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* normalizeAddress(' 0xABC123 ') // Returns '0xabc123'
|
|
43
|
+
* normalizeAddress('0xDEF456') // Returns '0xdef456'
|
|
44
|
+
* normalizeAddress(null) // Returns ''
|
|
45
|
+
* normalizeAddress(undefined) // Returns ''
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function normalizeAddress(address: string | null | undefined): string;
|
|
49
|
+
/**
|
|
50
|
+
* Compares two addresses after normalization.
|
|
51
|
+
* Returns true if both addresses normalize to the same value.
|
|
52
|
+
*
|
|
53
|
+
* @param address1 - First address to compare
|
|
54
|
+
* @param address2 - Second address to compare
|
|
55
|
+
* @returns True if addresses are equal after normalization
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* addressesEqual(' 0xABC ', '0xabc') // Returns true
|
|
60
|
+
* addressesEqual('0xDEF', '0xABC') // Returns false
|
|
61
|
+
* addressesEqual(null, '') // Returns true
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function addressesEqual(address1: string | null | undefined, address2: string | null | undefined): boolean;
|
|
65
|
+
//# sourceMappingURL=addressNormalization.d.ts.map
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/logger.d.ts
|
|
68
|
+
/**
|
|
69
|
+
* Logger utility for consistent logging across the application.
|
|
70
|
+
* Supports different log levels and can be disabled for testing.
|
|
71
|
+
*/
|
|
72
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
73
|
+
interface LoggerOptions {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
level: LogLevel;
|
|
76
|
+
}
|
|
77
|
+
declare class Logger {
|
|
78
|
+
private static instance;
|
|
79
|
+
private options;
|
|
80
|
+
private constructor();
|
|
81
|
+
static getInstance(): Logger;
|
|
82
|
+
configure(options: Partial<LoggerOptions>): void;
|
|
83
|
+
private shouldLog;
|
|
84
|
+
private formatMessage;
|
|
85
|
+
debug(system: string, message: string, ...args: unknown[]): void;
|
|
86
|
+
info(system: string, message: string, ...args: unknown[]): void;
|
|
87
|
+
warn(system: string, message: string, ...args: unknown[]): void;
|
|
88
|
+
error(system: string, message: string, ...args: unknown[]): void;
|
|
89
|
+
}
|
|
90
|
+
declare const logger: Logger;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/AppConfigService.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* Type for the strategy array in initialize method.
|
|
95
|
+
*/
|
|
96
|
+
type ConfigLoadStrategy = {
|
|
97
|
+
type: 'viteEnv';
|
|
98
|
+
env: ViteEnv | undefined;
|
|
99
|
+
} | {
|
|
100
|
+
type: 'json';
|
|
101
|
+
path?: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: 'localStorage';
|
|
104
|
+
key?: string;
|
|
105
|
+
};
|
|
106
|
+
interface ViteEnv {
|
|
107
|
+
[key: string]: string | boolean | undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* AppConfigService
|
|
111
|
+
*
|
|
112
|
+
* Responsible for loading, merging, and providing access to the application's
|
|
113
|
+
* runtime configuration (`AppRuntimeConfig`).
|
|
114
|
+
*/
|
|
115
|
+
declare class AppConfigService {
|
|
116
|
+
private config;
|
|
117
|
+
private isInitialized;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a new AppConfigService with default configuration.
|
|
120
|
+
*/
|
|
121
|
+
constructor();
|
|
122
|
+
private loadFromViteEnvironment;
|
|
123
|
+
private loadFromJson;
|
|
124
|
+
/**
|
|
125
|
+
* Initializes the service by loading configuration from the specified strategies.
|
|
126
|
+
* @param strategies - Array of configuration loading strategies to apply
|
|
127
|
+
*/
|
|
128
|
+
initialize(strategies: ConfigLoadStrategy[]): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the API key for a specific explorer service.
|
|
131
|
+
* @param serviceIdentifier - The service identifier
|
|
132
|
+
* @returns The API key if configured, undefined otherwise
|
|
133
|
+
*/
|
|
134
|
+
getExplorerApiKey(serviceIdentifier: string): string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the configuration for a global service.
|
|
137
|
+
* @param serviceName - The name of the service
|
|
138
|
+
* @returns The service configuration if found, undefined otherwise
|
|
139
|
+
*/
|
|
140
|
+
getGlobalServiceConfig(serviceName: string): ServiceParameterConfig | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Checks if a feature flag is enabled.
|
|
143
|
+
* @param flagName - The name of the feature flag
|
|
144
|
+
* @returns True if the feature is enabled, false otherwise
|
|
145
|
+
*/
|
|
146
|
+
isFeatureEnabled(flagName: string): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Gets a global service parameter value.
|
|
149
|
+
* @param serviceName The name of the service
|
|
150
|
+
* @param paramName The name of the parameter
|
|
151
|
+
* @returns The parameter value (can be any type including objects, arrays) or undefined if not found
|
|
152
|
+
*/
|
|
153
|
+
getGlobalServiceParam(serviceName: string, paramName: string): string | number | boolean | object | Array<unknown> | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the RPC endpoint override for a specific network.
|
|
156
|
+
* @param networkId - The network identifier
|
|
157
|
+
* @returns The RPC endpoint configuration if found, undefined otherwise
|
|
158
|
+
*/
|
|
159
|
+
getRpcEndpointOverride(networkId: string): string | RpcEndpointConfig | UserRpcProviderConfig | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Get the indexer endpoint override for a specific network.
|
|
162
|
+
* Indexer endpoints are used for querying historical blockchain data.
|
|
163
|
+
* @param networkId The network identifier (e.g., 'stellar-testnet')
|
|
164
|
+
* @returns The indexer endpoint configuration, or undefined if not configured
|
|
165
|
+
*/
|
|
166
|
+
getIndexerEndpointOverride(networkId: string): string | IndexerEndpointConfig | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Returns the entire configuration object.
|
|
169
|
+
* Primarily for debugging or for parts of the app that need a broader view.
|
|
170
|
+
* Use specific getters like `getExplorerApiKey` or `isFeatureEnabled` where possible.
|
|
171
|
+
*/
|
|
172
|
+
getConfig(): Readonly<AppRuntimeConfig>;
|
|
173
|
+
/**
|
|
174
|
+
* Gets a nested configuration object with type safety.
|
|
175
|
+
*
|
|
176
|
+
* This is a helper method to safely access complex nested configuration objects
|
|
177
|
+
* with proper TypeScript type checking.
|
|
178
|
+
*
|
|
179
|
+
* @param serviceName The name of the service (e.g., 'walletui')
|
|
180
|
+
* @param paramName The parameter name that contains the nested object (e.g., 'config')
|
|
181
|
+
* Pass an empty string to get the entire service configuration.
|
|
182
|
+
* @returns The typed nested configuration object or undefined if not found
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* // Get a typed UI kit configuration:
|
|
186
|
+
* const uiConfig = appConfigService.getTypedNestedConfig<UiKitConfiguration>('walletui', 'config');
|
|
187
|
+
* if (uiConfig) {
|
|
188
|
+
* console.log(uiConfig.kitName); // Properly typed
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* // Get entire service configuration:
|
|
192
|
+
* const allAnalytics = appConfigService.getTypedNestedConfig<AnalyticsConfig>('analytics', '');
|
|
193
|
+
*/
|
|
194
|
+
getTypedNestedConfig<T extends object>(serviceName: string, paramName: string): T | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Checks if a nested configuration exists and has a specific property.
|
|
197
|
+
*
|
|
198
|
+
* @param serviceName The name of the service
|
|
199
|
+
* @param paramName The parameter name containing the nested object
|
|
200
|
+
* @param propName The property name to check for
|
|
201
|
+
* @returns True if the property exists in the nested configuration
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* if (appConfigService.hasNestedConfigProperty('walletui', 'config', 'showInjectedConnector')) {
|
|
205
|
+
* // Do something when the property exists
|
|
206
|
+
* }
|
|
207
|
+
*/
|
|
208
|
+
hasNestedConfigProperty(serviceName: string, paramName: string, propName: string): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Gets wallet UI configuration for a specific ecosystem.
|
|
211
|
+
* Uses ecosystem-namespaced format with optional default fallback.
|
|
212
|
+
*
|
|
213
|
+
* @param ecosystemId The ecosystem ID (e.g., 'stellar', 'evm', 'solana')
|
|
214
|
+
* @returns The wallet UI configuration for the ecosystem, or undefined
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* Configuration format:
|
|
218
|
+
* {
|
|
219
|
+
* "globalServiceConfigs": {
|
|
220
|
+
* "walletui": {
|
|
221
|
+
* "stellar": { "kitName": "stellar-wallets-kit", "kitConfig": {} },
|
|
222
|
+
* "evm": { "kitName": "rainbowkit", "kitConfig": {} },
|
|
223
|
+
* "default": { "kitName": "custom", "kitConfig": {} }
|
|
224
|
+
* }
|
|
225
|
+
* }
|
|
226
|
+
* }
|
|
227
|
+
* const stellarConfig = appConfigService.getWalletUIConfig('stellar');
|
|
228
|
+
*/
|
|
229
|
+
getWalletUIConfig<T extends object = {
|
|
230
|
+
kitName: UiKitName;
|
|
231
|
+
kitConfig?: Record<string, unknown>;
|
|
232
|
+
}>(ecosystemId?: string): T | undefined;
|
|
233
|
+
}
|
|
234
|
+
declare const appConfigService: AppConfigService;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/UserRpcConfigService.d.ts
|
|
237
|
+
type RpcConfigEventType = 'rpc-config-changed' | 'rpc-config-cleared';
|
|
238
|
+
interface RpcConfigEvent {
|
|
239
|
+
type: RpcConfigEventType;
|
|
240
|
+
networkId: string;
|
|
241
|
+
config?: UserRpcProviderConfig;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Service for managing user-configured RPC endpoints.
|
|
245
|
+
* Stores RPC configurations in localStorage for persistence across sessions.
|
|
246
|
+
*/
|
|
247
|
+
declare class UserRpcConfigService {
|
|
248
|
+
private static readonly STORAGE_PREFIX;
|
|
249
|
+
private static readonly eventListeners;
|
|
250
|
+
/**
|
|
251
|
+
* Emits an RPC configuration event to all registered listeners
|
|
252
|
+
*/
|
|
253
|
+
private static emitEvent;
|
|
254
|
+
/**
|
|
255
|
+
* Subscribes to RPC configuration changes for a specific network or all networks
|
|
256
|
+
* @param networkId The network identifier or '*' for all networks
|
|
257
|
+
* @param listener The callback to invoke when RPC config changes
|
|
258
|
+
* @returns Unsubscribe function
|
|
259
|
+
*/
|
|
260
|
+
static subscribe(networkId: string, listener: (event: RpcConfigEvent) => void): () => void;
|
|
261
|
+
/**
|
|
262
|
+
* Saves a user RPC configuration for a specific network.
|
|
263
|
+
* @param networkId The network identifier
|
|
264
|
+
* @param config The RPC configuration to save
|
|
265
|
+
*/
|
|
266
|
+
static saveUserRpcConfig(networkId: string, config: UserRpcProviderConfig): void;
|
|
267
|
+
/**
|
|
268
|
+
* Retrieves a user RPC configuration for a specific network.
|
|
269
|
+
* @param networkId The network identifier
|
|
270
|
+
* @returns The stored configuration or null if not found
|
|
271
|
+
*/
|
|
272
|
+
static getUserRpcConfig(networkId: string): UserRpcProviderConfig | null;
|
|
273
|
+
/**
|
|
274
|
+
* Clears a user RPC configuration for a specific network.
|
|
275
|
+
* @param networkId The network identifier
|
|
276
|
+
*/
|
|
277
|
+
static clearUserRpcConfig(networkId: string): void;
|
|
278
|
+
/**
|
|
279
|
+
* Clears all user RPC configurations.
|
|
280
|
+
*/
|
|
281
|
+
static clearAllUserRpcConfigs(): void;
|
|
282
|
+
}
|
|
283
|
+
declare const userRpcConfigService: typeof UserRpcConfigService;
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/UserExplorerConfigService.d.ts
|
|
286
|
+
type ExplorerConfigEventType = 'explorer-config-changed' | 'explorer-config-cleared';
|
|
287
|
+
interface ExplorerConfigEvent {
|
|
288
|
+
type: ExplorerConfigEventType;
|
|
289
|
+
networkId: string;
|
|
290
|
+
config?: UserExplorerConfig;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Service for managing user-configured block explorer endpoints and API keys.
|
|
294
|
+
* Stores explorer configurations in localStorage for persistence across sessions.
|
|
295
|
+
*/
|
|
296
|
+
declare class UserExplorerConfigService {
|
|
297
|
+
private static readonly STORAGE_PREFIX;
|
|
298
|
+
private static readonly eventListeners;
|
|
299
|
+
/**
|
|
300
|
+
* Emits an explorer configuration event to all registered listeners
|
|
301
|
+
*/
|
|
302
|
+
private static emitEvent;
|
|
303
|
+
/**
|
|
304
|
+
* Subscribes to explorer configuration changes for a specific network or all networks
|
|
305
|
+
* @param networkId The network identifier or '*' for all networks
|
|
306
|
+
* @param listener The callback to invoke when explorer config changes
|
|
307
|
+
* @returns Unsubscribe function
|
|
308
|
+
*/
|
|
309
|
+
static subscribe(networkId: string, listener: (event: ExplorerConfigEvent) => void): () => void;
|
|
310
|
+
/**
|
|
311
|
+
* Saves a user explorer configuration for a specific network.
|
|
312
|
+
* @param networkId The network identifier
|
|
313
|
+
* @param config The explorer configuration to save
|
|
314
|
+
*/
|
|
315
|
+
static saveUserExplorerConfig(networkId: string, config: UserExplorerConfig): void;
|
|
316
|
+
/**
|
|
317
|
+
* Retrieves a user explorer configuration for a specific network.
|
|
318
|
+
* First checks for global settings, then falls back to network-specific settings.
|
|
319
|
+
* @param networkId The network identifier
|
|
320
|
+
* @returns The stored configuration or null if not found
|
|
321
|
+
*/
|
|
322
|
+
static getUserExplorerConfig(networkId: string): UserExplorerConfig | null;
|
|
323
|
+
/**
|
|
324
|
+
* Clears a user explorer configuration for a specific network.
|
|
325
|
+
* @param networkId The network identifier
|
|
326
|
+
*/
|
|
327
|
+
static clearUserExplorerConfig(networkId: string): void;
|
|
328
|
+
/**
|
|
329
|
+
* Clears all user explorer configurations.
|
|
330
|
+
*/
|
|
331
|
+
static clearAllUserExplorerConfigs(): void;
|
|
332
|
+
/**
|
|
333
|
+
* Gets all network IDs that have explorer configurations.
|
|
334
|
+
* @returns Array of network IDs
|
|
335
|
+
*/
|
|
336
|
+
static getConfiguredNetworkIds(): string[];
|
|
337
|
+
}
|
|
338
|
+
declare const userExplorerConfigService: typeof UserExplorerConfigService;
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/UserNetworkServiceConfigService.d.ts
|
|
341
|
+
/**
|
|
342
|
+
* Event types emitted by UserNetworkServiceConfigService
|
|
343
|
+
*/
|
|
344
|
+
type ServiceConfigEventType = 'service-config-changed' | 'service-config-cleared';
|
|
345
|
+
/**
|
|
346
|
+
* Event emitted when a service configuration changes or is cleared.
|
|
347
|
+
* Used for subscribing to configuration updates across the application.
|
|
348
|
+
*
|
|
349
|
+
* @interface ServiceConfigEvent
|
|
350
|
+
*/
|
|
351
|
+
interface ServiceConfigEvent {
|
|
352
|
+
/** Type of event: config changed or cleared */
|
|
353
|
+
type: ServiceConfigEventType;
|
|
354
|
+
/** Network ID for which the configuration changed */
|
|
355
|
+
networkId: string;
|
|
356
|
+
/** Service ID (e.g., 'rpc', 'explorer', 'contract-definitions') */
|
|
357
|
+
serviceId: string;
|
|
358
|
+
/** The new configuration data (only present for 'service-config-changed' events) */
|
|
359
|
+
config?: Record<string, unknown>;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Service for managing user-defined network service configurations.
|
|
363
|
+
*
|
|
364
|
+
* This service provides a generic, chain-agnostic way to store and retrieve
|
|
365
|
+
* per-network, per-service user configurations.
|
|
366
|
+
*
|
|
367
|
+
* Configurations are stored in localStorage with the key format:
|
|
368
|
+
* `tfb_service_config_{serviceId}__{networkId}`
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* // Save RPC configuration for Sepolia
|
|
373
|
+
* userNetworkServiceConfigService.save('ethereum-sepolia', 'rpc', {
|
|
374
|
+
* rpcUrl: 'https://sepolia.infura.io/v3/your-key'
|
|
375
|
+
* });
|
|
376
|
+
*
|
|
377
|
+
* // Retrieve configuration
|
|
378
|
+
* const config = userNetworkServiceConfigService.get('ethereum-sepolia', 'rpc');
|
|
379
|
+
*
|
|
380
|
+
* // Subscribe to changes
|
|
381
|
+
* const unsubscribe = userNetworkServiceConfigService.subscribe(
|
|
382
|
+
* 'ethereum-sepolia',
|
|
383
|
+
* 'rpc',
|
|
384
|
+
* (event) => {
|
|
385
|
+
* console.log('Config changed:', event.config);
|
|
386
|
+
* }
|
|
387
|
+
* );
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @class UserNetworkServiceConfigService
|
|
391
|
+
*/
|
|
392
|
+
declare class UserNetworkServiceConfigService {
|
|
393
|
+
private static readonly STORAGE_PREFIX;
|
|
394
|
+
private static readonly listeners;
|
|
395
|
+
/**
|
|
396
|
+
* Generates a localStorage key for a network-service combination.
|
|
397
|
+
*
|
|
398
|
+
* @private
|
|
399
|
+
* @param networkId - The network ID
|
|
400
|
+
* @param serviceId - The service ID
|
|
401
|
+
* @returns The storage key string
|
|
402
|
+
*/
|
|
403
|
+
private static key;
|
|
404
|
+
/**
|
|
405
|
+
* Subscribes to configuration change events for a specific network and/or service.
|
|
406
|
+
*
|
|
407
|
+
* Use '*' as a wildcard to listen to all networks or all services.
|
|
408
|
+
* The listener will be called whenever a matching configuration changes or is cleared.
|
|
409
|
+
*
|
|
410
|
+
* @param networkId - Network ID to listen to, or '*' for all networks
|
|
411
|
+
* @param serviceId - Service ID to listen to, or '*' for all services
|
|
412
|
+
* @param listener - Callback function to invoke when matching events occur
|
|
413
|
+
* @returns Unsubscribe function to remove the listener
|
|
414
|
+
*
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* // Listen to all RPC config changes across all networks
|
|
418
|
+
* const unsubscribe = userNetworkServiceConfigService.subscribe('*', 'rpc', (event) => {
|
|
419
|
+
* console.log(`${event.networkId} RPC config changed`);
|
|
420
|
+
* });
|
|
421
|
+
*
|
|
422
|
+
* // Later, unsubscribe
|
|
423
|
+
* unsubscribe();
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
static subscribe(networkId: string | '*', serviceId: string | '*', listener: (event: ServiceConfigEvent) => void): () => void;
|
|
427
|
+
/**
|
|
428
|
+
* Emits an event to all matching subscribers.
|
|
429
|
+
* Subscribers are matched based on exact network/service IDs or wildcards.
|
|
430
|
+
*
|
|
431
|
+
* @private
|
|
432
|
+
* @param event - The event to emit
|
|
433
|
+
*/
|
|
434
|
+
private static emit;
|
|
435
|
+
/**
|
|
436
|
+
* Saves a service configuration for a specific network.
|
|
437
|
+
*
|
|
438
|
+
* The configuration is stored in localStorage and all matching subscribers
|
|
439
|
+
* are notified via a 'service-config-changed' event.
|
|
440
|
+
*
|
|
441
|
+
* @param networkId - The network ID (e.g., 'ethereum-sepolia')
|
|
442
|
+
* @param serviceId - The service ID (e.g., 'rpc', 'explorer', 'contract-definitions')
|
|
443
|
+
* @param config - The configuration object to save
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* userNetworkServiceConfigService.save('ethereum-sepolia', 'rpc', {
|
|
448
|
+
* rpcUrl: 'https://sepolia.infura.io/v3/your-key'
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
static save(networkId: string, serviceId: string, config: Record<string, unknown>): void;
|
|
453
|
+
/**
|
|
454
|
+
* Retrieves a saved service configuration for a specific network.
|
|
455
|
+
*
|
|
456
|
+
* @param networkId - The network ID (e.g., 'ethereum-sepolia')
|
|
457
|
+
* @param serviceId - The service ID (e.g., 'rpc', 'explorer', 'contract-definitions')
|
|
458
|
+
* @returns The configuration object, or null if not found or if retrieval fails
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* const config = userNetworkServiceConfigService.get('ethereum-sepolia', 'rpc');
|
|
463
|
+
* if (config) {
|
|
464
|
+
* console.log('RPC URL:', config.rpcUrl);
|
|
465
|
+
* }
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
static get(networkId: string, serviceId: string): Record<string, unknown> | null;
|
|
469
|
+
/**
|
|
470
|
+
* Clears a saved service configuration for a specific network.
|
|
471
|
+
*
|
|
472
|
+
* Removes the configuration from localStorage and notifies all matching subscribers
|
|
473
|
+
* via a 'service-config-cleared' event.
|
|
474
|
+
*
|
|
475
|
+
* @param networkId - The network ID (e.g., 'ethereum-sepolia')
|
|
476
|
+
* @param serviceId - The service ID (e.g., 'rpc', 'explorer', 'contract-definitions')
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* userNetworkServiceConfigService.clear('ethereum-sepolia', 'rpc');
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
static clear(networkId: string, serviceId: string): void;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Singleton instance of UserNetworkServiceConfigService.
|
|
487
|
+
* This is the preferred way to access the service.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* import { userNetworkServiceConfigService } from '@openzeppelin/ui-utils';
|
|
492
|
+
*
|
|
493
|
+
* userNetworkServiceConfigService.save('ethereum-sepolia', 'rpc', { rpcUrl: '...' });
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
declare const userNetworkServiceConfigService: typeof UserNetworkServiceConfigService;
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/fieldDefaults.d.ts
|
|
499
|
+
/**
|
|
500
|
+
* Get a default value for a field type.
|
|
501
|
+
* This is a chain-agnostic utility that provides appropriate default values
|
|
502
|
+
* based on the UI field type.
|
|
503
|
+
*
|
|
504
|
+
* @param fieldType - The UI field type
|
|
505
|
+
* @returns The appropriate default value for that field type
|
|
506
|
+
*/
|
|
507
|
+
declare function getDefaultValueForType<T extends FieldType>(fieldType: T): FieldValue<T>;
|
|
508
|
+
//# sourceMappingURL=fieldDefaults.d.ts.map
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/fieldValidation.d.ts
|
|
511
|
+
/**
|
|
512
|
+
* Numeric type bounds configuration.
|
|
513
|
+
* Each adapter provides its own bounds map based on chain-specific type names.
|
|
514
|
+
*/
|
|
515
|
+
type NumericBoundsMap = Record<string, {
|
|
516
|
+
min?: number;
|
|
517
|
+
max?: number;
|
|
518
|
+
}>;
|
|
519
|
+
/**
|
|
520
|
+
* Enhances field validation with numeric bounds based on parameter type.
|
|
521
|
+
* Only applies bounds if they are not already set in the validation object.
|
|
522
|
+
*
|
|
523
|
+
* @param validation - Existing validation rules (may be undefined)
|
|
524
|
+
* @param parameterType - The blockchain parameter type (e.g., 'uint32', 'U32', 'Uint<0..255>')
|
|
525
|
+
* @param boundsMap - Chain-specific map of type names to min/max bounds
|
|
526
|
+
* @returns Enhanced validation object with numeric bounds applied
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```typescript
|
|
530
|
+
* const stellarBounds = { U32: { min: 0, max: 4_294_967_295 } };
|
|
531
|
+
* const validation = enhanceNumericValidation(undefined, 'U32', stellarBounds);
|
|
532
|
+
* // Returns: { min: 0, max: 4_294_967_295 }
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
declare function enhanceNumericValidation(validation: FieldValidation | undefined, parameterType: string, boundsMap: NumericBoundsMap): FieldValidation;
|
|
536
|
+
//# sourceMappingURL=fieldValidation.d.ts.map
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/typeguards.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* Type guard to check if a value is a non-null object (Record<string, unknown>).
|
|
541
|
+
* Useful for safely accessing properties on an 'unknown' type after this check.
|
|
542
|
+
* @param value - The value to check.
|
|
543
|
+
* @returns True if the value is a non-null object, false otherwise.
|
|
544
|
+
*/
|
|
545
|
+
declare function isRecordWithProperties(value: unknown): value is Record<string, unknown>;
|
|
546
|
+
/**
|
|
547
|
+
* Type guard to check if a value is a plain object (not an array, not null).
|
|
548
|
+
* This is useful for distinguishing between objects and arrays, since arrays are technically objects in JavaScript.
|
|
549
|
+
* @param value - The value to check.
|
|
550
|
+
* @returns True if the value is a plain object (not array, not null), false otherwise.
|
|
551
|
+
*/
|
|
552
|
+
declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
553
|
+
//# sourceMappingURL=typeguards.d.ts.map
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/cn.d.ts
|
|
556
|
+
/**
|
|
557
|
+
* Combines class names using clsx and tailwind-merge.
|
|
558
|
+
* @param inputs - Class values to combine
|
|
559
|
+
* @returns Merged class name string
|
|
560
|
+
*/
|
|
561
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
562
|
+
//# sourceMappingURL=cn.d.ts.map
|
|
563
|
+
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/formatting.d.ts
|
|
566
|
+
/**
|
|
567
|
+
* String and date formatting utility functions
|
|
568
|
+
* These utilities help with common formatting operations
|
|
569
|
+
*/
|
|
570
|
+
/**
|
|
571
|
+
* Truncates a string (like an Ethereum address) in the middle
|
|
572
|
+
* @param str The string to truncate
|
|
573
|
+
* @param startChars Number of characters to show at the beginning
|
|
574
|
+
* @param endChars Number of characters to show at the end
|
|
575
|
+
* @returns The truncated string with ellipsis in the middle
|
|
576
|
+
*/
|
|
577
|
+
declare function truncateMiddle(str: string, startChars?: number, endChars?: number): string;
|
|
578
|
+
/**
|
|
579
|
+
* Formats a timestamp as a relative time string (e.g., "2h ago", "just now")
|
|
580
|
+
* @param date The date to format
|
|
581
|
+
* @returns A human-readable relative time string
|
|
582
|
+
*/
|
|
583
|
+
declare function formatTimestamp(date: Date): string;
|
|
584
|
+
/**
|
|
585
|
+
* Detects whether a string contains hex-encoded or base64-encoded binary data.
|
|
586
|
+
* Useful for auto-detecting the encoding format of user inputs across blockchain adapters.
|
|
587
|
+
*
|
|
588
|
+
* @param value - The string to analyze
|
|
589
|
+
* @returns 'hex' if the string appears to be hexadecimal, 'base64' if it appears to be base64
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* detectBytesEncoding("48656c6c6f") // → 'hex'
|
|
594
|
+
* detectBytesEncoding("SGVsbG8=") // → 'base64'
|
|
595
|
+
* detectBytesEncoding("0x48656c6c6f") // → 'hex' (after stripping 0x prefix)
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
598
|
+
declare function detectBytesEncoding(value: string): 'base64' | 'hex';
|
|
599
|
+
//# sourceMappingURL=formatting.d.ts.map
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/generateId.d.ts
|
|
602
|
+
/**
|
|
603
|
+
* General utility functions, which are not specific to any blockchain
|
|
604
|
+
* It's important to keep these functions as simple as possible and avoid any
|
|
605
|
+
* dependencies from other packages.
|
|
606
|
+
*/
|
|
607
|
+
/**
|
|
608
|
+
* Generates a unique ID for form fields, components, etc.
|
|
609
|
+
* Uses crypto.getRandomValues() for browser-compatible random ID generation.
|
|
610
|
+
*
|
|
611
|
+
* @param prefix Optional prefix to add before the UUID
|
|
612
|
+
* @returns A string ID that is guaranteed to be unique
|
|
613
|
+
*/
|
|
614
|
+
declare function generateId(prefix?: string): string;
|
|
615
|
+
//# sourceMappingURL=generateId.d.ts.map
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/validators.d.ts
|
|
618
|
+
/**
|
|
619
|
+
* URL validation utilities
|
|
620
|
+
*/
|
|
621
|
+
/**
|
|
622
|
+
* Validates if a string is a valid URL (supports http, https, and ftp protocols).
|
|
623
|
+
* Relies solely on the URL constructor for validation.
|
|
624
|
+
*
|
|
625
|
+
* @param urlString - The string to validate
|
|
626
|
+
* @returns True if the URL is valid, false otherwise
|
|
627
|
+
*/
|
|
628
|
+
declare function isValidUrl(urlString: string): boolean;
|
|
629
|
+
/**
|
|
630
|
+
* Gets a user-friendly error message for invalid URLs.
|
|
631
|
+
*
|
|
632
|
+
* @returns Standard error message for invalid URLs
|
|
633
|
+
*/
|
|
634
|
+
declare function getInvalidUrlMessage(): string;
|
|
635
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/async.d.ts
|
|
638
|
+
/**
|
|
639
|
+
* Utility to add delay between operations
|
|
640
|
+
* @param ms - Milliseconds to delay
|
|
641
|
+
* @returns Promise that resolves after the specified delay
|
|
642
|
+
*/
|
|
643
|
+
declare const delay: (ms: number) => Promise<void>;
|
|
644
|
+
/**
|
|
645
|
+
* Executes operations in batches with rate limiting to prevent API overload
|
|
646
|
+
* @param operations - Array of functions that return promises
|
|
647
|
+
* @param batchSize - Number of operations to execute in parallel per batch (default: 2)
|
|
648
|
+
* @param delayMs - Delay in milliseconds between batches (default: 100)
|
|
649
|
+
* @returns Promise that resolves to an array of results from all operations
|
|
650
|
+
*/
|
|
651
|
+
declare function rateLimitedBatch<T>(operations: (() => Promise<T>)[], batchSize?: number, delayMs?: number): Promise<T[]>;
|
|
652
|
+
/**
|
|
653
|
+
* Wraps a promise with a timeout. Rejects with a descriptive Error after timeoutMs.
|
|
654
|
+
*
|
|
655
|
+
* @param promise The promise to wrap
|
|
656
|
+
* @param timeoutMs Timeout in milliseconds
|
|
657
|
+
* @param label Optional label to include in the timeout error message
|
|
658
|
+
*/
|
|
659
|
+
declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, label?: string): Promise<T>;
|
|
660
|
+
/**
|
|
661
|
+
* Default concurrency limit for parallel operations.
|
|
662
|
+
* Set to a reasonable value that balances performance and service limits.
|
|
663
|
+
*/
|
|
664
|
+
declare const DEFAULT_CONCURRENCY_LIMIT = 10;
|
|
665
|
+
/**
|
|
666
|
+
* Execute an array of promise-returning functions with a concurrency limit.
|
|
667
|
+
*
|
|
668
|
+
* Uses a worker pool approach that maintains up to `limit` concurrent operations.
|
|
669
|
+
* As soon as one operation completes, the next one starts immediately, maximizing
|
|
670
|
+
* throughput while respecting the concurrency limit.
|
|
671
|
+
*
|
|
672
|
+
* Results are returned in the same order as the input tasks, regardless of
|
|
673
|
+
* completion order.
|
|
674
|
+
*
|
|
675
|
+
* @param tasks Array of functions that return promises
|
|
676
|
+
* @param limit Maximum number of concurrent executions (default: 10)
|
|
677
|
+
* @returns Promise resolving to array of results in same order as input tasks
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```typescript
|
|
681
|
+
* // Fetch 100 role members with max 10 concurrent RPC requests
|
|
682
|
+
* const tasks = memberIndices.map((index) => () => getRoleMember(contract, role, index));
|
|
683
|
+
* const members = await promiseAllWithLimit(tasks, 10);
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
declare function promiseAllWithLimit<T>(tasks: (() => Promise<T>)[], limit?: number): Promise<T[]>;
|
|
687
|
+
/**
|
|
688
|
+
* Execute an array of promise-returning functions with a concurrency limit,
|
|
689
|
+
* settling all promises (similar to Promise.allSettled but with concurrency control).
|
|
690
|
+
*
|
|
691
|
+
* Unlike promiseAllWithLimit, this function does not fail fast on errors.
|
|
692
|
+
* All tasks will be executed regardless of individual failures.
|
|
693
|
+
*
|
|
694
|
+
* @param tasks Array of functions that return promises
|
|
695
|
+
* @param limit Maximum number of concurrent executions (default: 10)
|
|
696
|
+
* @returns Promise resolving to array of settled results in same order as input tasks
|
|
697
|
+
*
|
|
698
|
+
* @example
|
|
699
|
+
* ```typescript
|
|
700
|
+
* const tasks = items.map((item) => () => fetchItem(item.id));
|
|
701
|
+
* const results = await promiseAllSettledWithLimit(tasks, 10);
|
|
702
|
+
*
|
|
703
|
+
* for (const result of results) {
|
|
704
|
+
* if (result.status === 'fulfilled') {
|
|
705
|
+
* console.log('Success:', result.value);
|
|
706
|
+
* } else {
|
|
707
|
+
* console.log('Failed:', result.reason);
|
|
708
|
+
* }
|
|
709
|
+
* }
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
712
|
+
declare function promiseAllSettledWithLimit<T>(tasks: (() => Promise<T>)[], limit?: number): Promise<PromiseSettledResult<T>[]>;
|
|
713
|
+
//# sourceMappingURL=async.d.ts.map
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/hash.d.ts
|
|
716
|
+
/**
|
|
717
|
+
* Simple browser-compatible hash utilities
|
|
718
|
+
* These functions provide deterministic hashing for content comparison
|
|
719
|
+
* and are not intended for cryptographic purposes.
|
|
720
|
+
*/
|
|
721
|
+
/**
|
|
722
|
+
* Creates a simple hash from a string using a non-cryptographic algorithm
|
|
723
|
+
* Suitable for content comparison, caching keys, and quick fingerprinting
|
|
724
|
+
*
|
|
725
|
+
* @param str - The string to hash
|
|
726
|
+
* @returns A hexadecimal hash string (always positive)
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* ```typescript
|
|
730
|
+
* const hash1 = simpleHash('{"name": "test"}');
|
|
731
|
+
* const hash2 = simpleHash('{"name": "test"}');
|
|
732
|
+
* console.log(hash1 === hash2); // true - deterministic
|
|
733
|
+
* ```
|
|
734
|
+
*/
|
|
735
|
+
declare function simpleHash(str: string): string;
|
|
736
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region src/bytesValidation.d.ts
|
|
739
|
+
/**
|
|
740
|
+
* Options for bytes validation
|
|
741
|
+
*/
|
|
742
|
+
interface BytesValidationOptions {
|
|
743
|
+
/**
|
|
744
|
+
* Whether to accept hex, base64, or both formats
|
|
745
|
+
*/
|
|
746
|
+
acceptedFormats?: 'hex' | 'base64' | 'both';
|
|
747
|
+
/**
|
|
748
|
+
* Maximum length in bytes (not characters)
|
|
749
|
+
*/
|
|
750
|
+
maxBytes?: number;
|
|
751
|
+
/**
|
|
752
|
+
* Whether to allow 0x prefix for hex values
|
|
753
|
+
*/
|
|
754
|
+
allowHexPrefix?: boolean;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Result of bytes validation
|
|
758
|
+
*/
|
|
759
|
+
interface BytesValidationResult {
|
|
760
|
+
/**
|
|
761
|
+
* Whether the input is valid
|
|
762
|
+
*/
|
|
763
|
+
isValid: boolean;
|
|
764
|
+
/**
|
|
765
|
+
* Error message if validation failed
|
|
766
|
+
*/
|
|
767
|
+
error?: string;
|
|
768
|
+
/**
|
|
769
|
+
* Detected format of the input
|
|
770
|
+
*/
|
|
771
|
+
detectedFormat?: 'hex' | 'base64';
|
|
772
|
+
/**
|
|
773
|
+
* Cleaned value (whitespace removed, prefix handled)
|
|
774
|
+
*/
|
|
775
|
+
cleanedValue?: string;
|
|
776
|
+
/**
|
|
777
|
+
* Size in bytes
|
|
778
|
+
*/
|
|
779
|
+
byteSize?: number;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Validates bytes input using the established validator.js library.
|
|
783
|
+
*
|
|
784
|
+
* This function provides comprehensive validation for blockchain bytes data including:
|
|
785
|
+
* - Hex encoding validation (with optional 0x prefix)
|
|
786
|
+
* - Base64 encoding validation
|
|
787
|
+
* - Byte length validation
|
|
788
|
+
* - Format detection
|
|
789
|
+
*
|
|
790
|
+
* @param value - The input string to validate
|
|
791
|
+
* @param options - Validation options
|
|
792
|
+
* @returns Validation result with details
|
|
793
|
+
*
|
|
794
|
+
* @example
|
|
795
|
+
* ```typescript
|
|
796
|
+
* validateBytes('48656c6c6f') // → { isValid: true, detectedFormat: 'hex', byteSize: 5 }
|
|
797
|
+
* validateBytes('SGVsbG8=') // → { isValid: true, detectedFormat: 'base64', byteSize: 5 }
|
|
798
|
+
* validateBytes('invalid') // → { isValid: false, error: '...' }
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
declare function validateBytes(value: string, options?: BytesValidationOptions): BytesValidationResult;
|
|
802
|
+
/**
|
|
803
|
+
* Simple validation function that returns boolean or error string
|
|
804
|
+
* (for compatibility with existing React Hook Form validation)
|
|
805
|
+
*
|
|
806
|
+
* @param value - The input string to validate
|
|
807
|
+
* @param options - Validation options
|
|
808
|
+
* @returns true if valid, error string if invalid
|
|
809
|
+
*/
|
|
810
|
+
declare function validateBytesSimple(value: string, options?: BytesValidationOptions): boolean | string;
|
|
811
|
+
/**
|
|
812
|
+
* Extracts the size from a Bytes<N> type string, or returns undefined for dynamic Uint8Array
|
|
813
|
+
*
|
|
814
|
+
* @param type - Type string (e.g., "Bytes<32>", "Uint8Array", "bytes")
|
|
815
|
+
* @returns Size in bytes if fixed-size, undefined if dynamic
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```typescript
|
|
819
|
+
* getBytesSize('Bytes<32>') // → 32
|
|
820
|
+
* getBytesSize('Bytes<64>') // → 64
|
|
821
|
+
* getBytesSize('Uint8Array') // → undefined
|
|
822
|
+
* getBytesSize('bytes') // → undefined
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
825
|
+
declare function getBytesSize(type: string): number | undefined;
|
|
826
|
+
//# sourceMappingURL=bytesValidation.d.ts.map
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/bytesConversion.d.ts
|
|
829
|
+
/**
|
|
830
|
+
* Cross-platform bytes conversion utilities that work in both browser and Node.js
|
|
831
|
+
* without requiring Buffer polyfills.
|
|
832
|
+
*/
|
|
833
|
+
/**
|
|
834
|
+
* Convert a hex string to Uint8Array using native browser APIs
|
|
835
|
+
* @param hex - Hex string (with or without 0x prefix)
|
|
836
|
+
* @returns Uint8Array representation
|
|
837
|
+
*/
|
|
838
|
+
declare function hexToBytes(hex: string): Uint8Array;
|
|
839
|
+
/**
|
|
840
|
+
* Convert a base64 string to Uint8Array using native browser APIs
|
|
841
|
+
* Handles data URLs by stripping the prefix
|
|
842
|
+
* @param base64 - Base64 encoded string (with optional data URL prefix)
|
|
843
|
+
* @returns Uint8Array representation
|
|
844
|
+
*/
|
|
845
|
+
declare function base64ToBytes(base64: string): Uint8Array;
|
|
846
|
+
/**
|
|
847
|
+
* Convert Uint8Array to hex string
|
|
848
|
+
* @param bytes - Uint8Array to convert
|
|
849
|
+
* @param withPrefix - Whether to include '0x' prefix
|
|
850
|
+
* @returns Hex string representation
|
|
851
|
+
*/
|
|
852
|
+
declare function bytesToHex(bytes: Uint8Array, withPrefix?: boolean): string;
|
|
853
|
+
/**
|
|
854
|
+
* Convert string to bytes based on detected encoding (hex or base64)
|
|
855
|
+
* @param value - The string value to convert
|
|
856
|
+
* @param encoding - The detected encoding type
|
|
857
|
+
* @returns Uint8Array representation
|
|
858
|
+
*/
|
|
859
|
+
declare function stringToBytes(value: string, encoding: 'hex' | 'base64'): Uint8Array;
|
|
860
|
+
//# sourceMappingURL=bytesConversion.d.ts.map
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/environment.d.ts
|
|
863
|
+
/**
|
|
864
|
+
* Utility functions for environment detection
|
|
865
|
+
*/
|
|
866
|
+
/**
|
|
867
|
+
* Check if the application is running in development or test environment
|
|
868
|
+
* @returns True if NODE_ENV is 'development' or 'test'
|
|
869
|
+
*/
|
|
870
|
+
declare function isDevelopmentOrTestEnvironment(): boolean;
|
|
871
|
+
/**
|
|
872
|
+
* Check if the application is running in production environment
|
|
873
|
+
* @returns True if NODE_ENV is 'production'
|
|
874
|
+
*/
|
|
875
|
+
declare function isProductionEnvironment(): boolean;
|
|
876
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
877
|
+
//#endregion
|
|
878
|
+
//#region src/RouterService.d.ts
|
|
879
|
+
/**
|
|
880
|
+
* RouterService
|
|
881
|
+
*
|
|
882
|
+
* Minimal wrapper to abstract routing. This avoids coupling the app to a
|
|
883
|
+
* specific router implementation and allows future swaps.
|
|
884
|
+
*/
|
|
885
|
+
interface RouterService {
|
|
886
|
+
/** Returns the current location href (string form). */
|
|
887
|
+
currentLocation(): string;
|
|
888
|
+
/** Returns the value of a query parameter or null if not present. */
|
|
889
|
+
getParam(name: string): string | null;
|
|
890
|
+
/** Navigates to a path (client-side when router is present; falls back to location). */
|
|
891
|
+
navigate(path: string): void;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Singleton instance for global consumption.
|
|
895
|
+
*/
|
|
896
|
+
declare const routerService: RouterService;
|
|
897
|
+
//# sourceMappingURL=RouterService.d.ts.map
|
|
898
|
+
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region src/AnalyticsService.d.ts
|
|
901
|
+
/**
|
|
902
|
+
* Google Analytics service for tracking user interactions.
|
|
903
|
+
* Manages Google Analytics initialization and event tracking.
|
|
904
|
+
* Only active when the analytics_enabled feature flag is true.
|
|
905
|
+
*
|
|
906
|
+
* This is a generic service that provides core analytics functionality.
|
|
907
|
+
* App-specific tracking methods should be implemented in app-level hooks
|
|
908
|
+
* that use the generic `trackEvent` method.
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* ```typescript
|
|
912
|
+
* // Initialize analytics (typically done once at app startup)
|
|
913
|
+
* AnalyticsService.initialize('G-XXXXXXXXXX');
|
|
914
|
+
*
|
|
915
|
+
* // Track a custom event
|
|
916
|
+
* AnalyticsService.trackEvent('button_clicked', { button_name: 'submit' });
|
|
917
|
+
*
|
|
918
|
+
* // Track page view
|
|
919
|
+
* AnalyticsService.trackPageView('Dashboard', '/dashboard');
|
|
920
|
+
* ```
|
|
921
|
+
*/
|
|
922
|
+
declare class AnalyticsService {
|
|
923
|
+
private static initialized;
|
|
924
|
+
/**
|
|
925
|
+
* Initialize Google Analytics
|
|
926
|
+
* @param tagId - Google Analytics tag ID (e.g., G-N3DZK5FCT1)
|
|
927
|
+
*/
|
|
928
|
+
static initialize(tagId: string): void;
|
|
929
|
+
/**
|
|
930
|
+
* Check if analytics is enabled via feature flag
|
|
931
|
+
*/
|
|
932
|
+
static isEnabled(): boolean;
|
|
933
|
+
/**
|
|
934
|
+
* Reset the analytics service state (primarily for testing)
|
|
935
|
+
*/
|
|
936
|
+
static reset(): void;
|
|
937
|
+
/**
|
|
938
|
+
* Generic event tracking method.
|
|
939
|
+
* Use this to track any custom event with arbitrary parameters.
|
|
940
|
+
*
|
|
941
|
+
* @param eventName - Name of the event (e.g., 'button_clicked', 'form_submitted')
|
|
942
|
+
* @param parameters - Key-value pairs of event parameters
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* ```typescript
|
|
946
|
+
* AnalyticsService.trackEvent('ecosystem_selected', { ecosystem: 'evm' });
|
|
947
|
+
* AnalyticsService.trackEvent('wizard_step', { step_number: 2, step_name: 'configure' });
|
|
948
|
+
* ```
|
|
949
|
+
*/
|
|
950
|
+
static trackEvent(eventName: string, parameters: Record<string, string | number>): void;
|
|
951
|
+
/**
|
|
952
|
+
* Track page view event.
|
|
953
|
+
* Common event shared across all apps.
|
|
954
|
+
*
|
|
955
|
+
* @param pageName - Human-readable name of the page
|
|
956
|
+
* @param pagePath - URL path of the page
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* AnalyticsService.trackPageView('Dashboard', '/dashboard');
|
|
961
|
+
* ```
|
|
962
|
+
*/
|
|
963
|
+
static trackPageView(pageName: string, pagePath: string): void;
|
|
964
|
+
/**
|
|
965
|
+
* Track network selection event.
|
|
966
|
+
* Common event shared across all apps that involve network selection.
|
|
967
|
+
*
|
|
968
|
+
* @param networkId - Selected network ID
|
|
969
|
+
* @param ecosystem - Ecosystem the network belongs to (e.g., 'evm', 'stellar')
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* ```typescript
|
|
973
|
+
* AnalyticsService.trackNetworkSelection('ethereum-mainnet', 'evm');
|
|
974
|
+
* ```
|
|
975
|
+
*/
|
|
976
|
+
static trackNetworkSelection(networkId: string, ecosystem: string): void;
|
|
977
|
+
/**
|
|
978
|
+
* Load the Google Analytics gtag script
|
|
979
|
+
* @private
|
|
980
|
+
*/
|
|
981
|
+
private static loadGtagScript;
|
|
982
|
+
/**
|
|
983
|
+
* Initialize gtag with configuration
|
|
984
|
+
* @private
|
|
985
|
+
*/
|
|
986
|
+
private static initializeGtag;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Type declarations for Google Analytics gtag
|
|
990
|
+
*/
|
|
991
|
+
|
|
992
|
+
sideEffect();
|
|
993
|
+
|
|
994
|
+
//#endregion
|
|
995
|
+
//#region src/deepLink.d.ts
|
|
996
|
+
/**
|
|
997
|
+
* Deep-link utilities (chain-agnostic)
|
|
998
|
+
*
|
|
999
|
+
* NOTE: Stub implementation for TDD. Tests will drive full behavior in Phase 3.3.
|
|
1000
|
+
*/
|
|
1001
|
+
type DeepLinkParams = Record<string, string>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Parses URL query parameters into a key-value object.
|
|
1004
|
+
* @returns Object containing all URL query parameters
|
|
1005
|
+
*/
|
|
1006
|
+
declare function parseDeepLink(): DeepLinkParams;
|
|
1007
|
+
/**
|
|
1008
|
+
* Gets the forced service from deep link parameters.
|
|
1009
|
+
* @param params - Deep link parameters object
|
|
1010
|
+
* @returns Service name if specified, null otherwise
|
|
1011
|
+
*/
|
|
1012
|
+
declare function getForcedService(params: DeepLinkParams): string | null;
|
|
1013
|
+
/**
|
|
1014
|
+
* Computes the effective provider preference based on priority order.
|
|
1015
|
+
* @param input - Configuration object with provider options
|
|
1016
|
+
* @returns The effective provider and its source
|
|
1017
|
+
*/
|
|
1018
|
+
declare function computeEffectiveProviderPreference(input: {
|
|
1019
|
+
forcedService?: string | null;
|
|
1020
|
+
uiSelection?: string | null;
|
|
1021
|
+
appDefault?: string | null;
|
|
1022
|
+
adapterDefaultOrder: readonly string[];
|
|
1023
|
+
}): {
|
|
1024
|
+
effectiveProvider: string;
|
|
1025
|
+
source: 'urlForced' | 'ui' | 'appConfig' | 'adapterDefault';
|
|
1026
|
+
};
|
|
1027
|
+
//# sourceMappingURL=deepLink.d.ts.map
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/sanitize.d.ts
|
|
1030
|
+
/**
|
|
1031
|
+
* Minimal HTML sanitizer for client-side rendering of adapter-provided notes.
|
|
1032
|
+
*
|
|
1033
|
+
* - Strips <script>/<style> blocks and closing tags
|
|
1034
|
+
* - Removes inline event handlers (on*)
|
|
1035
|
+
* - Neutralizes javascript: URLs in href/src
|
|
1036
|
+
* - Whitelists a small set of tags: a,b,strong,i,em,code,br,ul,ol,li,p
|
|
1037
|
+
*
|
|
1038
|
+
* This utility is intentionally small and dependency-free. If we decide to
|
|
1039
|
+
* allow richer HTML, we can swap this implementation with a vetted library
|
|
1040
|
+
* (e.g., DOMPurify) behind the same function signature.
|
|
1041
|
+
*/
|
|
1042
|
+
declare function sanitizeHtml(html: string): string;
|
|
1043
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/access/snapshot.d.ts
|
|
1046
|
+
/**
|
|
1047
|
+
* Validates an access snapshot structure
|
|
1048
|
+
* @param snapshot The snapshot to validate
|
|
1049
|
+
* @returns True if valid, false otherwise
|
|
1050
|
+
*/
|
|
1051
|
+
declare function validateSnapshot(snapshot: AccessSnapshot): boolean;
|
|
1052
|
+
/**
|
|
1053
|
+
* Serializes an access snapshot to JSON string
|
|
1054
|
+
* @param snapshot The snapshot to serialize
|
|
1055
|
+
* @returns JSON string representation
|
|
1056
|
+
* @throws Error if snapshot is invalid
|
|
1057
|
+
*/
|
|
1058
|
+
declare function serializeSnapshot(snapshot: AccessSnapshot): string;
|
|
1059
|
+
/**
|
|
1060
|
+
* Deserializes a JSON string to an access snapshot
|
|
1061
|
+
* @param json The JSON string to deserialize
|
|
1062
|
+
* @returns Access snapshot object
|
|
1063
|
+
* @throws Error if JSON is invalid or snapshot structure is invalid
|
|
1064
|
+
*/
|
|
1065
|
+
declare function deserializeSnapshot(json: string): AccessSnapshot;
|
|
1066
|
+
/**
|
|
1067
|
+
* Creates an empty snapshot
|
|
1068
|
+
* @returns Empty snapshot with no roles and no ownership
|
|
1069
|
+
*/
|
|
1070
|
+
declare function createEmptySnapshot(): AccessSnapshot;
|
|
1071
|
+
/**
|
|
1072
|
+
* Finds a role assignment by role ID
|
|
1073
|
+
* @param snapshot The snapshot to search
|
|
1074
|
+
* @param roleId The role ID to find
|
|
1075
|
+
* @returns The role assignment if found, undefined otherwise
|
|
1076
|
+
*/
|
|
1077
|
+
declare function findRoleAssignment(snapshot: AccessSnapshot, roleId: string): RoleAssignment | undefined;
|
|
1078
|
+
/**
|
|
1079
|
+
* Checks if a snapshot has any roles
|
|
1080
|
+
* @param snapshot The snapshot to check
|
|
1081
|
+
* @returns True if snapshot has at least one role assignment
|
|
1082
|
+
*/
|
|
1083
|
+
declare function hasRoles(snapshot: AccessSnapshot): boolean;
|
|
1084
|
+
/**
|
|
1085
|
+
* Checks if a snapshot has ownership information
|
|
1086
|
+
* @param snapshot The snapshot to check
|
|
1087
|
+
* @returns True if snapshot has ownership information
|
|
1088
|
+
*/
|
|
1089
|
+
declare function hasOwnership(snapshot: AccessSnapshot): boolean;
|
|
1090
|
+
/**
|
|
1091
|
+
* Gets the total number of role members across all roles
|
|
1092
|
+
* @param snapshot The snapshot to count
|
|
1093
|
+
* @returns Total number of unique members across all roles
|
|
1094
|
+
*/
|
|
1095
|
+
declare function getTotalMemberCount(snapshot: AccessSnapshot): number;
|
|
1096
|
+
/**
|
|
1097
|
+
* Gets all unique members across all roles
|
|
1098
|
+
* @param snapshot The snapshot to extract members from
|
|
1099
|
+
* @returns Array of unique member addresses
|
|
1100
|
+
*/
|
|
1101
|
+
declare function getAllMembers(snapshot: AccessSnapshot): string[];
|
|
1102
|
+
/**
|
|
1103
|
+
* Compares two snapshots and returns differences
|
|
1104
|
+
* @param snapshot1 First snapshot
|
|
1105
|
+
* @param snapshot2 Second snapshot
|
|
1106
|
+
* @returns Object describing differences
|
|
1107
|
+
*/
|
|
1108
|
+
declare function compareSnapshots(snapshot1: AccessSnapshot, snapshot2: AccessSnapshot): {
|
|
1109
|
+
rolesAdded: RoleAssignment[];
|
|
1110
|
+
rolesRemoved: RoleAssignment[];
|
|
1111
|
+
rolesModified: Array<{
|
|
1112
|
+
role: RoleIdentifier;
|
|
1113
|
+
membersAdded: string[];
|
|
1114
|
+
membersRemoved: string[];
|
|
1115
|
+
}>;
|
|
1116
|
+
ownershipChanged: boolean;
|
|
1117
|
+
};
|
|
1118
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/access/errors.d.ts
|
|
1121
|
+
/**
|
|
1122
|
+
* Access Control Error Utilities
|
|
1123
|
+
*
|
|
1124
|
+
* Chain-agnostic helper functions for working with access control errors.
|
|
1125
|
+
* These utilities can be used across any adapter that implements access control.
|
|
1126
|
+
*
|
|
1127
|
+
* Note: These utilities work with the AccessControlError types from @openzeppelin/ui-types
|
|
1128
|
+
* but don't import them directly to avoid circular dependencies.
|
|
1129
|
+
*/
|
|
1130
|
+
/**
|
|
1131
|
+
* Base interface for access control errors (matches the class in types package)
|
|
1132
|
+
*/
|
|
1133
|
+
interface AccessControlErrorLike extends Error {
|
|
1134
|
+
readonly contractAddress?: string;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* Type guard to check if an error is an AccessControlError
|
|
1138
|
+
*
|
|
1139
|
+
* @param error The error to check
|
|
1140
|
+
* @returns True if the error has the AccessControlError structure
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* try {
|
|
1145
|
+
* await service.grantRole(...);
|
|
1146
|
+
* } catch (error) {
|
|
1147
|
+
* if (isAccessControlError(error)) {
|
|
1148
|
+
* console.log('Access control error:', error.contractAddress);
|
|
1149
|
+
* }
|
|
1150
|
+
* }
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
declare function isAccessControlError(error: unknown): error is AccessControlErrorLike;
|
|
1154
|
+
/**
|
|
1155
|
+
* Helper to safely extract error message from unknown error type
|
|
1156
|
+
*
|
|
1157
|
+
* @param error The error to extract message from
|
|
1158
|
+
* @returns The error message string
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* try {
|
|
1163
|
+
* await someOperation();
|
|
1164
|
+
* } catch (error) {
|
|
1165
|
+
* const message = getErrorMessage(error);
|
|
1166
|
+
* logger.error('Operation failed:', message);
|
|
1167
|
+
* }
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
declare function getErrorMessage(error: unknown): string;
|
|
1171
|
+
/**
|
|
1172
|
+
* Helper to create a user-friendly error message with full context
|
|
1173
|
+
*
|
|
1174
|
+
* This function formats an AccessControlError into a readable multi-line message
|
|
1175
|
+
* that includes all relevant context (contract address, roles, operations, etc.).
|
|
1176
|
+
*
|
|
1177
|
+
* @param error The AccessControlError to format
|
|
1178
|
+
* @returns Formatted error message string with all context
|
|
1179
|
+
*
|
|
1180
|
+
* @example
|
|
1181
|
+
* ```typescript
|
|
1182
|
+
* import { PermissionDenied } from '@openzeppelin/ui-types';
|
|
1183
|
+
* import { formatAccessControlError } from '@openzeppelin/ui-utils';
|
|
1184
|
+
*
|
|
1185
|
+
* try {
|
|
1186
|
+
* await service.grantRole(...);
|
|
1187
|
+
* } catch (error) {
|
|
1188
|
+
* if (error instanceof PermissionDenied) {
|
|
1189
|
+
* const formatted = formatAccessControlError(error);
|
|
1190
|
+
* showErrorToUser(formatted);
|
|
1191
|
+
* }
|
|
1192
|
+
* }
|
|
1193
|
+
* ```
|
|
1194
|
+
*
|
|
1195
|
+
* Output format:
|
|
1196
|
+
* ```
|
|
1197
|
+
* [ErrorName] Error message
|
|
1198
|
+
* Contract: 0x123...
|
|
1199
|
+
* [Additional context based on error type]
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
declare function formatAccessControlError(error: AccessControlErrorLike): string;
|
|
1203
|
+
//#endregion
|
|
1204
|
+
export { AnalyticsService, AppConfigService, BytesValidationOptions, BytesValidationResult, ConfigLoadStrategy, DEFAULT_CONCURRENCY_LIMIT, DeepLinkParams, ExplorerConfigEvent, NumericBoundsMap, RouterService, RpcConfigEvent, ServiceConfigEvent, UserExplorerConfigService, UserNetworkServiceConfigService, UserRpcConfigService, addressesEqual, appConfigService, base64ToBytes, buildRequiredInputSnapshot, bytesToHex, cn, compareSnapshots, computeEffectiveProviderPreference, createEmptySnapshot, delay, deserializeSnapshot, detectBytesEncoding, enhanceNumericValidation, findRoleAssignment, formatAccessControlError, formatTimestamp, generateId, getAllMembers, getBytesSize, getDefaultValueForType, getErrorMessage, getForcedService, getInvalidUrlMessage, getMissingRequiredContractInputs, getTotalMemberCount, hasMissingRequiredContractInputs, hasOwnership, hasRoles, hexToBytes, isAccessControlError, isDevelopmentOrTestEnvironment, isPlainObject, isProductionEnvironment, isRecordWithProperties, isValidUrl, logger, normalizeAddress, parseDeepLink, promiseAllSettledWithLimit, promiseAllWithLimit, rateLimitedBatch, requiredSnapshotsEqual, routerService, sanitizeHtml, serializeSnapshot, simpleHash, stringToBytes, truncateMiddle, userExplorerConfigService, userNetworkServiceConfigService, userRpcConfigService, validateBytes, validateBytesSimple, validateSnapshot, withTimeout };
|
|
1205
|
+
//# sourceMappingURL=index-qy1AQMhr.d.ts.map
|