I'm currently developing a simple prediction market test dapp to further my learning & I'm writing tests right now to check the first contract out. I wanted to make sure that I was referencing & updating certain values the correct way, so I imported Hardhat console.log so that I could log out some of the outputs. I currently have a struct and two enums, & I am able to log out the values of some of my mappings containing the struct & an enum, but console.log will not work on the others.
This is the warning I get: "Member 'log' not found or not visible after argument-dependent lookup in type(library console)."
I know that I must be trying to reference or access them wrong, and might just be using them plain wrong altogether. To that extent, can someone please explain to me how to access/set an enum value, and let me know if I'm doing it all wrong below? Are those values not able to be logged to the console for some reason? I guess I'm just confused as to what I'm really accessing here, as it's very hard for me to visualize right now. I get the aforementioned error on each of the first console.log statements in the if/else, but not the second ones (the ones that reference the struct).
Relevant code is below:
Result public result;
enum overUnder {
Over,
Under
}
enum Status {
Win,
Lose,
Draw
}
struct Result {
overUnder winner;
overUnder loser;
}
mapping(overUnder => uint256) public bets;
mapping(address => mapping(overUnder => uint256)) public betsPerBettor;
mapping(address => mapping(overUnder => Status)) public bettorWinLoss;
function winOrLose() public {
uint256 initialPrice = 100;
uint256 finalPrice = 120;
if (initialPrice > finalPrice) {
result.winner = overUnder.Under;
bettorWinLoss[msg.sender][overUnder.Under] = Status.Win;
console.log("User win under status: ", bettorWinLoss[msg.sender][overUnder.Under]);
console.log("Winners under: ", result.winner);
} else {
result.winner = overUnder.Over;
bettorWinLoss[msg.sender][overUnder.Over] = Status.Win;
console.log("User win over status: ", bettorWinLoss[msg.sender]);
console.log("Winners over: ", result.winner);
}
Thank you!