WIP: fix transactionAddress for incoming transactions + epicTransaction json

This commit is contained in:
ryleedavis 2023-10-09 09:37:25 -06:00
parent 848d45ad72
commit ed80a50432
2 changed files with 12 additions and 7 deletions

View file

@ -54,7 +54,7 @@ class EpicTransaction {
return EpicTransaction( return EpicTransaction(
parentKeyId: json['parent_key_id'] as String, parentKeyId: json['parent_key_id'] as String,
id: int.parse(json!['id'].toString()), id: int.parse(json!['id'].toString()),
txSlateId: json['tx_slate_id'].toString(), txSlateId: json['tx_slate_id'] as String?,
txType: EpicTransactionType.values.byName(json['tx_type'] as String), txType: EpicTransactionType.values.byName(json['tx_type'] as String),
creationTs: json['creation_ts'].toString(), creationTs: json['creation_ts'].toString(),
confirmationTs: json['confirmation_ts'].toString(), confirmationTs: json['confirmation_ts'].toString(),
@ -65,10 +65,14 @@ class EpicTransaction {
amountDebited: json['amount_debited'].toString(), amountDebited: json['amount_debited'].toString(),
fee: json['fee'].toString(), fee: json['fee'].toString(),
ttlCutoffHeight: json['ttl_cutoff_height'].toString(), ttlCutoffHeight: json['ttl_cutoff_height'].toString(),
messages: json['messages'] != null ? Messages.fromJson(json['messages'] as Map<String, dynamic>) : null, messages: json['messages'] != null
? Messages.fromJson(json['messages'] as Map<String, dynamic>)
: null,
storedTx: json['stored_tx'].toString(), storedTx: json['stored_tx'].toString(),
kernelExcess: json['kernel_excess'].toString(), kernelExcess: json['kernel_excess'].toString(),
kernelLookupMinHeight: json['kernel_lookup_min_height'] == null? null : int.parse(json['kernel_lookup_min_height'].toString()), kernelLookupMinHeight: json['kernel_lookup_min_height'] == null
? null
: int.parse(json['kernel_lookup_min_height'].toString()),
paymentProof: json['payment_proof'].toString(), paymentProof: json['payment_proof'].toString(),
); );
} }
@ -81,7 +85,9 @@ class Messages {
factory Messages.fromJson(Map<String, dynamic> json) { factory Messages.fromJson(Map<String, dynamic> json) {
final messageList = json['messages'] as List<dynamic>; final messageList = json['messages'] as List<dynamic>;
final messages = messageList.map((message) => Message.fromJson(message as Map<String, dynamic>)).toList(); final messages = messageList
.map((message) => Message.fromJson(message as Map<String, dynamic>))
.toList();
return Messages(messages: messages); return Messages(messages: messages);
} }
} }
@ -109,7 +115,6 @@ class Message {
} }
} }
enum EpicTransactionType { enum EpicTransactionType {
//Use Epic transaction type here //Use Epic transaction type here
TxReceived, TxReceived,

View file

@ -1255,7 +1255,7 @@ class EpicCashWallet extends CoinServiceAPI
DateTime dt = DateTime.parse(tx.creationTs); DateTime dt = DateTime.parse(tx.creationTs);
String? slateId = tx.txSlateId == "null" ? null : tx.txSlateId; String? slateId = tx.txSlateId;
String address = slatesToCommits[slateId] String address = slatesToCommits[slateId]
?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] ?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"]
as String? ?? as String? ??
@ -1308,7 +1308,7 @@ class EpicCashWallet extends CoinServiceAPI
.valueEqualTo(address) .valueEqualTo(address)
.findFirst(); .findFirst();
if (transactionAddress!.value.isEmpty) { if (transactionAddress == null || transactionAddress!.value.isEmpty) {
if (isIncoming) { if (isIncoming) {
//Use current receiving address as address //Use current receiving address as address
String receivingAddress = await currentReceivingAddress; String receivingAddress = await currentReceivingAddress;