hardhat 2.13.0-dev.2 → 2.13.0-dev.3
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/builtin-tasks/compile.js +16 -6
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +1 -1
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/help.js +2 -4
- package/builtin-tasks/help.js.map +1 -1
- package/builtin-tasks/task-names.d.ts +1 -0
- package/builtin-tasks/task-names.d.ts.map +1 -1
- package/builtin-tasks/task-names.js +3 -2
- package/builtin-tasks/task-names.js.map +1 -1
- package/builtin-tasks/test.js +22 -1
- package/builtin-tasks/test.js.map +1 -1
- package/internal/cli/bootstrap.d.ts +1 -0
- package/internal/cli/bootstrap.js +12 -20
- package/internal/cli/bootstrap.js.map +1 -1
- package/internal/cli/cli.d.ts +0 -1
- package/internal/cli/cli.d.ts.map +1 -1
- package/internal/cli/cli.js +20 -29
- package/internal/cli/cli.js.map +1 -1
- package/internal/cli/project-creation.d.ts +1 -2
- package/internal/cli/project-creation.d.ts.map +1 -1
- package/internal/cli/project-creation.js +105 -36
- package/internal/cli/project-creation.js.map +1 -1
- package/internal/cli/prompt.d.ts +2 -2
- package/internal/cli/prompt.d.ts.map +1 -1
- package/internal/cli/prompt.js +1 -2
- package/internal/cli/prompt.js.map +1 -1
- package/internal/cli/types.d.ts +1 -0
- package/internal/cli/types.d.ts.map +1 -1
- package/internal/core/config/config-env.d.ts +5 -11
- package/internal/core/config/config-env.d.ts.map +1 -1
- package/internal/core/config/config-env.js +2 -13
- package/internal/core/config/config-env.js.map +1 -1
- package/internal/core/config/config-loading.d.ts +2 -1
- package/internal/core/config/config-loading.d.ts.map +1 -1
- package/internal/core/config/config-loading.js +25 -7
- package/internal/core/config/config-loading.js.map +1 -1
- package/internal/core/config/config-validation.d.ts +2 -0
- package/internal/core/config/config-validation.d.ts.map +1 -1
- package/internal/core/config/config-validation.js +18 -1
- package/internal/core/config/config-validation.js.map +1 -1
- package/internal/core/config/extenders.d.ts +4 -7
- package/internal/core/config/extenders.d.ts.map +1 -1
- package/internal/core/config/extenders.js +5 -12
- package/internal/core/config/extenders.js.map +1 -1
- package/internal/core/errors-list.d.ts +28 -7
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +33 -10
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/jsonrpc/types/input/blockTag.d.ts +3 -3
- package/internal/core/jsonrpc/types/input/blockTag.d.ts.map +1 -1
- package/internal/core/project-structure.d.ts.map +1 -1
- package/internal/core/project-structure.js +6 -0
- package/internal/core/project-structure.js.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +25 -5
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -2
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +41 -19
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts +4 -2
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +39 -47
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/core/tasks/dsl.d.ts +6 -6
- package/internal/core/tasks/dsl.d.ts.map +1 -1
- package/internal/core/tasks/dsl.js.map +1 -1
- package/internal/core/tasks/task-definitions.d.ts +2 -2
- package/internal/core/tasks/task-definitions.d.ts.map +1 -1
- package/internal/core/tasks/task-definitions.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.d.ts +1 -0
- package/internal/hardhat-network/jsonrpc/handler.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +13 -18
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/RethnetState.d.ts +26 -0
- package/internal/hardhat-network/provider/RethnetState.d.ts.map +1 -0
- package/internal/hardhat-network/provider/RethnetState.js +84 -0
- package/internal/hardhat-network/provider/RethnetState.js.map +1 -0
- package/internal/hardhat-network/provider/modules/evm.d.ts +2 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.js +10 -4
- package/internal/hardhat-network/provider/modules/evm.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- 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 +6 -4
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +25 -21
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +25 -42
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +2 -2
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/utils/bloom.d.ts +32 -0
- package/internal/hardhat-network/provider/utils/bloom.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/bloom.js +79 -0
- package/internal/hardhat-network/provider/utils/bloom.js.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +12 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js +162 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +7 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +31 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -0
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -2
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/vm/block-builder.d.ts +31 -0
- package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/block-builder.js +151 -0
- package/internal/hardhat-network/provider/vm/block-builder.js.map +1 -0
- package/internal/hardhat-network/provider/vm/creation.d.ts +10 -0
- package/internal/hardhat-network/provider/vm/creation.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/creation.js +29 -0
- package/internal/hardhat-network/provider/vm/creation.js.map +1 -0
- package/internal/hardhat-network/provider/vm/dual.d.ts +43 -0
- package/internal/hardhat-network/provider/vm/dual.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/dual.js +488 -0
- package/internal/hardhat-network/provider/vm/dual.js.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +56 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js +416 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts +23 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.js +130 -0
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts +99 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.js +284 -0
- package/internal/hardhat-network/provider/vm/rethnet.js.map +1 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +52 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.js +3 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.js.map +1 -0
- package/internal/hardhat-network/stack-traces/compiler-to-model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.js +37 -11
- package/internal/hardhat-network/stack-traces/compiler-to-model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +1 -1
- package/internal/hardhat-network/stack-traces/debug.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +6 -2
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts +1 -0
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +85 -55
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +3 -1
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +9 -1
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +2 -2
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +2 -2
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +1 -0
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +1 -4
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/internal/solidity/compiler/downloader.js +2 -2
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/compiler/index.js +1 -1
- package/internal/solidity/compiler/index.js.map +1 -1
- package/internal/solidity/resolver.d.ts +4 -3
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +18 -7
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/abi-helpers.d.ts +1 -0
- package/internal/util/abi-helpers.d.ts.map +1 -1
- package/internal/util/abi-helpers.js +9 -0
- package/internal/util/abi-helpers.js.map +1 -1
- package/internal/util/download.d.ts.map +1 -1
- package/internal/util/download.js +12 -11
- package/internal/util/download.js.map +1 -1
- package/internal/util/packageInfo.d.ts +6 -1
- package/internal/util/packageInfo.d.ts.map +1 -1
- package/internal/util/packageInfo.js +14 -11
- package/internal/util/packageInfo.js.map +1 -1
- package/internal/util/proxy.d.ts +2 -0
- package/internal/util/proxy.d.ts.map +1 -0
- package/internal/util/proxy.js +19 -0
- package/internal/util/proxy.js.map +1 -0
- package/package.json +9 -10
- package/register.js +1 -4
- package/register.js.map +1 -1
- package/sample-projects/javascript/hardhat.config.js +1 -1
- package/sample-projects/javascript/scripts/deploy.js +2 -2
- package/sample-projects/javascript-esm/LICENSE.md +11 -0
- package/sample-projects/javascript-esm/README.md +13 -0
- package/sample-projects/javascript-esm/contracts/Lock.sol +34 -0
- package/sample-projects/javascript-esm/hardhat.config.cjs +6 -0
- package/sample-projects/javascript-esm/scripts/deploy.js +22 -0
- package/sample-projects/javascript-esm/test/Lock.js +123 -0
- package/sample-projects/typescript/hardhat.config.ts +1 -1
- package/sample-projects/typescript/scripts/deploy.ts +2 -2
- package/sample-projects/typescript/tsconfig.json +2 -1
- package/src/builtin-tasks/compile.ts +28 -7
- package/src/builtin-tasks/flatten.ts +4 -1
- package/src/builtin-tasks/help.ts +15 -16
- package/src/builtin-tasks/task-names.ts +2 -0
- package/src/builtin-tasks/test.ts +30 -2
- package/src/internal/artifacts.ts +947 -0
- package/src/internal/cli/bootstrap.ts +14 -36
- package/src/internal/cli/cli.ts +38 -43
- package/src/internal/cli/project-creation.ts +128 -47
- package/src/internal/cli/prompt.ts +2 -4
- package/src/internal/cli/types.ts +2 -0
- package/src/internal/core/config/config-env.ts +15 -27
- package/src/internal/core/config/config-loading.ts +35 -11
- package/src/internal/core/config/config-validation.ts +20 -0
- package/src/internal/core/config/extenders.ts +6 -15
- package/src/internal/core/errors-list.ts +36 -10
- package/src/internal/core/project-structure.ts +8 -0
- package/src/internal/core/providers/construction.ts +29 -24
- package/src/internal/core/providers/http.ts +38 -26
- package/src/internal/core/runtime-environment.ts +65 -60
- package/src/internal/core/tasks/dsl.ts +17 -17
- package/src/internal/core/tasks/task-definitions.ts +6 -2
- package/src/internal/hardhat-network/jsonrpc/handler.ts +31 -28
- package/src/internal/hardhat-network/provider/modules/evm.ts +15 -3
- package/src/internal/hardhat-network/provider/node-types.ts +1 -1
- package/src/internal/hardhat-network/provider/node.ts +5 -1
- package/src/internal/hardhat-network/provider/provider.ts +60 -49
- package/src/internal/hardhat-network/provider/return-data.ts +2 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +5 -2
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +46 -0
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/compiler-to-model.ts +71 -9
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/debug.ts +9 -2
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +177 -89
- package/src/internal/hardhat-network/stack-traces/model.ts +11 -1
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +3 -0
- package/src/internal/lib/hardhat-lib.ts +1 -6
- package/src/internal/solidity/compiler/downloader.ts +2 -2
- package/src/internal/solidity/compiler/index.ts +1 -1
- package/src/internal/solidity/resolver.ts +28 -11
- package/src/internal/util/abi-helpers.ts +9 -0
- package/src/internal/util/download.ts +13 -15
- package/src/internal/util/packageInfo.ts +24 -10
- package/src/internal/util/proxy.ts +18 -0
- package/src/register.ts +1 -6
- package/src/types/artifacts.ts +14 -112
- package/src/types/config.ts +2 -0
- package/src/types/runtime.ts +16 -13
- package/types/artifacts.d.ts +10 -96
- package/types/artifacts.d.ts.map +1 -1
- package/types/config.d.ts +2 -0
- package/types/config.d.ts.map +1 -1
- package/types/runtime.d.ts +9 -10
- package/types/runtime.d.ts.map +1 -1
- package/internal/artifacts/caching.d.ts +0 -28
- package/internal/artifacts/caching.d.ts.map +0 -1
- package/internal/artifacts/caching.js +0 -178
- package/internal/artifacts/caching.js.map +0 -1
- package/internal/artifacts/index.d.ts +0 -45
- package/internal/artifacts/index.d.ts.map +0 -1
- package/internal/artifacts/index.js +0 -191
- package/internal/artifacts/index.js.map +0 -1
- package/internal/artifacts/mutable.d.ts +0 -29
- package/internal/artifacts/mutable.d.ts.map +0 -1
- package/internal/artifacts/mutable.js +0 -226
- package/internal/artifacts/mutable.js.map +0 -1
- package/internal/artifacts/readonly.d.ts +0 -94
- package/internal/artifacts/readonly.d.ts.map +0 -1
- package/internal/artifacts/readonly.js +0 -343
- package/internal/artifacts/readonly.js.map +0 -1
- package/src/internal/artifacts/caching.ts +0 -259
- package/src/internal/artifacts/index.ts +0 -302
- package/src/internal/artifacts/mutable.ts +0 -330
- package/src/internal/artifacts/readonly.ts +0 -470
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/* eslint "@typescript-eslint/no-non-null-assertion": "error" */
|
|
1
2
|
import { ERROR } from "@nomicfoundation/ethereumjs-evm/dist/exceptions";
|
|
2
3
|
import { defaultAbiCoder as abi } from "@ethersproject/abi";
|
|
3
4
|
import semver from "semver";
|
|
4
5
|
|
|
6
|
+
import { assertHardhatInvariant } from "../../core/errors";
|
|
5
7
|
import { AbiHelpers } from "../../util/abi-helpers";
|
|
6
8
|
import { ReturnData } from "../provider/return-data";
|
|
7
9
|
|
|
@@ -69,13 +71,16 @@ export class ErrorInferrer {
|
|
|
69
71
|
trace.calldata.slice(0, 4)
|
|
70
72
|
);
|
|
71
73
|
|
|
72
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
calledFunction !== undefined &&
|
|
76
|
+
this._isFunctionNotPayableError(trace, calledFunction)
|
|
77
|
+
) {
|
|
73
78
|
return [
|
|
74
79
|
{
|
|
75
80
|
type: StackTraceEntryType.FUNCTION_NOT_PAYABLE_ERROR,
|
|
76
81
|
sourceReference: this._getFunctionStartSourceReference(
|
|
77
82
|
trace,
|
|
78
|
-
calledFunction
|
|
83
|
+
calledFunction
|
|
79
84
|
),
|
|
80
85
|
value: trace.value,
|
|
81
86
|
},
|
|
@@ -197,8 +202,9 @@ export class ErrorInferrer {
|
|
|
197
202
|
stacktrace[i + 2].type === StackTraceEntryType.RETURNDATA_SIZE_ERROR
|
|
198
203
|
) {
|
|
199
204
|
// ! below for tsc. we confirmed existence in the enclosing conditional.
|
|
200
|
-
const thatSrcRef = stacktrace[i + 2].sourceReference
|
|
205
|
+
const thatSrcRef = stacktrace[i + 2].sourceReference;
|
|
201
206
|
if (
|
|
207
|
+
thatSrcRef !== undefined &&
|
|
202
208
|
frame.sourceReference.range[0] === thatSrcRef.range[0] &&
|
|
203
209
|
frame.sourceReference.range[1] === thatSrcRef.range[1] &&
|
|
204
210
|
frame.sourceReference.line === thatSrcRef.line
|
|
@@ -286,7 +292,11 @@ export class ErrorInferrer {
|
|
|
286
292
|
lastSubmessageData.stepIndex
|
|
287
293
|
)
|
|
288
294
|
) {
|
|
289
|
-
const lastFrame = inferredStacktrace.pop()
|
|
295
|
+
const lastFrame = inferredStacktrace.pop();
|
|
296
|
+
assertHardhatInvariant(
|
|
297
|
+
lastFrame !== undefined,
|
|
298
|
+
"Expected inferred stack trace to have at least one frame"
|
|
299
|
+
);
|
|
290
300
|
inferredStacktrace.push({
|
|
291
301
|
type: StackTraceEntryType.CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR,
|
|
292
302
|
sourceReference: lastFrame.sourceReference,
|
|
@@ -421,13 +431,23 @@ export class ErrorInferrer {
|
|
|
421
431
|
);
|
|
422
432
|
} else if (isDecodedCallTrace(trace)) {
|
|
423
433
|
// This is here because of the optimizations
|
|
434
|
+
const functionSelector =
|
|
435
|
+
trace.bytecode.contract.getFunctionFromSelector(
|
|
436
|
+
trace.calldata.slice(0, 4)
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
// in general this shouldn't happen, but it does when viaIR is enabled,
|
|
440
|
+
// "optimizerSteps": "u" is used, and the called function is fallback or
|
|
441
|
+
// receive
|
|
442
|
+
if (functionSelector === undefined) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
424
446
|
inferredStacktrace.push({
|
|
425
447
|
type: StackTraceEntryType.REVERT_ERROR,
|
|
426
448
|
sourceReference: this._getFunctionStartSourceReference(
|
|
427
449
|
trace,
|
|
428
|
-
|
|
429
|
-
trace.calldata.slice(0, 4)
|
|
430
|
-
)!
|
|
450
|
+
functionSelector
|
|
431
451
|
),
|
|
432
452
|
message: new ReturnData(trace.returnData),
|
|
433
453
|
isInvalidOpcodeError: lastInstruction.opcode === Opcode.INVALID,
|
|
@@ -617,15 +637,21 @@ export class ErrorInferrer {
|
|
|
617
637
|
);
|
|
618
638
|
|
|
619
639
|
if (calledFunction !== undefined) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
640
|
+
const isValidCalldata = calledFunction.isValidCalldata(
|
|
641
|
+
trace.calldata.slice(4)
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
if (!isValidCalldata) {
|
|
645
|
+
return [
|
|
646
|
+
{
|
|
647
|
+
type: StackTraceEntryType.INVALID_PARAMS_ERROR,
|
|
648
|
+
sourceReference: this._getFunctionStartSourceReference(
|
|
649
|
+
trace,
|
|
650
|
+
calledFunction
|
|
651
|
+
),
|
|
652
|
+
},
|
|
653
|
+
];
|
|
654
|
+
}
|
|
629
655
|
}
|
|
630
656
|
|
|
631
657
|
if (this._solidity063MaybeUnmappedRevert(trace)) {
|
|
@@ -646,10 +672,17 @@ export class ErrorInferrer {
|
|
|
646
672
|
stacktrace: SolidityStackTrace
|
|
647
673
|
): SolidityStackTrace | undefined {
|
|
648
674
|
if (this._isCalledNonContractAccountError(trace)) {
|
|
675
|
+
const sourceReference = this._getLastSourceReference(trace);
|
|
676
|
+
|
|
677
|
+
// We are sure this is not undefined because there was at least a call instruction
|
|
678
|
+
assertHardhatInvariant(
|
|
679
|
+
sourceReference !== undefined,
|
|
680
|
+
"Expected source reference to be defined"
|
|
681
|
+
);
|
|
682
|
+
|
|
649
683
|
const nonContractCalledFrame: SolidityStackTraceEntry = {
|
|
650
684
|
type: StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR,
|
|
651
|
-
|
|
652
|
-
sourceReference: this._getLastSourceReference(trace)!,
|
|
685
|
+
sourceReference,
|
|
653
686
|
};
|
|
654
687
|
|
|
655
688
|
return [...stacktrace, nonContractCalledFrame];
|
|
@@ -749,12 +782,8 @@ export class ErrorInferrer {
|
|
|
749
782
|
|
|
750
783
|
private _isFunctionNotPayableError(
|
|
751
784
|
trace: DecodedCallMessageTrace,
|
|
752
|
-
calledFunction: ContractFunction
|
|
785
|
+
calledFunction: ContractFunction
|
|
753
786
|
): boolean {
|
|
754
|
-
if (calledFunction === undefined) {
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
787
|
// This error doesn't return data
|
|
759
788
|
if (trace.returnData.length > 0) {
|
|
760
789
|
return false;
|
|
@@ -1057,7 +1086,14 @@ export class ErrorInferrer {
|
|
|
1057
1086
|
continue;
|
|
1058
1087
|
}
|
|
1059
1088
|
|
|
1060
|
-
|
|
1089
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1090
|
+
trace.bytecode,
|
|
1091
|
+
inst.location
|
|
1092
|
+
);
|
|
1093
|
+
|
|
1094
|
+
if (sourceReference !== undefined) {
|
|
1095
|
+
return sourceReference;
|
|
1096
|
+
}
|
|
1061
1097
|
}
|
|
1062
1098
|
|
|
1063
1099
|
return undefined;
|
|
@@ -1105,27 +1141,49 @@ export class ErrorInferrer {
|
|
|
1105
1141
|
trace: DecodedEvmMessageTrace,
|
|
1106
1142
|
inst: Instruction
|
|
1107
1143
|
): RevertErrorStackTraceEntry {
|
|
1144
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1145
|
+
trace.bytecode,
|
|
1146
|
+
inst.location
|
|
1147
|
+
);
|
|
1148
|
+
assertHardhatInvariant(
|
|
1149
|
+
sourceReference !== undefined,
|
|
1150
|
+
"Expected source reference to be defined"
|
|
1151
|
+
);
|
|
1152
|
+
|
|
1108
1153
|
return {
|
|
1109
1154
|
type: StackTraceEntryType.REVERT_ERROR,
|
|
1110
|
-
sourceReference
|
|
1111
|
-
trace.bytecode,
|
|
1112
|
-
inst.location
|
|
1113
|
-
)!,
|
|
1155
|
+
sourceReference,
|
|
1114
1156
|
message: new ReturnData(trace.returnData),
|
|
1115
1157
|
isInvalidOpcodeError: inst.opcode === Opcode.INVALID,
|
|
1116
1158
|
};
|
|
1117
1159
|
}
|
|
1118
1160
|
|
|
1161
|
+
private _instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1162
|
+
trace: DecodedEvmMessageTrace,
|
|
1163
|
+
inst: Instruction
|
|
1164
|
+
): UnmappedSolc063RevertErrorStackTraceEntry {
|
|
1165
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1166
|
+
trace.bytecode,
|
|
1167
|
+
inst.location
|
|
1168
|
+
);
|
|
1169
|
+
|
|
1170
|
+
return {
|
|
1171
|
+
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1172
|
+
sourceReference,
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1119
1176
|
private _instructionWithinFunctionToPanicStackTraceEntry(
|
|
1120
1177
|
trace: DecodedEvmMessageTrace,
|
|
1121
1178
|
inst: Instruction,
|
|
1122
1179
|
errorCode: bigint
|
|
1123
1180
|
): PanicErrorStackTraceEntry {
|
|
1181
|
+
const lastSourceReference = this._getLastSourceReference(trace);
|
|
1124
1182
|
return {
|
|
1125
1183
|
type: StackTraceEntryType.PANIC_ERROR,
|
|
1126
1184
|
sourceReference:
|
|
1127
1185
|
sourceLocationToSourceReference(trace.bytecode, inst.location) ??
|
|
1128
|
-
|
|
1186
|
+
lastSourceReference,
|
|
1129
1187
|
errorCode,
|
|
1130
1188
|
};
|
|
1131
1189
|
}
|
|
@@ -1135,11 +1193,18 @@ export class ErrorInferrer {
|
|
|
1135
1193
|
inst: Instruction,
|
|
1136
1194
|
message: string
|
|
1137
1195
|
): CustomErrorStackTraceEntry {
|
|
1196
|
+
const lastSourceReference = this._getLastSourceReference(trace);
|
|
1197
|
+
|
|
1198
|
+
assertHardhatInvariant(
|
|
1199
|
+
lastSourceReference !== undefined,
|
|
1200
|
+
"Expected last source reference to be defined"
|
|
1201
|
+
);
|
|
1202
|
+
|
|
1138
1203
|
return {
|
|
1139
1204
|
type: StackTraceEntryType.CUSTOM_ERROR,
|
|
1140
1205
|
sourceReference:
|
|
1141
1206
|
sourceLocationToSourceReference(trace.bytecode, inst.location) ??
|
|
1142
|
-
|
|
1207
|
+
lastSourceReference,
|
|
1143
1208
|
message,
|
|
1144
1209
|
};
|
|
1145
1210
|
}
|
|
@@ -1251,16 +1316,16 @@ export class ErrorInferrer {
|
|
|
1251
1316
|
): UnmappedSolc063RevertErrorStackTraceEntry | undefined {
|
|
1252
1317
|
// If we are within a function there's a last valid location. It may
|
|
1253
1318
|
// be the entire contract.
|
|
1254
|
-
const prevInst = this._getLastInstructionWithValidLocation(trace)
|
|
1319
|
+
const prevInst = this._getLastInstructionWithValidLocation(trace);
|
|
1255
1320
|
const lastStep = trace.steps[trace.steps.length - 1] as EvmStep;
|
|
1256
1321
|
const nextInstPc = lastStep.pc + 1;
|
|
1257
1322
|
const hasNextInst = trace.bytecode.hasInstruction(nextInstPc);
|
|
1258
1323
|
|
|
1259
1324
|
if (hasNextInst) {
|
|
1260
1325
|
const nextInst = trace.bytecode.getInstruction(nextInstPc);
|
|
1261
|
-
const prevLoc = prevInst
|
|
1326
|
+
const prevLoc = prevInst?.location;
|
|
1262
1327
|
const nextLoc = nextInst.location;
|
|
1263
|
-
const prevFunc = prevLoc
|
|
1328
|
+
const prevFunc = prevLoc?.getContainingFunction();
|
|
1264
1329
|
const nextFunc = nextLoc?.getContainingFunction();
|
|
1265
1330
|
|
|
1266
1331
|
// This is probably a require. This means that we have the exact
|
|
@@ -1270,37 +1335,31 @@ export class ErrorInferrer {
|
|
|
1270
1335
|
if (
|
|
1271
1336
|
prevFunc !== undefined &&
|
|
1272
1337
|
nextLoc !== undefined &&
|
|
1338
|
+
prevLoc !== undefined &&
|
|
1273
1339
|
prevLoc.equals(nextLoc)
|
|
1274
1340
|
) {
|
|
1275
|
-
return
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
),
|
|
1280
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1281
|
-
};
|
|
1341
|
+
return this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1342
|
+
trace,
|
|
1343
|
+
nextInst
|
|
1344
|
+
);
|
|
1282
1345
|
}
|
|
1283
1346
|
|
|
1284
1347
|
let revertFrame: UnmappedSolc063RevertErrorStackTraceEntry | undefined;
|
|
1285
1348
|
|
|
1286
1349
|
// If the previous and next location don't match, we try to use the
|
|
1287
1350
|
// previous one if it's inside a function, otherwise we use the next one
|
|
1288
|
-
if (prevFunc !== undefined) {
|
|
1289
|
-
revertFrame =
|
|
1290
|
-
|
|
1351
|
+
if (prevFunc !== undefined && prevInst !== undefined) {
|
|
1352
|
+
revertFrame =
|
|
1353
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1291
1354
|
trace,
|
|
1292
1355
|
prevInst
|
|
1293
|
-
)
|
|
1294
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1295
|
-
};
|
|
1356
|
+
);
|
|
1296
1357
|
} else if (nextFunc !== undefined) {
|
|
1297
|
-
revertFrame =
|
|
1298
|
-
|
|
1358
|
+
revertFrame =
|
|
1359
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1299
1360
|
trace,
|
|
1300
1361
|
nextInst
|
|
1301
|
-
)
|
|
1302
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1303
|
-
};
|
|
1362
|
+
);
|
|
1304
1363
|
}
|
|
1305
1364
|
|
|
1306
1365
|
if (revertFrame !== undefined) {
|
|
@@ -1310,18 +1369,15 @@ export class ErrorInferrer {
|
|
|
1310
1369
|
return revertFrame;
|
|
1311
1370
|
}
|
|
1312
1371
|
|
|
1313
|
-
if (isCreateTrace(trace)) {
|
|
1372
|
+
if (isCreateTrace(trace) && prevInst !== undefined) {
|
|
1314
1373
|
// Solidity is smart enough to stop emitting extra instructions after
|
|
1315
1374
|
// an unconditional revert happens in a constructor. If this is the case
|
|
1316
1375
|
// we just return a special error.
|
|
1317
1376
|
const constructorRevertFrame: UnmappedSolc063RevertErrorStackTraceEntry =
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
),
|
|
1323
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1324
|
-
};
|
|
1377
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1378
|
+
trace,
|
|
1379
|
+
prevInst
|
|
1380
|
+
);
|
|
1325
1381
|
|
|
1326
1382
|
// When the latest instruction is not within a function we need
|
|
1327
1383
|
// some default sourceReference to show to the user
|
|
@@ -1349,24 +1405,22 @@ export class ErrorInferrer {
|
|
|
1349
1405
|
return constructorRevertFrame;
|
|
1350
1406
|
}
|
|
1351
1407
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1408
|
+
if (prevInst !== undefined) {
|
|
1409
|
+
// We may as well just be in a function or modifier and just happen
|
|
1410
|
+
// to be at the last instruction of the runtime bytecode.
|
|
1411
|
+
// In this case we just return whatever the last mapped intruction
|
|
1412
|
+
// points to.
|
|
1413
|
+
const latestInstructionRevertFrame: UnmappedSolc063RevertErrorStackTraceEntry =
|
|
1414
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1359
1415
|
trace,
|
|
1360
1416
|
prevInst
|
|
1361
|
-
)
|
|
1362
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1363
|
-
};
|
|
1417
|
+
);
|
|
1364
1418
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1419
|
+
if (latestInstructionRevertFrame.sourceReference !== undefined) {
|
|
1420
|
+
this._solidity063CorrectLineNumber(latestInstructionRevertFrame);
|
|
1421
|
+
}
|
|
1422
|
+
return latestInstructionRevertFrame;
|
|
1367
1423
|
}
|
|
1368
|
-
|
|
1369
|
-
return latestInstructionRevertFrame;
|
|
1370
1424
|
}
|
|
1371
1425
|
|
|
1372
1426
|
private _isContractTooLargeError(trace: DecodedCreateMessageTrace) {
|
|
@@ -1376,6 +1430,10 @@ export class ErrorInferrer {
|
|
|
1376
1430
|
private _solidity063CorrectLineNumber(
|
|
1377
1431
|
revertFrame: UnmappedSolc063RevertErrorStackTraceEntry
|
|
1378
1432
|
) {
|
|
1433
|
+
if (revertFrame.sourceReference === undefined) {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1379
1437
|
const lines = revertFrame.sourceReference.sourceContent.split("\n");
|
|
1380
1438
|
|
|
1381
1439
|
const currentLine = lines[revertFrame.sourceReference.line - 1];
|
|
@@ -1443,13 +1501,19 @@ export class ErrorInferrer {
|
|
|
1443
1501
|
bytecode: Bytecode,
|
|
1444
1502
|
callInst: Instruction
|
|
1445
1503
|
): CallFailedErrorStackTraceEntry {
|
|
1504
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1505
|
+
bytecode,
|
|
1506
|
+
callInst.location
|
|
1507
|
+
);
|
|
1508
|
+
assertHardhatInvariant(
|
|
1509
|
+
sourceReference !== undefined,
|
|
1510
|
+
"Expected source reference to be defined"
|
|
1511
|
+
);
|
|
1512
|
+
|
|
1446
1513
|
// Calls only happen within functions
|
|
1447
1514
|
return {
|
|
1448
1515
|
type: StackTraceEntryType.CALL_FAILED_ERROR,
|
|
1449
|
-
sourceReference
|
|
1450
|
-
bytecode,
|
|
1451
|
-
callInst.location
|
|
1452
|
-
)!,
|
|
1516
|
+
sourceReference,
|
|
1453
1517
|
};
|
|
1454
1518
|
}
|
|
1455
1519
|
|
|
@@ -1498,10 +1562,16 @@ export class ErrorInferrer {
|
|
|
1498
1562
|
const callOpcodeStep = trace.steps[callSubtraceStepIndex - 1] as EvmStep;
|
|
1499
1563
|
const callInst = trace.bytecode.getInstruction(callOpcodeStep.pc);
|
|
1500
1564
|
|
|
1565
|
+
// Calls are always made from within functions
|
|
1566
|
+
assertHardhatInvariant(
|
|
1567
|
+
callInst.location !== undefined,
|
|
1568
|
+
"Expected call instruction location to be defined"
|
|
1569
|
+
);
|
|
1570
|
+
|
|
1501
1571
|
return this._isLastLocation(
|
|
1502
1572
|
trace,
|
|
1503
1573
|
callSubtraceStepIndex + 1,
|
|
1504
|
-
callInst.location
|
|
1574
|
+
callInst.location
|
|
1505
1575
|
);
|
|
1506
1576
|
}
|
|
1507
1577
|
|
|
@@ -1510,7 +1580,14 @@ export class ErrorInferrer {
|
|
|
1510
1580
|
instIndex: number,
|
|
1511
1581
|
callInstruction: Instruction
|
|
1512
1582
|
): boolean {
|
|
1513
|
-
const callLocation = callInstruction.location
|
|
1583
|
+
const callLocation = callInstruction.location;
|
|
1584
|
+
|
|
1585
|
+
// Calls are always made from within functions
|
|
1586
|
+
assertHardhatInvariant(
|
|
1587
|
+
callLocation !== undefined,
|
|
1588
|
+
"Expected call location to be defined"
|
|
1589
|
+
);
|
|
1590
|
+
|
|
1514
1591
|
return this._isLastLocation(trace, instIndex, callLocation);
|
|
1515
1592
|
}
|
|
1516
1593
|
|
|
@@ -1681,30 +1758,41 @@ export function instructionToCallstackStackTraceEntry(
|
|
|
1681
1758
|
};
|
|
1682
1759
|
}
|
|
1683
1760
|
|
|
1684
|
-
const func = inst.location
|
|
1761
|
+
const func = inst.location?.getContainingFunction();
|
|
1685
1762
|
|
|
1686
1763
|
if (func !== undefined) {
|
|
1764
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1765
|
+
bytecode,
|
|
1766
|
+
inst.location
|
|
1767
|
+
);
|
|
1768
|
+
assertHardhatInvariant(
|
|
1769
|
+
sourceReference !== undefined,
|
|
1770
|
+
"Expected source reference to be defined"
|
|
1771
|
+
);
|
|
1772
|
+
|
|
1687
1773
|
return {
|
|
1688
1774
|
type: StackTraceEntryType.CALLSTACK_ENTRY,
|
|
1689
|
-
sourceReference
|
|
1690
|
-
bytecode,
|
|
1691
|
-
inst.location
|
|
1692
|
-
)!,
|
|
1775
|
+
sourceReference,
|
|
1693
1776
|
functionType: func.type,
|
|
1694
1777
|
};
|
|
1695
1778
|
}
|
|
1696
1779
|
|
|
1780
|
+
assertHardhatInvariant(
|
|
1781
|
+
inst.location !== undefined,
|
|
1782
|
+
"Expected instruction location to be defined"
|
|
1783
|
+
);
|
|
1784
|
+
|
|
1697
1785
|
return {
|
|
1698
1786
|
type: StackTraceEntryType.CALLSTACK_ENTRY,
|
|
1699
1787
|
sourceReference: {
|
|
1700
1788
|
function: undefined,
|
|
1701
1789
|
contract: bytecode.contract.name,
|
|
1702
|
-
sourceName: inst.location
|
|
1703
|
-
sourceContent: inst.location
|
|
1704
|
-
line: inst.location
|
|
1790
|
+
sourceName: inst.location.file.sourceName,
|
|
1791
|
+
sourceContent: inst.location.file.content,
|
|
1792
|
+
line: inst.location.getStartingLineNumber(),
|
|
1705
1793
|
range: [
|
|
1706
|
-
inst.location
|
|
1707
|
-
inst.location
|
|
1794
|
+
inst.location.offset,
|
|
1795
|
+
inst.location.offset + inst.location.length,
|
|
1708
1796
|
],
|
|
1709
1797
|
},
|
|
1710
1798
|
functionType: ContractFunctionType.FUNCTION,
|
|
@@ -261,12 +261,22 @@ export class ContractFunction {
|
|
|
261
261
|
public readonly contract?: Contract,
|
|
262
262
|
public readonly visibility?: ContractFunctionVisibility,
|
|
263
263
|
public readonly isPayable?: boolean,
|
|
264
|
-
public selector?: Buffer
|
|
264
|
+
public selector?: Buffer,
|
|
265
|
+
public readonly paramTypes?: any[]
|
|
265
266
|
) {
|
|
266
267
|
if (contract !== undefined && !contract.location.contains(location)) {
|
|
267
268
|
throw new Error("Incompatible contract and function location");
|
|
268
269
|
}
|
|
269
270
|
}
|
|
271
|
+
|
|
272
|
+
public isValidCalldata(calldata: Buffer): boolean {
|
|
273
|
+
if (this.paramTypes === undefined) {
|
|
274
|
+
// if we don't know the param types, we just assume that the call is valid
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return AbiHelpers.isValidCalldata(this.paramTypes, calldata);
|
|
279
|
+
}
|
|
270
280
|
}
|
|
271
281
|
|
|
272
282
|
export class CustomError {
|
|
@@ -112,7 +112,6 @@ function encodeStackTraceEntry(
|
|
|
112
112
|
|
|
113
113
|
case StackTraceEntryType.CALLSTACK_ENTRY:
|
|
114
114
|
case StackTraceEntryType.REVERT_ERROR:
|
|
115
|
-
case StackTraceEntryType.PANIC_ERROR:
|
|
116
115
|
case StackTraceEntryType.CUSTOM_ERROR:
|
|
117
116
|
case StackTraceEntryType.FUNCTION_NOT_PAYABLE_ERROR:
|
|
118
117
|
case StackTraceEntryType.INVALID_PARAMS_ERROR:
|
|
@@ -122,7 +121,6 @@ function encodeStackTraceEntry(
|
|
|
122
121
|
case StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR:
|
|
123
122
|
case StackTraceEntryType.CALL_FAILED_ERROR:
|
|
124
123
|
case StackTraceEntryType.DIRECT_LIBRARY_CALL_ERROR:
|
|
125
|
-
case StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR:
|
|
126
124
|
return sourceReferenceToSolidityCallsite(stackTraceEntry.sourceReference);
|
|
127
125
|
|
|
128
126
|
case StackTraceEntryType.UNRECOGNIZED_CREATE_CALLSTACK_ENTRY:
|
|
@@ -188,6 +186,8 @@ function encodeStackTraceEntry(
|
|
|
188
186
|
|
|
189
187
|
case StackTraceEntryType.OTHER_EXECUTION_ERROR:
|
|
190
188
|
case StackTraceEntryType.CONTRACT_TOO_LARGE_ERROR:
|
|
189
|
+
case StackTraceEntryType.PANIC_ERROR:
|
|
190
|
+
case StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR:
|
|
191
191
|
if (stackTraceEntry.sourceReference === undefined) {
|
|
192
192
|
return new SolidityCallSite(
|
|
193
193
|
undefined,
|
|
@@ -81,7 +81,7 @@ export interface RevertErrorStackTraceEntry {
|
|
|
81
81
|
export interface PanicErrorStackTraceEntry {
|
|
82
82
|
type: StackTraceEntryType.PANIC_ERROR;
|
|
83
83
|
errorCode: bigint;
|
|
84
|
-
sourceReference
|
|
84
|
+
sourceReference?: SourceReference;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export interface CustomErrorStackTraceEntry {
|
|
@@ -93,7 +93,7 @@ export interface CustomErrorStackTraceEntry {
|
|
|
93
93
|
|
|
94
94
|
export interface UnmappedSolc063RevertErrorStackTraceEntry {
|
|
95
95
|
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR;
|
|
96
|
-
sourceReference
|
|
96
|
+
sourceReference?: SourceReference;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface FunctionNotPayableErrorStackTraceEntry {
|
|
@@ -171,7 +171,10 @@ export class SolidityTracer {
|
|
|
171
171
|
const stacktrace: SolidityStackTrace = [];
|
|
172
172
|
|
|
173
173
|
let subtracesSeen = 0;
|
|
174
|
+
|
|
175
|
+
// There was a jump into a function according to the sourcemaps
|
|
174
176
|
let jumpedIntoFunction = false;
|
|
177
|
+
|
|
175
178
|
const functionJumpdests: Instruction[] = [];
|
|
176
179
|
|
|
177
180
|
let lastSubmessageData: SubmessageData | undefined;
|
|
@@ -36,16 +36,11 @@ if (HardhatContext.isCreated()) {
|
|
|
36
36
|
|
|
37
37
|
const { resolvedConfig, userConfig } = loadConfigAndTasks(hardhatArguments);
|
|
38
38
|
|
|
39
|
-
const artifactsExtensions = ctx.extendersManager
|
|
40
|
-
.getArtifactsExtenders()
|
|
41
|
-
.map((artifactsExtender) => artifactsExtender(resolvedConfig));
|
|
42
|
-
|
|
43
39
|
env = new Environment(
|
|
44
40
|
resolvedConfig,
|
|
45
41
|
hardhatArguments,
|
|
46
42
|
ctx.tasksDSL.getTaskDefinitions(),
|
|
47
|
-
ctx.extendersManager.
|
|
48
|
-
artifactsExtensions,
|
|
43
|
+
ctx.extendersManager.getExtenders(),
|
|
49
44
|
ctx.experimentalHardhatNetworkMessageTraceHooks,
|
|
50
45
|
userConfig
|
|
51
46
|
);
|
|
@@ -294,7 +294,7 @@ export class CompilerDownloader implements ICompilerDownloader {
|
|
|
294
294
|
build: CompilerBuild,
|
|
295
295
|
downloadPath: string
|
|
296
296
|
): Promise<boolean> {
|
|
297
|
-
const ethereumjsUtil =
|
|
297
|
+
const ethereumjsUtil = require("@nomicfoundation/ethereumjs-util");
|
|
298
298
|
const { keccak256 } = await import("../../util/keccak");
|
|
299
299
|
|
|
300
300
|
const expectedKeccak256 = build.keccak256;
|
|
@@ -328,7 +328,7 @@ export class CompilerDownloader implements ICompilerDownloader {
|
|
|
328
328
|
downloadPath.endsWith(".zip")
|
|
329
329
|
) {
|
|
330
330
|
// some window builds are zipped, some are not
|
|
331
|
-
const
|
|
331
|
+
const AdmZip = require("adm-zip");
|
|
332
332
|
|
|
333
333
|
const solcFolder = path.join(this._compilersDir, build.version);
|
|
334
334
|
await fsExtra.ensureDir(solcFolder);
|
|
@@ -25,7 +25,7 @@ export class Compiler implements ICompiler {
|
|
|
25
25
|
return this._loadedSolc;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const solcWrapper = require("solc/wrapper");
|
|
29
29
|
this._loadedSolc = solcWrapper(
|
|
30
30
|
this._loadCompilerSources(this._pathToSolcJs)
|
|
31
31
|
);
|
|
@@ -69,7 +69,10 @@ export class Resolver {
|
|
|
69
69
|
constructor(
|
|
70
70
|
private readonly _projectRoot: string,
|
|
71
71
|
private readonly _parser: Parser,
|
|
72
|
-
private readonly _readFile: (absolutePath: string) => Promise<string
|
|
72
|
+
private readonly _readFile: (absolutePath: string) => Promise<string>,
|
|
73
|
+
private readonly _transformImportName: (
|
|
74
|
+
importName: string
|
|
75
|
+
) => Promise<string>
|
|
73
76
|
) {}
|
|
74
77
|
|
|
75
78
|
/**
|
|
@@ -100,12 +103,14 @@ export class Resolver {
|
|
|
100
103
|
/**
|
|
101
104
|
* Resolves an import from an already resolved file.
|
|
102
105
|
* @param from The file were the import statement is present.
|
|
103
|
-
* @param
|
|
106
|
+
* @param importName The path in the import statement.
|
|
104
107
|
*/
|
|
105
108
|
public async resolveImport(
|
|
106
109
|
from: ResolvedFile,
|
|
107
|
-
|
|
110
|
+
importName: string
|
|
108
111
|
): Promise<ResolvedFile> {
|
|
112
|
+
const imported = await this._transformImportName(importName);
|
|
113
|
+
|
|
109
114
|
const scheme = this._getUriScheme(imported);
|
|
110
115
|
if (scheme !== undefined) {
|
|
111
116
|
throw new HardhatError(ERRORS.RESOLVER.INVALID_IMPORT_PROTOCOL, {
|
|
@@ -182,14 +187,26 @@ export class Resolver {
|
|
|
182
187
|
ERRORS.RESOLVER.LIBRARY_FILE_NOT_FOUND
|
|
183
188
|
)
|
|
184
189
|
) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
if (imported !== importName) {
|
|
191
|
+
throw new HardhatError(
|
|
192
|
+
ERRORS.RESOLVER.IMPORTED_MAPPED_FILE_NOT_FOUND,
|
|
193
|
+
{
|
|
194
|
+
imported,
|
|
195
|
+
importName,
|
|
196
|
+
from: from.sourceName,
|
|
197
|
+
},
|
|
198
|
+
error
|
|
199
|
+
);
|
|
200
|
+
} else {
|
|
201
|
+
throw new HardhatError(
|
|
202
|
+
ERRORS.RESOLVER.IMPORTED_FILE_NOT_FOUND,
|
|
203
|
+
{
|
|
204
|
+
imported,
|
|
205
|
+
from: from.sourceName,
|
|
206
|
+
},
|
|
207
|
+
error
|
|
208
|
+
);
|
|
209
|
+
}
|
|
193
210
|
}
|
|
194
211
|
|
|
195
212
|
if (
|