hardhat 2.12.2 → 2.13.0-dev.1
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/artifacts/caching.d.ts +27 -0
- package/internal/artifacts/caching.d.ts.map +1 -0
- package/internal/artifacts/caching.js +167 -0
- package/internal/artifacts/caching.js.map +1 -0
- package/internal/artifacts/index.d.ts +44 -0
- package/internal/artifacts/index.d.ts.map +1 -0
- package/internal/artifacts/index.js +187 -0
- package/internal/artifacts/index.js.map +1 -0
- package/internal/artifacts/mutable.d.ts +29 -0
- package/internal/artifacts/mutable.d.ts.map +1 -0
- package/internal/artifacts/mutable.js +226 -0
- package/internal/artifacts/mutable.js.map +1 -0
- package/internal/artifacts/readonly.d.ts +88 -0
- package/internal/artifacts/readonly.d.ts.map +1 -0
- package/internal/artifacts/readonly.js +324 -0
- package/internal/artifacts/readonly.js.map +1 -0
- package/internal/cli/cli.js +5 -2
- package/internal/cli/cli.js.map +1 -1
- package/internal/core/config/config-env.d.ts +7 -1
- package/internal/core/config/config-env.d.ts.map +1 -1
- package/internal/core/config/config-env.js +13 -2
- package/internal/core/config/config-env.js.map +1 -1
- package/internal/core/config/extenders.d.ts +7 -4
- package/internal/core/config/extenders.d.ts.map +1 -1
- package/internal/core/config/extenders.js +12 -5
- package/internal/core/config/extenders.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/runtime-environment.d.ts +2 -2
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +2 -2
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/hardhat-network/provider/utils/bloom.d.ts +28 -0
- package/internal/hardhat-network/provider/utils/bloom.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/bloom.js +73 -0
- package/internal/hardhat-network/provider/utils/bloom.js.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +29 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js +214 -0
- package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +1 -0
- package/internal/hardhat-network/provider/vm/block-builder.d.ts +30 -0
- package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/block-builder.js +147 -0
- package/internal/hardhat-network/provider/vm/block-builder.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 +120 -0
- package/internal/hardhat-network/provider/vm/dual.js.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +55 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js +272 -0
- package/internal/hardhat-network/provider/vm/ethereumjs.js.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts +111 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.js +171 -0
- package/internal/hardhat-network/provider/vm/rethnet.js.map +1 -0
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +36 -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/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +4 -1
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/package.json +1 -1
- package/register.js +4 -1
- package/register.js.map +1 -1
- package/src/internal/artifacts/caching.ts +239 -0
- package/src/internal/artifacts/index.ts +296 -0
- package/src/internal/artifacts/mutable.ts +330 -0
- package/src/internal/artifacts/readonly.ts +438 -0
- package/src/internal/cli/cli.ts +6 -1
- package/src/internal/core/config/config-env.ts +13 -1
- package/src/internal/core/config/extenders.ts +15 -6
- package/src/internal/core/errors-list.ts +9 -0
- package/src/internal/core/runtime-environment.ts +3 -1
- package/src/internal/lib/hardhat-lib.ts +6 -1
- package/src/register.ts +6 -1
- package/src/types/artifacts.ts +104 -3
- package/src/types/runtime.ts +7 -1
- package/types/artifacts.d.ts +90 -3
- package/types/artifacts.d.ts.map +1 -1
- package/types/runtime.d.ts +6 -1
- package/types/runtime.d.ts.map +1 -1
- package/src/internal/artifacts.ts +0 -918
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { EVMResult, InterpreterStep, Message } from "@nomicfoundation/ethereumjs-evm";
|
|
3
|
+
import type { RunTxResult } from "@nomicfoundation/ethereumjs-vm";
|
|
4
|
+
import type { Block } from "@nomicfoundation/ethereumjs-block";
|
|
5
|
+
import type { Common } from "@nomicfoundation/ethereumjs-common";
|
|
6
|
+
import type { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
|
7
|
+
import type { Account, Address } from "@nomicfoundation/ethereumjs-util";
|
|
8
|
+
import type { RpcDebugTracingConfig } from "../../../core/jsonrpc/types/input/debugTraceTransaction";
|
|
9
|
+
import type { RpcDebugTraceOutput } from "../output";
|
|
10
|
+
export interface VMAdapter {
|
|
11
|
+
dryRun(tx: TypedTransaction, blockContext: Block, forceBaseFeeZero?: boolean): Promise<RunTxResult>;
|
|
12
|
+
getCommon(): Common;
|
|
13
|
+
isEip1559Active(blockNumberOrPending?: bigint | "pending"): boolean;
|
|
14
|
+
getAccount(address: Address): Promise<Account>;
|
|
15
|
+
getContractStorage(address: Address, key: Buffer): Promise<Buffer>;
|
|
16
|
+
getContractCode(address: Address): Promise<Buffer>;
|
|
17
|
+
putAccount(address: Address, account: Account): Promise<void>;
|
|
18
|
+
putContractCode(address: Address, value: Buffer): Promise<void>;
|
|
19
|
+
putContractStorage(address: Address, key: Buffer, value: Buffer): Promise<void>;
|
|
20
|
+
getStateRoot(): Promise<Buffer>;
|
|
21
|
+
setBlockContext(block: Block, irregularStateOrUndefined: Buffer | undefined): Promise<void>;
|
|
22
|
+
restoreContext(stateRoot: Buffer): Promise<void>;
|
|
23
|
+
startBlock(): Promise<void>;
|
|
24
|
+
runTxInBlock(tx: TypedTransaction, block: Block): Promise<RunTxResult>;
|
|
25
|
+
addBlockRewards(rewards: Array<[Address, bigint]>): Promise<void>;
|
|
26
|
+
sealBlock(): Promise<void>;
|
|
27
|
+
revertBlock(): Promise<void>;
|
|
28
|
+
traceTransaction(hash: Buffer, block: Block, config: RpcDebugTracingConfig): Promise<RpcDebugTraceOutput>;
|
|
29
|
+
enableTracing(callbacks: {
|
|
30
|
+
beforeMessage: (message: Message, next: any) => Promise<void>;
|
|
31
|
+
step: (step: InterpreterStep, next: any) => Promise<void>;
|
|
32
|
+
afterMessage: (result: EVMResult, next: any) => Promise<void>;
|
|
33
|
+
}): void;
|
|
34
|
+
disableTracing(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=vm-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm-adapter.d.ts","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/vm-adapter.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACR,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE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AgB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACvE,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAG7B,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,aAAa,CAAC,SAAS,EAAE;QACvB,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,YAAY,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/D,GAAG,IAAI,CAAC;IACT,cAAc,IAAI,IAAI,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm-adapter.js","sourceRoot":"","sources":["../../../../src/internal/hardhat-network/provider/vm/vm-adapter.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardhat-lib.d.ts","sourceRoot":"","sources":["../../src/internal/lib/hardhat-lib.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAUxD,QAAA,IAAI,GAAG,EAAE,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"hardhat-lib.d.ts","sourceRoot":"","sources":["../../src/internal/lib/hardhat-lib.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAUxD,QAAA,IAAI,GAAG,EAAE,yBAAyB,CAAC;AA2CnC,SAAS,GAAG,CAAC"}
|
|
@@ -28,7 +28,10 @@ else {
|
|
|
28
28
|
debug_1.default.enable("hardhat*");
|
|
29
29
|
}
|
|
30
30
|
const { resolvedConfig, userConfig } = (0, config_loading_1.loadConfigAndTasks)(hardhatArguments);
|
|
31
|
-
|
|
31
|
+
const artifactsExtensions = ctx.extendersManager
|
|
32
|
+
.getArtifactsExtenders()
|
|
33
|
+
.map((artifactsExtender) => artifactsExtender(resolvedConfig));
|
|
34
|
+
env = new runtime_environment_1.Environment(resolvedConfig, hardhatArguments, ctx.tasksDSL.getTaskDefinitions(), ctx.extendersManager.getEnvironmentExtenders(), artifactsExtensions, ctx.experimentalHardhatNetworkMessageTraceHooks, userConfig);
|
|
32
35
|
ctx.setHardhatRuntimeEnvironment(env);
|
|
33
36
|
}
|
|
34
37
|
module.exports = env;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hardhat-lib.js","sourceRoot":"","sources":["../../src/internal/lib/hardhat-lib.ts"],"names":[],"mappings":";;;;AAAA,kDAA0B;AAG1B,wCAA4C;AAC5C,kEAAmE;AACnE,2CAA8C;AAC9C,qDAA6C;AAC7C,gEAAsE;AACtE,kEAA0E;AAC1E,qEAA0D;AAE1D,IAAI,GAAmB,CAAC;AACxB,IAAI,GAA8B,CAAC;AAEnC,IAAI,wBAAc,CAAC,SAAS,EAAE,EAAE;IAC9B,GAAG,GAAG,wBAAc,CAAC,iBAAiB,EAAE,CAAC;IAEzC,6EAA6E;IAC7E,uBAAuB;IACvB,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE;QACjC,MAAM,IAAI,qBAAY,CAAC,oBAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;KACrE;IAED,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC;CACv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AAE;QAC5B,eAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC1B;IAED,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAA,mCAAkB,EAAC,gBAAgB,CAAC,CAAC;IAE5E,MAAM,mBAAmB,GAAG,GAAG,CAAC,gBAAgB;SAC7C,qBAAqB,EAAE;SACvB,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC;IAEjE,GAAG,GAAG,IAAI,iCAAW,CACnB,cAAc,EACd,gBAAgB,EAChB,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,EACjC,GAAG,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,EAC9C,mBAAmB,EACnB,GAAG,CAAC,2CAA2C,EAC/C,UAAU,CACX,CAAC;IAEF,GAAG,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC;CACvC;AAED,iBAAS,GAAG,CAAC"}
|
package/package.json
CHANGED
package/register.js
CHANGED
|
@@ -25,7 +25,10 @@ if (!context_1.HardhatContext.isCreated()) {
|
|
|
25
25
|
(0, typescript_support_1.loadTsNode)(hardhatArguments.tsconfig, hardhatArguments.typecheck);
|
|
26
26
|
}
|
|
27
27
|
const { resolvedConfig, userConfig } = (0, config_loading_1.loadConfigAndTasks)(hardhatArguments);
|
|
28
|
-
const
|
|
28
|
+
const artifactsExtensions = ctx.extendersManager
|
|
29
|
+
.getArtifactsExtenders()
|
|
30
|
+
.map((artifactsExtender) => artifactsExtender(resolvedConfig));
|
|
31
|
+
const env = new runtime_environment_1.Environment(resolvedConfig, hardhatArguments, ctx.tasksDSL.getTaskDefinitions(), ctx.extendersManager.getEnvironmentExtenders(), artifactsExtensions, ctx.experimentalHardhatNetworkMessageTraceHooks, userConfig);
|
|
29
32
|
ctx.setHardhatRuntimeEnvironment(env);
|
|
30
33
|
env.injectToGlobal();
|
|
31
34
|
}
|
package/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,gDAAoD;AACpD,0EAA2E;AAC3E,wEAA8E;AAC9E,0EAAkF;AAClF,6EAAkE;AAClE,2EAG4C;AAC5C,qDAGiC;AAEjC,IAAI,CAAC,wBAAc,CAAC,SAAS,EAAE,EAAE;IAC/B,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAEvC,MAAM,GAAG,GAAG,wBAAc,CAAC,oBAAoB,EAAE,CAAC;IAElD,IAAI,IAAA,oCAA0B,GAAE,EAAE;QAChC,IAAA,oCAA0B,GAAE,CAAC;KAC9B;IAED,MAAM,gBAAgB,GAAG,IAAA,sCAAsB,EAC7C,0CAAyB,EACzB,OAAO,CAAC,GAAG,CACZ,CAAC;IAEF,IAAI,gBAAgB,CAAC,OAAO,EAAE;QAC5B,eAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC1B;IAED,IAAI,IAAA,0CAAqB,EAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE;QAClD,IAAA,+BAAU,EAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACnE;IAED,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAA,mCAAkB,EAAC,gBAAgB,CAAC,CAAC;IAE5E,MAAM,GAAG,GAAG,IAAI,iCAAW,CACzB,cAAc,EACd,gBAAgB,EAChB,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,EACjC,GAAG,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["src/register.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,gDAAoD;AACpD,0EAA2E;AAC3E,wEAA8E;AAC9E,0EAAkF;AAClF,6EAAkE;AAClE,2EAG4C;AAC5C,qDAGiC;AAEjC,IAAI,CAAC,wBAAc,CAAC,SAAS,E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
+
CompilerOutput,
|
|
7
|
+
} from "../../types";
|
|
8
|
+
|
|
9
|
+
import { MutableSource } from "./mutable";
|
|
10
|
+
|
|
11
|
+
interface Cache {
|
|
12
|
+
artifactPaths?: string[];
|
|
13
|
+
debugFilePaths?: string[];
|
|
14
|
+
buildInfoPaths?: string[];
|
|
15
|
+
artifactNameToArtifactPathCache: Map<string, string>;
|
|
16
|
+
artifactFQNToBuildInfoPathCache: Map<string, string>;
|
|
17
|
+
artifactNameToArtifact: Map<string, Artifact>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class CachingSource extends MutableSource implements ArtifactsSource {
|
|
21
|
+
// Undefined means that the cache is disabled.
|
|
22
|
+
private _cache?: Cache = {
|
|
23
|
+
artifactNameToArtifactPathCache: new Map(),
|
|
24
|
+
artifactFQNToBuildInfoPathCache: new Map(),
|
|
25
|
+
artifactNameToArtifact: new Map(),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
constructor(artifactsPath: string) {
|
|
29
|
+
super(artifactsPath);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public async readArtifact(name: string): Promise<Artifact | undefined> {
|
|
33
|
+
const cached = this._cache?.artifactNameToArtifact.get(name);
|
|
34
|
+
if (cached !== undefined) {
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const artifact = await super.readArtifact(name);
|
|
39
|
+
if (artifact === undefined) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this._cache?.artifactNameToArtifact.set(name, artifact);
|
|
44
|
+
|
|
45
|
+
return artifact;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public readArtifactSync(name: string): Artifact | undefined {
|
|
49
|
+
const cached = this._cache?.artifactNameToArtifact.get(name);
|
|
50
|
+
if (cached !== undefined) {
|
|
51
|
+
return cached;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const artifact = super.readArtifactSync(name);
|
|
55
|
+
if (artifact === undefined) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this._cache?.artifactNameToArtifact.set(name, artifact);
|
|
60
|
+
|
|
61
|
+
return artifact;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public async getBuildInfo(
|
|
65
|
+
fullyQualifiedName: string
|
|
66
|
+
): Promise<BuildInfo | undefined> {
|
|
67
|
+
let buildInfoPath =
|
|
68
|
+
this._cache?.artifactFQNToBuildInfoPathCache.get(fullyQualifiedName);
|
|
69
|
+
|
|
70
|
+
if (buildInfoPath === undefined) {
|
|
71
|
+
buildInfoPath = await super._getBuildInfoPath(fullyQualifiedName);
|
|
72
|
+
|
|
73
|
+
if (buildInfoPath === undefined) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this._cache?.artifactFQNToBuildInfoPathCache.set(
|
|
78
|
+
fullyQualifiedName,
|
|
79
|
+
buildInfoPath
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return super._getBuildInfoByPath(buildInfoPath);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async getArtifactPaths(): Promise<string[]> {
|
|
87
|
+
const cached = this._cache?.artifactPaths;
|
|
88
|
+
if (cached !== undefined) {
|
|
89
|
+
return cached;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const artifactPaths = await super.getArtifactPaths();
|
|
93
|
+
|
|
94
|
+
if (this._cache !== undefined) {
|
|
95
|
+
this._cache.artifactPaths = artifactPaths;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return artifactPaths;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public async getBuildInfoPaths(): Promise<string[]> {
|
|
102
|
+
const cached = this._cache?.buildInfoPaths;
|
|
103
|
+
if (cached !== undefined) {
|
|
104
|
+
return cached;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const buildInfoPaths = await super.getBuildInfoPaths();
|
|
108
|
+
|
|
109
|
+
if (this._cache !== undefined) {
|
|
110
|
+
this._cache.buildInfoPaths = buildInfoPaths;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return buildInfoPaths;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public async getDebugFilePaths(): Promise<string[]> {
|
|
117
|
+
const cached = this._cache?.debugFilePaths;
|
|
118
|
+
if (cached !== undefined) {
|
|
119
|
+
return cached;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const debugFilePaths = await super.getDebugFilePaths();
|
|
123
|
+
|
|
124
|
+
if (this._cache !== undefined) {
|
|
125
|
+
this._cache.debugFilePaths = debugFilePaths;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return debugFilePaths;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async saveArtifactAndDebugFile(
|
|
132
|
+
artifact: Artifact,
|
|
133
|
+
pathToBuildInfo?: string
|
|
134
|
+
) {
|
|
135
|
+
try {
|
|
136
|
+
await super.saveArtifactAndDebugFile(artifact, pathToBuildInfo);
|
|
137
|
+
} finally {
|
|
138
|
+
this.clearCache();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public async saveBuildInfo(
|
|
143
|
+
solcVersion: string,
|
|
144
|
+
solcLongVersion: string,
|
|
145
|
+
input: CompilerInput,
|
|
146
|
+
output: CompilerOutput
|
|
147
|
+
): Promise<string> {
|
|
148
|
+
try {
|
|
149
|
+
return await super.saveBuildInfo(
|
|
150
|
+
solcVersion,
|
|
151
|
+
solcLongVersion,
|
|
152
|
+
input,
|
|
153
|
+
output
|
|
154
|
+
);
|
|
155
|
+
} finally {
|
|
156
|
+
this.clearCache();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Remove all artifacts that don't correspond to the current solidity files
|
|
162
|
+
*/
|
|
163
|
+
public async removeObsoleteArtifacts() {
|
|
164
|
+
// We clear the cache here, as we want to be sure this runs correctly
|
|
165
|
+
this.clearCache();
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
await super.removeObsoleteArtifacts();
|
|
169
|
+
} finally {
|
|
170
|
+
// We clear the cache here, as this may have non-existent paths now
|
|
171
|
+
this.clearCache();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public clearCache() {
|
|
176
|
+
// Avoid accidentally re-enabling the cache
|
|
177
|
+
if (this._cache === undefined) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this._cache = {
|
|
182
|
+
artifactFQNToBuildInfoPathCache: new Map(),
|
|
183
|
+
artifactNameToArtifactPathCache: new Map(),
|
|
184
|
+
artifactNameToArtifact: new Map(),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public disableCache() {
|
|
189
|
+
this._cache = undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
protected async _getArtifactPath(name: string): Promise<string | undefined> {
|
|
193
|
+
const cached = this._cache?.artifactNameToArtifactPathCache.get(name);
|
|
194
|
+
if (cached !== undefined) {
|
|
195
|
+
return cached;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const result = await super._getArtifactPath(name);
|
|
199
|
+
if (result === undefined) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this._cache?.artifactNameToArtifactPathCache.set(name, result);
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
protected _getArtifactPathsSync(): string[] {
|
|
208
|
+
const cached = this._cache?.artifactPaths;
|
|
209
|
+
if (cached !== undefined) {
|
|
210
|
+
return cached;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const result = super._getArtifactPathsSync();
|
|
214
|
+
|
|
215
|
+
if (this._cache !== undefined) {
|
|
216
|
+
this._cache.artifactPaths = result;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Sync version of _getArtifactPath
|
|
224
|
+
*/
|
|
225
|
+
protected _getArtifactPathSync(name: string): string | undefined {
|
|
226
|
+
const cached = this._cache?.artifactNameToArtifactPathCache.get(name);
|
|
227
|
+
if (cached !== undefined) {
|
|
228
|
+
return cached;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const result = super._getArtifactPathSync(name);
|
|
232
|
+
if (result === undefined) {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
this._cache?.artifactNameToArtifactPathCache.set(name, result);
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import * as os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Artifact,
|
|
6
|
+
Artifacts as IArtifacts,
|
|
7
|
+
ArtifactsSource,
|
|
8
|
+
BuildInfo,
|
|
9
|
+
CompilerInput,
|
|
10
|
+
CompilerOutput,
|
|
11
|
+
} from "../../types";
|
|
12
|
+
import { parseFullyQualifiedName } from "../../utils/contract-names";
|
|
13
|
+
|
|
14
|
+
import { ARTIFACT_FORMAT_VERSION } from "../constants";
|
|
15
|
+
import { HardhatError } from "../core/errors";
|
|
16
|
+
import { ERRORS } from "../core/errors-list";
|
|
17
|
+
|
|
18
|
+
import { CachingSource } from "./caching";
|
|
19
|
+
|
|
20
|
+
export class Artifacts implements IArtifacts {
|
|
21
|
+
private readonly _hardhatSource: CachingSource;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly _artifactsPath: string,
|
|
25
|
+
private readonly _extensionSources: ArtifactsSource[] = []
|
|
26
|
+
) {
|
|
27
|
+
this._hardhatSource = new CachingSource(this._artifactsPath);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async readArtifact(
|
|
31
|
+
contractNameOrFullyQualifiedName: string
|
|
32
|
+
): Promise<Artifact> {
|
|
33
|
+
let artifact: Artifact | undefined = await this._hardhatSource.readArtifact(
|
|
34
|
+
contractNameOrFullyQualifiedName
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (artifact === undefined) {
|
|
38
|
+
const artifacts: Array<Artifact | undefined> = await Promise.all(
|
|
39
|
+
this._extensionSources.map((source) =>
|
|
40
|
+
source.readArtifact(contractNameOrFullyQualifiedName)
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
artifact = artifacts.find((_artifact) => _artifact !== undefined);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (artifact === undefined) {
|
|
48
|
+
this._throwNotFound(contractNameOrFullyQualifiedName);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return artifact;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public readArtifactSync(contractNameOrFullyQualifiedName: string): Artifact {
|
|
55
|
+
let artifact: Artifact | undefined = this._hardhatSource.readArtifactSync(
|
|
56
|
+
contractNameOrFullyQualifiedName
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (artifact === undefined) {
|
|
60
|
+
for (const source of this._extensionSources) {
|
|
61
|
+
artifact = source.readArtifactSync(contractNameOrFullyQualifiedName);
|
|
62
|
+
if (artifact !== undefined) {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (artifact === undefined) {
|
|
69
|
+
this._throwNotFound(contractNameOrFullyQualifiedName);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return artifact;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async artifactExists(
|
|
76
|
+
contractNameOrFullyQualifiedName: string
|
|
77
|
+
): Promise<boolean> {
|
|
78
|
+
const existencesPerSource = await Promise.all(
|
|
79
|
+
[this._hardhatSource, ...this._extensionSources].map((source) =>
|
|
80
|
+
source.artifactExists(contractNameOrFullyQualifiedName)
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
return existencesPerSource.includes(true);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async getAllFullyQualifiedNames(): Promise<string[]> {
|
|
87
|
+
return (
|
|
88
|
+
await Promise.all(
|
|
89
|
+
[this._hardhatSource, ...this._extensionSources].map((s) =>
|
|
90
|
+
s.getAllFullyQualifiedNames()
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
).flat();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public async getBuildInfo(
|
|
97
|
+
fullyQualifiedName: string
|
|
98
|
+
): Promise<BuildInfo | undefined> {
|
|
99
|
+
let buildInfo = await this._hardhatSource.getBuildInfo(fullyQualifiedName);
|
|
100
|
+
|
|
101
|
+
if (buildInfo === undefined) {
|
|
102
|
+
const buildInfos: Array<BuildInfo | undefined> = await Promise.all(
|
|
103
|
+
this._extensionSources.map((source) =>
|
|
104
|
+
source.getBuildInfo(fullyQualifiedName)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
buildInfo = buildInfos.find((info) => info !== undefined);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return buildInfo;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public async getArtifactPaths(): Promise<string[]> {
|
|
114
|
+
return (
|
|
115
|
+
await Promise.all(
|
|
116
|
+
[this._hardhatSource, ...this._extensionSources].map((s) =>
|
|
117
|
+
s.getArtifactPaths()
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
).flat();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public async getDebugFilePaths(): Promise<string[]> {
|
|
124
|
+
return (
|
|
125
|
+
await Promise.all(
|
|
126
|
+
[this._hardhatSource, ...this._extensionSources].map((s) =>
|
|
127
|
+
s.getDebugFilePaths()
|
|
128
|
+
)
|
|
129
|
+
)
|
|
130
|
+
).flat();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public async getBuildInfoPaths(): Promise<string[]> {
|
|
134
|
+
return (
|
|
135
|
+
await Promise.all(
|
|
136
|
+
[this._hardhatSource, ...this._extensionSources].map((s) =>
|
|
137
|
+
s.getBuildInfoPaths()
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
).flat();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public clearCache(): void {
|
|
144
|
+
for (const source of [this._hardhatSource, ...this._extensionSources]) {
|
|
145
|
+
source.clearCache();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public disableCache(): void {
|
|
150
|
+
for (const source of [this._hardhatSource, ...this._extensionSources]) {
|
|
151
|
+
source.disableCache();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public saveArtifactAndDebugFile(
|
|
156
|
+
artifact: Artifact,
|
|
157
|
+
pathToBuildInfo?: string
|
|
158
|
+
): Promise<void> {
|
|
159
|
+
return this._hardhatSource.saveArtifactAndDebugFile(
|
|
160
|
+
artifact,
|
|
161
|
+
pathToBuildInfo
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public saveBuildInfo(
|
|
166
|
+
solcVersion: string,
|
|
167
|
+
solcLongVersion: string,
|
|
168
|
+
input: CompilerInput,
|
|
169
|
+
output: CompilerOutput
|
|
170
|
+
): Promise<string> {
|
|
171
|
+
return this._hardhatSource.saveBuildInfo(
|
|
172
|
+
solcVersion,
|
|
173
|
+
solcLongVersion,
|
|
174
|
+
input,
|
|
175
|
+
output
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public formArtifactPathFromFullyQualifiedName(
|
|
180
|
+
fullyQualifiedName: string
|
|
181
|
+
): string {
|
|
182
|
+
return this._hardhatSource.formArtifactPathFromFullyQualifiedName(
|
|
183
|
+
fullyQualifiedName
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public addValidArtifacts(
|
|
188
|
+
validArtifacts: Array<{ sourceName: string; artifacts: string[] }>
|
|
189
|
+
) {
|
|
190
|
+
this._hardhatSource.addValidArtifacts(validArtifacts);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public async removeObsoleteArtifacts() {
|
|
194
|
+
return this._hardhatSource.removeObsoleteArtifacts();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private _throwNotFound(contractNameOrFullyQualifiedName: string): never {
|
|
198
|
+
const suggestions = this._hardhatSource.getSuggestions(
|
|
199
|
+
contractNameOrFullyQualifiedName
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const uniqueSuggestions = [...new Set(suggestions)].sort();
|
|
203
|
+
|
|
204
|
+
const suggestion = this._formatSuggestions(
|
|
205
|
+
uniqueSuggestions,
|
|
206
|
+
contractNameOrFullyQualifiedName
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
throw new HardhatError(ERRORS.ARTIFACTS.NOT_FOUND, {
|
|
210
|
+
contractName: contractNameOrFullyQualifiedName,
|
|
211
|
+
suggestion,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private _formatSuggestions(names: string[], contractName: string): string {
|
|
216
|
+
switch (names.length) {
|
|
217
|
+
case 0:
|
|
218
|
+
return "";
|
|
219
|
+
case 1:
|
|
220
|
+
return `Did you mean "${names[0]}"?`;
|
|
221
|
+
default:
|
|
222
|
+
return `We found some that were similar:
|
|
223
|
+
|
|
224
|
+
${names.map((n) => ` * ${n}`).join(os.EOL)}
|
|
225
|
+
|
|
226
|
+
Please replace "${contractName}" for the correct contract name wherever you are trying to read its artifact.
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* DO NOT DELETE OR CHANGE
|
|
233
|
+
*
|
|
234
|
+
* use this.formArtifactPathFromFullyQualifiedName instead
|
|
235
|
+
* @deprecated until typechain migrates to public version
|
|
236
|
+
* @see https://github.com/dethcrypto/TypeChain/issues/544
|
|
237
|
+
*/
|
|
238
|
+
private _getArtifactPathFromFullyQualifiedName(
|
|
239
|
+
fullyQualifiedName: string
|
|
240
|
+
): string {
|
|
241
|
+
const { sourceName, contractName } =
|
|
242
|
+
parseFullyQualifiedName(fullyQualifiedName);
|
|
243
|
+
|
|
244
|
+
return path.join(this._artifactsPath, sourceName, `${contractName}.json`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Retrieves an artifact for the given `contractName` from the compilation output.
|
|
250
|
+
*
|
|
251
|
+
* @param sourceName The contract's source name.
|
|
252
|
+
* @param contractName the contract's name.
|
|
253
|
+
* @param contractOutput the contract's compilation output as emitted by `solc`.
|
|
254
|
+
*/
|
|
255
|
+
export function getArtifactFromContractOutput(
|
|
256
|
+
sourceName: string,
|
|
257
|
+
contractName: string,
|
|
258
|
+
contractOutput: any
|
|
259
|
+
): Artifact {
|
|
260
|
+
const evmBytecode = contractOutput.evm && contractOutput.evm.bytecode;
|
|
261
|
+
let bytecode: string =
|
|
262
|
+
evmBytecode && evmBytecode.object ? evmBytecode.object : "";
|
|
263
|
+
|
|
264
|
+
if (bytecode.slice(0, 2).toLowerCase() !== "0x") {
|
|
265
|
+
bytecode = `0x${bytecode}`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const evmDeployedBytecode =
|
|
269
|
+
contractOutput.evm && contractOutput.evm.deployedBytecode;
|
|
270
|
+
let deployedBytecode: string =
|
|
271
|
+
evmDeployedBytecode && evmDeployedBytecode.object
|
|
272
|
+
? evmDeployedBytecode.object
|
|
273
|
+
: "";
|
|
274
|
+
|
|
275
|
+
if (deployedBytecode.slice(0, 2).toLowerCase() !== "0x") {
|
|
276
|
+
deployedBytecode = `0x${deployedBytecode}`;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const linkReferences =
|
|
280
|
+
evmBytecode && evmBytecode.linkReferences ? evmBytecode.linkReferences : {};
|
|
281
|
+
const deployedLinkReferences =
|
|
282
|
+
evmDeployedBytecode && evmDeployedBytecode.linkReferences
|
|
283
|
+
? evmDeployedBytecode.linkReferences
|
|
284
|
+
: {};
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
_format: ARTIFACT_FORMAT_VERSION,
|
|
288
|
+
contractName,
|
|
289
|
+
sourceName,
|
|
290
|
+
abi: contractOutput.abi,
|
|
291
|
+
bytecode,
|
|
292
|
+
deployedBytecode,
|
|
293
|
+
linkReferences,
|
|
294
|
+
deployedLinkReferences,
|
|
295
|
+
};
|
|
296
|
+
}
|