This repository was archived by the owner on Oct 16, 2025. It is now read-only.
Commit afa7351
committed
Align Provider type w/ other packages & re-expose
The Provider type which is used internally by this package is not
compatible with the SafeEventEmitterProvider type used by
`eth-json-rpc-middleware`. This means that whenever using this package
with `eth-json-rpc-middleware` we have to resort to the following
hackery:
```
import { PollingBlockTracker, Provider } from 'eth-block-tracker';
import { JsonRpcEngine } from 'json-rpc-engine';
import { providerFromEngine } from '../src';
const engine = new JsonRpcEngine();
const provider = providerFromEngine(engine);
const blockTracker = new PollingBlockTracker({
// Notice the typecasting here
provider: provider as Provider,
});
```
SafeEventEmitterProvider is the more accurate type here in this case,
because it correctly types the `error` argument for the callback that
`sendAsync` calls as `unknown` rather than `Error`, so we follow suit
here.
Additionally, this package used to expose the Provider type and that was
changed in 6.0.0 without being documented, probably because it was
located in the same file as BaseBlockTracker. So here we move the type
to a more obvious place and re-expose it.1 parent 3f6b456 commit afa7351
File tree
6 files changed
+20
-16
lines changed- src
- tests
6 files changed
+20
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 9 | | |
18 | 10 | | |
19 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | 4 | | |
10 | 5 | | |
11 | 6 | | |
12 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
0 commit comments