I have a contract that uses an eth/usd price feed library to convert a uint value into its USD equivalent.
pragma solidity 0.8.0; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; library PriceConverter { // No state variables inside of libraries // All functions must be internal function getPrice(AggregatorV3Interface priceFeed) internal view returns (uint256 _price) { (, int256 price, , , ) = priceFeed.latestRoundData(); return uint256(price * 1e10); } function getConversionRate(uint256 ethAmount, AggregatorV3Interface priceFeed) internal view returns (uint256) { uint256 price = getPrice(priceFeed); uint256 ethAmountInUsd = (price * ethAmount) / 1e18; return (ethAmountInUsd); } } pragma solidity 0.8.0; import "./PriceConverter.sol"; contract Foo { using priceConverter for uint256; MINIMUM_USD = 7000000000000 function bar() public payable { require(msg.value.getConversionRate() > MINIMUM_USD) } }
In my hardhat test I am trying to call the getConversionRate() uint256 function in my contract to test some values, but I am unsure how to access it.