prool 0.0.12 → 0.0.14
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/CHANGELOG.md +12 -0
- package/README.md +341 -0
- package/_lib/exports/instances.d.ts +4 -3
- package/_lib/exports/instances.d.ts.map +1 -1
- package/_lib/exports/instances.js +1 -0
- package/_lib/exports/instances.js.map +1 -1
- package/_lib/instances/rundler.d.ts +604 -0
- package/_lib/instances/rundler.d.ts.map +1 -0
- package/_lib/instances/rundler.js +86 -0
- package/_lib/instances/rundler.js.map +1 -0
- package/_lib/utils.d.ts +7 -11
- package/_lib/utils.d.ts.map +1 -1
- package/_lib/utils.js +21 -15
- package/_lib/utils.js.map +1 -1
- package/exports/instances.test.ts +1 -0
- package/exports/instances.ts +4 -3
- package/instances/anvil.test.ts +1 -1
- package/instances/package.json +5 -0
- package/instances/rundler.test.ts +115 -0
- package/instances/rundler.ts +451 -0
- package/package.json +4 -2
- package/pool.test.ts +5 -1
- package/processes/package.json +5 -0
- package/server.test.ts +40 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils.test.ts +29 -14
- package/utils.ts +37 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# prool
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`0187ef8`](https://github.com/wevm/prool/commit/0187ef8a00ea4b25367b8427ed00d217388f3d65) Thanks [@jxom](https://github.com/jxom)! - Added Rundler instance.
|
|
8
|
+
|
|
9
|
+
## 0.0.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`a879039`](https://github.com/wevm/prool/commit/a879039aeec7e0018f51b8b7fcc11c314eba94db) Thanks [@jxom](https://github.com/jxom)! - Added proxy packages for entrypoints.
|
|
14
|
+
|
|
3
15
|
## 0.0.12
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
<br/>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/wevm/prool/blob/main/.github/prool-dark.svg">
|
|
6
|
+
<img alt="mipd logo" src="https://github.com/wevm/prool/blob/main/.github/prool-light.svg" width="auto" height="100">
|
|
7
|
+
</picture>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
HTTP testing instances for Ethereum</a>
|
|
12
|
+
<p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/prool">
|
|
16
|
+
<picture>
|
|
17
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/prool?colorA=21262d&colorB=21262d&style=flat">
|
|
18
|
+
<img src="https://img.shields.io/npm/v/prool?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Version">
|
|
19
|
+
</picture>
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://github.com/wevm/prool/blob/main/LICENSE">
|
|
22
|
+
<picture>
|
|
23
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/l/prool?colorA=21262d&colorB=21262d&style=flat">
|
|
24
|
+
<img src="https://img.shields.io/npm/l/prool?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="MIT License">
|
|
25
|
+
</picture>
|
|
26
|
+
</a>
|
|
27
|
+
<a href="https://www.npmjs.com/package/prool">
|
|
28
|
+
<picture>
|
|
29
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/prool?colorA=21262d&colorB=21262d&style=flat">
|
|
30
|
+
<img src="https://img.shields.io/npm/dm/prool?colorA=f6f8fa&colorB=f6f8fa&style=flat" alt="Downloads per month">
|
|
31
|
+
</picture>
|
|
32
|
+
</a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
## Introduction
|
|
36
|
+
|
|
37
|
+
Prool is a library that provides programmatic HTTP testing instances for Ethereum. It is designed to be used in testing environments (e.g. [Vitest](https://vitest.dev/)) where you need to interact with an Ethereum server instance (e.g. Execution Node, 4337 Bundler, Indexer, etc) over HTTP or WebSocket.
|
|
38
|
+
|
|
39
|
+
Prool contains a set of pre-configured instances that can be used to simulate Ethereum server environments, being:
|
|
40
|
+
|
|
41
|
+
- **Local Execution Nodes:** [`anvil`](#anvil-execution-node)
|
|
42
|
+
- **Bundler Nodes:** [`alto`](#alto-bundler-node), [`rundler`](#rundler), `silius`⚠️, [`stackup`](#stackup-bundler-node)
|
|
43
|
+
- **Indexer Nodes:** `ponder`⚠️
|
|
44
|
+
|
|
45
|
+
⚠️ = soon
|
|
46
|
+
|
|
47
|
+
You can also create your own custom instances by using the [`defineInstance` function](#defineinstance).
|
|
48
|
+
|
|
49
|
+
## Table of Contents
|
|
50
|
+
|
|
51
|
+
- [Install](#install)
|
|
52
|
+
- [Getting Started](#getting-started)
|
|
53
|
+
- [Anvil (Execution Node)](#anvil-execution-node)
|
|
54
|
+
- [Alto (Bundler Node)](#alto-bundler-node)
|
|
55
|
+
- [Rundler (Bundler Node)](#rundler-bundler-node)
|
|
56
|
+
- [Stackup (Bundler Node)](#stackup-bundler-node)
|
|
57
|
+
- [Reference](#reference)
|
|
58
|
+
- [`createServer`](#createserver)
|
|
59
|
+
- [`defineInstance`](#defineinstance)
|
|
60
|
+
- [`definePool`](#definepool)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm i prool
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm add prool
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
bun i prool
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Getting Started
|
|
78
|
+
|
|
79
|
+
### Anvil (Execution Node)
|
|
80
|
+
|
|
81
|
+
#### Requirements
|
|
82
|
+
|
|
83
|
+
- [Foundry](https://getfoundry.sh/) binary installed
|
|
84
|
+
- Download: `curl -L https://foundry.paradigm.xyz | bash`
|
|
85
|
+
|
|
86
|
+
#### Usage
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createServer } from 'prool'
|
|
90
|
+
import { anvil } from 'prool/instances'
|
|
91
|
+
|
|
92
|
+
const server = createServer({
|
|
93
|
+
instance: anvil(),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
await server.start()
|
|
97
|
+
// Instances accessible at:
|
|
98
|
+
// "http://localhost:8545/1"
|
|
99
|
+
// "http://localhost:8545/2"
|
|
100
|
+
// "http://localhost:8545/3"
|
|
101
|
+
// "http://localhost:8545/n"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Parameters
|
|
105
|
+
|
|
106
|
+
See [`AnvilParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c95294aae795e548897c/src/instances/anvil.ts#L5).
|
|
107
|
+
|
|
108
|
+
### Alto (Bundler Node)
|
|
109
|
+
|
|
110
|
+
#### Requirements
|
|
111
|
+
|
|
112
|
+
- [`@pimlico/alto`](npm.im/@pimlico/alto): `npm i @pimlico/alto`
|
|
113
|
+
|
|
114
|
+
#### Usage
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { createServer } from 'prool'
|
|
118
|
+
import { anvil, alto } from 'prool/instances'
|
|
119
|
+
|
|
120
|
+
const executionServer = createServer({
|
|
121
|
+
instance: anvil(),
|
|
122
|
+
port: 8545
|
|
123
|
+
})
|
|
124
|
+
await executionServer.start()
|
|
125
|
+
// Instances accessible at:
|
|
126
|
+
// "http://localhost:8545/1"
|
|
127
|
+
// "http://localhost:8545/2"
|
|
128
|
+
// "http://localhost:8545/3"
|
|
129
|
+
// "http://localhost:8545/n"
|
|
130
|
+
|
|
131
|
+
const bundlerServer = createServer({
|
|
132
|
+
instance: (key) => alto({
|
|
133
|
+
entrypoints: ['0x0000000071727De22E5E9d8BAf0edAc6f37da032'],
|
|
134
|
+
rpcUrl: `http://localhost:8545/${key}`,
|
|
135
|
+
executorPrivateKeys: ['0x...'],
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
await bundlerServer.start()
|
|
139
|
+
// Instances accessible at:
|
|
140
|
+
// "http://localhost:3000/1" (→ http://localhost:8545/1)
|
|
141
|
+
// "http://localhost:3000/2" (→ http://localhost:8545/2)
|
|
142
|
+
// "http://localhost:3000/3" (→ http://localhost:8545/3)
|
|
143
|
+
// "http://localhost:3000/n" (→ http://localhost:8545/n)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Parameters
|
|
147
|
+
|
|
148
|
+
See [`AltoParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c95294aae795e548897c/src/instances/alto.ts#L7).
|
|
149
|
+
|
|
150
|
+
### Rundler (Bundler Node)
|
|
151
|
+
|
|
152
|
+
#### Requirements
|
|
153
|
+
|
|
154
|
+
- [Rundler](https://github.com/alchemyplatform/rundler) binary installed
|
|
155
|
+
- [Download](https://github.com/alchemyplatform/rundler/releases)
|
|
156
|
+
|
|
157
|
+
#### Usage
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { createServer } from 'prool'
|
|
161
|
+
import { anvil, rundler } from 'prool/instances'
|
|
162
|
+
|
|
163
|
+
const executionServer = createServer({
|
|
164
|
+
instance: anvil(),
|
|
165
|
+
port: 8545
|
|
166
|
+
})
|
|
167
|
+
await executionServer.start()
|
|
168
|
+
// Instances accessible at:
|
|
169
|
+
// "http://localhost:8545/1"
|
|
170
|
+
// "http://localhost:8545/2"
|
|
171
|
+
// "http://localhost:8545/3"
|
|
172
|
+
// "http://localhost:8545/n"
|
|
173
|
+
|
|
174
|
+
const bundlerServer = createServer({
|
|
175
|
+
instance: (key) => rundler({
|
|
176
|
+
nodeHttp: `http://localhost:8545/${key}`,
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
await bundlerServer.start()
|
|
180
|
+
// Instances accessible at:
|
|
181
|
+
// "http://localhost:3000/1" (→ http://localhost:8545/1)
|
|
182
|
+
// "http://localhost:3000/2" (→ http://localhost:8545/2)
|
|
183
|
+
// "http://localhost:3000/3" (→ http://localhost:8545/3)
|
|
184
|
+
// "http://localhost:3000/n" (→ http://localhost:8545/n)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Parameters
|
|
188
|
+
|
|
189
|
+
See [RundlerParameters]().
|
|
190
|
+
|
|
191
|
+
### Stackup (Bundler Node)
|
|
192
|
+
|
|
193
|
+
#### Requirements
|
|
194
|
+
|
|
195
|
+
- [Docker](https://docs.docker.com/get-docker/)
|
|
196
|
+
- Stackup Docker Image: `docker pull stackupwallet/stackup-bundler:latest`
|
|
197
|
+
|
|
198
|
+
#### Usage
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { createServer } from 'prool'
|
|
202
|
+
import { anvil, stackup } from 'prool/instances'
|
|
203
|
+
|
|
204
|
+
const executionServer = createServer({
|
|
205
|
+
instance: anvil(),
|
|
206
|
+
port: 8545
|
|
207
|
+
})
|
|
208
|
+
await executionServer.start()
|
|
209
|
+
// Instances accessible at:
|
|
210
|
+
// "http://localhost:8545/1"
|
|
211
|
+
// "http://localhost:8545/2"
|
|
212
|
+
// "http://localhost:8545/3"
|
|
213
|
+
// "http://localhost:8545/n"
|
|
214
|
+
|
|
215
|
+
const bundlerServer = createServer({
|
|
216
|
+
instance: (key) => stackup({
|
|
217
|
+
ethClientUrl: `http://localhost:8545/${key}`,
|
|
218
|
+
privateKey: '0x...',
|
|
219
|
+
})
|
|
220
|
+
})
|
|
221
|
+
await bundlerServer.start()
|
|
222
|
+
// Instances accessible at:
|
|
223
|
+
// "http://localhost:4337/1" (→ http://localhost:8545/1)
|
|
224
|
+
// "http://localhost:4337/2" (→ http://localhost:8545/2)
|
|
225
|
+
// "http://localhost:4337/3" (→ http://localhost:8545/3)
|
|
226
|
+
// "http://localhost:4337/n" (→ http://localhost:8545/n)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Parameters
|
|
230
|
+
|
|
231
|
+
See [`StackupParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c95294aae795e548897c/src/instances/stackup.ts#L5).
|
|
232
|
+
|
|
233
|
+
## Reference
|
|
234
|
+
|
|
235
|
+
### `createServer`
|
|
236
|
+
|
|
237
|
+
Creates a server that manages a pool of instances via a proxy.
|
|
238
|
+
|
|
239
|
+
#### Usage
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import { createServer } from 'prool'
|
|
243
|
+
import { anvil } from 'prool/instances'
|
|
244
|
+
|
|
245
|
+
const executionServer = createServer({
|
|
246
|
+
instance: anvil(),
|
|
247
|
+
})
|
|
248
|
+
await executionServer.start()
|
|
249
|
+
// Instances accessible at:
|
|
250
|
+
// "http://localhost:8545/1"
|
|
251
|
+
// "http://localhost:8545/2"
|
|
252
|
+
// "http://localhost:8545/3"
|
|
253
|
+
// "http://localhost:8545/n"
|
|
254
|
+
// "http://localhost:8545/n/start"
|
|
255
|
+
// "http://localhost:8545/n/stop"
|
|
256
|
+
// "http://localhost:8545/n/restart"
|
|
257
|
+
// "http://localhost:8545/healthcheck"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Endpoints:**
|
|
261
|
+
- `/:key`: Proxy to instance at `key`.
|
|
262
|
+
- `/:key/start`: Start instance at `key`.
|
|
263
|
+
- `/:key/stop`: Stop instance at `key`.
|
|
264
|
+
- `/:key/restart`: Restart instance at `key`.
|
|
265
|
+
- `/healthcheck`: Healthcheck endpoint.
|
|
266
|
+
|
|
267
|
+
#### API
|
|
268
|
+
|
|
269
|
+
| Name | Description | Type |
|
|
270
|
+
| ---------- | -------------------------------------------------------- | --------------------------------------- |
|
|
271
|
+
| `instance` | Instance for the server. | `Instance \| (key: number) => Instance` |
|
|
272
|
+
| `limit` | Number of instances that can be instantiated in the pool | `number` |
|
|
273
|
+
| `host` | Host for the server. | `string` |
|
|
274
|
+
| `port` | Port for the server. | `number` |
|
|
275
|
+
| returns | Server | `CreateServerReturnType` |
|
|
276
|
+
|
|
277
|
+
### `defineInstance`
|
|
278
|
+
|
|
279
|
+
Creates an instance definition, that can be used with [`createServer`](#createserver) or [`definePool`](#definepool).
|
|
280
|
+
|
|
281
|
+
#### Usage
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
import { defineInstance } from 'prool'
|
|
285
|
+
|
|
286
|
+
const foo = defineInstance((parameters: FooParameters) => {
|
|
287
|
+
return {
|
|
288
|
+
name: 'foo',
|
|
289
|
+
host: 'localhost',
|
|
290
|
+
port: 3000,
|
|
291
|
+
async start() {
|
|
292
|
+
// ...
|
|
293
|
+
},
|
|
294
|
+
async stop() {
|
|
295
|
+
// ...
|
|
296
|
+
},
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
#### API
|
|
302
|
+
|
|
303
|
+
| Name | Description | Type |
|
|
304
|
+
| ------- | -------------------- | ------------------ |
|
|
305
|
+
| `fn` | Instance definition. | `DefineInstanceFn` |
|
|
306
|
+
| returns | Instance. | `Instance` |
|
|
307
|
+
|
|
308
|
+
### `definePool`
|
|
309
|
+
|
|
310
|
+
Defines a pool of instances. Instances can be started, cached, and stopped against an identifier.
|
|
311
|
+
|
|
312
|
+
#### Usage
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { definePool } from 'prool'
|
|
316
|
+
import { anvil } from 'prool/instances'
|
|
317
|
+
|
|
318
|
+
const pool = definePool({
|
|
319
|
+
instance: anvil(),
|
|
320
|
+
})
|
|
321
|
+
const instance_1 = await pool.start(1)
|
|
322
|
+
const instance_2 = await pool.start(2)
|
|
323
|
+
const instance_3 = await pool.start(3)
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### API
|
|
327
|
+
|
|
328
|
+
| Name | Description | Type |
|
|
329
|
+
| ---------- | -------------------------------------------------------- | ---------- |
|
|
330
|
+
| `instance` | Instance for the pool. | `Instance` |
|
|
331
|
+
| `limit` | Number of instances that can be instantiated in the pool | `number` |
|
|
332
|
+
| returns | Pool. | `Pool` |
|
|
333
|
+
|
|
334
|
+
## Authors
|
|
335
|
+
|
|
336
|
+
- [@jxom](https://github.com/jxom) (jxom.eth, [Twitter](https://twitter.com/jakemoxey))
|
|
337
|
+
- [@tmm](https://github.com/tmm) (awkweb.eth, [Twitter](https://twitter.com/awkweb))
|
|
338
|
+
|
|
339
|
+
## License
|
|
340
|
+
|
|
341
|
+
[MIT](/LICENSE) License
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { type AltoParameters
|
|
2
|
-
export { type AnvilParameters
|
|
3
|
-
export { type
|
|
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 { stackup, type StackupParameters } from '../instances/stackup.js';
|
|
4
5
|
//# sourceMappingURL=instances.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../exports/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../exports/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../../exports/instances.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../../exports/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,KAAK,EAAwB,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAA0B,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,OAAO,EAA0B,MAAM,yBAAyB,CAAA"}
|