Skip to content

hardhat command evaluates hardhat.config.ts for system commands like keystore #7122

@michalbrabec

Description

@michalbrabec

Feedback

I set an account in keystore to an invalid value (prefix 0x was missing)
When I try to run npx hardhat keystore set OP_SENDER --force to update it, I get

Error HHE15: Invalid config:
        * Config error in config.networks.op.accounts.0: Expected a hex-encoded private key or a Configuration Variable

It evaluates the hardhat.config.ts even for keystore commands and help
Not sure if this can be avoided without significant redesign, but it makes it difficult to fix the value once set to invalid

The hardhat.config.ts is the default from v-next (https://github.com/NomicFoundation/hardhat/blob/v-next/v-next/example-project/hardhat.config.ts), but the config var OP_SENDERis not set, which results in invalid networks configuration.

Repro Steps

  • git clone -b v-next https://github.com/NomicFoundation/hardhat.git
  • cd hardhat
  • pnpm i
  • pnpm build
  • cd v-next/example-project
  • change the hardhat.config.ts
    • replace line 121 with accounts: ['configVariable("OP_SENDER")'], (add quotes around the variable)
  • npx hardhat keystore set OP_SENDER --force

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    To-do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions