In Progress Add Mock

This commit is contained in:
2024-08-04 04:51:48 +08:00
parent 89363c573a
commit 6e9c6dd633
9 changed files with 254 additions and 78 deletions

View File

@@ -0,0 +1,9 @@
// For Localhost, Hardhat, Ganache Without Price Feed To Get Price Feed
const { ethers, run, network } = require("hardhat");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
};

View File

@@ -0,0 +1,32 @@
// import
const { ethers, run, network } = require("hardhat");
const { networkConfig } = require("../helper-hardhat-config");
/* Above same as:
const helperConfig = require("../helper-hardhat-config");
const networkConfig = helperConfig.networkConfig;
*/
// main function
//function deployFunc() {
// const {getNamedAccounts, deployments} = hre;
// // Same as hre.getNamedAccounts & hre.deployments
//}
//module.exports.default = deployFunc;
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
const ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"];
// if contract doest't exist, we deploy a minimal version for our local testing
// When going for localhost / hardhat network we want to use a mock
// Auto Change Chains To Get different Gas
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress], // put price feed address
log: true,
});
};