forked from NomicFoundation/hardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.ts
41 lines (39 loc) · 890 Bytes
/
reset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { NumberLike } from "../types";
import { clearSnapshots } from "../loadFixture";
import { getHardhatProvider, toNumber } from "../utils";
export async function reset(
url?: string,
blockNumber?: NumberLike
): Promise<void> {
const provider = await getHardhatProvider();
await clearSnapshots();
if (url === undefined) {
await provider.request({
method: "hardhat_reset",
params: [],
});
} else if (blockNumber === undefined) {
await provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: url,
},
},
],
});
} else {
await provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: url,
blockNumber: toNumber(blockNumber),
},
},
],
});
}
}