I am reviewing a piece of code intended for the creation of an oracle and I get the following error: "Struct containing a (nested) mapping cannot be constructed"
I know it is related to the new compiler versions and I have been following some of the threads of people with similar problems in their codes but I have not just found the solution.
I hope you can help me. I leave the code snippet below.
pragma solidity ^0.8.0;
contract Oracle {
Request[] requests;
uint currentId = 0;
uint minQuorum = 2;
uint totalOracleCount = 3;
struct Request{
uint id;
string urlToQuery;
string attributeToFetch;
string agreedValue;
mapping(uint => string) answers;
mapping(address => uint) quorum;
}
function createRequest (
string memory _urlToQuery,
string memory _attributeToFetch
)
public
{
uint length = requests.push(Request(currentId, _urlToQuery, _attributeToFetch, "")); **// The error is here**
Request storage r = requests[length-1];
}
}