Cyfrin / foundry-full-course-cu

GNU General Public License v3.0
3.63k stars 894 forks source link

Bad import #2070

Closed Aletheios42 closed 3 months ago

Aletheios42 commented 3 months ago

Section

Section 3 | FUNDME

Could you please leave a link to the Cyfrin Updraft Lesson (or YouTube video timestamp) where this error occurs? (You can right click a video and "copy video URL at current time")

https://updraft.cyfrin.io/courses/solidity/fund-me/deploying-to-zksync?lesson_format=video

Describe the bug

while deploying fundme.sol to zksync:

In the video you say you can import interfaz like this: import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

but it gives this compiling error:

Failed to compile:
Error HH404: File @chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol, imported from contracts/priceConverter.sol, not found.
HardhatError: HH404: File @chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol, imported from contracts/priceConverter.sol, not found.

so the way i solve it was bu creating a file AggregatorV3Interface.sol where i explicitly write down the interfaz like this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
    function decimals() external view returns (uint8);
    function description() external view returns (string memory);
    function version() external view returns (uint256);
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

and by doing that, and the rest of the tasks , moving files to contracts repository, moving library to Fundme.sol and chaing oracle address now compiles and the contract is ready to be deployed

TO SUM UP: change npm import for explicit interfaz in another file, and import that interfaz file

EngrPips commented 3 months ago

This will be attended to appropriately as soon as possible.

cromewar commented 3 months ago

Hello @AlejandroPintosAlcarazo, the source of the problem here is that Chainlink keeps changing occasionally and moving things over.

The solution is to add shared to the import like this:

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
cromewar commented 3 months ago

I have to ask, though, @AlejandroPintosAlcarazo, you mentioned that on the video, the import goes like this:

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

Without the shared.

Am I missing something?

Aletheios42 commented 3 months ago

now i understand what happened: in seccion 3 fund me:

  1. Creating your own libraries, the import looks like this: import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; (without share/)

but in 26. Deploying To Zksync the import looks like this: import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; (with share/)

i just used the same code i build in the cap 14 to deploy to in sepolia, to deploy in zksync as well, the code changed between caps (i think without any indication), that s why i couldnt compile...

i checked now and if you add share it actually deploy in zksync.

so to sum up:
the version of the import in cap 14 and cap 26 doesnt match.

cromewar commented 3 months ago

Excellent context, @AlejandroPintosAlcarazo. I will add and update section 14 to assess the import difference.