Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FundMe] could not import AggregatorV3Interface #35

Open
neelesh004 opened this issue Sep 2, 2024 · 1 comment
Open

[FundMe] could not import AggregatorV3Interface #35

neelesh004 opened this issue Sep 2, 2024 · 1 comment

Comments

@neelesh004
Copy link

THIS IS MY ERROR

akashneelesh@Akashs-MacBook-Air foundry-fund-me-f24 % forge build
[⠊] Compiling...
[⠒] Compiling 3 files with Solc 0.8.26
[⠢] Solc 0.8.26 finished in 25.44ms
Error: 
Compiler run failed:
Error (6275): Source "lib/chainlink-brownie-contracts/contracts/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol" not found: File not found. Searched the following locations: "/Users/akashneelesh/foundry-simple-storage-f24/foundry-fund-me-f24".
ParserError: Source "lib/chainlink-brownie-contracts/contracts/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol" not found: File not found. Searched the following locations: "/Users/akashneelesh/foundry-simple-storage-f24/foundry-fund-me-f24".
 --> src/FundMe.sol:6:1:
  |
6 | import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error (6275): Source "lib/chainlink-brownie-contracts/contracts/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol" not found: File not found. Searched the following locations: "/Users/akashneelesh/foundry-simple-storage-f24/foundry-fund-me-f24".
ParserError: Source "lib/chainlink-brownie-contracts/contracts/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol" not found: File not found. Searched the following locations: "/Users/akashneelesh/foundry-simple-storage-f24/foundry-fund-me-f24".
 --> src/PriceConverter.sol:4:1:
  |
4 | import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

THIS IS MY CODING

// SPDX-License-Identifier: MIT
// 1. Pragma
pragma solidity 0.8.26;
// 2. Imports

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

// 3. Interfaces, Libraries, Contracts
error FundMe__NotOwner();

/**
* @title A sample Funding Contract
* @author Patrick Collins
* @notice This contract is for creating a sample funding contract
* @dev This implements price feeds as our library
*/
contract FundMe {
  // Type Declarations
  using PriceConverter for uint256;

  // State variables
  uint256 public constant MINIMUM_USD = 5 * 10 ** 18;
  address private immutable i_owner;
  address[] private s_funders;
  mapping(address => uint256) private s_addressToAmountFunded;
  AggregatorV3Interface private s_priceFeed;

  // Events (we have none!)

  // Modifiers
  modifier onlyOwner() {
      // require(msg.sender == i_owner);
      if (msg.sender != i_owner) revert FundMe__NotOwner();
      _;
  }

  // Functions Order:
  //// constructor
  //// receive
  //// fallback
  //// external
  //// public
  //// internal
  //// private
  //// view / pure

  constructor(address priceFeed) {
      s_priceFeed = AggregatorV3Interface(priceFeed);
      i_owner = msg.sender;
  }

  /// @notice Funds our contract based on the ETH/USD price
  function fund() public payable {
      require(
          msg.value.getConversionRate(s_priceFeed) >= MINIMUM_USD,
          "You need to spend more ETH!"
      );
      // require(PriceConverter.getConversionRate(msg.value) >= MINIMUM_USD, "You need to spend more ETH!");
      s_addressToAmountFunded[msg.sender] += msg.value;
      s_funders.push(msg.sender);
  }

  function withdraw() public onlyOwner {
      for (
          uint256 funderIndex = 0;
          funderIndex < s_funders.length;
          funderIndex++
      ) {
          address funder = s_funders[funderIndex];
          s_addressToAmountFunded[funder] = 0;
      }
      s_funders = new address[](0);
      // Transfer vs call vs Send
      // payable(msg.sender).transfer(address(this).balance);
      (bool success, ) = i_owner.call{value: address(this).balance}("");
      require(success);
  }

  function cheaperWithdraw() public onlyOwner {
      address[] memory funders = s_funders;
      // mappings can't be in memory, sorry!
      for (
          uint256 funderIndex = 0;
          funderIndex < funders.length;
          funderIndex++
      ) {
          address funder = funders[funderIndex];
          s_addressToAmountFunded[funder] = 0;
      }
      s_funders = new address[](0);
      // payable(msg.sender).transfer(address(this).balance);
      (bool success, ) = i_owner.call{value: address(this).balance}("");
      require(success);
  }

  /**
   * Getter Functions
   */

  /**
   * @notice Gets the amount that an address has funded
   *  @param fundingAddress the address of the funder
   *  @return the amount funded
   */
  function getAddressToAmountFunded(
      address fundingAddress
  ) public view returns (uint256) {
      return s_addressToAmountFunded[fundingAddress];
  }

  function getVersion() public view returns (uint256) {
      return s_priceFeed.version();
  }

  function getFunder(uint256 index) public view returns (address) {
      return s_funders[index];
  }

  function getOwner() public view returns (address) {
      return i_owner;
  }

  function getPriceFeed() public view returns (AggregatorV3Interface) {
      return s_priceFeed;
  }
}
@Kann05
Copy link

Kann05 commented Oct 15, 2024

Same issue lol. have you fixed it . I downloaded the library but nothing has changed the error still persist
Source "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported

Never mind it was Visual Code's problem they fixed it //Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants