The following script is from a tutorial by Patrick Collins on creating NFTs. the source of this code is https://github.com/PatrickAlphaC/all-on-chain-generated-nft/blob/main/deploy/02_Deploy_RandomSVG.js
in the scripts that deploy contracts, the author uses a pattern similar to this:
let { networkConfig, getNetworkIdFromName } = require('../helper-hardhat-config')
const fs = require('fs')
module.exports = async ({
getNamedAccounts,
deployments,
getChainId
}) => {
const { deploy, get, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = await getChainId()
...
...
const VRFCoordinatorMock = await deployments.get('VRFCoordinatorMock')
...
...
I am trying to understand what's going on under the hood with:
{
getNamedAccounts,
deployments,
getChainId
}
It looks like some object is getting unpacked/deconstructed (?). I couldn't find any documentation about what it is, or if I did, its too complex for me to understand.
Can someone please tell me where this async function is getting exported to, and who will be requiring (i.e. calling) this function ?
If the above 3 properties were deconstructed from some object, what is that object? how does it fit in the bigger Hardhat picture?