|
1 | 1 | import { z } from 'zod'; |
2 | 2 |
|
| 3 | +import { type ContractClassPublic, ContractClassPublicSchema } from '../contract/interfaces/contract_class.js'; |
| 4 | +import { |
| 5 | + type ContractInstanceWithAddress, |
| 6 | + ContractInstanceWithAddressSchema, |
| 7 | +} from '../contract/interfaces/contract_instance.js'; |
3 | 8 | import { type PublicStorageOverride, PublicStorageOverrideSchema } from './public_storage_override.js'; |
4 | 9 |
|
5 | 10 | /** |
6 | 11 | * Pre-simulation state overrides. Each field is optional and additive: the simulator applies all |
7 | | - * provided overrides to the ephemeral world-state fork before running the tx. |
| 12 | + * provided overrides to the ephemeral world-state fork (and contract DB) before running the tx. |
| 13 | + * |
| 14 | + * - `publicStorage`: write specific (contract, slot) pairs in the public-data tree |
| 15 | + * - `contractClasses`: shadow contract classes in the contract DB |
| 16 | + * - `contractInstances`: shadow contract instances in the contract DB |
8 | 17 | * |
9 | 18 | * Modeled after Foundry / Geth `eth_call` state overrides: a single argument that bundles all the |
10 | | - * override types in one place rather than threading separate parameters through the RPC. Future |
11 | | - * override flavors (e.g. contract class/instance shadows, nullifier overrides) can be added as |
12 | | - * additional optional fields without changing the RPC shape. |
| 19 | + * override types in one place rather than threading separate parameters through the RPC. |
13 | 20 | */ |
14 | 21 | export type StateOverrides = { |
15 | 22 | /** Public-storage writes to apply before simulation. */ |
16 | 23 | publicStorage?: PublicStorageOverride[]; |
| 24 | + /** Contract classes to shadow in the contract DB for the duration of the simulation. */ |
| 25 | + contractClasses?: ContractClassPublic[]; |
| 26 | + /** Contract instances to shadow in the contract DB for the duration of the simulation. */ |
| 27 | + contractInstances?: ContractInstanceWithAddress[]; |
17 | 28 | }; |
18 | 29 |
|
19 | 30 | export const StateOverridesSchema = z.object({ |
20 | 31 | publicStorage: z.array(PublicStorageOverrideSchema).optional(), |
| 32 | + contractClasses: z.array(ContractClassPublicSchema).optional(), |
| 33 | + contractInstances: z.array(ContractInstanceWithAddressSchema).optional(), |
21 | 34 | }); |
0 commit comments