I want to reuse on type DateRange
in two contracts. However, I fail with multiple errors. Currently I have one error:
G21FE98E9 Member "endTicks" not found or not visible after argument-dependent lookup in tuple(uint64,uint64)
I didn't find any related info that could help solve this issue.
Here is complete contract code:
pragma solidity ^0.4.21;
contract SeasonFactory {
address public owner;
address[] public seasons;
event SeasonCreated(uint64 indexed beginTicks, uint64 indexed endTicks, address season);
function SeasonFactory() public {
owner = msg.sender;
}
function newSeason(uint64 beginTicks, uint64 endTicks) public restricted {
require(beginTicks < endTicks);
require(seasons.length == 0 || Season(seasons[seasons.length - 1]).period().endTicks() < beginTicks);
Season season = new Season(owner, beginTicks, endTicks);
seasons.push(season);
emit SeasonCreated(beginTicks, endTicks, season);
}
function getSeasonsCount() public view returns(uint) {
return seasons.length;
}
function getSeasonForDate(uint64 ticks) public view returns(address) {
for (uint i = seasons.length - 1; i >= 0; i--) {
Season season = Season(seasons[i]);
if (ticks >= season.period.beginTicks() && ticks <= season.period.endTicks())
return season;
}
return 0;
}
modifier restricted {
require(owner == msg.sender);
_;
}
}
contract Season {
address public owner;
SharedTypes.DateRange public period;
function Season(address owner_, uint64 beginTicks, uint64 endTicks) public {
owner = owner_;
period = SharedTypes.DateRange(beginTicks, endTicks);
}
}
library SharedTypes {
struct DateRange {
uint64 beginTicks;
uint64 endTicks;
}
}
What could be wrong here?
Season(seasons[seasons.length - 1]).period().endTicks() < beginTicks)
andSeason season = Season(seasons[i])
when Season needs 3 parameters? – ReyHaynes Apr 24 '18 at 15:15Season
function fromcontract Season
, you need to place that contract above theSeasonFactory
and inherit it properly withcontract SeasonFactory is Season {}
– ReyHaynes Apr 24 '18 at 15:18address
which is known to be a contract T. See dappsforbeginners.wordpress.com/tutorials/… – Alex Zhukovskiy Apr 24 '18 at 15:57