PatrickAlphaC / hardhat-fund-me-fcc

82 stars 184 forks source link

00-deploy-mocks gives an error: Cannot read properties of undefined (reading 'length') [Tutorial Time: 10:48:00] #40

Closed Nitro-lens closed 2 years ago

Nitro-lens commented 2 years ago

So I am at moment 10:48:00 in the tutorial, and it returns me this:

An unexpected error occurred:

Error: ERROR processing C:\Users\Pc\hardhat-fund-me-fcc\deploy\00-deploy-mocks.js:
TypeError: Cannot read properties of undefined (reading 'length')

error when I try to run: yarn hardhat deploy --tags mocks

I manually copied all the code from the tutorial in my Visual Studio and I think I got all the steps right. Here's my code:

00-deploy-mocks.js

const {network} = require("hardhat")
const {developmentChains, DECIMALS, INITIAL_ANSWER} = require("../helper-hardhat-config")
const chainId = network.config.chainId

module.exports = async({getNamedAccounts,deployments})=>{
    const {deploy,log} = deployments
    const {deployer} = await getNamedAccounts()

    if(developmentChains.includes(network.name)){
        log("Local Network detected! Deploying mocks...")
        await deploy("MockV3Aggregator", {
            contract: "MockV3Aggregator",
            from: deployer,
            log:true,
            args: [DECIMALS, INITIAL_ANSWER],
        })
        log("Mocks deployed!")
        log("-----------------------")
    }
}

module.exports.tags = ["all","mocks"]

helper-hardhat-config.js

const networkConfig = {
    4: {
        name: "rinkeyby",
        ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e"

    },

    137: {
        name:"polygon",
        ethUsdPriceFeed:"0xF9680D99D6C9589e2a93a78A04A279e509205945",
    },

    //31337
}

const developmentChains = ["hardhat", "localhost"]
const DECIMALS = 8
const INITIAL_ANSWER = 200000000000

module.exports = {
    networkConfig,
    developmentChains,
    DECIMALS,
    INITIAL_ANSWER,
}

What am I missing? It goes beyond the first if verification so I assume it has something to do with what's beyond deploy("MockV3Aggregator",

Nitro-lens commented 2 years ago

It was solved by this: https://github.com/PatrickAlphaC/hardhat-fund-me-fcc/issues/28

THANKS A LOT! 🥂 I didn't read it

PatrickAlphaC commented 2 years ago

Nice!