Skip to content

Commit 063aec1

Browse files
committed
chore: namespace imports
1 parent d12ee6b commit 063aec1

32 files changed

+1721
-1876
lines changed

.changeset/giant-knives-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"prool": minor
3+
---
4+
5+
**Breaking:** Removed `silius` + `stackup` instances.

.changeset/lazy-toys-report.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
"prool": minor
3+
---
4+
5+
**Breaking:** Refactored to use namespace imports.
6+
7+
### Imports
8+
9+
```diff
10+
- import { createServer } from 'prool'
11+
- import { anvil, alto, rundler } from 'prool/instances'
12+
- import { defineInstance } from 'prool'
13+
- import { definePool } from 'prool'
14+
+ import { Instance, Pool, Server } from 'prool'
15+
```
16+
17+
### `Server.create``Server.create`
18+
19+
```diff
20+
- const server = createServer({
21+
- instance: anvil(),
22+
+ const server = Server.create({
23+
+ instance: Instance.anvil(),
24+
})
25+
```
26+
27+
### `anvil`, `alto`, `rundler``Instance.anvil`, `Instance.alto`, `Instance.rundler`
28+
29+
```diff
30+
- const instance = anvil({ ... })
31+
+ const instance = Instance.anvil({ ... })
32+
33+
- const instance = alto({ ... })
34+
+ const instance = Instance.alto({ ... })
35+
36+
- const instance = rundler({ ... })
37+
+ const instance = Instance.rundler({ ... })
38+
```
39+
40+
### `defineInstance``Instance.define`
41+
42+
```diff
43+
- const foo = defineInstance((parameters) => {
44+
+ const foo = Instance.define((parameters) => {
45+
return {
46+
name: 'foo',
47+
// ...
48+
}
49+
})
50+
```
51+
52+
### `definePool``Pool.define`
53+
54+
```diff
55+
- const pool = definePool({
56+
- instance: anvil(),
57+
+ const pool = Pool.define({
58+
+ instance: Instance.anvil(),
59+
})
60+
```

README.md

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,21 @@ Prool is a library that provides programmatic HTTP testing instances for Ethereu
3939
Prool contains a set of pre-configured instances that can be used to simulate Ethereum server environments, being:
4040

4141
- **Local Execution Nodes:** [`anvil`](#anvil-execution-node)
42-
- **Bundler Nodes:** [`alto`](#alto-bundler-node), [`rundler`](#rundler-bundler-node)
43-
- **Indexer Nodes:** `ponder`⚠️
42+
- **ERC-4337 Bundler Nodes:** [`alto`](#alto-bundler-node), [`rundler`](#rundler-bundler-node)
4443

45-
⚠️ = soon
46-
47-
You can also create your own custom instances by using the [`defineInstance` function](#defineinstance).
44+
You can also create your own custom instances by using the [`Instance.define` function](#instancedefine).
4845

4946
## Table of Contents
5047

5148
- [Install](#install)
5249
- [Getting Started](#getting-started)
5350
- [Anvil (Execution Node)](#anvil-execution-node)
54-
- [Alto (Bundler Node)](#alto-bundler-node)
55-
- [Rundler (Bundler Node)](#rundler-bundler-node)
51+
- [Alto (ERC-4337 Bundler Node)](#alto-bundler-node)
52+
- [Rundler (ERC-4337 Bundler Node)](#rundler-bundler-node)
5653
- [Reference](#reference)
57-
- [`createServer`](#createserver)
58-
- [`defineInstance`](#defineinstance)
59-
- [`definePool`](#definepool)
54+
- [`Server.create`](#servercreate)
55+
- [`Instance.define`](#instancedefine)
56+
- [`Pool.define`](#pooldefine)
6057

6158

6259
## Install
@@ -85,11 +82,10 @@ bun i prool
8582
#### Usage
8683

8784
```ts
88-
import { createServer } from 'prool'
89-
import { anvil } from 'prool/instances'
85+
import { Instance, Server } from 'prool'
9086

91-
const server = createServer({
92-
instance: anvil(),
87+
const server = Server.create({
88+
instance: Instance.anvil(),
9389
})
9490

9591
await server.start()
@@ -113,11 +109,10 @@ See [`AnvilParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c
113109
#### Usage
114110

115111
```ts
116-
import { createServer } from 'prool'
117-
import { anvil, alto } from 'prool/instances'
112+
import { Instance, Server } from 'prool'
118113

119-
const executionServer = createServer({
120-
instance: anvil(),
114+
const executionServer = Server.create({
115+
instance: Instance.anvil(),
121116
port: 8545
122117
})
123118
await executionServer.start()
@@ -127,8 +122,8 @@ await executionServer.start()
127122
// "http://localhost:8545/3"
128123
// "http://localhost:8545/n"
129124

130-
const bundlerServer = createServer({
131-
instance: (key) => alto({
125+
const bundlerServer = Server.create({
126+
instance: (key) => Instance.alto({
132127
entrypoints: ['0x0000000071727De22E5E9d8BAf0edAc6f37da032'],
133128
rpcUrl: `http://localhost:8545/${key}`,
134129
executorPrivateKeys: ['0x...'],
@@ -156,11 +151,10 @@ See [`AltoParameters`](https://github.com/wevm/prool/blob/801ede06ded8b2cb2d59c9
156151
#### Usage
157152

158153
```ts
159-
import { createServer } from 'prool'
160-
import { anvil, rundler } from 'prool/instances'
154+
import { Instance, Server } from 'prool'
161155

162-
const executionServer = createServer({
163-
instance: anvil(),
156+
const executionServer = Server.create({
157+
instance: Instance.anvil(),
164158
port: 8545
165159
})
166160
await executionServer.start()
@@ -170,8 +164,8 @@ await executionServer.start()
170164
// "http://localhost:8545/3"
171165
// "http://localhost:8545/n"
172166

173-
const bundlerServer = createServer({
174-
instance: (key) => rundler({
167+
const bundlerServer = Server.create({
168+
instance: (key) => Instance.rundler({
175169
nodeHttp: `http://localhost:8545/${key}`,
176170
})
177171
})
@@ -189,18 +183,17 @@ See [RundlerParameters]().
189183

190184
## Reference
191185

192-
### `createServer`
186+
### `Server.create`
193187

194188
Creates a server that manages a pool of instances via a proxy.
195189

196190
#### Usage
197191

198192
```ts
199-
import { createServer } from 'prool'
200-
import { anvil } from 'prool/instances'
193+
import { Instance, Server } from 'prool'
201194

202-
const executionServer = createServer({
203-
instance: anvil(),
195+
const executionServer = Server.create({
196+
instance: Instance.anvil(),
204197
})
205198
await executionServer.start()
206199
// Instances accessible at:
@@ -229,18 +222,18 @@ await executionServer.start()
229222
| `limit` | Number of instances that can be instantiated in the pool | `number` |
230223
| `host` | Host for the server. | `string` |
231224
| `port` | Port for the server. | `number` |
232-
| returns | Server | `CreateServerReturnType` |
225+
| returns | Server | `Server.Server` |
233226

234-
### `defineInstance`
227+
### `Instance.define`
235228

236-
Creates an instance definition, that can be used with [`createServer`](#createserver) or [`definePool`](#definepool).
229+
Creates an instance definition, that can be used with [`Server.create`](#servercreate) or [`Pool.define`](#pooldefine).
237230

238231
#### Usage
239232

240233
```ts
241-
import { defineInstance } from 'prool'
234+
import { Instance } from 'prool'
242235

243-
const foo = defineInstance((parameters: FooParameters) => {
236+
const foo = Instance.define((parameters: FooParameters) => {
244237
return {
245238
name: 'foo',
246239
host: 'localhost',
@@ -262,18 +255,17 @@ const foo = defineInstance((parameters: FooParameters) => {
262255
| `fn` | Instance definition. | `DefineInstanceFn` |
263256
| returns | Instance. | `Instance` |
264257

265-
### `definePool`
258+
### `Pool.define`
266259

267260
Defines a pool of instances. Instances can be started, cached, and stopped against an identifier.
268261

269262
#### Usage
270263

271264
```ts
272-
import { definePool } from 'prool'
273-
import { anvil } from 'prool/instances'
265+
import { Instance, Pool } from 'prool'
274266

275-
const pool = definePool({
276-
instance: anvil(),
267+
const pool = Pool.define({
268+
instance: Instance.anvil(),
277269
})
278270
const instance_1 = await pool.start(1)
279271
const instance_2 = await pool.start(2)

package.json

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"@types/http-proxy": "^1.17.17",
1818
"@types/node": "^24.10.2",
1919
"@types/ws": "^8.18.1",
20-
"@vitest/coverage-v8": "^1.6.0",
20+
"@vitest/coverage-v8": "^4.0.15",
2121
"typescript": "^5.9.3",
22-
"vitest": "^1.6.0",
22+
"vitest": "^4.0.15",
2323
"ws": "^8.18.3",
2424
"zile": "^0.0.13"
2525
},
@@ -35,19 +35,9 @@
3535
},
3636
"exports": {
3737
".": {
38-
"src": "./src/exports/index.ts",
39-
"types": "./dist/exports/index.d.ts",
40-
"default": "./dist/exports/index.js"
41-
},
42-
"./processes": {
43-
"src": "./src/exports/processes.ts",
44-
"types": "./dist/exports/processes.d.ts",
45-
"default": "./dist/exports/processes.js"
46-
},
47-
"./instances": {
48-
"src": "./src/exports/instances.ts",
49-
"types": "./dist/exports/instances.d.ts",
50-
"default": "./dist/exports/instances.js"
38+
"src": "./src/index.ts",
39+
"types": "./dist/index.d.ts",
40+
"default": "./dist/index.js"
5141
}
5242
},
5343
"dependencies": {
@@ -80,7 +70,7 @@
8070
}
8171
],
8272
"keywords": [],
83-
"main": "./dist/exports/index.js",
84-
"module": "./dist/exports/index.js",
85-
"types": "./dist/exports/index.d.ts"
73+
"main": "./dist/index.js",
74+
"module": "./dist/index.js",
75+
"types": "./dist/index.d.ts"
8676
}

0 commit comments

Comments
 (0)