From ed80a50432f084c2424e0f4b53cc8d502c0588d1 Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Mon, 9 Oct 2023 09:37:25 -0600 Subject: [PATCH] WIP: fix transactionAddress for incoming transactions + epicTransaction json --- .../models/blockchain_data/epic_transaction.dart | 15 ++++++++++----- lib/services/coins/epiccash/epiccash_wallet.dart | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/models/isar/models/blockchain_data/epic_transaction.dart b/lib/models/isar/models/blockchain_data/epic_transaction.dart index 251c89705..2cac24a95 100644 --- a/lib/models/isar/models/blockchain_data/epic_transaction.dart +++ b/lib/models/isar/models/blockchain_data/epic_transaction.dart @@ -54,7 +54,7 @@ class EpicTransaction { return EpicTransaction( parentKeyId: json['parent_key_id'] as String, 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), creationTs: json['creation_ts'].toString(), confirmationTs: json['confirmation_ts'].toString(), @@ -65,10 +65,14 @@ class EpicTransaction { amountDebited: json['amount_debited'].toString(), fee: json['fee'].toString(), ttlCutoffHeight: json['ttl_cutoff_height'].toString(), - messages: json['messages'] != null ? Messages.fromJson(json['messages'] as Map) : null, + messages: json['messages'] != null + ? Messages.fromJson(json['messages'] as Map) + : null, storedTx: json['stored_tx'].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(), ); } @@ -81,7 +85,9 @@ class Messages { factory Messages.fromJson(Map json) { final messageList = json['messages'] as List; - final messages = messageList.map((message) => Message.fromJson(message as Map)).toList(); + final messages = messageList + .map((message) => Message.fromJson(message as Map)) + .toList(); return Messages(messages: messages); } } @@ -109,7 +115,6 @@ class Message { } } - enum EpicTransactionType { //Use Epic transaction type here TxReceived, diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 67ecce654..419430778 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -1255,7 +1255,7 @@ class EpicCashWallet extends CoinServiceAPI DateTime dt = DateTime.parse(tx.creationTs); - String? slateId = tx.txSlateId == "null" ? null : tx.txSlateId; + String? slateId = tx.txSlateId; String address = slatesToCommits[slateId] ?[tx.txType == EpicTransactionType.TxReceived ? "from" : "to"] as String? ?? @@ -1308,7 +1308,7 @@ class EpicCashWallet extends CoinServiceAPI .valueEqualTo(address) .findFirst(); - if (transactionAddress!.value.isEmpty) { + if (transactionAddress == null || transactionAddress!.value.isEmpty) { if (isIncoming) { //Use current receiving address as address String receivingAddress = await currentReceivingAddress;