I have two related contracts, let's call them Supplier
and Producer
.
A Supplier
can have a State
of inactive
, active
, or kaput
, but only active
suppliers can be added to a Producer
.
So something like this:
contract Supplier {
enum State { inactive, active, kaput }
State constant DEFAULT_STATE = State.inactive
State public status;
function Supplier() {
status = DEFAULT_STATE;
}
}
But doing this doesn't work.
contract Producer {
function addSupplier(Supplier _supplier) {
require(_supplier.status == Supplier.State.active);
}
}
I considered using an Interface but enum
is specifically disallowed in an Interface.
How do I expose enum
definitions to external contracts without resorting to something ugly like require(uint(supplier.status) == 1);