Certificate.fromJson constructor
Constructs a certificate instance from its json form.
Implementation
factory Certificate.fromJson(Map<String, dynamic> json) {
final CertificateType type;
try {
type = CertificateType.fromName(json.keys.first);
} on StateError {
throw MessageException("Invalid json certificate.",
details: {"json": json});
}
switch (type) {
case CertificateType.genesisKeyDelegation:
return GenesisKeyDelegation.fromJson(json);
case CertificateType.moveInstantaneousRewardsCert:
return MoveInstantaneousRewardsCert.fromJson(json);
case CertificateType.poolRegistration:
return PoolRegistration.fromJson(json);
case CertificateType.poolRetirement:
return PoolRetirement.fromJson(json);
case CertificateType.stakeDelegation:
return StakeDelegation.fromJson(json);
case CertificateType.stakeDeregistration:
return StakeDeregistration.fromJson(json);
default:
return StakeRegistration.fromJson(json);
}
}