ScV2SemanticOutput.fromJson constructor
ScV2SemanticOutput.fromJson(
- Map<String, dynamic> json
)
Implementation
factory ScV2SemanticOutput.fromJson(Map<String, dynamic> json) {
final value = json['value'];
final address = json['address'];
final isChange = json['isChange'];
if (value is! String || address is! String || isChange is! bool) {
throw const FormatException('Malformed SC V2 semantic output');
}
if (!RegExp(r'^[1-9][0-9]*$').hasMatch(value) ||
!RegExp(r'^[0-9a-f]{76}$').hasMatch(address)) {
throw const FormatException('Non-canonical SC V2 semantic output');
}
return ScV2SemanticOutput(
value: BigInt.parse(value),
address: address,
isChange: isChange,
);
}