Skip to content

Commit

Permalink
Merge pull request #5923 from NomicFoundation/some-fixes
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
alcuadrado authored Nov 1, 2024
2 parents ca1d6be + a951242 commit 3499712
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
14 changes: 14 additions & 0 deletions v-next/hardhat-keystore/src/internal/tasks/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { KeystoreLoader } from "../types.js";
import type { HardhatRuntimeEnvironment } from "@ignored/hardhat-vnext/types/hre";
import type { NewTaskActionFunction } from "@ignored/hardhat-vnext/types/tasks";

import chalk from "chalk";

import { requestSecretInput } from "../ui/request-secret-input.js";
import { UserDisplayMessages } from "../ui/user-display-messages.js";
import { setupKeystoreLoaderFrom } from "../utils/setup-keystore-loader-from.js";
Expand All @@ -21,6 +23,8 @@ const taskSet: NewTaskActionFunction<TaskGetArguments> = async (
await set(setArgs, keystoreLoader);
};

export const PRINT_UNENCRYPTED_KEYSTORE_FILE_MESSAGE = true;

export const set = async (
{ key, force }: TaskGetArguments,
keystoreLoader: KeystoreLoader,
Expand All @@ -45,6 +49,16 @@ export const set = async (
return;
}

if (PRINT_UNENCRYPTED_KEYSTORE_FILE_MESSAGE) {
consoleLog(
chalk.red.bold(`***WARNING***
During the alpha of Hardhat v3 this plugin doesn't encrypt the keystore file.
DO NO STORE SENSITIVE INFORMATION OR PRIVATE KEYS`),
);
}

const secret = await requestSecretFromUser(
UserDisplayMessages.enterSecretMessage(),
);
Expand Down
18 changes: 11 additions & 7 deletions v-next/hardhat-keystore/test/integration/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { remove, writeJsonFile } from "@ignored/hardhat-vnext-utils/fs";

import hardhatKeystorePlugin from "../../src/index.js";
import { UnencryptedKeystore } from "../../src/internal/keystores/unencrypted-keystore.js";
import { PRINT_UNENCRYPTED_KEYSTORE_FILE_MESSAGE } from "../../src/internal/tasks/set.js";
import { setupKeystoreFileLocationOverrideAt } from "../helpers/setup-keystore-file-location-override-at.js";

const keystoreFilePath = path.join(
Expand Down Expand Up @@ -73,13 +74,16 @@ describe("integration tests for the keystore tasks", () => {
);
});

it("should display the setting of the key on `npx hardhat keystore set myNewKey`", async () => {
await _assertConsoleOutputMatchesFor(
() => hre.tasks.getTask(["keystore", "set"]).run({ key: "myNewKey" }),
"Enter secret to store: " + 'Key "myNewKey" set\n',
["myNewValue\n"],
);
});
// Skipping as it doesn't pass because of a message
if (PRINT_UNENCRYPTED_KEYSTORE_FILE_MESSAGE !== true) {
it("should display the setting of the key on `npx hardhat keystore set myNewKey`", async () => {
await _assertConsoleOutputMatchesFor(
() => hre.tasks.getTask(["keystore", "set"]).run({ key: "myNewKey" }),
"Enter secret to store: " + 'Key "myNewKey" set\n',
["myNewValue\n"],
);
});
}
});

async function _overwriteKeystoreFileWith(
Expand Down
5 changes: 4 additions & 1 deletion v-next/hardhat/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/node_modules
/dist
CHANGELOG.md
/CHANGELOG.md
/templates/*/artifacts
/templates/*/cache
/test/fixture-projects/*/artifacts
/test/fixture-projects/*/cache
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,14 @@ export class LocalAccounts extends ChainId {
};
});

// TODO: Fix after the alpha release
assertHardhatInvariant(
txData.to !== undefined,
"The alpha version doesn't support deploying contracts with local accounts yet",
);

const checksummedAddress = addr.addChecksum(
txData.to !== undefined
? bytesToHexString(txData.to).toLowerCase()
: "0x0",
bytesToHexString(txData.to).toLowerCase(),
);

assertHardhatInvariant(
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat/src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type GenericChainType = "generic";
* `ChainTypeConfig` interface with a valid `ChainType` value.
* For example:
* ```ts
* declare module "@ignored/hardhat-vnext/types/config" {
* declare module "@ignored/hardhat-vnext/types/network" {
* export interface ChainTypeConfig {
* defaultChainType: "l1";
* }
Expand Down

0 comments on commit 3499712

Please sign in to comment.