I have a mapping like this:
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
pragma experimental "v0.5.0";
...
mapping(bytes32 => LibMarket.Market) public hashToMarket;
where each Market
is defined as:
struct Market {
address a;
uint256 b;
uint256 c;
string d;
string e;
}
in a library file LibMarket
.
In another contract, I'm trying to access this mapping using the hash like so:
LibMarket.Market memory market = registry.hashToMarket(marketHash);
However, I'm receiving the error
Exchange.sol:139:9: TypeError: Different number of components on the left hand side (1) than on the right hand side (5). LibMarket.Market memory market = registry.hashToMarket(marketHash); ^----------------------------------------------------------------^
Why am I getting this error?
EDIT:
Although this doesn't answer this exact question. A simple workaround is to define a different getter function in the contract that has the hashToMarket
mapping like so and it will work as intended:
function getMarket(bytes32 marketHash) public view returns(LibMarket.Market) {
return hashToMarket[marketHash];
}