Open 0xdavinchee opened 3 years ago
I have been playing around w/ the code and I wanted to add a little more detail to this bug, I am actually able to run the deployment script by passing in a named account address when running npx hardhat node
, but this doesn't work when trying to run tests, maybe it is something to do with fixtures
? @wighawag
Hello there, facing the same problem, I got an Error: Unknown Signer for account: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
when deploying from tests script through a fixture.
Turned out I found my problem quickly after posting maybe you are in the same situation as I am.
While the docs says await deployments.fixture(); // ensure you start from a fresh deployments
it did not seem to work in my case (got the unknown signer error). When starting from a "fresh" fixture using await deployments.fixture(""); // notice the quotes
worked for me. Hope it helps.
EDIT: In the end even though using await deployments.fixture("");
made the problem disappears I think the base problem came from the fact I was calling the ficture in a describe
block instead of an it
one.
Hi all, thanks for the reports. does anyone have a reproduction repo with the issue ?
Hi, I'd like to add more details to this issue. The minimum reproduction is as simple as
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [address],
});
const signer = await hre.ethers.getSigner(address);
await hre.deployments.deploy(contractName, {
args: deployArgs,
from: signer.address,
log: true
})
I think the root cause is that hardhat-deploy saves all availableAccounts
during the initialization (https://github.com/wighawag/hardhat-deploy/blob/master/src/helpers.ts#L290) while impersonated accounts are added after the initialization. Therefore, we set the unknown = true
here https://github.com/wighawag/hardhat-deploy/blob/master/src/helpers.ts#L1693 and an exception is thrown here https://github.com/wighawag/hardhat-deploy/blob/master/src/helpers.ts#L595.
I don't understand why unknown
is checked and an exception is thrown if unknown is True. Can't we defer that to signer.sendTransaction
and re-raise UnknownSignerError
if ethers.js throws us an error? We don't need to keep track of availableAccounts
if we do it in this way.
Encountered the same error as describe above, I added a simple availableAccounts["ADDRESS".toLowerCase()] = true;
after the mentioned line above and it fixed the issue.
This issue might need to be re-opened.
Hey, sorry hard to find time these days, @yiteng-guo the links you provided are unfortunately not permalink so can't use them as the code changed since then @Magicking similarly not sure what line you are referring to
Permalinks for what @yiteng-guo was mentioning.
availableAccounts
during initialization: https://github.com/wighawag/hardhat-deploy/blob/f85305ba6ffef2750d64ade7509e7fd65a05bc27/src/helpers.ts#L287
unknown = true
set here if not present in availableAccounts
: https://github.com/wighawag/hardhat-deploy/blob/f85305ba6ffef2750d64ade7509e7fd65a05bc27/src/helpers.ts#L1769
Exception is thrown here: https://github.com/wighawag/hardhat-deploy/blob/f85305ba6ffef2750d64ade7509e7fd65a05bc27/src/helpers.ts#L442
The problem is that even when ethSigners
has a valid value (because of the impersonation), the exception gets thrown.
Also now sure how @Magicking was able to add to availableAccounts
when importing hardhat-deploy
package.
This may help you guys, I was trying to run deployments against forked mainnet node (i.e. localhost network) and was able to make it work by adding autoImpersonate: true
option on the localhost
network section:
...
networks: {
localhost: {
...
autoImpersonate: true,
...
}
}
...
Have had to call hardhat_impersonateAccount
somewhere before running deployment scripts
I had this issue while trying to use extendProvider
to add custom logic to request()
method.
I fixed this by adding accounts: "remote"
on the hardhat.config.ts
as per below:
goerli: {
accounts: "remote",
chainId: 5,
url: `https://rpc.ankr.com/eth_goerli`,
},
I am attempting to impersonate an account via the
namedAccounts
property of the HardhatUserConfig object like so:However, I end up getting an error when I try deploying like so:
The error is this jumble of chaos: