hardhat 2.16.0-dev.0 → 2.16.0

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.
Files changed (72) hide show
  1. package/builtin-tasks/compile.js +18 -18
  2. package/builtin-tasks/compile.js.map +1 -1
  3. package/console.sol +3 -4
  4. package/internal/cli/analytics.d.ts +6 -6
  5. package/internal/cli/analytics.d.ts.map +1 -1
  6. package/internal/cli/analytics.js +43 -115
  7. package/internal/cli/analytics.js.map +1 -1
  8. package/internal/cli/bootstrap.js +0 -0
  9. package/internal/cli/cli.js +1 -1
  10. package/internal/cli/cli.js.map +1 -1
  11. package/internal/core/jsonrpc/types/input/blockTag.d.ts +3 -3
  12. package/internal/core/jsonrpc/types/input/filterRequest.d.ts +6 -6
  13. package/package.json +1 -3
  14. package/src/builtin-tasks/compile.ts +43 -35
  15. package/src/internal/cli/analytics.ts +82 -134
  16. package/src/internal/cli/cli.ts +1 -1
  17. package/internal/core/config/extenders.d.ts +0 -7
  18. package/internal/core/config/extenders.d.ts.map +0 -1
  19. package/internal/core/config/extenders.js +0 -16
  20. package/internal/core/config/extenders.js.map +0 -1
  21. package/internal/hardhat-network/provider/RethnetState.d.ts +0 -29
  22. package/internal/hardhat-network/provider/RethnetState.d.ts.map +0 -1
  23. package/internal/hardhat-network/provider/RethnetState.js +0 -110
  24. package/internal/hardhat-network/provider/RethnetState.js.map +0 -1
  25. package/internal/hardhat-network/provider/utils/bloom.d.ts +0 -32
  26. package/internal/hardhat-network/provider/utils/bloom.d.ts.map +0 -1
  27. package/internal/hardhat-network/provider/utils/bloom.js +0 -79
  28. package/internal/hardhat-network/provider/utils/bloom.js.map +0 -1
  29. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +0 -17
  30. package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +0 -1
  31. package/internal/hardhat-network/provider/utils/convertToRethnet.js +0 -390
  32. package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +0 -1
  33. package/internal/hardhat-network/provider/vm/block-builder/dual.d.ts +0 -14
  34. package/internal/hardhat-network/provider/vm/block-builder/dual.d.ts.map +0 -1
  35. package/internal/hardhat-network/provider/vm/block-builder/dual.js +0 -47
  36. package/internal/hardhat-network/provider/vm/block-builder/dual.js.map +0 -1
  37. package/internal/hardhat-network/provider/vm/block-builder/hardhat.d.ts +0 -27
  38. package/internal/hardhat-network/provider/vm/block-builder/hardhat.d.ts.map +0 -1
  39. package/internal/hardhat-network/provider/vm/block-builder/hardhat.js +0 -136
  40. package/internal/hardhat-network/provider/vm/block-builder/hardhat.js.map +0 -1
  41. package/internal/hardhat-network/provider/vm/block-builder/rethnet.d.ts +0 -20
  42. package/internal/hardhat-network/provider/vm/block-builder/rethnet.d.ts.map +0 -1
  43. package/internal/hardhat-network/provider/vm/block-builder/rethnet.js +0 -55
  44. package/internal/hardhat-network/provider/vm/block-builder/rethnet.js.map +0 -1
  45. package/internal/hardhat-network/provider/vm/block-builder.d.ts +0 -19
  46. package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +0 -1
  47. package/internal/hardhat-network/provider/vm/block-builder.js +0 -24
  48. package/internal/hardhat-network/provider/vm/block-builder.js.map +0 -1
  49. package/internal/hardhat-network/provider/vm/creation.d.ts +0 -10
  50. package/internal/hardhat-network/provider/vm/creation.d.ts.map +0 -1
  51. package/internal/hardhat-network/provider/vm/creation.js +0 -29
  52. package/internal/hardhat-network/provider/vm/creation.js.map +0 -1
  53. package/internal/hardhat-network/provider/vm/dual.d.ts +0 -43
  54. package/internal/hardhat-network/provider/vm/dual.d.ts.map +0 -1
  55. package/internal/hardhat-network/provider/vm/dual.js +0 -487
  56. package/internal/hardhat-network/provider/vm/dual.js.map +0 -1
  57. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +0 -61
  58. package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +0 -1
  59. package/internal/hardhat-network/provider/vm/ethereumjs.js +0 -517
  60. package/internal/hardhat-network/provider/vm/ethereumjs.js.map +0 -1
  61. package/internal/hardhat-network/provider/vm/exit.d.ts +0 -24
  62. package/internal/hardhat-network/provider/vm/exit.d.ts.map +0 -1
  63. package/internal/hardhat-network/provider/vm/exit.js +0 -140
  64. package/internal/hardhat-network/provider/vm/exit.js.map +0 -1
  65. package/internal/hardhat-network/provider/vm/rethnet.d.ts +0 -87
  66. package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +0 -1
  67. package/internal/hardhat-network/provider/vm/rethnet.js +0 -262
  68. package/internal/hardhat-network/provider/vm/rethnet.js.map +0 -1
  69. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +0 -53
  70. package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +0 -1
  71. package/internal/hardhat-network/provider/vm/vm-adapter.js +0 -3
  72. package/internal/hardhat-network/provider/vm/vm-adapter.js.map +0 -1
@@ -1,21 +1,21 @@
1
1
  import * as t from "io-ts";
2
2
  export declare const rpcFilterRequest: t.TypeC<{
3
- fromBlock: t.Type<bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined, bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined, unknown>;
4
- toBlock: t.Type<bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined, bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined, unknown>;
3
+ fromBlock: t.Type<bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined, bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined, unknown>;
4
+ toBlock: t.Type<bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined, bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined, unknown>;
5
5
  address: t.Type<Buffer | Buffer[] | undefined, Buffer | Buffer[] | undefined, unknown>;
6
6
  topics: t.Type<(Buffer | (Buffer | null)[] | null)[] | undefined, (Buffer | (Buffer | null)[] | null)[] | undefined, unknown>;
7
7
  blockHash: t.Type<Buffer | undefined, Buffer | undefined, unknown>;
8
8
  }>;
9
9
  export declare type RpcFilterRequest = t.TypeOf<typeof rpcFilterRequest>;
10
10
  export declare const optionalRpcFilterRequest: t.Type<{
11
- fromBlock: bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined;
12
- toBlock: bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined;
11
+ fromBlock: bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined;
12
+ toBlock: bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined;
13
13
  address: Buffer | Buffer[] | undefined;
14
14
  topics: (Buffer | (Buffer | null)[] | null)[] | undefined;
15
15
  blockHash: Buffer | undefined;
16
16
  } | undefined, {
17
- fromBlock: bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined;
18
- toBlock: bigint | "pending" | "latest" | "earliest" | "safe" | "finalized" | undefined;
17
+ fromBlock: bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined;
18
+ toBlock: bigint | "pending" | "earliest" | "latest" | "safe" | "finalized" | undefined;
19
19
  address: Buffer | Buffer[] | undefined;
20
20
  topics: (Buffer | (Buffer | null)[] | null)[] | undefined;
21
21
  blockHash: Buffer | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hardhat",
3
- "version": "2.16.0-dev.0",
3
+ "version": "2.16.0",
4
4
  "author": "Nomic Labs LLC",
5
5
  "license": "MIT",
6
6
  "homepage": "https://hardhat.org",
@@ -70,7 +70,6 @@
70
70
  "@types/lodash": "^4.14.123",
71
71
  "@types/mocha": ">=9.1.0",
72
72
  "@types/node": "^14.0.0",
73
- "@types/qs": "^6.5.3",
74
73
  "@types/resolve": "^1.17.1",
75
74
  "@types/semver": "^6.0.2",
76
75
  "@types/sinon": "^9.0.8",
@@ -137,7 +136,6 @@
137
136
  "mnemonist": "^0.38.0",
138
137
  "mocha": "^10.0.0",
139
138
  "p-map": "^4.0.0",
140
- "qs": "^6.7.0",
141
139
  "raw-body": "^2.4.1",
142
140
  "resolve": "1.17.0",
143
141
  "semver": "^6.3.0",
@@ -43,6 +43,7 @@ import { getAllFilesMatching } from "../internal/util/fs-utils";
43
43
  import {
44
44
  TASK_COMPILE,
45
45
  TASK_COMPILE_GET_COMPILATION_TASKS,
46
+ TASK_COMPILE_REMOVE_OBSOLETE_ARTIFACTS,
46
47
  TASK_COMPILE_SOLIDITY,
47
48
  TASK_COMPILE_SOLIDITY_CHECK_ERRORS,
48
49
  TASK_COMPILE_SOLIDITY_COMPILE,
@@ -72,7 +73,6 @@ import {
72
73
  TASK_COMPILE_SOLIDITY_READ_FILE,
73
74
  TASK_COMPILE_SOLIDITY_RUN_SOLC,
74
75
  TASK_COMPILE_SOLIDITY_RUN_SOLCJS,
75
- TASK_COMPILE_REMOVE_OBSOLETE_ARTIFACTS,
76
76
  TASK_COMPILE_TRANSFORM_IMPORT_NAME,
77
77
  } from "./task-names";
78
78
  import {
@@ -115,16 +115,18 @@ const DEFAULT_CONCURRENCY_LEVEL = Math.max(os.cpus().length - 1, 1);
115
115
  * This is the right task to override to change how the solidity files of the
116
116
  * project are obtained.
117
117
  */
118
- subtask(
119
- TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
120
- async (_, { config }): Promise<string[]> => {
121
- const paths = await getAllFilesMatching(config.paths.sources, (f) =>
122
- f.endsWith(".sol")
123
- );
124
-
125
- return paths;
126
- }
127
- );
118
+ subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS)
119
+ .addOptionalParam("sourcePath", undefined, undefined, types.string)
120
+ .setAction(
121
+ async (
122
+ { sourcePath }: { sourcePath?: string },
123
+ { config }
124
+ ): Promise<string[]> => {
125
+ return getAllFilesMatching(sourcePath ?? config.paths.sources, (f) =>
126
+ f.endsWith(".sol")
127
+ );
128
+ }
129
+ );
128
130
 
129
131
  /**
130
132
  * Receives a list of absolute paths and returns a list of source names
@@ -134,17 +136,24 @@ subtask(
134
136
  * is generated.
135
137
  */
136
138
  subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_NAMES)
139
+ .addOptionalParam("rootPath", undefined, undefined, types.string)
137
140
  .addParam("sourcePaths", undefined, undefined, types.any)
138
141
  .setAction(
139
142
  async (
140
- { sourcePaths }: { sourcePaths: string[] },
143
+ {
144
+ rootPath,
145
+ sourcePaths,
146
+ }: {
147
+ rootPath?: string;
148
+ sourcePaths: string[];
149
+ },
141
150
  { config }
142
151
  ): Promise<string[]> => {
143
- const sourceNames = await Promise.all(
144
- sourcePaths.map((p) => localPathToSourceName(config.paths.root, p))
152
+ return Promise.all(
153
+ sourcePaths.map((p) =>
154
+ localPathToSourceName(rootPath ?? config.paths.root, p)
155
+ )
145
156
  );
146
-
147
- return sourceNames;
148
157
  }
149
158
  );
150
159
 
@@ -152,11 +161,9 @@ subtask(TASK_COMPILE_SOLIDITY_READ_FILE)
152
161
  .addParam("absolutePath", undefined, undefined, types.string)
153
162
  .setAction(
154
163
  async ({ absolutePath }: { absolutePath: string }): Promise<string> => {
155
- const content = await fsExtra.readFile(absolutePath, {
164
+ return fsExtra.readFile(absolutePath, {
156
165
  encoding: "utf8",
157
166
  });
158
-
159
- return content;
160
167
  }
161
168
  );
162
169
 
@@ -178,19 +185,25 @@ subtask(TASK_COMPILE_TRANSFORM_IMPORT_NAME)
178
185
  * node_modules) and generating the graph.
179
186
  */
180
187
  subtask(TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH)
188
+ .addOptionalParam("rootPath", undefined, undefined, types.string)
181
189
  .addParam("sourceNames", undefined, undefined, types.any)
182
190
  .addOptionalParam("solidityFilesCache", undefined, undefined, types.any)
183
191
  .setAction(
184
192
  async (
185
193
  {
194
+ rootPath,
186
195
  sourceNames,
187
196
  solidityFilesCache,
188
- }: { sourceNames: string[]; solidityFilesCache?: SolidityFilesCache },
197
+ }: {
198
+ rootPath?: string;
199
+ sourceNames: string[];
200
+ solidityFilesCache?: SolidityFilesCache;
201
+ },
189
202
  { config, run }
190
203
  ): Promise<taskTypes.DependencyGraph> => {
191
204
  const parser = new Parser(solidityFilesCache);
192
205
  const resolver = new Resolver(
193
- config.paths.root,
206
+ rootPath ?? config.paths.root,
194
207
  parser,
195
208
  (absolutePath: string) =>
196
209
  run(TASK_COMPILE_SOLIDITY_READ_FILE, { absolutePath }),
@@ -201,12 +214,8 @@ subtask(TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH)
201
214
  const resolvedFiles = await Promise.all(
202
215
  sourceNames.map((sn) => resolver.resolveSourceName(sn))
203
216
  );
204
- const dependencyGraph = await DependencyGraph.createFromResolvedFiles(
205
- resolver,
206
- resolvedFiles
207
- );
208
217
 
209
- return dependencyGraph;
218
+ return DependencyGraph.createFromResolvedFiles(resolver, resolvedFiles);
210
219
  }
211
220
  );
212
221
 
@@ -628,9 +637,7 @@ subtask(TASK_COMPILE_SOLIDITY_RUN_SOLCJS)
628
637
  }) => {
629
638
  const compiler = new Compiler(solcJsPath);
630
639
 
631
- const output = await compiler.compile(input);
632
-
633
- return output;
640
+ return compiler.compile(input);
634
641
  }
635
642
  );
636
643
 
@@ -645,9 +652,7 @@ subtask(TASK_COMPILE_SOLIDITY_RUN_SOLC)
645
652
  async ({ input, solcPath }: { input: CompilerInput; solcPath: string }) => {
646
653
  const compiler = new NativeCompiler(solcPath);
647
654
 
648
- const output = await compiler.compile(input);
649
-
650
- return output;
655
+ return compiler.compile(input);
651
656
  }
652
657
  );
653
658
 
@@ -1290,13 +1295,16 @@ subtask(TASK_COMPILE_SOLIDITY)
1290
1295
  }: { force: boolean; quiet: boolean; concurrency: number },
1291
1296
  { artifacts, config, run }
1292
1297
  ) => {
1298
+ const rootPath = config.paths.root;
1299
+
1293
1300
  const sourcePaths: string[] = await run(
1294
- TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS
1301
+ TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
1302
+ { sourcePath: config.paths.sources }
1295
1303
  );
1296
-
1297
1304
  const sourceNames: string[] = await run(
1298
1305
  TASK_COMPILE_SOLIDITY_GET_SOURCE_NAMES,
1299
1306
  {
1307
+ rootPath,
1300
1308
  sourcePaths,
1301
1309
  }
1302
1310
  );
@@ -1308,7 +1316,7 @@ subtask(TASK_COMPILE_SOLIDITY)
1308
1316
 
1309
1317
  const dependencyGraph: taskTypes.DependencyGraph = await run(
1310
1318
  TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH,
1311
- { sourceNames, solidityFilesCache }
1319
+ { rootPath, sourceNames, solidityFilesCache }
1312
1320
  );
1313
1321
 
1314
1322
  solidityFilesCache = await invalidateCacheMissingArtifacts(
@@ -3,10 +3,8 @@ import type { request as RequestT } from "undici";
3
3
  import AbortController from "abort-controller";
4
4
  import debug from "debug";
5
5
  import os from "os";
6
- import qs from "qs";
7
6
  import { v4 as uuid } from "uuid";
8
7
 
9
- import * as builtinTaskNames from "../../builtin-tasks/task-names";
10
8
  import { isLocalDev } from "../core/execution-mode";
11
9
  import { isRunningOnCiServer } from "../util/ci-detection";
12
10
  import {
@@ -19,37 +17,46 @@ import { getPackageJson } from "../util/packageInfo";
19
17
 
20
18
  const log = debug("hardhat:core:analytics");
21
19
 
22
- // VERY IMPORTANT:
23
- // The documentation doesn't say so, but the user-agent parameter is required (ua).
24
- // If you don't send it, you won't get an error or anything, Google will *silently* drop your hit.
25
- //
26
- // https://stackoverflow.com/questions/27357954/google-analytics-measurement-protocol-not-working
27
- interface RawAnalytics {
28
- v: "1";
29
- tid: string;
30
- cid: string;
31
- dp: string;
32
- dh: string;
33
- t: string;
34
- ua: string;
35
- cs: string;
36
- cm: string;
37
- cd1: string;
38
- cd2: string;
39
- cd3: string;
20
+ /* eslint-disable @typescript-eslint/naming-convention */
21
+ interface AnalyticsPayload {
22
+ client_id: string;
23
+ user_id: string;
24
+ user_properties: {
25
+ projectId: {
26
+ value?: string;
27
+ };
28
+ userType: {
29
+ value?: string;
30
+ };
31
+ hardhatVersion: {
32
+ value?: string;
33
+ };
34
+ operatingSystem: {
35
+ value?: string;
36
+ };
37
+ nodeVersion: {
38
+ value?: string;
39
+ };
40
+ };
41
+ events: Array<{
42
+ name: string;
43
+ params: {
44
+ engagement_time_msec: string;
45
+ session_id: string;
46
+ };
47
+ }>;
40
48
  }
49
+ /* eslint-enable @typescript-eslint/naming-convention */
41
50
 
42
51
  type AbortAnalytics = () => void;
43
52
 
44
- const googleAnalyticsUrl = "https://www.google-analytics.com/collect";
45
-
46
53
  export class Analytics {
47
54
  public static async getInstance(telemetryConsent: boolean | undefined) {
48
- const analytics: Analytics = new Analytics({
49
- clientId: await getClientId(),
55
+ const analytics: Analytics = new Analytics(
56
+ await getClientId(),
50
57
  telemetryConsent,
51
- userType: getUserType(),
52
- });
58
+ getUserType()
59
+ );
53
60
 
54
61
  return analytics;
55
62
  }
@@ -57,22 +64,22 @@ export class Analytics {
57
64
  private readonly _clientId: string;
58
65
  private readonly _enabled: boolean;
59
66
  private readonly _userType: string;
60
- // Hardhat's tracking id. I guess there's no other choice than keeping it here.
61
- private readonly _trackingId: string = "UA-117668706-3";
62
-
63
- private constructor({
64
- clientId,
65
- telemetryConsent,
66
- userType,
67
- }: {
68
- clientId: string;
69
- telemetryConsent: boolean | undefined;
70
- userType: string;
71
- }) {
67
+ private readonly _analyticsUrl: string =
68
+ "https://www.google-analytics.com/mp/collect";
69
+ private readonly _apiSecret: string = "fQ5joCsDRTOp55wX8a2cVw";
70
+ private readonly _measurementId: string = "G-8LQ007N2QJ";
71
+ private _sessionId: string;
72
+
73
+ private constructor(
74
+ clientId: string,
75
+ telemetryConsent: boolean | undefined,
76
+ userType: string
77
+ ) {
72
78
  this._clientId = clientId;
73
79
  this._enabled =
74
80
  !isLocalDev() && !isRunningOnCiServer() && telemetryConsent === true;
75
81
  this._userType = userType;
82
+ this._sessionId = Math.random().toString();
76
83
  }
77
84
 
78
85
  /**
@@ -83,106 +90,70 @@ export class Analytics {
83
90
  *
84
91
  * Trying to abort a successfully completed request is a no-op, so it's always safe to call it.
85
92
  *
86
- * @param taskName The name of the task to be logged
87
- *
88
93
  * @returns The abort function
89
94
  */
90
- public async sendTaskHit(
91
- taskName: string
92
- ): Promise<[AbortAnalytics, Promise<void>]> {
93
- if (this._isABuiltinTaskName(taskName)) {
94
- taskName = "builtin";
95
- } else {
96
- taskName = "custom";
97
- }
98
-
95
+ public async sendTaskHit(): Promise<[AbortAnalytics, Promise<void>]> {
99
96
  if (!this._enabled) {
100
97
  return [() => {}, Promise.resolve()];
101
98
  }
102
99
 
103
- return this._sendHit(await this._taskHit(taskName));
100
+ return this._sendHit(await this._buildTaskHitPayload());
104
101
  }
105
102
 
106
- private _isABuiltinTaskName(taskName: string) {
107
- return Object.values<string>(builtinTaskNames).includes(taskName);
108
- }
109
-
110
- private async _taskHit(taskName: string): Promise<RawAnalytics> {
103
+ private async _buildTaskHitPayload(): Promise<AnalyticsPayload> {
111
104
  return {
112
- // Measurement protocol version.
113
- v: "1",
114
-
115
- // Hit type, we're only using pageviews for now.
116
- t: "pageview",
117
-
118
- // Hardhat's tracking Id.
119
- tid: this._trackingId,
120
-
121
- // Client Id.
122
- cid: this._clientId,
123
-
124
- // Document path, must start with a '/'.
125
- dp: `/task/${taskName}`,
126
-
127
- // Host name.
128
- dh: "cli.hardhat.org",
129
-
130
- // User agent, must be present.
131
- // We use it to inform Node version used and OS.
132
- // Example:
133
- // Node/v8.12.0 (Darwin 17.7.0)
134
- ua: getUserAgent(),
135
-
136
- // We're using the following values (Campaign source, Campaign medium) to track
137
- // whether the user is a Developer or CI, as Custom Dimensions are not working for us atm.
138
- cs: this._userType,
139
- cm: "User Type",
140
-
141
- // We're using custom dimensions for tracking different user projects, and user types (Developer/CI).
142
- //
143
- // See the following link for docs on these paremeters:
144
- // https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#pr_cd_
145
- //
146
- // See the following link for setting up our custom dimensions in the Google Analytics dashboard
147
- // https://support.google.com/tagmanager/answer/6164990
148
- //
149
- // Custom dimension 1: Project Id
150
- cd1: "hardhat-project",
151
- // Custom dimension 2: User type
152
- // Possible values: "CI", "Developer".
153
- cd2: this._userType,
154
- // Custom dimension 3: Hardhat Version
155
- // Example: "Hardhat 1.0.0".
156
- cd3: await getHardhatVersion(),
105
+ client_id: this._clientId,
106
+ user_id: this._clientId,
107
+ user_properties: {
108
+ projectId: { value: "hardhat-project" },
109
+ userType: { value: this._userType },
110
+ hardhatVersion: { value: await getHardhatVersion() },
111
+ operatingSystem: { value: os.platform() },
112
+ nodeVersion: { value: process.version },
113
+ },
114
+ events: [
115
+ {
116
+ name: "task",
117
+ params: {
118
+ // From the GA docs: amount of time someone spends with your web
119
+ // page in focus or app screen in the foreground
120
+ // The parameter has no use for our app, but it's required in order
121
+ // for user activity to display in standard reports like Realtime
122
+ engagement_time_msec: "10000",
123
+ session_id: this._sessionId,
124
+ },
125
+ },
126
+ ],
157
127
  };
158
128
  }
159
129
 
160
- private _sendHit(hit: RawAnalytics): [AbortAnalytics, Promise<void>] {
130
+ private _sendHit(payload: AnalyticsPayload): [AbortAnalytics, Promise<void>] {
161
131
  const { request } = require("undici") as { request: typeof RequestT };
162
-
163
- log(`Sending hit for ${hit.dp}`);
132
+ const eventName = payload.events[0].name;
133
+ log(`Sending hit for ${eventName}`);
164
134
 
165
135
  const controller = new AbortController();
166
136
 
167
137
  const abortAnalytics = () => {
168
- log(`Aborting hit for ${JSON.stringify(hit.dp)}`);
138
+ log(`Aborting hit for ${eventName}`);
169
139
 
170
140
  controller.abort();
171
141
  };
172
142
 
173
- const hitPayload = qs.stringify(hit);
143
+ log(`Hit payload: ${JSON.stringify(payload)}`);
174
144
 
175
- log(`Hit payload: ${JSON.stringify(hit)}`);
176
-
177
- const hitPromise = request(googleAnalyticsUrl, {
178
- body: hitPayload,
145
+ const hitPromise = request(this._analyticsUrl, {
146
+ query: {
147
+ api_secret: this._apiSecret,
148
+ measurement_id: this._measurementId,
149
+ },
150
+ body: JSON.stringify(payload),
179
151
  method: "POST",
180
152
  signal: controller.signal,
181
153
  })
182
154
  .then(() => {
183
- log(`Hit for ${JSON.stringify(hit.dp)} sent successfully`);
155
+ log(`Hit for ${eventName} sent successfully`);
184
156
  })
185
- // We're not really interested in handling failed analytics requests
186
157
  .catch(() => {
187
158
  log("Hit request failed");
188
159
  });
@@ -214,29 +185,6 @@ function getUserType(): string {
214
185
  return isRunningOnCiServer() ? "CI" : "Developer";
215
186
  }
216
187
 
217
- /**
218
- * At the moment, we couldn't find a reliably way to report the OS () in Node,
219
- * as the versions reported by the various `os` APIs (`os.platform()`, `os.type()`, etc)
220
- * return values different to those expected by Google Analytics
221
- * We decided to take the compromise of just reporting the OS Platform (OSX/Linux/Windows) for now (version information is bogus for now).
222
- */
223
- function getOperatingSystem(): string {
224
- switch (os.type()) {
225
- case "Windows_NT":
226
- return "(Windows NT 6.1; Win64; x64)";
227
- case "Darwin":
228
- return "(Macintosh; Intel Mac OS X 10_13_6)";
229
- case "Linux":
230
- return "(X11; Linux x86_64)";
231
- default:
232
- return "(Unknown)";
233
- }
234
- }
235
-
236
- function getUserAgent(): string {
237
- return `Node/${process.version} ${getOperatingSystem()}`;
238
- }
239
-
240
188
  async function getHardhatVersion(): Promise<string> {
241
189
  const { version } = await getPackageJson();
242
190
 
@@ -233,7 +233,7 @@ async function main() {
233
233
  const providerExtenders = ctx.providerExtenders;
234
234
  const taskDefinitions = ctx.tasksDSL.getTaskDefinitions();
235
235
 
236
- const [abortAnalytics, hitPromise] = await analytics.sendTaskHit(taskName);
236
+ const [abortAnalytics, hitPromise] = await analytics.sendTaskHit();
237
237
 
238
238
  let taskArguments: TaskArguments;
239
239
 
@@ -1,7 +0,0 @@
1
- import { EnvironmentExtender } from "../../../types";
2
- export declare class ExtenderManager {
3
- private readonly _extenders;
4
- add(extender: EnvironmentExtender): void;
5
- getExtenders(): EnvironmentExtender[];
6
- }
7
- //# sourceMappingURL=extenders.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extenders.d.ts","sourceRoot":"","sources":["../../../src/internal/core/config/extenders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IAEjD,GAAG,CAAC,QAAQ,EAAE,mBAAmB;IAIjC,YAAY,IAAI,mBAAmB,EAAE;CAG7C"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExtenderManager = void 0;
4
- class ExtenderManager {
5
- constructor() {
6
- this._extenders = [];
7
- }
8
- add(extender) {
9
- this._extenders.push(extender);
10
- }
11
- getExtenders() {
12
- return this._extenders;
13
- }
14
- }
15
- exports.ExtenderManager = ExtenderManager;
16
- //# sourceMappingURL=extenders.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extenders.js","sourceRoot":"","sources":["../../../src/internal/core/config/extenders.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAe;IAA5B;QACmB,eAAU,GAA0B,EAAE,CAAC;IAS1D,CAAC;IAPQ,GAAG,CAAC,QAA6B;QACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAVD,0CAUC"}
@@ -1,29 +0,0 @@
1
- /// <reference types="node" />
2
- import { Address } from "@nomicfoundation/ethereumjs-util";
3
- import { StateManager, Account, Bytecode, RethnetContext } from "rethnet-evm";
4
- import { ForkConfig, GenesisAccount } from "./node-types";
5
- export declare class RethnetStateManager {
6
- private _state;
7
- constructor(_state: StateManager);
8
- static withGenesisAccounts(context: RethnetContext, genesisAccounts: GenesisAccount[]): RethnetStateManager;
9
- static forkRemote(context: RethnetContext, forkConfig: ForkConfig, genesisAccounts: GenesisAccount[]): Promise<RethnetStateManager>;
10
- asInner(): StateManager;
11
- accountExists(address: Address): Promise<boolean>;
12
- getAccount(address: Address): Promise<Account | null>;
13
- getAccountStorageRoot(address: Address): Promise<Buffer | null>;
14
- accountIsEmpty(address: Address): Promise<boolean>;
15
- deleteAccount(address: Address): Promise<void>;
16
- makeSnapshot(): Promise<Buffer>;
17
- removeSnapshot(stateRoot: Buffer): Promise<void>;
18
- modifyAccount(address: Address, modifyAccountFn: (balance: bigint, nonce: bigint, code: Bytecode | undefined) => Promise<Account>): Promise<void>;
19
- getContractCode(address: Address): Promise<Buffer>;
20
- getContractStorage(address: Address, key: Buffer): Promise<Buffer>;
21
- putContractStorage(address: Address, key: Buffer, value: Buffer): Promise<void>;
22
- checkpoint(): Promise<void>;
23
- commit(): Promise<void>;
24
- revert(): Promise<void>;
25
- getStateRoot(): Promise<Buffer>;
26
- setBlockContext(stateRoot: Buffer, blockNumber?: bigint): Promise<void>;
27
- serialize(): Promise<string>;
28
- }
29
- //# sourceMappingURL=RethnetState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RethnetState.d.ts","sourceRoot":"","sources":["../../../src/internal/hardhat-network/provider/RethnetState.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGR,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM1D,qBAAa,mBAAmB;IAClB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;WAE1B,mBAAmB,CAC/B,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,cAAc,EAAE,GAChC,mBAAmB;WAcF,UAAU,CAC5B,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,cAAc,EAAE,GAChC,OAAO,CAAC,mBAAmB,CAAC;IA0BxB,OAAO,IAAI,YAAY;IAIjB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjD,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAIrD,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI/D,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAUlD,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,aAAa,CACxB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,CACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,QAAQ,GAAG,SAAS,KACvB,OAAO,CAAC,OAAO,CAAC,GACpB,OAAO,CAAC,IAAI,CAAC;IAIH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAalD,kBAAkB,CAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC;IAOL,kBAAkB,CAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAOH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,eAAe,CAC1B,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAIH,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;CAG1C"}