Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No overload matches this call - Lock's deploy script #4118

Closed
0xartcro opened this issue Jul 5, 2023 · 14 comments
Closed

No overload matches this call - Lock's deploy script #4118

0xartcro opened this issue Jul 5, 2023 · 14 comments
Labels
status:needs-more-info There's not enough information to start working on this issue

Comments

@0xartcro
Copy link

0xartcro commented Jul 5, 2023

Version of Hardhat

2.16.1

What happened?

Installed latest version of Hardhat including Toolbox 3 and after opening Lock's deploy.ts script it shows errors:

No overload matches this call.
  Overload 1 of 4, '(name: "Lock", args: any[], signerOrOptions?: Signer | FactoryOptions | undefined): Promise<Lock>', gave the following error.
    Argument of type '{ value: bigint; }' is not assignable to parameter of type 'Signer | FactoryOptions | undefined'.
      Object literal may only specify known properties, and 'value' does not exist in type 'Signer | FactoryOptions'.
  Overload 2 of 4, '(name: string, args: any[], signerOrOptions?: Signer | FactoryOptions | undefined): Promise<Contract>', gave the following error.
    Argument of type '{ value: bigint; }' is not assignable to parameter of type 'Signer | FactoryOptions | undefined'.
      Object literal may only specify known properties, and 'value' does not exist in type 'Signer | FactoryOptions'.ts(2769)

Running the script compiles and deploys everything properly though.

Using Visual Studio Code.

Minimal reproduction steps

  1. Install latest version of hardhat

My package.json file:

{
  "name": "hardhat",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^3.0.0",
    "hardhat": "^2.16.1",
    "typescript": "^5.1.6"
  },
  "dependencies": {
    "@openzeppelin/hardhat-upgrades": "^2.0.0"
  }
}
  1. Setup project for Typescript
  2. Open deploy.ts script

Search terms

No response

@fvictorio
Copy link
Member

Uhm, I cannot reproduce this. I generated the sample typescript project, opened the script with VSCode, and got no errors.

Can you share your tsconfig.json file?

@fvictorio fvictorio added status:needs-more-info There's not enough information to start working on this issue and removed status:triaging labels Jul 6, 2023
@0xartcro
Copy link
Author

0xartcro commented Jul 7, 2023

Uhm, I cannot reproduce this. I generated the sample typescript project, opened the script with VSCode, and got no errors.

Can you share your tsconfig.json file?

{
  "compilerOptions": {
    "target": "es2020",
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "resolveJsonModule": true
  }
}

I've seen someone else having same issue and asking about that here https://ethereum.stackexchange.com/questions/152107/error-in-hardhat-basic-example-deploy-ts

So I am not the only one I guess

@clauBv23
Copy link
Contributor

clauBv23 commented Jul 9, 2023

The issue here is related to TypeChain, not Hardhat, the script runs without a problem, but the error is shown once the hardhat.d.ts file is autogenerated.

This is due to the latest version of hardhat-ethers that TypeChain supports is v3.0.0 and in version v3.0.1 transactions override where added, updating the deployContract function params type,
d8056fb#diff-8d6cd3812336cbda37672c85460dd7086a6dd3fa1c6848ab12dce44fedd880e7

In the hardhat.d.ts file, changing the return type of the function will fix this issue.
Only have to change FactoryOptions for DeployContractOptions.

This could work until TypeChain is updated.

edit: I have been taking a look at TypeCheck and not sure what is the issue but think it should work with v3.0.1

@boldrack
Copy link

boldrack commented Jul 9, 2023

@clauBv23 I'm using hardhat-ethers 3.0.0 and I'm facing the same issue now .

@clauBv23
Copy link
Contributor

clauBv23 commented Jul 9, 2023

@boldrack what version of hardhat and hardhat-toolbox are you using?
And yes you are right when adding hardhat-ethers v3.0.0 to the project it works but you can check that the balance of the deployed contract is zero (it should be 0.001 ethers due to it being passed as value).
So the problem remained the same, you are providing a param that the function is not expecting.
That's why the sample project was different before v3.0.1

@boldrack
Copy link

boldrack commented Jul 9, 2023

@clauBv23 I"m using hardhat 2.16.1 and hardhat-toolbox 3.0.0

I think there's been a mixup in the usage of DeployContractOptions and FactoryOptions

DeployContractOptions is supposed to cater for that value param, correct me if i'm wrong.

@clauBv23
Copy link
Contributor

clauBv23 commented Jul 9, 2023

Yeap, it looks like DeployContractOptions was created to extend FactoryOptions and support transaction overrides (in this case value) as mentioned in v3.0.1 release

export type DeployContractOptions = FactoryOptions & ethers.Overrides;

@DainisGorbunovs
Copy link

DainisGorbunovs commented Jul 16, 2023

Fix

I've added a fix to @typechain/ethers-v6, which should solve this issue.
It's in code review dethcrypto/TypeChain#852

Merged:

Workaround for now

Manually import DeployContractOptions:

import { DeployContractOptions } from '@nomicfoundation/hardhat-ethers/types'

Then assert type of the object to be DeployContractOptions, and your IDE (Visual Studio Code, WebStorm/IntelliJ) will work correctly.

  const lock = await ethers.deployContract('Lock', [unlockTime], {
    value: lockedAmount,
  } as DeployContractOptions)

@fvictorio
Copy link
Member

Thanks a lot everyone for the info, I will look into this again

@fvictorio fvictorio added status:ready This issue is ready to be worked on and removed status:needs-more-info There's not enough information to start working on this issue labels Jul 17, 2023
@fvictorio fvictorio self-assigned this Jul 17, 2023
@clauBv23
Copy link
Contributor

I just tried with the latest version of @typechain/hardhat@8.0.2 and the typechain error has gone

@fvictorio
Copy link
Member

Ah interesting. @0xartcro can you check if that fixes the issue for you?

@fvictorio fvictorio added status:needs-more-info There's not enough information to start working on this issue and removed status:ready This issue is ready to be worked on labels Jul 18, 2023
@DainisGorbunovs
Copy link

I can confirm this issue is now solved due to flexible patch versioning in hardhat-toolbox package and absence of a lock file. The actual fix is in typechain@8.3.0 and @typechain/ethers-v6@0.4.1+.

Users with already existing projects will need to run npm update typechain @typechain/ethers-v6, or if using pnpm pnpm up typechain @typechain/ethers-v6.

Here are the package versions currently used when creating a TypeScript project:

Versions
  • npm install --save-dev hardhat
    • "hardhat": "^2.17.0" (2.17.0 in package-lock.json)
  • npx hardhat
    • "@nomicfoundation/hardhat-toolbox": "^3.0.0" (3.0.0 in package-lock.json), with these peer dependencies:
      • "typechain": "^8.2.0"
      • "@typechain/ethers-v6": "^0.4.0"
      • "@typechain/hardhat": "^8.0.0"
    • "@typechain/hardhat" is 8.0.2` with these peer dependencies:
      • "@typechain/ethers-v6": "^0.4.2" with this peer dependency:
        • "typechain": "^8.3.0", which in my case is 8.3.0.

@0xartcro
Copy link
Author

Ah interesting. @0xartcro can you check if that fixes the issue for you?

It does, thanks

@fvictorio fvictorio removed their assignment Jul 26, 2023
@fvictorio
Copy link
Member

Thanks. In that case I think I will close this issue. I didn't re-read the whole conversation so let me know if I'm missing something and I'll re-open.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:needs-more-info There's not enough information to start working on this issue
Projects
Archived in project
Development

No branches or pull requests

5 participants