Voter.fromJson constructor
Implementation
factory Voter.fromJson(Map<String, dynamic> json) {
final type = VoterType.fromName(json.keys.firstOrNull);
return switch (type) {
VoterType.constitutionalCommitteeHotKeyHash =>
VoterConstitutionalCommitteeHotKeyHash.fromJson(json),
VoterType.constitutionalCommitteeHotScriptHash =>
VoterConstitutionalCommitteeHotScriptHash.fromJson(json),
VoterType.drepKeyHash => VoterDRepKeyHash.fromJson(json),
VoterType.drepScriptHash => VoterDRepScriptHash.fromJson(json),
VoterType.stakingPoolKeyHash => VoterStakingPoolKeyHash.fromJson(json),
_ => throw UnimplementedError("Invalid voter type.")
};
}