ScriptRef.fromJson constructor

ScriptRef.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory ScriptRef.fromJson(Map<String, dynamic> json) {
  final ScriptRefType type;
  try {
    type = ScriptRefType.fromName(json.keys.first);
  } on StateError {
    throw MessageException("Invalid ScriptRef json.",
        details: {"json": json});
  }
  switch (type) {
    case ScriptRefType.nativeScript:
      return ScriptRefNativeScript.fromJson(json);
    default:
      return ScriptRefPlutusScript.fromJson(json);
  }
}