fromJson method

  1. @override
SeigniorageAllocation fromJson(
  1. Map<String, dynamic> json
)

Implementation

@override
SeigniorageAllocation fromJson(Map<String, dynamic> json) {
  final String top = json.keys.first;
  Map<String, dynamic> inner = json[top];
  final bool isDelegator = (top.toLowerCase() == "delegator");
  ClPublicKey? delegatorPublicKey;
  ClPublicKey? validatorPublicKey;
  if (inner.containsKey("delegator_public_key")) {
    delegatorPublicKey = ClPublicKeyJsonConverter().fromJson(inner["delegator_public_key"]);
  }
  if (inner.containsKey("validator_public_key")) {
    validatorPublicKey = ClPublicKeyJsonConverter().fromJson(inner["validator_public_key"]);
  }
  final BigInt amount = BigInt.parse(inner["amount"]);
  return SeigniorageAllocation(isDelegator, delegatorPublicKey, validatorPublicKey, amount);
}