hardhat 2.6.4 → 2.6.8
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 +35 -0
- package/builtin-tasks/compile.js +9 -0
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/node.js +24 -7
- package/builtin-tasks/node.js.map +1 -1
- package/internal/cli/cli.js +5 -0
- package/internal/cli/cli.js.map +1 -1
- package/internal/cli/project-creation.d.ts.map +1 -1
- package/internal/cli/project-creation.js +29 -3
- package/internal/cli/project-creation.js.map +1 -1
- package/internal/core/config/config-loading.js +1 -1
- package/internal/core/config/default-config.d.ts +1 -0
- package/internal/core/config/default-config.d.ts.map +1 -1
- package/internal/core/config/default-config.js +4 -3
- package/internal/core/config/default-config.js.map +1 -1
- package/internal/core/errors-list.d.ts +14 -0
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +19 -0
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/providers/accounts.d.ts.map +1 -1
- package/internal/core/providers/accounts.js +14 -0
- package/internal/core/providers/accounts.js.map +1 -1
- package/internal/core/providers/gas-providers.d.ts.map +1 -1
- package/internal/core/providers/gas-providers.js +1 -1
- package/internal/core/providers/gas-providers.js.map +1 -1
- package/internal/hardhat-network/provider/modules/hardhat.d.ts +1 -0
- package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/hardhat.js +6 -0
- package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
- package/internal/hardhat-network/provider/modules/personal.d.ts +9 -0
- package/internal/hardhat-network/provider/modules/personal.d.ts.map +1 -0
- package/internal/hardhat-network/provider/modules/personal.js +31 -0
- package/internal/hardhat-network/provider/modules/personal.js.map +1 -0
- package/internal/hardhat-network/provider/node.d.ts +1 -0
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +29 -10
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +1 -0
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +5 -0
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +14 -0
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +1 -1
- package/internal/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +2 -0
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/internal/util/antlr-prototype-pollution-workaround.d.ts +16 -0
- package/internal/util/antlr-prototype-pollution-workaround.d.ts.map +1 -0
- package/internal/util/antlr-prototype-pollution-workaround.js +22 -0
- package/internal/util/antlr-prototype-pollution-workaround.js.map +1 -0
- package/package.json +2 -2
- package/recommended-gitignore.txt +3 -0
- package/register.js +2 -0
- package/register.js.map +1 -1
- package/sample-projects/advanced/{.env.template → .env.example} +0 -0
- package/sample-projects/advanced/.eslintrc.js +0 -8
- package/sample-projects/advanced/README.md +1 -1
- package/sample-projects/advanced/hardhat.config.js +0 -3
- package/sample-projects/advanced/npmignore +3 -0
- package/sample-projects/advanced/scripts/deploy.js +4 -6
- package/sample-projects/advanced-ts/.eslintrc.js +24 -0
- package/sample-projects/advanced-ts/README.md +46 -0
- package/sample-projects/advanced-ts/hardhat.config.ts +43 -0
- package/sample-projects/advanced-ts/npmignore +3 -0
- package/sample-projects/advanced-ts/scripts/deploy.ts +30 -0
- package/sample-projects/advanced-ts/test/index.ts +19 -0
- package/sample-projects/advanced-ts/tsconfig.json +12 -0
- package/src/builtin-tasks/compile.ts +14 -0
- package/src/builtin-tasks/node.ts +39 -7
- package/src/internal/cli/cli.ts +6 -0
- package/src/internal/cli/project-creation.ts +61 -4
- package/src/internal/core/config/config-loading.ts +1 -1
- package/src/internal/core/config/default-config.ts +2 -1
- package/src/internal/core/errors-list.ts +19 -0
- package/src/internal/core/providers/accounts.ts +19 -0
- package/src/internal/core/providers/gas-providers.ts +1 -1
- package/src/internal/hardhat-network/provider/modules/hardhat.ts +9 -0
- package/src/internal/hardhat-network/provider/modules/personal.ts +39 -0
- package/src/internal/hardhat-network/provider/node.ts +30 -10
- package/src/internal/hardhat-network/provider/provider.ts +7 -0
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +19 -0
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +1 -1
- package/src/internal/lib/hardhat-lib.ts +3 -0
- package/src/internal/util/antlr-prototype-pollution-workaround.ts +17 -0
- package/src/register.ts +3 -0
|
@@ -142,7 +142,7 @@ export class AutomaticGasPriceProvider extends ProviderWrapper {
|
|
|
142
142
|
public static readonly EIP1559_BASE_FEE_MAX_FULL_BLOCKS_PREFERENCE: number = 3;
|
|
143
143
|
|
|
144
144
|
// See eth_feeHistory for an explanation of what this means
|
|
145
|
-
public static readonly EIP1559_REWARD_PERCENTILE: number =
|
|
145
|
+
public static readonly EIP1559_REWARD_PERCENTILE: number = 50;
|
|
146
146
|
|
|
147
147
|
private _nodeHasFeeHistory?: boolean;
|
|
148
148
|
private _nodeSupportsEIP1559?: boolean;
|
|
@@ -66,6 +66,9 @@ export class HardhatModule {
|
|
|
66
66
|
case "hardhat_intervalMine":
|
|
67
67
|
return this._intervalMineAction(...this._intervalMineParams(params));
|
|
68
68
|
|
|
69
|
+
case "hardhat_getAutomine":
|
|
70
|
+
return this._getAutomine();
|
|
71
|
+
|
|
69
72
|
case "hardhat_stopImpersonatingAccount":
|
|
70
73
|
return this._stopImpersonatingAction(
|
|
71
74
|
...this._stopImpersonatingParams(params)
|
|
@@ -184,6 +187,12 @@ export class HardhatModule {
|
|
|
184
187
|
return true;
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
// hardhat_getAutomine
|
|
191
|
+
|
|
192
|
+
private async _getAutomine(): Promise<boolean> {
|
|
193
|
+
return this._node.getAutomine();
|
|
194
|
+
}
|
|
195
|
+
|
|
187
196
|
// hardhat_stopImpersonatingAccount
|
|
188
197
|
|
|
189
198
|
private _stopImpersonatingParams(params: any[]): [Buffer] {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Address, toRpcSig } from "ethereumjs-util";
|
|
2
|
+
import { rpcAddress, rpcData } from "../../../core/jsonrpc/types/base-types";
|
|
3
|
+
import { validateParams } from "../../../core/jsonrpc/types/input/validation";
|
|
4
|
+
import { MethodNotFoundError } from "../../../core/providers/errors";
|
|
5
|
+
import { HardhatNode } from "../node";
|
|
6
|
+
|
|
7
|
+
/* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
|
|
8
|
+
|
|
9
|
+
export class PersonalModule {
|
|
10
|
+
constructor(private readonly _node: HardhatNode) {}
|
|
11
|
+
|
|
12
|
+
public async processRequest(
|
|
13
|
+
method: string,
|
|
14
|
+
params: any[] = []
|
|
15
|
+
): Promise<any> {
|
|
16
|
+
switch (method) {
|
|
17
|
+
case "personal_sign": {
|
|
18
|
+
return this._signAction(...this._signParams(params));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
throw new MethodNotFoundError(`Method ${method} not found`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// personal_sign
|
|
26
|
+
|
|
27
|
+
private _signParams(params: any[]): [Buffer, Buffer] {
|
|
28
|
+
return validateParams(params, rpcData, rpcAddress);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private async _signAction(data: Buffer, address: Buffer): Promise<string> {
|
|
32
|
+
const signature = await this._node.signPersonalMessage(
|
|
33
|
+
new Address(address),
|
|
34
|
+
data
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return toRpcSig(signature.v, signature.r, signature.s);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1103,6 +1103,10 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1103
1103
|
this._automine = automine;
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
|
+
public getAutomine() {
|
|
1107
|
+
return this._automine;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1106
1110
|
public async setBlockGasLimit(gasLimit: BN | number) {
|
|
1107
1111
|
this._txPool.setBlockGasLimit(gasLimit);
|
|
1108
1112
|
await this._txPool.updatePendingAndQueued();
|
|
@@ -1372,12 +1376,28 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1372
1376
|
.map((hash) => this.getTransactionReceipt(hash))
|
|
1373
1377
|
);
|
|
1374
1378
|
|
|
1375
|
-
const
|
|
1376
|
-
.map((r) =>
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1379
|
+
const effectiveGasRewardAndGas = receipts
|
|
1380
|
+
.map((r, i) => {
|
|
1381
|
+
const tx = block.transactions[i];
|
|
1382
|
+
const baseFeePerGas = block.header.baseFeePerGas ?? new BN(0);
|
|
1383
|
+
|
|
1384
|
+
// reward = min(maxPriorityFeePerGas, maxFeePerGas - baseFeePerGas)
|
|
1385
|
+
let effectiveGasReward: BN;
|
|
1386
|
+
if ("maxPriorityFeePerGas" in tx) {
|
|
1387
|
+
effectiveGasReward = tx.maxFeePerGas.sub(baseFeePerGas);
|
|
1388
|
+
if (tx.maxPriorityFeePerGas.lt(effectiveGasReward)) {
|
|
1389
|
+
effectiveGasReward = tx.maxPriorityFeePerGas;
|
|
1390
|
+
}
|
|
1391
|
+
} else {
|
|
1392
|
+
effectiveGasReward = tx.gasPrice.sub(baseFeePerGas);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
return {
|
|
1396
|
+
effectiveGasReward,
|
|
1397
|
+
gasUsed: rpcQuantityToBN(r?.gasUsed!),
|
|
1398
|
+
};
|
|
1399
|
+
})
|
|
1400
|
+
.sort((a, b) => a.effectiveGasReward.cmp(b.effectiveGasReward));
|
|
1381
1401
|
|
|
1382
1402
|
return rewardPercentiles.map((p) => {
|
|
1383
1403
|
let gasUsed = new BN(0);
|
|
@@ -1385,16 +1405,16 @@ Hardhat Network's forking functionality only works with blocks from at least spu
|
|
|
1385
1405
|
.muln(Math.ceil(p * FLOATS_PRECISION))
|
|
1386
1406
|
.divn(100 * FLOATS_PRECISION);
|
|
1387
1407
|
|
|
1388
|
-
for (const values of
|
|
1408
|
+
for (const values of effectiveGasRewardAndGas) {
|
|
1389
1409
|
gasUsed = gasUsed.add(values.gasUsed);
|
|
1390
1410
|
|
|
1391
1411
|
if (targetGas.lte(gasUsed)) {
|
|
1392
|
-
return values.
|
|
1412
|
+
return values.effectiveGasReward;
|
|
1393
1413
|
}
|
|
1394
1414
|
}
|
|
1395
1415
|
|
|
1396
|
-
return
|
|
1397
|
-
.
|
|
1416
|
+
return effectiveGasRewardAndGas[effectiveGasRewardAndGas.length - 1]
|
|
1417
|
+
.effectiveGasReward;
|
|
1398
1418
|
});
|
|
1399
1419
|
}
|
|
1400
1420
|
|
|
@@ -32,6 +32,7 @@ import { EthModule } from "./modules/eth";
|
|
|
32
32
|
import { EvmModule } from "./modules/evm";
|
|
33
33
|
import { HardhatModule } from "./modules/hardhat";
|
|
34
34
|
import { ModulesLogger } from "./modules/logger";
|
|
35
|
+
import { PersonalModule } from "./modules/personal";
|
|
35
36
|
import { NetModule } from "./modules/net";
|
|
36
37
|
import { Web3Module } from "./modules/web3";
|
|
37
38
|
import { HardhatNode } from "./node";
|
|
@@ -65,6 +66,7 @@ export class HardhatNetworkProvider
|
|
|
65
66
|
private _evmModule?: EvmModule;
|
|
66
67
|
private _hardhatModule?: HardhatModule;
|
|
67
68
|
private _debugModule?: DebugModule;
|
|
69
|
+
private _personalModule?: PersonalModule;
|
|
68
70
|
private readonly _mutex = new Mutex();
|
|
69
71
|
|
|
70
72
|
constructor(
|
|
@@ -205,6 +207,10 @@ export class HardhatNetworkProvider
|
|
|
205
207
|
return this._debugModule!.processRequest(method, params);
|
|
206
208
|
}
|
|
207
209
|
|
|
210
|
+
if (method.startsWith("personal_")) {
|
|
211
|
+
return this._personalModule!.processRequest(method, params);
|
|
212
|
+
}
|
|
213
|
+
|
|
208
214
|
throw new MethodNotFoundError(`Method ${method} not found`);
|
|
209
215
|
}
|
|
210
216
|
|
|
@@ -265,6 +271,7 @@ export class HardhatNetworkProvider
|
|
|
265
271
|
this._experimentalHardhatNetworkMessageTraceHooks
|
|
266
272
|
);
|
|
267
273
|
this._debugModule = new DebugModule(node);
|
|
274
|
+
this._personalModule = new PersonalModule(node);
|
|
268
275
|
|
|
269
276
|
this._forwardNodeEvents(node);
|
|
270
277
|
}
|
|
@@ -191,6 +191,25 @@ export class ErrorInferrer {
|
|
|
191
191
|
return true;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
// look TWO frames ahead to determine if this is a specific occurrence of
|
|
195
|
+
// a redundant CALLSTACK_ENTRY frame observed when using Solidity 0.8.5:
|
|
196
|
+
if (
|
|
197
|
+
frame.type === StackTraceEntryType.CALLSTACK_ENTRY &&
|
|
198
|
+
i + 2 < stacktrace.length &&
|
|
199
|
+
stacktrace[i + 2].sourceReference !== undefined &&
|
|
200
|
+
stacktrace[i + 2].type === StackTraceEntryType.RETURNDATA_SIZE_ERROR
|
|
201
|
+
) {
|
|
202
|
+
// ! below for tsc. we confirmed existence in the enclosing conditional.
|
|
203
|
+
const thatSrcRef = stacktrace[i + 2].sourceReference!;
|
|
204
|
+
if (
|
|
205
|
+
frame.sourceReference.range[0] === thatSrcRef.range[0] &&
|
|
206
|
+
frame.sourceReference.range[1] === thatSrcRef.range[1] &&
|
|
207
|
+
frame.sourceReference.line === thatSrcRef.line
|
|
208
|
+
) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
194
213
|
// constructors contain the whole contract, so we ignore them
|
|
195
214
|
if (
|
|
196
215
|
frame.sourceReference.function === "constructor" &&
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
StackTraceEntryType,
|
|
32
32
|
} from "./solidity-stack-trace";
|
|
33
33
|
|
|
34
|
-
export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.
|
|
34
|
+
export const SUPPORTED_SOLIDITY_VERSION_RANGE = "<=0.8.9";
|
|
35
35
|
export const FIRST_SOLC_VERSION_SUPPORTED = "0.5.1";
|
|
36
36
|
|
|
37
37
|
export class SolidityTracer {
|
|
@@ -8,10 +8,13 @@ import { ERRORS } from "../core/errors-list";
|
|
|
8
8
|
import { getEnvHardhatArguments } from "../core/params/env-variables";
|
|
9
9
|
import { HARDHAT_PARAM_DEFINITIONS } from "../core/params/hardhat-params";
|
|
10
10
|
import { Environment } from "../core/runtime-environment";
|
|
11
|
+
import { applyWorkaround } from "../util/antlr-prototype-pollution-workaround";
|
|
11
12
|
|
|
12
13
|
let ctx: HardhatContext;
|
|
13
14
|
let env: HardhatRuntimeEnvironment;
|
|
14
15
|
|
|
16
|
+
applyWorkaround();
|
|
17
|
+
|
|
15
18
|
if (HardhatContext.isCreated()) {
|
|
16
19
|
ctx = HardhatContext.getHardhatContext();
|
|
17
20
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function applies a workaround to an ANTLR issue that arises when used
|
|
3
|
+
* with Immutable.js.
|
|
4
|
+
*
|
|
5
|
+
* ANTLR defines String.prototype.hashCode, and Immutable.js uses hashCode
|
|
6
|
+
* functions internally (for equality), including on strings.
|
|
7
|
+
*
|
|
8
|
+
* If the parser is required lazily (which it normally is) in the middle of an
|
|
9
|
+
* execution, the custom state managers can break, because we'd be redefining
|
|
10
|
+
* the String's equality function as seen by Immutable.js.
|
|
11
|
+
*
|
|
12
|
+
* By always including the parser we make the equality function's definition
|
|
13
|
+
* stable during the entire execution.
|
|
14
|
+
*/
|
|
15
|
+
export function applyWorkaround() {
|
|
16
|
+
require("@solidity-parser/parser");
|
|
17
|
+
}
|
package/src/register.ts
CHANGED
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
disableReplWriterShowProxy,
|
|
14
14
|
isNodeCalledWithoutAScript,
|
|
15
15
|
} from "./internal/util/console";
|
|
16
|
+
import { applyWorkaround } from "./internal/util/antlr-prototype-pollution-workaround";
|
|
17
|
+
|
|
18
|
+
applyWorkaround();
|
|
16
19
|
|
|
17
20
|
if (!HardhatContext.isCreated()) {
|
|
18
21
|
require("source-map-support/register");
|