hardhat 2.22.4 → 2.22.6
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/internal/cli/bootstrap.js +2 -3
- package/internal/cli/bootstrap.js.map +1 -1
- package/internal/cli/constants.d.ts.map +1 -1
- package/internal/cli/constants.js +1 -1
- package/internal/cli/constants.js.map +1 -1
- package/internal/cli/is-node-version-to-warn-on.d.ts +13 -0
- package/internal/cli/is-node-version-to-warn-on.d.ts.map +1 -0
- package/internal/cli/is-node-version-to-warn-on.js +46 -0
- package/internal/cli/is-node-version-to-warn-on.js.map +1 -0
- package/internal/core/config/default-config.d.ts.map +1 -1
- package/internal/core/config/default-config.js +26 -0
- package/internal/core/config/default-config.js.map +1 -1
- package/internal/core/errors-list.d.ts +7 -0
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +9 -0
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +5 -0
- package/internal/core/providers/http.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +12 -8
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +35 -21
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToEdr.js +30 -4
- package/internal/hardhat-network/provider/utils/convertToEdr.js.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts +0 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.js +0 -16
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -1
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts +8 -1
- package/internal/hardhat-network/provider/vm/minimal-vm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/minimal-vm.js +6 -2
- package/internal/hardhat-network/provider/vm/minimal-vm.js.map +1 -1
- package/internal/hardhat-network/provider/vm/types.d.ts +8 -0
- package/internal/hardhat-network/provider/vm/types.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +0 -2
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +8 -7
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +13 -29
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/package.json +3 -9
- package/src/internal/cli/bootstrap.ts +3 -3
- package/src/internal/cli/constants.ts +1 -1
- package/src/internal/cli/is-node-version-to-warn-on.ts +54 -0
- package/src/internal/core/config/default-config.ts +26 -0
- package/src/internal/core/errors-list.ts +11 -0
- package/src/internal/core/providers/http.ts +6 -0
- package/src/internal/hardhat-network/provider/provider.ts +46 -33
- package/src/internal/hardhat-network/provider/utils/convertToEdr.ts +36 -4
- package/src/internal/hardhat-network/provider/vm/exit.ts +0 -21
- package/src/internal/hardhat-network/provider/vm/minimal-vm.ts +14 -3
- package/src/internal/hardhat-network/provider/vm/types.ts +7 -0
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +0 -2
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +13 -26
- package/internal/hardhat-network/provider/MiningTimer.d.ts +0 -28
- package/internal/hardhat-network/provider/MiningTimer.d.ts.map +0 -1
- package/internal/hardhat-network/provider/MiningTimer.js +0 -96
- package/internal/hardhat-network/provider/MiningTimer.js.map +0 -1
- package/src/internal/hardhat-network/provider/MiningTimer.ts +0 -118
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { IntervalMiningConfig } from "./node-types";
|
|
2
|
-
|
|
3
|
-
enum MiningTimerState {
|
|
4
|
-
STOP,
|
|
5
|
-
RUNNING,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/* eslint-disable @nomicfoundation/hardhat-internal-rules/only-hardhat-error */
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Timer used to periodically call the given mining function.
|
|
12
|
-
*
|
|
13
|
-
* `_blockTime` can be a number or a pair of numbers (of milliseconds). If it
|
|
14
|
-
* is a number, it will call the given function repeatedly every `_blockTime`
|
|
15
|
-
* milliseconds. If it is a pair of numbers, then after each call it will
|
|
16
|
-
* randomly choose how much to wait until the next call.
|
|
17
|
-
*
|
|
18
|
-
* `_mineFunction` is the function to call. It can be async, and it is assumed
|
|
19
|
-
* that it will never throw.
|
|
20
|
-
*/
|
|
21
|
-
export class MiningTimer {
|
|
22
|
-
private _state = MiningTimerState.STOP;
|
|
23
|
-
private _timeout: NodeJS.Timeout | null = null;
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
private _blockTime: IntervalMiningConfig,
|
|
27
|
-
private readonly _mineFunction: () => Promise<any>
|
|
28
|
-
) {
|
|
29
|
-
this._validateBlockTime(_blockTime);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public getBlockTime(): IntervalMiningConfig {
|
|
33
|
-
return this._blockTime;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public enabled(): boolean {
|
|
37
|
-
return this._blockTime !== 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public setBlockTime(blockTime: IntervalMiningConfig): void {
|
|
41
|
-
this._validateBlockTime(blockTime);
|
|
42
|
-
|
|
43
|
-
if (blockTime === 0) {
|
|
44
|
-
this.stop();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
this._blockTime = blockTime;
|
|
49
|
-
|
|
50
|
-
if (this._state === MiningTimerState.RUNNING) {
|
|
51
|
-
this.stop();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.start();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public start(): void {
|
|
58
|
-
if (this._state === MiningTimerState.RUNNING || !this.enabled()) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const blockTime = this._getNextBlockTime();
|
|
63
|
-
|
|
64
|
-
this._state = MiningTimerState.RUNNING;
|
|
65
|
-
this._timeout = setTimeout(() => this._loop(), blockTime);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public stop(): void {
|
|
69
|
-
if (this._state === MiningTimerState.STOP) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this._state = MiningTimerState.STOP;
|
|
74
|
-
|
|
75
|
-
if (this._timeout !== null) {
|
|
76
|
-
clearTimeout(this._timeout);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private _validateBlockTime(blockTime: IntervalMiningConfig) {
|
|
81
|
-
if (Array.isArray(blockTime)) {
|
|
82
|
-
const [rangeStart, rangeEnd] = blockTime;
|
|
83
|
-
if (rangeEnd < rangeStart) {
|
|
84
|
-
throw new Error("Invalid block time range");
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if (blockTime < 0) {
|
|
88
|
-
throw new Error("Block time cannot be negative");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private async _loop() {
|
|
94
|
-
if (this._state === MiningTimerState.STOP) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
await this._mineFunction();
|
|
99
|
-
|
|
100
|
-
const blockTime = this._getNextBlockTime();
|
|
101
|
-
|
|
102
|
-
this._timeout = setTimeout(() => {
|
|
103
|
-
this._loop(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
104
|
-
}, blockTime);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private _getNextBlockTime(): number {
|
|
108
|
-
if (Array.isArray(this._blockTime)) {
|
|
109
|
-
const [minBlockTime, maxBlockTime] = this._blockTime;
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
minBlockTime + Math.floor(Math.random() * (maxBlockTime - minBlockTime))
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return this._blockTime;
|
|
117
|
-
}
|
|
118
|
-
}
|