-
// SPDX-License-Identifier: MIT
pragma solidity 0.6.0;
import "@chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol"; I have imported @chainlink/contracts as well but still it gives error.
|
Beta Was this translation helpful? Give feedback.
Answered by
ProKing13
Mar 24, 2024
Replies: 1 comment
-
it is finally solved // SPDX-License-Identifier: MIT
pragma solidity 0.6.0;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorInterface.sol";
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
// import "@chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
abstract contract MockV3Aggregator is
AggregatorInterface,
AggregatorV3Interface
{
uint256 public constant override version = 0;
uint8 public override decimals;
int256 public override latestAnswer;
uint256 public override latestTimestamp;
uint256 public override latestRound;
mapping(uint256 => int256) public override getAnswer;
mapping(uint256 => uint256) public override getTimestamp;
mapping(uint256 => uint256) private getStartedAt;
constructor(uint8 _decimals, int256 _initialAnswer) public {
decimals = _decimals;
updateAnswer(_initialAnswer);
}
function updateAnswer(int256 _answer) public {
latestAnswer = _answer;
latestTimestamp = block.timestamp;
latestRound++;
getAnswer[latestRound] = _answer;
getTimestamp[latestRound] = block.timestamp;
getStartedAt[latestRound] = block.timestamp;
}
function updateRoundData(
uint80 _roundId,
int256 _answer,
uint256 _timestamp,
uint256 _startedAt
) public {
latestRound = _roundId;
latestAnswer = _answer;
latestTimestamp = _timestamp;
getAnswer[latestRound] = _answer;
getTimestamp[latestRound] = _timestamp;
getStartedAt[latestRound] = _startedAt;
}
function getRoundData(
uint80 _roundId
)
external
view
override
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return (
_roundId,
getAnswer[_roundId],
getStartedAt[_roundId],
getTimestamp[_roundId],
_roundId
);
}
function latestRoundData()
external
view
override
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return (
uint80(latestRound),
getAnswer[latestRound],
getStartedAt[latestRound],
getTimestamp[latestRound],
uint80(latestRound)
);
}
function description() external view override returns (string memory) {
return "v0.6/tests/MockV3Aggregator.sol";
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ProKing13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is finally solved