This commit is contained in:
John Smith
2023-05-15 11:33:32 -04:00
parent 5f9fec0b18
commit cbdbd34af8
11 changed files with 436 additions and 203 deletions
+21 -10
View File
@@ -36,16 +36,29 @@ Object? veilidApiToEncodable(Object? value) {
return value;
}
switch (value.runtimeType) {
case AttachmentState:
return (value as AttachmentState).json;
case VeilidLogLevel:
return (value as VeilidLogLevel).json;
case VeilidConfigLogLevel:
return (value as VeilidConfigLogLevel).json;
// case KeyPair:
// return (value as KeyPair).json;
}
throw UnsupportedError('Cannot convert to JSON: $value');
}
T? Function(dynamic) optFromJson<T>(T Function(dynamic) jsonConstructor) {
return (dynamic j) {
if (j == null) {
return null;
} else {
return jsonConstructor(j);
}
};
}
List<T> Function(dynamic) jsonListConstructor<T>(
T Function(dynamic) jsonConstructor) {
return (dynamic j) {
return (j as List<dynamic>).map((e) => jsonConstructor(e)).toList();
};
}
//////////////////////////////////////
/// VeilidVersion
@@ -71,8 +84,7 @@ class Timestamp {
Timestamp.fromString(String s) : value = BigInt.parse(s);
Timestamp.fromJson(dynamic json) : this.fromString(json as String);
String get json {
String toJson() {
return toString();
}
@@ -97,8 +109,7 @@ class TimestampDuration {
TimestampDuration.fromString(String s) : value = BigInt.parse(s);
TimestampDuration.fromJson(dynamic json) : this.fromString(json as String);
String get json {
String toJson() {
return toString();
}