Open massun-onibakuchi opened 3 years ago
That's what I did in ts
const hre = require("hardhat");
vault = await hre.ethers.getVerifiedContractAt(BANK_ADDRESS);
I have the same problem. I have created a HH js script that is supposed to cache the ABIs of a series of contracts. But the function does not exists:
require('hardhat-etherscan-abi');
const hre = require("hardhat");
async function fetchAndSaveABI(contractName, address) {
const abi = await hre.ethers.getVerifiedContractAt(address);
// stuff
};
I tried a series of things, without success.
I don't know typescript well enough to fix this. Maybe someone can help?
The issue was that I was trying to create a script in the HH scaffold. But when I converted it into a HH task, then it worked correctly.
@poma I tried looking into it. And from what I've gathered, because you're trying to extend the hre.ethers
, with this plugin, it's required much more, than just extendEnvironment
. If you look at hardhat-deploy-ethers
plugin you will understand.
It's easier to just extend hre
with new functions via extendEnvironment
.
So currently it's impossible for me to use this plugin (at least in Typescript), and I don't have so much time to rewrite it...
It seems like hardhat-deploy-ethers is doing similar stuff: https://github.com/wighawag/hardhat-deploy-ethers/blob/main/src/internal/index.ts#L27 except that my code seems to capture previous ethers
on initialization instead of inside lazyObject
init. I'll try to experiment with it.
I tried to do it in their way, but then one thing led to another... Looks like you have to duplicate and extend the whole eth.ethers
just to add your custom functions.
I think if you look at this line: https://github.com/wighawag/hardhat-deploy-ethers/blob/f4990b24fd2eb6865d96a53c84b5eab0f094495a/src/internal/type-extensions.ts#L14 it limits the type to ethers
and HardhatEthersHelpers
, which leads to: https://github.com/wighawag/hardhat-deploy-ethers/blob/f4990b24fd2eb6865d96a53c84b5eab0f094495a/src/types/index.ts#L24
I didn't have enough time to decide where the extension of hre.ethers
should happen so to adhere to the hardhat plugin guidelines. The hardhat-deploy-ethers
overrides the whole thing from scratch it seems. Basically replacing the original one. It's meant to be used in place of the original hre.ethers
.
P.S. but again I only spent 30 minutes on this whole plugin stuff :))
Is there a way to extend HardhatEthersHelpers
maybe? I've tried to experiment in typescript
branch but no luck so far.
Have no idea... they have a discord server with a channel for plugin development, maybe you can ask there: https://discord.gg/unHHhmK92a
Anyone ever find a solution to this?
I try some test. I added this to my hardhat.config.ts:
import "hardhat-etherscan-abi"
Then I try to a following test.It give me a error ,
I also try the same test in js, it worked properly. @poma