wighawag / hardhat-deploy-ethers

MIT License
70 stars 25 forks source link

'getContract' function does not exist when used with tenderly-cli #26

Closed samlaf closed 1 year ago

samlaf commented 2 years ago

There are a few similar issues already, like https://github.com/wighawag/hardhat-deploy-ethers/issues/1 and https://github.com/wighawag/hardhat-deploy-ethers/issues/12, but none that mention tenderly-cli.

my ethers.getContract function was working fine, until I installed hardhat-tenderly. Now, I get errors.

When I import hardhat-tenderly before hardhat-deploy-ethers in hardhat.config.ts,

import * as tdly from "@tenderly/hardhat-tenderly";
tdly.setup();

import "hardhat-deploy";
import "@nomiclabs/hardhat-ethers";

I get (but adding a // @ts-ignore the code runs fine, so its just a ts module problem..)

Property 'getContract' does not exist on type 'typeof import("/Users/deckysetiawan/devel/bots/liquidation-bots/aave-v3-liquidator/node_modules/ethers/lib/ethers") & HardhatEthersHelpers'. Did you mean 'getContractAt'?ts(2551)

If I change the ordering in hardhat.config.ts,

    const liquidatorContract = await ethers.getContract("Liquidator", liquidator) as Liquidator;
                                            ^
TypeError: hardhat_1.ethers.getContract is not a function
    at main (/Users/deckysetiawan/devel/scripts/liquidation.ts:41:45)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

and this time even adding // @ts-ignore does not fix the issue.

Any idea what is going on? My package.json looks like

{
  "name": "hardhat-template",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "compile": "npx hardhat compile",
    "test": "npx hardhat test",
    "graphql-codegen": "graphql-codegen --config codegen.yml"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@aave/contract-helpers": "^1.3.7",
    "@aave/core-v3": "^1.13.1",
    "@aave/math-utils": "^1.3.7",
    "@graphql-codegen/cli": "^2.6.2",
    "@graphql-codegen/introspection": "2.1.1",
    "@graphql-codegen/typescript": "2.5.1",
    "@graphql-codegen/typescript-graphql-request": "^4.4.10",
    "@graphql-codegen/typescript-operations": "^2.4.2",
    "@graphql-codegen/typescript-resolvers": "2.6.6",
    "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10",
    "@nomiclabs/hardhat-etherscan": "^3.0.3",
    "@nomiclabs/hardhat-waffle": "^2.0.3",
    "@openzeppelin/contracts": "^4.5.0",
    "@tenderly/hardhat-tenderly": "^1.1.3",
    "@traderjoe-xyz/core": "^2.4.6",
    "@typechain/ethers-v5": "^10.0.0",
    "@typechain/hardhat": "^6.0.0",
    "@types/chai": "^4.3.0",
    "@types/mocha": "^9.1.0",
    "@types/node": "^17.0.23",
    "chai": "^4.3.6",
    "dayjs": "^1.11.3",
    "dotenv": "^16.0.0",
    "ethereum-multicall": "^2.12.0",
    "ethereum-waffle": "^3.4.4",
    "ethers": "^5.6.9",
    "graphql": "^16.5.0",
    "graphql-request": "^4.3.0",
    "hardhat": "^2.9.2",
    "hardhat-deploy": "^0.11.10",
    "hardhat-gas-reporter": "^1.0.8",
    "prettier": "^2.6.1",
    "prettier-plugin-solidity": "^1.0.0-beta.19",
    "reflect-metadata": "^0.1.13",
    "solhint": "^3.3.7",
    "solhint-plugin-prettier": "^0.0.5",
    "ts-generator": "^0.1.1",
    "ts-node": "^10.7.0",
    "typechain": "^8.0.0",
    "typescript": "^4.6.3",
    "yarn-upgrade-all": "^0.6.1"
  },
  "dependencies": {}
}
wighawag commented 2 years ago

This is a dupliacte of https://github.com/wighawag/hardhat-deploy-ethers/issues/12

There are some other work around mentioned there, including using npm aliases

It might also be a good idea to tell tenderly team to not hardcode dependency on other plugin so user can chose to use different implementation

hardhat-deploy-ethers aims at becoming an extension of hardhat-ethers but unfortunately there is a blocking issue : https://github.com/NomicFoundation/hardhat/issues/1040

samlaf commented 2 years ago

You can see in my package.json that I already have "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.10" hardhat-ethers installed as an alias. I even tried removing the carret "^" as you suggested in one of the related issues, but nothing works. removed node_modules and yarn.lock and reinstalled; still same issue.

I will open an issue in hardhat-tenderly. How can they fix this? How should they go about installing hardhat-ethers without hardcoding it, as you suggest?

wighawag commented 2 years ago

hardhat-ethers without hardcoding it, as you suggest?

they can import it at runtime if needed, but they might not even need it in the first place. hardhat-deploy-ethers depends o hardhat-deploy yet do not have a hardcoded dependency on hardhat-deploy, it simply uses it and so tell user to install it.

wighawag commented 1 year ago

hardhat-deploy-ethers@next has been released Please, try it out.

It is now an extension to hardhat-ethers so you need both

But note that that new version do not support external artifact if you were using them