prool 0.0.25 → 0.1.1

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.
Files changed (114) hide show
  1. package/{LICENSE → LICENSE.md} +1 -1
  2. package/README.md +46 -163
  3. package/{_lib/instance.d.ts → dist/Instance.d.ts} +28 -25
  4. package/dist/Instance.d.ts.map +1 -0
  5. package/{_lib/instance.js → dist/Instance.js} +9 -4
  6. package/dist/Instance.js.map +1 -0
  7. package/{_lib/pool.d.ts → dist/Pool.d.ts} +15 -13
  8. package/dist/Pool.d.ts.map +1 -0
  9. package/{_lib/pool.js → dist/Pool.js} +3 -3
  10. package/dist/Pool.js.map +1 -0
  11. package/{_lib/server.d.ts → dist/Server.d.ts} +7 -10
  12. package/dist/Server.d.ts.map +1 -0
  13. package/{_lib/server.js → dist/Server.js} +8 -9
  14. package/dist/Server.js.map +1 -0
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/instances/alto.d.ts +452 -0
  20. package/dist/instances/alto.d.ts.map +1 -0
  21. package/{_lib → dist}/instances/alto.js +4 -4
  22. package/dist/instances/alto.js.map +1 -0
  23. package/dist/instances/anvil.d.ts +458 -0
  24. package/dist/instances/anvil.d.ts.map +1 -0
  25. package/{_lib → dist}/instances/anvil.js +4 -4
  26. package/dist/instances/anvil.js.map +1 -0
  27. package/dist/instances/tempo.d.ts +189 -0
  28. package/dist/instances/tempo.d.ts.map +1 -0
  29. package/dist/instances/tempo.js +200 -0
  30. package/dist/instances/tempo.js.map +1 -0
  31. package/{_lib → dist/internal}/utils.d.ts +5 -5
  32. package/dist/internal/utils.d.ts.map +1 -0
  33. package/{_lib → dist/internal}/utils.js +37 -7
  34. package/dist/internal/utils.js.map +1 -0
  35. package/{_lib → dist}/processes/execa.d.ts +11 -10
  36. package/dist/processes/execa.d.ts.map +1 -0
  37. package/{_lib → dist}/processes/execa.js +1 -1
  38. package/dist/processes/execa.js.map +1 -0
  39. package/package.json +17 -16
  40. package/{instance.test.ts → src/Instance.test.ts} +12 -12
  41. package/{instance.ts → src/Instance.ts} +51 -42
  42. package/{pool.test.ts → src/Pool.test.ts} +41 -55
  43. package/{pool.ts → src/Pool.ts} +21 -19
  44. package/{server.test.ts → src/Server.test.ts} +26 -149
  45. package/{server.ts → src/Server.ts} +9 -11
  46. package/src/index.ts +3 -0
  47. package/{instances → src/instances}/alto.test.ts +8 -11
  48. package/src/instances/alto.ts +289 -0
  49. package/{instances → src/instances}/anvil.test.ts +5 -6
  50. package/src/instances/anvil.ts +306 -0
  51. package/{instances/silius.test.ts → src/instances/tempo.test.ts} +20 -44
  52. package/src/instances/tempo.ts +322 -0
  53. package/{utils.test.ts → src/internal/utils.test.ts} +20 -6
  54. package/{utils.ts → src/internal/utils.ts} +47 -17
  55. package/{processes → src/processes}/execa.test.ts +6 -11
  56. package/{processes → src/processes}/execa.ts +19 -15
  57. package/src/processes/index.ts +1 -0
  58. package/CHANGELOG.md +0 -154
  59. package/_lib/exports/index.d.ts +0 -5
  60. package/_lib/exports/index.d.ts.map +0 -1
  61. package/_lib/exports/index.js +0 -5
  62. package/_lib/exports/index.js.map +0 -1
  63. package/_lib/exports/instances.d.ts +0 -7
  64. package/_lib/exports/instances.d.ts.map +0 -1
  65. package/_lib/exports/instances.js +0 -7
  66. package/_lib/exports/instances.js.map +0 -1
  67. package/_lib/exports/processes.d.ts +0 -2
  68. package/_lib/exports/processes.d.ts.map +0 -1
  69. package/_lib/exports/processes.js +0 -2
  70. package/_lib/exports/processes.js.map +0 -1
  71. package/_lib/instance.d.ts.map +0 -1
  72. package/_lib/instance.js.map +0 -1
  73. package/_lib/instances/alto.d.ts +0 -449
  74. package/_lib/instances/alto.d.ts.map +0 -1
  75. package/_lib/instances/alto.js.map +0 -1
  76. package/_lib/instances/anvil.d.ts +0 -455
  77. package/_lib/instances/anvil.d.ts.map +0 -1
  78. package/_lib/instances/anvil.js.map +0 -1
  79. package/_lib/instances/rundler.d.ts +0 -604
  80. package/_lib/instances/rundler.d.ts.map +0 -1
  81. package/_lib/instances/rundler.js +0 -86
  82. package/_lib/instances/rundler.js.map +0 -1
  83. package/_lib/instances/silius.d.ts +0 -224
  84. package/_lib/instances/silius.d.ts.map +0 -1
  85. package/_lib/instances/silius.js +0 -117
  86. package/_lib/instances/silius.js.map +0 -1
  87. package/_lib/instances/stackup.d.ts +0 -86
  88. package/_lib/instances/stackup.d.ts.map +0 -1
  89. package/_lib/instances/stackup.js +0 -89
  90. package/_lib/instances/stackup.js.map +0 -1
  91. package/_lib/pool.d.ts.map +0 -1
  92. package/_lib/pool.js.map +0 -1
  93. package/_lib/processes/execa.d.ts.map +0 -1
  94. package/_lib/processes/execa.js.map +0 -1
  95. package/_lib/server.d.ts.map +0 -1
  96. package/_lib/server.js.map +0 -1
  97. package/_lib/utils.d.ts.map +0 -1
  98. package/_lib/utils.js.map +0 -1
  99. package/exports/index.test.ts +0 -16
  100. package/exports/index.ts +0 -29
  101. package/exports/instances.test.ts +0 -15
  102. package/exports/instances.ts +0 -13
  103. package/exports/processes.test.ts +0 -10
  104. package/exports/processes.ts +0 -8
  105. package/instances/alto.ts +0 -280
  106. package/instances/anvil.ts +0 -304
  107. package/instances/package.json +0 -5
  108. package/instances/rundler.test.ts +0 -111
  109. package/instances/rundler.ts +0 -451
  110. package/instances/silius.ts +0 -347
  111. package/instances/stackup.test.ts +0 -106
  112. package/instances/stackup.ts +0 -162
  113. package/processes/package.json +0 -5
  114. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,13 +0,0 @@
1
- export { alto, type AltoParameters } from '../instances/alto.js'
2
- export { anvil, type AnvilParameters } from '../instances/anvil.js'
3
- export { rundler, type RundlerParameters } from '../instances/rundler.js'
4
- export { silius, type SiliusParameters } from '../instances/silius.js'
5
- export { stackup, type StackupParameters } from '../instances/stackup.js'
6
- export {
7
- defineInstance,
8
- type DefineInstanceFn,
9
- type DefineInstanceReturnType,
10
- type Instance,
11
- type InstanceOptions,
12
- type InstanceStartOptions,
13
- } from '../instance.js'
@@ -1,10 +0,0 @@
1
- import { expect, test } from 'vitest'
2
- import * as exports from './processes.js'
3
-
4
- test('exports', () => {
5
- expect(Object.keys(exports)).toMatchInlineSnapshot(`
6
- [
7
- "execa",
8
- ]
9
- `)
10
- })
@@ -1,8 +0,0 @@
1
- export {
2
- type ExecaParameters,
3
- type ExecaProcess,
4
- type ExecaReturnType,
5
- type ExecaStartOptions,
6
- type Process_internal,
7
- execa,
8
- } from '../processes/execa.js'
package/instances/alto.ts DELETED
@@ -1,280 +0,0 @@
1
- import { resolve } from 'node:path'
2
- import { defineInstance } from '../instance.js'
3
- import { execa } from '../processes/execa.js'
4
- import { toArgs } from '../utils.js'
5
-
6
- export type AltoParameters = {
7
- /**
8
- * API version (used for internal Pimlico versioning compatibility).
9
- */
10
- apiVersion?: readonly string[] | undefined
11
- /**
12
- * Override the sender native token balance during estimation
13
- */
14
- balanceOverride?: boolean | undefined
15
- /**
16
- * Binary path of the `alto` executable.
17
- */
18
- binary?: string | undefined
19
- /**
20
- * Address of the `BundleBulker` contract.
21
- */
22
- bundleBulkerAddress?: `0x${string}` | undefined
23
- /**
24
- * Set if the bundler bundle user operations automatically or only when calling `debug_bundler_sendBundleNow`.
25
- * @default "auto"
26
- */
27
- bundleMode?: 'auto' | 'manual' | undefined
28
- /**
29
- * Indicates weather the chain is a OP stack chain, arbitrum chain, or default EVM chain.
30
- */
31
- chainType?: 'default' | 'op-stack' | 'arbitrum' | undefined
32
- /**
33
- * Path to JSON config file.
34
- */
35
- config?: string | undefined
36
- /**
37
- * Skip user operation validation, use with caution.
38
- */
39
- dangerousSkipUserOperationValidation?: boolean | undefined
40
- /**
41
- * Default API version.
42
- */
43
- defaultApiVersion?: string | undefined
44
- /**
45
- * Enable debug endpoints.
46
- * @default false
47
- */
48
- enableDebugEndpoints?: boolean | undefined
49
- /**
50
- * Include user ops with the same sender in the single bundle.
51
- * @default true
52
- */
53
- enforceUniqueSendersPerBundle?: boolean | undefined
54
- /**
55
- * EntryPoint contract addresses.
56
- */
57
- entrypoints: readonly `0x${string}`[]
58
- /**
59
- * Address of the EntryPoint simulations contract.
60
- */
61
- entrypointSimulationContract?: `0x${string}` | undefined
62
- /**
63
- * Private keys of the executor accounts.
64
- */
65
- executorPrivateKeys?: readonly `0x${string}`[]
66
- /**
67
- * Interval to refill the signer balance (seconds).
68
- * @default 1200
69
- */
70
- executorRefillInterval?: number | undefined
71
- /**
72
- * Should the node make expiration checks.
73
- * @default true
74
- */
75
- expirationCheck?: boolean | undefined
76
- /**
77
- * Amount to multiply the gas prices fetched from the node.
78
- * @default "100"
79
- */
80
- gasPriceBump?: string | undefined
81
- /**
82
- * Maximum that the gas prices fetched using pimlico_getUserOperationGasPrice will be accepted for (seconds).
83
- * @default 10
84
- */
85
- gasPriceExpiry?: number | undefined
86
- /**
87
- * The minimum percentage of incoming user operation gas prices compared to the gas price used by the bundler to submit bundles.
88
- * @default 101
89
- */
90
- gasPriceFloorPercent?: number | undefined
91
- /**
92
- * Amount to multiply the gas prices fetched using `pimlico_getUserOperationGasPrice`.
93
- * @default "105,110,115"
94
- */
95
- gasPriceMultipliers?: readonly string[] | undefined
96
- /**
97
- * Use a fixed value for gas limits during bundle transaction gas limit estimations
98
- */
99
- fixedGasLimitForEstimation?: string | undefined
100
- /**
101
- * Flush stuck transactions with old nonces during bundler startup.
102
- */
103
- flushStuckTransactionsDuringStartup?: boolean | undefined
104
- /**
105
- * Log in JSON format.
106
- */
107
- json?: boolean | undefined
108
- /**
109
- * Send legacy transactions instead of an EIP-1559 transactions.
110
- * @default false
111
- */
112
- legacyTransactions?: boolean | undefined
113
- /**
114
- * Calculate the bundle transaction gas limits locally instead of using the RPC gas limit estimation.
115
- */
116
- localGasLimitCalculation?: boolean | undefined
117
- /**
118
- * Default log level.
119
- */
120
- logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | undefined
121
- /**
122
- * Max block range for `eth_getLogs` calls.
123
- */
124
- maxBlockRange?: number | undefined
125
- /**
126
- * Maximum number of operations allowed in the mempool before a bundle is submitted.
127
- * @default 10
128
- */
129
- maxBundleSize?: number | undefined
130
- /**
131
- * Maximum time to wait for a bundle to be submitted (ms).
132
- * @default 1000
133
- */
134
- maxBundleWait?: number | undefined
135
- /**
136
- * Maximum amount of gas per bundle.
137
- * @default "5000000"
138
- */
139
- maxGasPerBundle?: string | undefined
140
- /**
141
- * Maximum number of executor accounts to use from the list of executor private keys.
142
- */
143
- maxExecutors?: number | undefined
144
- /**
145
- * Maximum amount of parallel user ops to keep in the meempool (same sender, different nonce keys).
146
- * @default 10
147
- */
148
- mempoolMaxParallelOps?: number | undefined
149
- /**
150
- * Maximum amount of sequential user ops to keep in the mempool (same sender and nonce key, different nonce values).
151
- * @default 0
152
- */
153
- mempoolMaxQueuedOps?: number | undefined
154
- /**
155
- * Minimum stake required for a relay (in 10e18).
156
- * @default 1
157
- */
158
- minEntityStake?: number | undefined
159
- /**
160
- * Minimum unstake delay (seconds).
161
- * @default 1
162
- */
163
- minEntityUnstakeDelay?: number | undefined
164
- /**
165
- * Minimum balance required for each executor account (below which the utility account will refill).
166
- */
167
- minExecutorBalance?: string | undefined
168
- /**
169
- * Name of the network (used for metrics).
170
- * @default "localhost"
171
- */
172
- networkName?: string | undefined
173
- /**
174
- * Amount to multiply the paymaster gas limits fetched from simulations.
175
- */
176
- paymasterGasLimitMultiplier?: string | undefined
177
- /**
178
- * Address of the `PerOpInflator` contract.
179
- */
180
- perOpInflatorAddress?: `0x${string}` | undefined
181
- /**
182
- * Polling interval for querying for new blocks (ms).
183
- * @default 1000
184
- */
185
- pollingInterval?: number | undefined
186
- /**
187
- * Port to listen on.
188
- * @default 3000
189
- */
190
- port?: number | undefined
191
- /**
192
- * RPC url to connect to.
193
- */
194
- rpcUrl: string
195
- /**
196
- * Enable safe mode (enforcing all ERC-4337 rules).
197
- * @default true
198
- */
199
- safeMode?: boolean | undefined
200
- /**
201
- * RPC url to send transactions to (e.g. flashbots relay).
202
- */
203
- sendTransactionRpcUrl?: string | undefined
204
- /**
205
- * Timeout for incoming requests (in ms).
206
- */
207
- timeout?: number | undefined
208
- /**
209
- * Private key of the utility account.
210
- */
211
- utilityPrivateKey?: string | undefined
212
- /**
213
- * Maximum payload size for websocket messages in bytes (default to 1MB).
214
- */
215
- websocketMaxPayloadSize?: number | undefined
216
- /**
217
- * Enable websocket server.
218
- */
219
- websocket?: boolean | undefined
220
- }
221
-
222
- /**
223
- * Defines an Alto instance.
224
- *
225
- * @example
226
- * ```ts
227
- * const instance = alto({
228
- * entrypoints: ['0x0000000071727De22E5E9d8BAf0edAc6f37da032'],
229
- * rpcUrl: `http://localhost:8545`,
230
- * executorPrivateKeys: ['0x...'],
231
- * })
232
- * await instance.start()
233
- * // ...
234
- * await instance.stop()
235
- * ```
236
- */
237
- export const alto = defineInstance((parameters?: AltoParameters) => {
238
- const { ...args } = (parameters || {}) as AltoParameters
239
-
240
- const name = 'alto'
241
- const process = execa({ name })
242
-
243
- return {
244
- _internal: {
245
- args,
246
- get process() {
247
- return process._internal.process
248
- },
249
- },
250
- host: 'localhost',
251
- name,
252
- port: args.port ?? 3000,
253
- async start({ port = args.port ?? 3000 }, options) {
254
- const binary = (() => {
255
- if (args.binary) return [args.binary]
256
- const libPath = (
257
- 'resolve' in import.meta
258
- ? import.meta.resolve('@pimlico/alto').split('file:')[1]
259
- : require.resolve('@pimlico/alto')
260
- )!
261
- return ['node', resolve(libPath, '../cli/alto.js')]
262
- })()
263
-
264
- await process.start(($) => $`${binary} ${toArgs({ port, ...args })}`, {
265
- ...options,
266
- // Resolve when the process is listening via a "Server listening at" message.
267
- resolver({ process, reject, resolve }) {
268
- process.stdout.on('data', (data) => {
269
- const message = data.toString()
270
- if (message.includes('Server listening at')) resolve()
271
- })
272
- process.stderr.on('data', reject)
273
- },
274
- })
275
- },
276
- async stop() {
277
- await process.stop()
278
- },
279
- }
280
- })
@@ -1,304 +0,0 @@
1
- import { defineInstance } from '../instance.js'
2
- import { execa } from '../processes/execa.js'
3
- import { toArgs } from '../utils.js'
4
-
5
- export type AnvilParameters = {
6
- /**
7
- * Number of dev accounts to generate and configure.
8
- *
9
- * @defaultValue 10
10
- */
11
- accounts?: number | undefined
12
- /**
13
- * Set the Access-Control-Allow-Origin response header (CORS).
14
- *
15
- * @defaultValue *
16
- */
17
- allowOrigin?: string | undefined
18
- /**
19
- * Enable autoImpersonate on startup
20
- */
21
- autoImpersonate?: boolean | undefined
22
- /**
23
- * The balance of every dev account in Ether.
24
- *
25
- * @defaultValue 10000
26
- */
27
- balance?: number | bigint | undefined
28
- /**
29
- * The base fee in a block.
30
- */
31
- blockBaseFeePerGas?: number | bigint | undefined
32
- /**
33
- * Block time in seconds for interval mining.
34
- */
35
- blockTime?: number | undefined
36
- /**
37
- * Path or alias to the Anvil binary.
38
- */
39
- binary?: string | undefined
40
- /**
41
- * The chain id.
42
- */
43
- chainId?: number | undefined
44
- /**
45
- * EIP-170: Contract code size limit in bytes. Useful to increase this because of tests.
46
- *
47
- * @defaultValue 0x6000 (~25kb)
48
- */
49
- codeSizeLimit?: number | undefined
50
- /**
51
- * Sets the number of assumed available compute units per second for this fork provider.
52
- *
53
- * @defaultValue 350
54
- * @see https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups
55
- */
56
- computeUnitsPerSecond?: number | undefined
57
- /**
58
- * Writes output of `anvil` as json to user-specified file.
59
- */
60
- configOut?: string | undefined
61
- /**
62
- * Sets the derivation path of the child key to be derived.
63
- *
64
- * @defaultValue m/44'/60'/0'/0/
65
- */
66
- derivationPath?: string | undefined
67
- /**
68
- * Disable the `call.gas_limit <= block.gas_limit` constraint.
69
- */
70
- disableBlockGasLimit?: boolean | undefined
71
- /**
72
- * Dump the state of chain on exit to the given file. If the value is a directory, the state will be
73
- * written to `<VALUE>/state.json`.
74
- */
75
- dumpState?: string | undefined
76
- /**
77
- * Fetch state over a remote endpoint instead of starting from an empty state.
78
- *
79
- * If you want to fetch state from a specific block number, add a block number like `http://localhost:8545@1400000`
80
- * or use the `forkBlockNumber` option.
81
- */
82
- forkUrl?: string | undefined
83
- /**
84
- * Fetch state from a specific block number over a remote endpoint.
85
- *
86
- * Requires `forkUrl` to be set.
87
- */
88
- forkBlockNumber?: number | bigint | undefined
89
- /**
90
- * Specify chain id to skip fetching it from remote endpoint. This enables offline-start mode.
91
- *
92
- * You still must pass both `forkUrl` and `forkBlockNumber`, and already have your required state cached
93
- * on disk, anything missing locally would be fetched from the remote.
94
- */
95
- forkChainId?: number | undefined
96
- /**
97
- * Specify headers to send along with any request to the remote JSON-RPC server in forking mode.
98
- *
99
- * e.g. "User-Agent: test-agent"
100
- *
101
- * Requires `forkUrl` to be set.
102
- */
103
- forkHeader?: Record<string, string> | undefined
104
- /**
105
- * Initial retry backoff on encountering errors.
106
- */
107
- forkRetryBackoff?: number | undefined
108
- /**
109
- * The block gas limit.
110
- */
111
- gasLimit?: number | bigint | undefined
112
- /**
113
- * The gas price.
114
- */
115
- gasPrice?: number | bigint | undefined
116
- /**
117
- * The EVM hardfork to use.
118
- */
119
- hardfork?:
120
- | 'Frontier'
121
- | 'Homestead'
122
- | 'Dao'
123
- | 'Tangerine'
124
- | 'SpuriousDragon'
125
- | 'Byzantium'
126
- | 'Constantinople'
127
- | 'Petersburg'
128
- | 'Istanbul'
129
- | 'Muirglacier'
130
- | 'Berlin'
131
- | 'London'
132
- | 'ArrowGlacier'
133
- | 'GrayGlacier'
134
- | 'Paris'
135
- | 'Shanghai'
136
- | 'Cancun'
137
- | 'Prague'
138
- | 'Latest'
139
- | undefined
140
- /**
141
- * The host the server will listen on.
142
- */
143
- host?: string | undefined
144
- /**
145
- * Initialize the genesis block with the given `genesis.json` file.
146
- */
147
- init?: string | undefined
148
- /**
149
- * Launch an ipc server at the given path or default path = `/tmp/anvil.ipc`.
150
- */
151
- ipc?: string | undefined
152
- /**
153
- * Initialize the chain from a previously saved state snapshot.
154
- */
155
- loadState?: string | undefined
156
- /**
157
- * BIP39 mnemonic phrase used for generating accounts.
158
- */
159
- mnemonic?: string | undefined
160
- /**
161
- * Automatically generates a BIP39 mnemonic phrase, and derives accounts from it.
162
- */
163
- mnemonicRandom?: boolean | undefined
164
- /**
165
- * Disable CORS.
166
- */
167
- noCors?: boolean | undefined
168
- /**
169
- * Disable auto and interval mining, and mine on demand instead.
170
- */
171
- noMining?: boolean | undefined
172
- /**
173
- * Disables rate limiting for this node's provider.
174
- *
175
- * @defaultValue false
176
- * @see https://github.com/alchemyplatform/alchemy-docs/blob/master/documentation/compute-units.md#rate-limits-cups
177
- */
178
- noRateLimit?: boolean | undefined
179
- /**
180
- * Explicitly disables the use of RPC caching.
181
- *
182
- * All storage slots are read entirely from the endpoint.
183
- */
184
- noStorageCaching?: boolean | undefined
185
- /**
186
- * How transactions are sorted in the mempool.
187
- *
188
- * @defaultValue fees
189
- */
190
- order?: string | undefined
191
- /**
192
- * Run an Optimism chain.
193
- */
194
- optimism?: boolean | undefined
195
- /**
196
- * Port number to listen on.
197
- *
198
- * @defaultValue 8545
199
- */
200
- port?: number | undefined
201
- /**
202
- * Don't keep full chain history. If a number argument is specified, at most this number of states is kept in memory.
203
- */
204
- pruneHistory?: number | undefined | boolean
205
- /**
206
- * Number of retry requests for spurious networks (timed out requests).
207
- *
208
- * @defaultValue 5
209
- */
210
- retries?: number | undefined
211
- /**
212
- * Don't print anything on startup and don't print logs.
213
- */
214
- silent?: boolean | undefined
215
- /**
216
- * Slots in an epoch.
217
- */
218
- slotsInAnEpoch?: number | undefined
219
- /**
220
- * Enable steps tracing used for debug calls returning geth-style traces.
221
- */
222
- stepsTracing?: boolean | undefined
223
- /**
224
- * Interval in seconds at which the status is to be dumped to disk.
225
- */
226
- stateInterval?: number | undefined
227
- /**
228
- * This is an alias for both `loadState` and `dumpState`. It initializes the chain with the state stored at the
229
- * file, if it exists, and dumps the chain's state on exit
230
- */
231
- state?: string | undefined
232
- /**
233
- * Timeout in ms for requests sent to remote JSON-RPC server in forking mode.
234
- *
235
- * @defaultValue 45000
236
- */
237
- timeout?: number | undefined
238
- /**
239
- * The timestamp of the genesis block.
240
- */
241
- timestamp?: number | bigint | undefined
242
- /**
243
- * Number of blocks with transactions to keep in memory.
244
- */
245
- transactionBlockKeeper?: number | undefined
246
- }
247
-
248
- /**
249
- * Defines an Anvil instance.
250
- *
251
- * @example
252
- * ```ts
253
- * const instance = anvil({ forkRpcUrl: 'https://cloudflare-eth.com', port: 8546 })
254
- * await instance.start()
255
- * // ...
256
- * await instance.stop()
257
- * ```
258
- */
259
- export const anvil = defineInstance((parameters?: AnvilParameters) => {
260
- const { binary = 'anvil', ...args } = parameters || {}
261
-
262
- const name = 'anvil'
263
- const process = execa({ name })
264
-
265
- return {
266
- _internal: {
267
- args,
268
- get process() {
269
- return process._internal.process
270
- },
271
- },
272
- host: args.host ?? 'localhost',
273
- name,
274
- port: args.port ?? 8545,
275
- async start({ port = args.port }, options) {
276
- return await process.start(
277
- ($) =>
278
- $({
279
- env: {
280
- FOUNDRY_DISABLE_NIGHTLY_WARNING: 'true',
281
- },
282
- })`${binary} ${toArgs({ ...args, port })}`,
283
- {
284
- ...options,
285
- // Resolve when the process is listening via a "Listening on" message.
286
- resolver({ process, reject, resolve }) {
287
- process.stdout.on('data', (data) => {
288
- const message = data.toString()
289
- if (message.includes('Listening on')) resolve()
290
- })
291
- process.stderr.on('data', (data) => {
292
- const message = data.toString()
293
- if (message.includes('Warning')) return
294
- reject(message)
295
- })
296
- },
297
- },
298
- )
299
- },
300
- async stop() {
301
- await process.stop()
302
- },
303
- }
304
- })
@@ -1,5 +0,0 @@
1
- {
2
- "type": "module",
3
- "types": "../_lib/exports/instances/index.d.ts",
4
- "module": "../_lib/exports/instances/index.js"
5
- }