I saw a similar question here which I tried to use in my example but I still get confused from the code. Can you tell me what is the difference between those two examples?
contract First {
struct Emission {
string accountIdHash;
string orderIdHash;
}
function getData(string memory _orderIdHash) public view returns (string memory,string memory)
{
return (
"Account1",
"Order1"
);
}
}
interface IFirst {
function getData(string memory) external view returns (
string memory,
string memory
);
}
contract Second {
address contractFirst;
struct Emission {
string accountId;
string orderId;
}
Emission emission;
constructor(address _addressContractFirst)
{
contractFirst = _addressContractFirst;
}
function mint(string memory _orderIdHash) public {
(string memory accountIdHash, string memory orderIdHash) = IFirst(contractFirst).getData(_orderIdHash);
emission = Emission(accountIdHash, orderIdHash);
}
}
And this example:
function mint(string memory _orderIdHash) public {
Emission memory emission = Emission(IFirst(contractFirst).getData(_orderIdHash));
}
For me they are absolutely the same but in the second example Solidity throws an error saying that:
Wrong argument count for struct constructor: 1 arguments given but expected 2.