convertToJSON method
Convert the transaction in JSON
Implementation
String convertToJSON() {
final String json = jsonEncode(<String, Object?>{
'version': version,
'address': address == null ? '' : address!,
'type': type,
'data': {
'content': HEX.encode(Uint16List.fromList(utf8.encode(data!.content!))),
'code': data == null || data!.code == null ? '' : data!.code!,
'ownerships': List<dynamic>.from(data!.ownerships!.map((Ownership x) {
return <String, Object?>{
'secret': x.secret == null ? '' : x.secret!,
'authorizedKeys': x.authorizedPublicKeys,
};
})),
'ledger': {
'uco': {
'transfers': List<dynamic>.from(
data!.ledger!.uco!.transfers!.map((UCOTransfer x) {
return {
'to': x.to == null ? '' : x.to!,
'amount': x.amount == null ? 0 : x.amount!.toInt(),
};
}))
},
'token': {
'transfers': List<dynamic>.from(
data!.ledger!.token!.transfers!.map((TokenTransfer x) {
return {
'to': x.to == null ? '' : x.to!,
'amount': x.amount == null ? 0 : x.amount!.toInt(),
'tokenAddress': x.tokenAddress!,
'tokenId': x.tokenId
};
}))
},
},
'recipients':
List<dynamic>.from(data!.recipients!.map((String x) => x)),
},
'previousPublicKey': previousPublicKey == null ? '' : previousPublicKey!,
'previousSignature': previousSignature == null ? '' : previousSignature!,
'originSignature': originSignature == null ? '' : originSignature!
});
return json;
}