@thehoneyjar/sigil-dev-toolbar 0.1.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.
@@ -0,0 +1,1099 @@
1
+ import { Address, Hash, Hex } from 'viem';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import * as react from 'react';
4
+ import { ReactNode } from 'react';
5
+
6
+ /**
7
+ * Zone hierarchy for physics validation
8
+ */
9
+ type Zone = 'critical' | 'elevated' | 'standard' | 'local';
10
+ /**
11
+ * Lens context for User Lens impersonation validation
12
+ */
13
+ interface LensContext {
14
+ /** Address being impersonated */
15
+ impersonatedAddress: string;
16
+ /** Real user address (for signing) */
17
+ realAddress?: string;
18
+ /** Component being validated */
19
+ component: string;
20
+ /** Value observed in the UI */
21
+ observedValue?: string;
22
+ /** Value from on-chain read */
23
+ onChainValue?: string;
24
+ /** Value from indexer (Envio, Subgraph) */
25
+ indexedValue?: string;
26
+ /** Data source used by component */
27
+ dataSource?: 'on-chain' | 'indexed' | 'mixed' | 'unknown';
28
+ }
29
+ /**
30
+ * Lens validation issue types
31
+ */
32
+ type LensIssueType = 'data_source_mismatch' | 'stale_indexed_data' | 'lens_financial_check' | 'impersonation_leak';
33
+ /**
34
+ * Lens validation issue severity
35
+ */
36
+ type LensIssueSeverity = 'error' | 'warning' | 'info';
37
+ /**
38
+ * Individual lens validation issue
39
+ */
40
+ interface LensValidationIssue {
41
+ /** Issue type */
42
+ type: LensIssueType;
43
+ /** Severity */
44
+ severity: LensIssueSeverity;
45
+ /** Human-readable message */
46
+ message: string;
47
+ /** Component where issue was found */
48
+ component: string;
49
+ /** Zone context */
50
+ zone?: Zone;
51
+ /** Expected value */
52
+ expected?: string;
53
+ /** Actual value */
54
+ actual?: string;
55
+ /** Suggested fix */
56
+ suggestion?: string;
57
+ }
58
+ /**
59
+ * Lens validation result
60
+ */
61
+ interface LensValidationResult {
62
+ /** Whether validation passed */
63
+ valid: boolean;
64
+ /** List of issues found */
65
+ issues: LensValidationIssue[];
66
+ /** Summary message */
67
+ summary: string;
68
+ }
69
+ /**
70
+ * User Lens state for address impersonation
71
+ */
72
+ interface UserLensState {
73
+ /** Whether impersonation is enabled */
74
+ enabled: boolean;
75
+ /** The address being impersonated (for reads) */
76
+ impersonatedAddress: Address | null;
77
+ /** Saved addresses for quick selection */
78
+ savedAddresses: SavedAddress[];
79
+ }
80
+ /**
81
+ * Saved address entry
82
+ */
83
+ interface SavedAddress {
84
+ address: Address;
85
+ label: string;
86
+ ens?: string;
87
+ }
88
+ /**
89
+ * Simulation state for testing scenarios
90
+ */
91
+ interface SimulationState {
92
+ /** Whether simulation mode is active */
93
+ enabled: boolean;
94
+ /** Current simulation scenario */
95
+ scenario: SimulationScenario | null;
96
+ }
97
+ /**
98
+ * Simulation scenario configuration
99
+ */
100
+ interface SimulationScenario {
101
+ id: string;
102
+ name: string;
103
+ description: string;
104
+ /** Override values for contract reads */
105
+ overrides: Record<string, unknown>;
106
+ }
107
+ /**
108
+ * Comparison state for before/after views
109
+ */
110
+ interface ComparisonState {
111
+ /** Whether comparison mode is active */
112
+ enabled: boolean;
113
+ /** Captured "before" state */
114
+ beforeState: Record<string, unknown> | null;
115
+ /** Current "after" state */
116
+ afterState: Record<string, unknown> | null;
117
+ }
118
+ /**
119
+ * Diagnostics state for debugging
120
+ */
121
+ interface DiagnosticsState {
122
+ /** Whether diagnostics panel is open */
123
+ enabled: boolean;
124
+ /** Recent physics violations */
125
+ violations: PhysicsViolation[];
126
+ /** Recent taste signals */
127
+ tasteSignals: TasteSignal[];
128
+ }
129
+ /**
130
+ * Physics violation detected by toolbar
131
+ */
132
+ interface PhysicsViolation {
133
+ id: string;
134
+ timestamp: number;
135
+ type: 'behavioral' | 'animation' | 'material' | 'protected';
136
+ severity: 'error' | 'warning' | 'info';
137
+ message: string;
138
+ element?: string;
139
+ suggestion?: string;
140
+ }
141
+ /**
142
+ * Taste signal for preference learning
143
+ */
144
+ interface TasteSignal {
145
+ id: string;
146
+ timestamp: number;
147
+ type: 'ACCEPT' | 'MODIFY' | 'REJECT';
148
+ component: string;
149
+ effect: string;
150
+ change?: {
151
+ from: string;
152
+ to: string;
153
+ };
154
+ }
155
+ /**
156
+ * Dev toolbar configuration options
157
+ */
158
+ interface DevToolbarConfig {
159
+ /** Position of the toolbar */
160
+ position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
161
+ /** Initial collapsed state */
162
+ defaultCollapsed: boolean;
163
+ /** Enable User Lens feature */
164
+ enableUserLens: boolean;
165
+ /** Enable Simulation feature */
166
+ enableSimulation: boolean;
167
+ /** Enable Comparison feature */
168
+ enableComparison: boolean;
169
+ /** Enable Diagnostics feature */
170
+ enableDiagnostics: boolean;
171
+ /** Keyboard shortcut to toggle toolbar */
172
+ toggleShortcut: string;
173
+ /** Callback for Anchor/Lens IPC */
174
+ onAnchorRequest?: (request: AnchorRequest) => Promise<AnchorResponse>;
175
+ /** Callback for taste signal logging */
176
+ onTasteSignal?: (signal: TasteSignal) => void;
177
+ }
178
+ /**
179
+ * Anchor verification request
180
+ */
181
+ interface AnchorRequest {
182
+ type: 'validate' | 'verify' | 'check';
183
+ context: {
184
+ address: Address;
185
+ isImpersonating: boolean;
186
+ realAddress?: Address;
187
+ };
188
+ payload: Record<string, unknown>;
189
+ }
190
+ /**
191
+ * Anchor verification response
192
+ */
193
+ interface AnchorResponse {
194
+ valid: boolean;
195
+ violations?: PhysicsViolation[];
196
+ suggestions?: string[];
197
+ }
198
+ /**
199
+ * Active tab in the toolbar
200
+ */
201
+ type ToolbarTab = 'lens' | 'simulate' | 'compare' | 'diagnose';
202
+ /**
203
+ * Complete toolbar state
204
+ */
205
+ interface DevToolbarState {
206
+ /** Whether toolbar is visible */
207
+ visible: boolean;
208
+ /** Whether toolbar is collapsed */
209
+ collapsed: boolean;
210
+ /** Currently active tab */
211
+ activeTab: ToolbarTab;
212
+ /** User Lens state */
213
+ userLens: UserLensState;
214
+ /** Simulation state */
215
+ simulation: SimulationState;
216
+ /** Comparison state */
217
+ comparison: ComparisonState;
218
+ /** Diagnostics state */
219
+ diagnostics: DiagnosticsState;
220
+ }
221
+ /**
222
+ * Dev toolbar store actions
223
+ */
224
+ interface DevToolbarActions {
225
+ show: () => void;
226
+ hide: () => void;
227
+ toggle: () => void;
228
+ collapse: () => void;
229
+ expand: () => void;
230
+ setActiveTab: (tab: ToolbarTab) => void;
231
+ enableLens: (address: Address) => void;
232
+ disableLens: () => void;
233
+ setImpersonatedAddress: (address: Address | null) => void;
234
+ saveAddress: (entry: SavedAddress) => void;
235
+ removeAddress: (address: Address) => void;
236
+ enableSimulation: (scenario: SimulationScenario) => void;
237
+ disableSimulation: () => void;
238
+ captureBeforeState: (state: Record<string, unknown>) => void;
239
+ captureAfterState: (state: Record<string, unknown>) => void;
240
+ clearComparison: () => void;
241
+ addViolation: (violation: PhysicsViolation) => void;
242
+ clearViolations: () => void;
243
+ addTasteSignal: (signal: TasteSignal) => void;
244
+ clearTasteSignals: () => void;
245
+ reset: () => void;
246
+ }
247
+
248
+ /**
249
+ * Create the Zustand store with persistence
250
+ */
251
+ type DevToolbarStore = DevToolbarState & DevToolbarActions;
252
+ /**
253
+ * Props for DevToolbarProvider
254
+ */
255
+ interface DevToolbarProviderProps {
256
+ children: ReactNode;
257
+ config?: Partial<DevToolbarConfig>;
258
+ }
259
+ /**
260
+ * Provider component for the dev toolbar
261
+ */
262
+ declare function DevToolbarProvider({ children, config: userConfig }: DevToolbarProviderProps): react_jsx_runtime.JSX.Element;
263
+ /**
264
+ * Hook to access the dev toolbar store
265
+ */
266
+ declare function useDevToolbar(): DevToolbarStore;
267
+ /**
268
+ * Hook to access specific state with selector
269
+ */
270
+ declare function useDevToolbarSelector<T>(selector: (state: DevToolbarStore) => T): T;
271
+ /**
272
+ * Hook to access the toolbar config
273
+ */
274
+ declare function useDevToolbarConfig(): DevToolbarConfig;
275
+
276
+ /**
277
+ * Return type for useLensAwareAccount
278
+ */
279
+ interface LensAwareAccount {
280
+ /** Address for reads - impersonated if lens enabled, otherwise real */
281
+ address: Address | undefined;
282
+ /** The user's real connected address (always available for signing) */
283
+ realAddress: Address | undefined;
284
+ /** Whether currently impersonating another address */
285
+ isImpersonating: boolean;
286
+ /** The impersonated address (if any) */
287
+ impersonatedAddress: Address | null;
288
+ /** Whether the wallet is connected */
289
+ isConnected: boolean;
290
+ }
291
+ /**
292
+ * Hook that returns impersonated address for reads, real address for writes.
293
+ *
294
+ * Use this hook in place of wagmi's `useAccount` when you want components
295
+ * to display data for an impersonated address while still being able to
296
+ * sign transactions with the real connected wallet.
297
+ *
298
+ * @example
299
+ * ```tsx
300
+ * function WalletInfo() {
301
+ * const { address, realAddress, isImpersonating } = useLensAwareAccount()
302
+ *
303
+ * // Use `address` for reading data (respects impersonation)
304
+ * const { data: balance } = useBalance({ address })
305
+ *
306
+ * // Use `realAddress` for signing transactions
307
+ * const { writeContract } = useWriteContract()
308
+ *
309
+ * return (
310
+ * <div>
311
+ * <p>Viewing: {address}</p>
312
+ * {isImpersonating && <Badge>Lens Active</Badge>}
313
+ * <button onClick={() => writeContract({ ... })}>
314
+ * Sign with {realAddress}
315
+ * </button>
316
+ * </div>
317
+ * )
318
+ * }
319
+ * ```
320
+ */
321
+ declare function useLensAwareAccount(): LensAwareAccount;
322
+ /**
323
+ * Hook to get just the impersonation status
324
+ *
325
+ * @example
326
+ * ```tsx
327
+ * function LensBadge() {
328
+ * const isImpersonating = useIsImpersonating()
329
+ * if (!isImpersonating) return null
330
+ * return <Badge variant="warning">Lens Active</Badge>
331
+ * }
332
+ * ```
333
+ */
334
+ declare function useIsImpersonating(): boolean;
335
+ /**
336
+ * Hook to get the impersonated address (or null if not impersonating)
337
+ */
338
+ declare function useImpersonatedAddress(): Address | null;
339
+ /**
340
+ * Hook to get saved addresses for quick selection
341
+ */
342
+ declare function useSavedAddresses(): {
343
+ savedAddresses: SavedAddress[];
344
+ saveAddress: (entry: SavedAddress) => void;
345
+ removeAddress: (address: `0x${string}`) => void;
346
+ selectAddress: (address: `0x${string}` | null) => void;
347
+ };
348
+
349
+ /**
350
+ * IPC Types for Toolbar <-> Anchor/Lens Communication
351
+ */
352
+
353
+ /** IPC Request types */
354
+ type IPCRequestType = 'lens-validate' | 'anchor-validate' | 'lens-verify';
355
+ /** Base IPC Request */
356
+ interface IPCRequest<T = unknown> {
357
+ /** Unique request ID */
358
+ id: string;
359
+ /** Request type */
360
+ type: IPCRequestType;
361
+ /** Timestamp */
362
+ timestamp: number;
363
+ /** Request payload */
364
+ payload: T;
365
+ }
366
+ /** Lens validation request payload */
367
+ interface LensValidatePayload {
368
+ /** Lens context to validate */
369
+ context: LensContext;
370
+ /** Zone for validation */
371
+ zone?: Zone;
372
+ }
373
+ /** Anchor validation request payload */
374
+ interface AnchorValidatePayload {
375
+ /** Grounding statement */
376
+ statement?: string;
377
+ /** Lens context (optional) */
378
+ lensContext?: LensContext;
379
+ /** Zone for lens validation */
380
+ zone?: Zone;
381
+ }
382
+ /** IPC Response status */
383
+ type IPCResponseStatus = 'success' | 'error' | 'timeout';
384
+ /** Base IPC Response */
385
+ interface IPCResponse<T = unknown> {
386
+ /** Request ID this responds to */
387
+ requestId: string;
388
+ /** Response status */
389
+ status: IPCResponseStatus;
390
+ /** Timestamp */
391
+ timestamp: number;
392
+ /** Response data (if success) */
393
+ data?: T;
394
+ /** Error message (if error) */
395
+ error?: string;
396
+ /** Exit code from CLI */
397
+ exitCode?: number;
398
+ }
399
+ /** Lens validation response data */
400
+ interface LensValidateResponse {
401
+ valid: boolean;
402
+ issues: LensValidationResult['issues'];
403
+ summary: string;
404
+ }
405
+ /** Anchor validation response data */
406
+ interface AnchorValidateResponse {
407
+ status?: 'VALID' | 'DRIFT' | 'DECEPTIVE';
408
+ checks?: {
409
+ relevance: {
410
+ passed: boolean;
411
+ reason: string;
412
+ };
413
+ hierarchy: {
414
+ passed: boolean;
415
+ reason: string;
416
+ };
417
+ rules: {
418
+ passed: boolean;
419
+ reason: string;
420
+ };
421
+ };
422
+ requiredZone?: Zone;
423
+ citedZone?: Zone | null;
424
+ correction?: string;
425
+ lens_validation?: LensValidateResponse;
426
+ }
427
+ /** IPC Client configuration */
428
+ interface IPCClientConfig {
429
+ /** Base path for IPC files */
430
+ basePath?: string;
431
+ /** Timeout for responses (ms) */
432
+ timeout?: number;
433
+ /** Polling interval for responses (ms) */
434
+ pollInterval?: number;
435
+ }
436
+
437
+ /**
438
+ * React hook for IPC Client
439
+ */
440
+
441
+ interface UseIPCClientReturn {
442
+ /** Validate lens context */
443
+ validateLens: (context: LensContext, zone?: Zone) => Promise<LensValidateResponse>;
444
+ /** Validate with Anchor */
445
+ validateAnchor: (statement?: string, lensContext?: LensContext, zone?: Zone) => Promise<AnchorValidateResponse>;
446
+ /** Whether a request is in progress */
447
+ isLoading: boolean;
448
+ /** Last error message */
449
+ error: string | null;
450
+ /** Clear error */
451
+ clearError: () => void;
452
+ }
453
+ /**
454
+ * Hook for using the IPC client in components
455
+ */
456
+ declare function useIPCClient(): UseIPCClientReturn;
457
+
458
+ /**
459
+ * Fork Chain State Service
460
+ *
461
+ * Provides integration with Anvil/Tenderly for chain state forking.
462
+ * Enables transaction simulation without real funds.
463
+ */
464
+
465
+ /**
466
+ * Fork provider type
467
+ */
468
+ type ForkProvider = 'anvil' | 'tenderly' | 'custom';
469
+ /**
470
+ * Fork configuration
471
+ */
472
+ interface ForkConfig {
473
+ /** Fork provider type */
474
+ provider: ForkProvider;
475
+ /** RPC URL to fork from (mainnet, testnet, etc.) */
476
+ forkUrl: string;
477
+ /** Block number to fork at (undefined = latest) */
478
+ forkBlockNumber?: bigint;
479
+ /** Chain ID for the fork */
480
+ chainId: number;
481
+ /** Anvil-specific: port to run on */
482
+ anvilPort?: number;
483
+ /** Tenderly-specific: project slug */
484
+ tenderlyProject?: string;
485
+ /** Tenderly-specific: API key */
486
+ tenderlyApiKey?: string;
487
+ /** Custom fork RPC URL (when provider = 'custom') */
488
+ customForkRpc?: string;
489
+ }
490
+ /**
491
+ * Fork state
492
+ */
493
+ interface ForkState {
494
+ /** Whether fork is active */
495
+ active: boolean;
496
+ /** Fork RPC URL */
497
+ rpcUrl: string | null;
498
+ /** Block number fork was created at */
499
+ blockNumber: bigint | null;
500
+ /** Chain ID */
501
+ chainId: number | null;
502
+ /** Fork creation timestamp */
503
+ createdAt: number | null;
504
+ /** Number of snapshots taken */
505
+ snapshotCount: number;
506
+ /** Current snapshot ID */
507
+ currentSnapshotId: string | null;
508
+ }
509
+ /**
510
+ * Fork snapshot for state restoration
511
+ */
512
+ interface ForkSnapshot {
513
+ id: string;
514
+ blockNumber: bigint;
515
+ timestamp: number;
516
+ description?: string;
517
+ }
518
+ /**
519
+ * Fork service interface
520
+ */
521
+ interface ForkService {
522
+ /** Create a new fork */
523
+ createFork(config: ForkConfig): Promise<ForkState>;
524
+ /** Get current fork state */
525
+ getState(): ForkState;
526
+ /** Take a snapshot of current fork state */
527
+ snapshot(description?: string): Promise<ForkSnapshot>;
528
+ /** Revert to a snapshot */
529
+ revert(snapshotId: string): Promise<boolean>;
530
+ /** Reset fork to initial state */
531
+ reset(): Promise<void>;
532
+ /** Destroy the fork */
533
+ destroy(): Promise<void>;
534
+ /** Set account balance (for testing) */
535
+ setBalance(address: Address, balance: bigint): Promise<void>;
536
+ /** Impersonate an address (for testing) */
537
+ impersonateAccount(address: Address): Promise<void>;
538
+ /** Stop impersonating an address */
539
+ stopImpersonating(address: Address): Promise<void>;
540
+ /** Mine a block */
541
+ mineBlock(blocks?: number): Promise<void>;
542
+ /** Get fork RPC URL */
543
+ getRpcUrl(): string | null;
544
+ }
545
+ /**
546
+ * Create an Anvil-based fork service
547
+ */
548
+ declare function createAnvilForkService(): ForkService;
549
+ /**
550
+ * Create a Tenderly-based fork service
551
+ */
552
+ declare function createTenderlyForkService(): ForkService;
553
+ /**
554
+ * Create a fork service based on provider type
555
+ */
556
+ declare function createForkService(provider: ForkProvider): ForkService;
557
+ /**
558
+ * Get the default fork service
559
+ */
560
+ declare function getForkService(provider?: ForkProvider): ForkService;
561
+ /**
562
+ * Reset the default fork service
563
+ */
564
+ declare function resetForkService(): void;
565
+
566
+ /**
567
+ * Hook for managing fork chain state
568
+ *
569
+ * Provides React integration for fork service.
570
+ */
571
+
572
+ /**
573
+ * Fork state hook return type
574
+ */
575
+ interface UseForkStateReturn {
576
+ /** Current fork state */
577
+ state: ForkState;
578
+ /** Whether fork operation is in progress */
579
+ isLoading: boolean;
580
+ /** Error message if any */
581
+ error: string | null;
582
+ /** Create a new fork */
583
+ createFork: (config: ForkConfig) => Promise<void>;
584
+ /** Take a snapshot */
585
+ snapshot: (description?: string) => Promise<ForkSnapshot | null>;
586
+ /** Revert to a snapshot */
587
+ revert: (snapshotId: string) => Promise<boolean>;
588
+ /** Reset fork to initial state */
589
+ reset: () => Promise<void>;
590
+ /** Destroy the fork */
591
+ destroy: () => Promise<void>;
592
+ /** Set account balance */
593
+ setBalance: (address: Address, balance: bigint) => Promise<void>;
594
+ /** Impersonate an account */
595
+ impersonateAccount: (address: Address) => Promise<void>;
596
+ /** Stop impersonating an account */
597
+ stopImpersonating: (address: Address) => Promise<void>;
598
+ /** Mine blocks */
599
+ mineBlock: (blocks?: number) => Promise<void>;
600
+ /** All snapshots taken */
601
+ snapshots: ForkSnapshot[];
602
+ }
603
+ /**
604
+ * Hook for managing fork chain state
605
+ */
606
+ declare function useForkState(defaultProvider?: ForkProvider): UseForkStateReturn;
607
+
608
+ /**
609
+ * Transaction Simulation Service
610
+ *
611
+ * Executes transactions against fork and captures results.
612
+ * Provides dry-run functionality without real funds.
613
+ */
614
+
615
+ /**
616
+ * Transaction request for simulation
617
+ */
618
+ interface SimulationTransactionRequest {
619
+ /** Transaction sender */
620
+ from: Address;
621
+ /** Transaction recipient */
622
+ to: Address;
623
+ /** Transaction value in wei */
624
+ value?: bigint;
625
+ /** Transaction data */
626
+ data?: Hex;
627
+ /** Gas limit (optional, will be estimated if not provided) */
628
+ gas?: bigint;
629
+ /** Gas price (optional) */
630
+ gasPrice?: bigint;
631
+ /** Max fee per gas (EIP-1559) */
632
+ maxFeePerGas?: bigint;
633
+ /** Max priority fee per gas (EIP-1559) */
634
+ maxPriorityFeePerGas?: bigint;
635
+ /** Nonce (optional, will be fetched if not provided) */
636
+ nonce?: number;
637
+ }
638
+ /**
639
+ * Balance change from simulation
640
+ */
641
+ interface BalanceChange {
642
+ /** Address whose balance changed */
643
+ address: Address;
644
+ /** Token address (null for ETH) */
645
+ token: Address | null;
646
+ /** Token symbol (if known) */
647
+ symbol?: string;
648
+ /** Balance before transaction */
649
+ before: bigint;
650
+ /** Balance after transaction */
651
+ after: bigint;
652
+ /** Change amount (can be negative) */
653
+ delta: bigint;
654
+ }
655
+ /**
656
+ * State change from simulation
657
+ */
658
+ interface StateChange {
659
+ /** Contract address */
660
+ address: Address;
661
+ /** Storage slot */
662
+ slot: Hex;
663
+ /** Value before transaction */
664
+ before: Hex;
665
+ /** Value after transaction */
666
+ after: Hex;
667
+ }
668
+ /**
669
+ * Event log from simulation
670
+ */
671
+ interface SimulationLog {
672
+ /** Contract address that emitted the log */
673
+ address: Address;
674
+ /** Log topics */
675
+ topics: Hex[];
676
+ /** Log data */
677
+ data: Hex;
678
+ /** Decoded event name (if ABI available) */
679
+ eventName?: string;
680
+ /** Decoded event args (if ABI available) */
681
+ decodedArgs?: Record<string, unknown>;
682
+ }
683
+ /**
684
+ * Simulation result
685
+ */
686
+ interface SimulationResult {
687
+ /** Whether transaction succeeded */
688
+ success: boolean;
689
+ /** Transaction hash (from simulation) */
690
+ hash?: Hash;
691
+ /** Gas used */
692
+ gasUsed: bigint;
693
+ /** Gas limit */
694
+ gasLimit: bigint;
695
+ /** Effective gas price */
696
+ effectiveGasPrice: bigint;
697
+ /** Total cost in wei (gasUsed * effectiveGasPrice + value) */
698
+ totalCost: bigint;
699
+ /** Return value (if any) */
700
+ returnValue?: Hex;
701
+ /** Revert reason (if failed) */
702
+ revertReason?: string;
703
+ /** Balance changes */
704
+ balanceChanges: BalanceChange[];
705
+ /** State changes */
706
+ stateChanges: StateChange[];
707
+ /** Event logs */
708
+ logs: SimulationLog[];
709
+ /** Block number simulation was run at */
710
+ blockNumber: bigint;
711
+ /** Timestamp of simulation */
712
+ timestamp: number;
713
+ }
714
+ /**
715
+ * Simulation service interface
716
+ */
717
+ interface SimulationService {
718
+ /** Simulate a transaction */
719
+ simulate(tx: SimulationTransactionRequest): Promise<SimulationResult>;
720
+ /** Estimate gas for a transaction */
721
+ estimateGas(tx: SimulationTransactionRequest): Promise<bigint>;
722
+ /** Get current gas price */
723
+ getGasPrice(): Promise<bigint>;
724
+ /** Decode revert reason from error data */
725
+ decodeRevertReason(data: Hex): string | null;
726
+ }
727
+ /**
728
+ * Create a simulation service using a fork service
729
+ */
730
+ declare function createSimulationService(forkService: ForkService): SimulationService;
731
+ /**
732
+ * Get the default simulation service
733
+ */
734
+ declare function getSimulationService(forkService: ForkService): SimulationService;
735
+ /**
736
+ * Reset the default simulation service
737
+ */
738
+ declare function resetSimulationService(): void;
739
+
740
+ /**
741
+ * Hook for Transaction Simulation
742
+ *
743
+ * Provides easy integration for simulating transactions against a fork.
744
+ * Manages fork state, simulation service, and result caching.
745
+ */
746
+
747
+ /**
748
+ * Transaction request input for the hook
749
+ */
750
+ interface TransactionInput {
751
+ /** Transaction recipient */
752
+ to: Address;
753
+ /** Transaction data */
754
+ data?: Hex;
755
+ /** Transaction value in wei */
756
+ value?: bigint;
757
+ /** Gas limit (optional) */
758
+ gas?: bigint;
759
+ }
760
+ /**
761
+ * Hook configuration
762
+ */
763
+ interface UseTransactionSimulationConfig {
764
+ /** Fork provider (default: 'anvil') */
765
+ provider?: ForkProvider;
766
+ /** Fork RPC URL (for custom provider) */
767
+ forkUrl?: string;
768
+ /** Chain ID */
769
+ chainId?: number;
770
+ /** Anvil port (default: 8545) */
771
+ anvilPort?: number;
772
+ /** Auto-connect on mount */
773
+ autoConnect?: boolean;
774
+ /** Sender address (will be impersonated) */
775
+ from?: Address;
776
+ }
777
+ /**
778
+ * Hook return type
779
+ */
780
+ interface UseTransactionSimulationReturn {
781
+ /** Latest simulation result */
782
+ result: SimulationResult | null;
783
+ /** Whether simulation is running */
784
+ isSimulating: boolean;
785
+ /** Whether fork is connected */
786
+ isConnected: boolean;
787
+ /** Whether fork is connecting */
788
+ isConnecting: boolean;
789
+ /** Error message if any */
790
+ error: string | null;
791
+ /** Simulate a transaction */
792
+ simulate: (tx: TransactionInput) => Promise<SimulationResult | null>;
793
+ /** Connect to fork */
794
+ connect: (config?: Partial<ForkConfig>) => Promise<void>;
795
+ /** Disconnect from fork */
796
+ disconnect: () => Promise<void>;
797
+ /** Clear the last result */
798
+ clearResult: () => void;
799
+ /** Reset the fork state */
800
+ reset: () => Promise<void>;
801
+ }
802
+ /**
803
+ * Hook for transaction simulation
804
+ *
805
+ * @example
806
+ * ```tsx
807
+ * const { result, isSimulating, error, simulate } = useTransactionSimulation({
808
+ * from: '0x...',
809
+ * autoConnect: true,
810
+ * })
811
+ *
812
+ * const handleSimulate = async () => {
813
+ * await simulate({
814
+ * to: '0x...',
815
+ * data: '0x...',
816
+ * value: 0n,
817
+ * })
818
+ * }
819
+ * ```
820
+ */
821
+ declare function useTransactionSimulation(config?: UseTransactionSimulationConfig): UseTransactionSimulationReturn;
822
+ /**
823
+ * Hook for simulation with automatic fork management
824
+ *
825
+ * Simplified version that auto-connects and manages fork lifecycle.
826
+ *
827
+ * @example
828
+ * ```tsx
829
+ * const { result, isSimulating, simulate } = useSimulation('0x...')
830
+ *
831
+ * // Simulate a simple transfer
832
+ * await simulate({
833
+ * to: recipientAddress,
834
+ * value: parseEther('1'),
835
+ * })
836
+ * ```
837
+ */
838
+ declare function useSimulation(from: Address, options?: Omit<UseTransactionSimulationConfig, 'from' | 'autoConnect'>): Omit<UseTransactionSimulationReturn, 'connect' | 'disconnect'>;
839
+
840
+ /**
841
+ * User Lens panel for address impersonation
842
+ */
843
+ declare function UserLens(): react_jsx_runtime.JSX.Element;
844
+ /**
845
+ * Badge component showing when lens is active
846
+ */
847
+ declare function LensActiveBadge(): react_jsx_runtime.JSX.Element | null;
848
+
849
+ /**
850
+ * Main Dev Toolbar component
851
+ *
852
+ * Renders only in development mode (checks process.env.NODE_ENV)
853
+ */
854
+ declare function DevToolbar(): react_jsx_runtime.JSX.Element | null;
855
+ /**
856
+ * Floating trigger button to show toolbar when hidden
857
+ */
858
+ declare function DevToolbarTrigger(): react_jsx_runtime.JSX.Element | null;
859
+ /**
860
+ * Complete toolbar with trigger
861
+ */
862
+ declare function DevToolbarWithTrigger(): react_jsx_runtime.JSX.Element;
863
+
864
+ /** Diagnostic query item */
865
+ interface DiagnosticItem {
866
+ id: string;
867
+ label: string;
868
+ component: string;
869
+ observedValue: string;
870
+ onChainValue?: string;
871
+ indexedValue?: string;
872
+ dataSource: 'on-chain' | 'indexed' | 'mixed' | 'unknown';
873
+ zone: Zone;
874
+ status: 'pending' | 'verified' | 'mismatch' | 'unknown';
875
+ }
876
+ /**
877
+ * Diagnostic Panel Props
878
+ */
879
+ interface DiagnosticPanelProps {
880
+ /** Items to diagnose */
881
+ items?: DiagnosticItem[];
882
+ /** Whether to auto-query on mount */
883
+ autoQuery?: boolean;
884
+ /** Callback when diagnosis completes */
885
+ onDiagnosisComplete?: (result: {
886
+ verified: DiagnosticItem[];
887
+ issues: LensValidationIssue[];
888
+ }) => void;
889
+ }
890
+ /**
891
+ * Diagnostic Panel Component
892
+ */
893
+ declare function DiagnosticPanel({ items: initialItems, autoQuery, onDiagnosisComplete, }: DiagnosticPanelProps): react_jsx_runtime.JSX.Element;
894
+ /**
895
+ * Hook for managing diagnostic items
896
+ */
897
+ declare function useDiagnosticItems(): {
898
+ items: DiagnosticItem[];
899
+ addItem: (item: Omit<DiagnosticItem, 'id' | 'status'>) => void;
900
+ removeItem: (id: string) => void;
901
+ clearItems: () => void;
902
+ updateItem: (id: string, updates: Partial<DiagnosticItem>) => void;
903
+ };
904
+
905
+ /**
906
+ * Simulation Panel Props
907
+ */
908
+ interface SimulationPanelProps {
909
+ /** Function to run simulation */
910
+ onSimulate?: (tx: SimulationTransactionRequest) => Promise<SimulationResult>;
911
+ /** Latest simulation result */
912
+ result?: SimulationResult | null;
913
+ /** Whether simulation is in progress */
914
+ isSimulating?: boolean;
915
+ /** Error message if simulation failed */
916
+ error?: string | null;
917
+ /** ETH price for USD estimates (optional) */
918
+ ethPrice?: number;
919
+ /** Whether to show detailed state changes */
920
+ showStateChanges?: boolean;
921
+ /** Whether to show decoded logs (requires ABI) */
922
+ showDecodedLogs?: boolean;
923
+ }
924
+ /**
925
+ * Simulation Panel Component
926
+ */
927
+ declare function SimulationPanel({ onSimulate, result, isSimulating, error, ethPrice, showDecodedLogs, }: SimulationPanelProps): react_jsx_runtime.JSX.Element;
928
+
929
+ /**
930
+ * State Comparison Component
931
+ *
932
+ * Side-by-side comparison of app state with diff highlighting.
933
+ * Shows data source tracing (indexed vs on-chain) and discrepancies.
934
+ */
935
+ /**
936
+ * Data source type
937
+ */
938
+ type DataSource = 'on-chain' | 'indexed' | 'cache' | 'local' | 'unknown';
939
+ /**
940
+ * State value with metadata
941
+ */
942
+ interface StateValue {
943
+ /** The actual value */
944
+ value: unknown;
945
+ /** Data source */
946
+ source: DataSource;
947
+ /** Timestamp when value was fetched */
948
+ fetchedAt?: number;
949
+ /** Key path in state tree */
950
+ path: string;
951
+ }
952
+ /**
953
+ * Comparison result for a single value
954
+ */
955
+ interface ComparisonItem {
956
+ /** Key/path of the value */
957
+ path: string;
958
+ /** Left side value (e.g., "before" or "indexed") */
959
+ left?: StateValue;
960
+ /** Right side value (e.g., "after" or "on-chain") */
961
+ right?: StateValue;
962
+ /** Whether values differ */
963
+ isDifferent: boolean;
964
+ /** Change type */
965
+ changeType: 'added' | 'removed' | 'modified' | 'unchanged';
966
+ }
967
+ /**
968
+ * State snapshot for comparison
969
+ */
970
+ interface StateSnapshot {
971
+ /** Snapshot ID */
972
+ id: string;
973
+ /** Snapshot label */
974
+ label: string;
975
+ /** Timestamp */
976
+ timestamp: number;
977
+ /** State values */
978
+ values: Record<string, StateValue>;
979
+ }
980
+ /**
981
+ * Props for StateComparison component
982
+ */
983
+ interface StateComparisonProps {
984
+ /** Left state snapshot (e.g., "before" or "indexed") */
985
+ leftSnapshot?: StateSnapshot | null;
986
+ /** Right state snapshot (e.g., "after" or "on-chain") */
987
+ rightSnapshot?: StateSnapshot | null;
988
+ /** Left label */
989
+ leftLabel?: string;
990
+ /** Right label */
991
+ rightLabel?: string;
992
+ /** Filter to show only differences */
993
+ showOnlyDifferences?: boolean;
994
+ /** Filter by data source */
995
+ filterSource?: DataSource | null;
996
+ /** Callback when export is requested */
997
+ onExport?: (data: ComparisonItem[]) => void;
998
+ }
999
+ /**
1000
+ * State Comparison Component
1001
+ */
1002
+ declare function StateComparison({ leftSnapshot, rightSnapshot, leftLabel, rightLabel, showOnlyDifferences, filterSource, onExport, }: StateComparisonProps): react_jsx_runtime.JSX.Element;
1003
+ /**
1004
+ * Hook for managing state snapshots
1005
+ */
1006
+ declare function useStateSnapshots(): {
1007
+ snapshots: StateSnapshot[];
1008
+ leftSnapshot: StateSnapshot | null;
1009
+ rightSnapshot: StateSnapshot | null;
1010
+ leftId: string | null;
1011
+ rightId: string | null;
1012
+ setLeftId: react.Dispatch<react.SetStateAction<string | null>>;
1013
+ setRightId: react.Dispatch<react.SetStateAction<string | null>>;
1014
+ captureSnapshot: (label: string, values: Record<string, StateValue>) => StateSnapshot;
1015
+ deleteSnapshot: (id: string) => void;
1016
+ clearSnapshots: () => void;
1017
+ };
1018
+
1019
+ /**
1020
+ * IPC Client for Toolbar <-> Anchor/Lens Communication
1021
+ *
1022
+ * Provides a transport-agnostic interface for communicating with
1023
+ * Anchor and Lens CLIs. In development mode, uses localStorage for
1024
+ * request/response exchange. In production, would use file-based IPC.
1025
+ */
1026
+
1027
+ /** IPC Transport interface */
1028
+ interface IPCTransport {
1029
+ /** Write a request */
1030
+ writeRequest(request: IPCRequest): Promise<void>;
1031
+ /** Read a response (returns null if not found) */
1032
+ readResponse(requestId: string, cliType: string): Promise<IPCResponse | null>;
1033
+ /** Cleanup request/response files */
1034
+ cleanup(requestId: string): Promise<void>;
1035
+ }
1036
+ /**
1037
+ * LocalStorage-based transport for development/browser
1038
+ * Stores requests in localStorage, responses come from external source
1039
+ */
1040
+ declare class LocalStorageTransport implements IPCTransport {
1041
+ private prefix;
1042
+ constructor(prefix?: string);
1043
+ writeRequest(request: IPCRequest): Promise<void>;
1044
+ readResponse(requestId: string, cliType: string): Promise<IPCResponse | null>;
1045
+ cleanup(requestId: string): Promise<void>;
1046
+ }
1047
+ /**
1048
+ * Mock transport for testing
1049
+ * Immediately resolves with mock responses
1050
+ */
1051
+ declare class MockTransport implements IPCTransport {
1052
+ private mockResponses;
1053
+ setMockResponse(requestId: string, cliType: string, response: IPCResponse): void;
1054
+ writeRequest(_request: IPCRequest): Promise<void>;
1055
+ readResponse(requestId: string, cliType: string): Promise<IPCResponse | null>;
1056
+ cleanup(_requestId: string): Promise<void>;
1057
+ }
1058
+ /**
1059
+ * IPC Client for communicating with Anchor/Lens CLIs
1060
+ */
1061
+ declare class IPCClient {
1062
+ private config;
1063
+ private transport;
1064
+ constructor(transport?: IPCTransport, config?: IPCClientConfig);
1065
+ /**
1066
+ * Send a request and wait for response
1067
+ */
1068
+ send<T, R>(type: IPCRequestType, payload: T, cliType?: string): Promise<R>;
1069
+ /**
1070
+ * Poll for response until timeout
1071
+ */
1072
+ private waitForResponse;
1073
+ /**
1074
+ * Validate lens context via Anchor CLI
1075
+ */
1076
+ validateLensContext(context: LensContext, zone?: Zone): Promise<LensValidateResponse>;
1077
+ /**
1078
+ * Run full Anchor validation with optional lens context
1079
+ */
1080
+ validateAnchor(statement?: string, lensContext?: LensContext, zone?: Zone): Promise<AnchorValidateResponse>;
1081
+ /**
1082
+ * Get the current transport
1083
+ */
1084
+ getTransport(): IPCTransport;
1085
+ /**
1086
+ * Set a new transport
1087
+ */
1088
+ setTransport(transport: IPCTransport): void;
1089
+ }
1090
+ /**
1091
+ * Get the default IPC client instance
1092
+ */
1093
+ declare function getIPCClient(): IPCClient;
1094
+ /**
1095
+ * Reset the default IPC client (useful for testing)
1096
+ */
1097
+ declare function resetIPCClient(): void;
1098
+
1099
+ export { type AnchorRequest, type AnchorResponse, type AnchorValidatePayload, type AnchorValidateResponse, type BalanceChange, type ComparisonItem, type ComparisonState, type DataSource, DevToolbar, type DevToolbarActions, type DevToolbarConfig, DevToolbarProvider, type DevToolbarProviderProps, type DevToolbarState, DevToolbarTrigger, DevToolbarWithTrigger, DiagnosticPanel, type DiagnosticPanelProps, type DiagnosticsState, type ForkConfig, type ForkProvider, type ForkService, type ForkSnapshot, type ForkState, IPCClient, type IPCClientConfig, type IPCRequest, type IPCRequestType, type IPCResponse, type IPCResponseStatus, type IPCTransport, LensActiveBadge, type LensAwareAccount, type LensContext, type LensIssueSeverity, type LensIssueType, type LensValidatePayload, type LensValidateResponse, type LensValidationIssue, type LensValidationResult, LocalStorageTransport, MockTransport, type PhysicsViolation, type SavedAddress, type SimulationLog, SimulationPanel, type SimulationPanelProps, type SimulationResult, type SimulationScenario, type SimulationService, type SimulationState, type SimulationTransactionRequest, type StateChange, StateComparison, type StateComparisonProps, type StateSnapshot, type StateValue, type TasteSignal, type ToolbarTab, type TransactionInput, type UseForkStateReturn, type UseIPCClientReturn, type UseTransactionSimulationConfig, type UseTransactionSimulationReturn, UserLens, type UserLensState, type Zone, createAnvilForkService, createForkService, createSimulationService, createTenderlyForkService, getForkService, getIPCClient, getSimulationService, resetForkService, resetIPCClient, resetSimulationService, useDevToolbar, useDevToolbarConfig, useDevToolbarSelector, useDiagnosticItems, useForkState, useIPCClient, useImpersonatedAddress, useIsImpersonating, useLensAwareAccount, useSavedAddresses, useSimulation, useStateSnapshots, useTransactionSimulation };