NomicFoundation / hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
https://hardhat.org
Other
7k stars 1.36k forks source link

"hardhat_setLedgerOutputEnabled - Method not supported" message when deploying a contract with Hardhat Ignition #5406

Open BenBktech opened 2 weeks ago

BenBktech commented 2 weeks ago

Version of Hardhat

2.22.5

What happened?

There is a "hardhat_setLedgerOutputEnabled - Method not supported" message on the "Hardhat node" console when deploying a contract with Hardhat Ignition.

Minimal reproduction steps

Create a new contract contracts/Bank.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

///@title A simple Bank contract which allows users to deposit and then, withdraw ethers
///@author Ben BK 

contract Bank {

    struct Account {
        uint balance;
        uint lastDeposit;
    }

    mapping(address => Account) accounts;

    event etherDeposited(address indexed account, uint amount);
    event etherWithdrawed(address indexed account, uint amount);

    ///@notice Allows the user to withdraw ethers from the smart contract 
    ///@param _amount The amount of ethers the user wants to withdraw
    function withdraw(uint _amount) external {
        require(accounts[msg.sender].balance >= _amount, "Not enough funds");
        accounts[msg.sender].balance -= _amount;
        (bool received, ) = msg.sender.call{value: _amount}("");
        require(received, "An error occured");
        emit etherWithdrawed(msg.sender, _amount);
    }

    ///@notice Allows a user to deposit ethers on the smart contract
    function deposit() external payable {
        require(msg.value > 0, "Not enough funds deposited");
        accounts[msg.sender].balance += msg.value;
        accounts[msg.sender].lastDeposit = block.timestamp;
        emit etherDeposited(msg.sender, msg.value);
    }

    ///@notice Allows to get the amount of ethers the user has on the smart contract 
    ///@return The amount of ethers the user has on the smart contract
    function getBalanceOfUser() external view returns(uint) {
        return accounts[msg.sender].balance;
    }
}

Create a new ignition module ignition/modules/Bank.js

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

module.exports = buildModule("BankModule", (m) => {

  const bank = m.contract("Bank");

  return { bank };
});

hardhat.config.js file :

require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.24",
};

package.json :

{
  "devDependencies": {
    "@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
    "@nomicfoundation/hardhat-ethers": "^3.0.0",
    "@nomicfoundation/hardhat-ignition": "^0.15.0",
    "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.0",
    "@nomicfoundation/hardhat-toolbox": "^5.0.0",
    "@nomicfoundation/hardhat-verify": "^2.0.0",
    "@typechain/ethers-v6": "^0.5.0",
    "@typechain/hardhat": "^9.0.0",
    "chai": "^4.2.0",
    "ethers": "^6.4.0",
    "hardhat": "^2.22.5",
    "hardhat-gas-reporter": "^1.0.8",
    "solidity-coverage": "^0.8.0",
    "typechain": "^8.3.0"
  }
}

Launch the Hardhat local node with : yarn hardhat node

Open a new Terminal and launch : yarn hardhat ignition deploy .\ignition\modules\Bank.js --network localhost

Come back on the Hardhat local node terminal, there is the following message in red : hardhat_setLedgerOutputEnabled - Method not supported

Search terms

hardhat, ignition, hardhat_setLedgerOutputEnabled - Method not supported, setLedgerOutputEnabled

kanej commented 2 weeks ago

Thanks @BenBktech, for the details and reproduction steps.

This is likely a side-effect of our implementation in hardhat-ledger. We piggy-backed the rpc mechanism to control UI display in the wrapped ledger provider.

This warning in can safely be ignored, but we shouldn't be warning on doing something that is fully expected (an Ignition deployment).

BenBktech commented 2 weeks ago

Thank you for your answer @kanej