I want my contract to inherit another contract, the issue is that the contract uses a struct inside its constructor, and I'm not sure how to pass that data type from my contract.
Method 1
Contract I want to inherit:
contract Parent {
struct CustomType {
uint x;
bool y;
string z;
}
constructor(CustomType memory customType) {
}
}
My contract:
contract Child is Parent{
struct CustomType {
uint x;
bool y;
string z;
}
constructor(CustomType memory customType) Parent(customType) {}
}
The error:
TypeError: Invalid type for argument in modifier invocation. Invalid implicit conversion from struct Child.CustomType memory to struct Parent.CustomType memory requested.
Method 2
Importing the struct into the file and using it also doesn't work:
import {Parent, CustomType} from "./Inherit.sol";
contract Child is Parent{
constructor(CustomType memory customType) Parent(customType) {}
}
The error:
DeclarationError: Declaration "CustomType" not found in "contracts/Inherit.sol"