ChainType.fromJson constructor

ChainType.fromJson(
  1. dynamic json
)

Implementation

factory ChainType.fromJson(dynamic json) {
  String type;
  if (json is String) {
    type = json;
  } else if (json is Map<String, dynamic>) {
    type = json.keys.first;
    if (type == 'Custom') {
      return Custom(json[type]);
    }
  } else {
    throw Exception('ChainType: Invalid json value: "$json"');
  }
  switch (type) {
    case 'Development':
      return const Development();
    case 'Local':
      return const Local();
    case 'Live':
      return const Live();
    default:
      throw Exception('ChainType: unknown type "$type"');
  }
}