NomicFoundation / hardhat-ignition

Hardhat Ignition is a declarative deployment system that enables you to deploy your smart contracts without navigating the mechanics of the deployment process.
https://hardhat.org/ignition
MIT License
106 stars 23 forks source link

Allow creating global parameters #803

Closed tmigone closed 2 days ago

tmigone commented 3 weeks ago

Describe the feature

Problem

Module parameters are great but sometimes you can have multiple modules requiring the exact same parameter which can become a bit tedious to manage.

For example, if I wanted to set the owner for a bunch of contracts on different modules I would have a config file like this:

{
  "GraphProxyAdmin": {
    "owner": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
    "pauseGuardian": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC"
  },
  "Controller": {
    "owner": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
  },
  "RewardsManager": {
    "owner": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
    "issuancePerBlock": "114155251141552511415n"
  }
}

Solution

It would be nice to have global parameters that could be accessed from any module. Maybe use the global keyword to group them.

The config file in this case would be much cleaner, and the global parameters would immediately be recognized as such:

{
  "global": {
    "owner": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
    "pauseGuardian": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC"
  },
  "RewardsManager": {
    "issuancePerBlock": "114155251141552511415n"
  }
}

Then for accessing the global parameters the API could be something like:

const owner = m.getGlobalParameter('owner')

Search terms

global, parameter, module parameter

alcuadrado commented 1 week ago

For future reference: https://github.com/graphprotocol/contracts/pull/1025#discussion_r1761943147