smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.31k stars 2.96k forks source link

Hey @MasterofBlockchain the deployer in this statement `const response = await FundMe.getAddressToAMountFunder(deployer)` is the same deployer here `deployer = (await getNamedAccounts()).deployer` i.e. the account that deployed the FundMe contract when we linked them in this statement `FundMe = await ethers.getContract("FundMe", deployer)` #2061

Closed TimeKeyRoll closed 2 years ago

TimeKeyRoll commented 2 years ago

Hey @MasterofBlockchain the deployer in this statement const response = await FundMe.getAddressToAMountFunder(deployer) is the same deployer here deployer = (await getNamedAccounts()).deployer i.e. the account that deployed the FundMe contract when we linked them in this statement FundMe = await ethers.getContract("FundMe", deployer)

Originally posted by @othaime-en in https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/2049#discussioncomment-3474661

TimeKeyRoll commented 2 years ago

I understand what is a deployer but what i don't understand is how its helping us in the function?

TimeKeyRoll commented 2 years ago

And same deployer question about mentioned line.

it("adds funders to funder array", async function () {
            await FundMe.fund({ value: sendValue })
            const funder = await FundMe.getFunder(0)
            assert.equal(funder, deployer)

i understand all the test but does not get assert.equal(funder, deployer) this line with deployer how deployer is helping us to test?

sorry for stupid questions. but need to know :)

br0wnD3v commented 2 years ago

We need to see that the person who originally sent ETH, in this case 'deployer' is actually pushed in the funders[] array. FundMe.fund({value:sendValue}) is chained to the deployer account so the transaction is made with the deployer address and therefore the deployer address is pushed into the funders array. funder = await FundMe.getFunder(0) is supposed to return the first entry in the funders[] and should return the expected address i.e the deployer's address.

And don't worry about the question being stupid or not :) You are doing good 👍🏽

TimeKeyRoll commented 2 years ago

Thank you very much.

br0wnD3v commented 2 years ago

Happy to help :) Close the issue If you think you got your answer, Cheers 😄