transaction description key id address (#1755)

* transaction description key id+address * minor fix[skip ci] * fix backward compatibility * add monero primary address

Serhii committed Oct 18, 2024 at 05:58 UTC 5c2735be42db03bf7f4311389804fc7025dea7c1
9 files changed +32 -6
cw_core/lib/wallet_addresses.dart
+1 -1
@@ -23,7 +23,7 @@ abstract class WalletAddresses {
23 return _localAddress ?? address;
24 }
25
26 - String? get primaryAddress => null;
26 + String get primaryAddress;
27
28 String? _localAddress;
29
cw_evm/lib/evm_chain_wallet_addresses.dart
+3
@@ -17,6 +17,9 @@ abstract class EVMChainWalletAddressesBase extends WalletAddresses with Store {
17 @observable
18 String address;
19
20 + @override
21 + String get primaryAddress => address;
22 +
23 @override
24 Future<void> init() async {
25 address = walletInfo.address;
cw_monero/lib/monero_wallet_addresses.dart
+3
@@ -29,6 +29,9 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store {
29 @observable
30 String address;
31
32 + @override
33 + String get primaryAddress => getAddress(accountIndex: account?.id ?? 0, addressIndex: 0);
34 +
35 @override
36 String get latestAddress {
37 var addressIndex = subaddress_list.numSubaddresses(account?.id??0) - 1;
cw_nano/lib/nano_wallet_addresses.dart
+3
@@ -18,6 +18,9 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
18 @observable
19 String address;
20
21 + @override
22 + String get primaryAddress => address;
23 +
24 @observable
25 NanoAccount? account;
26
cw_solana/lib/solana_wallet_addresses.dart
+3
@@ -14,6 +14,9 @@ abstract class SolanaWalletAddressesBase extends WalletAddresses with Store {
14 @override
15 String address;
16
17 + @override
18 + String get primaryAddress => address;
19 +
20 @override
21 Future<void> init() async {
22 address = walletInfo.address;
cw_tron/lib/tron_wallet_addresses.dart
+3
@@ -17,6 +17,9 @@ abstract class TronWalletAddressesBase extends WalletAddresses with Store {
17 @observable
18 String address;
19
20 + @override
21 + String get primaryAddress => address;
22 +
23 @override
24 Future<void> init() async {
25 address = walletInfo.address;
cw_wownero/lib/wownero_wallet_addresses.dart
+3
@@ -29,6 +29,9 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store {
29 @observable
30 String address;
31
32 + @override
33 + String get primaryAddress => getAddress(accountIndex: account?.id ?? 0, addressIndex: 0);
34 +
35 @override
36 String get latestAddress {
37 var addressIndex = subaddress_list.numSubaddresses(account?.id??0) - 1;
lib/view_model/send/send_view_model.dart
+9 -3
@@ -482,12 +482,18 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
482 nano!.updateTransactions(wallet);
483 }
484
485 +
486 if (pendingTransaction!.id.isNotEmpty) {
487 +
488 + final descriptionKey = '${pendingTransaction!.id}_${wallet.walletAddresses.primaryAddress}';
489 _settingsStore.shouldSaveRecipientAddress
490 ? await transactionDescriptionBox.add(TransactionDescription(
488 - id: pendingTransaction!.id, recipientAddress: address, transactionNote: note))
489 - : await transactionDescriptionBox
490 - .add(TransactionDescription(id: pendingTransaction!.id, transactionNote: note));
491 + id: descriptionKey,
492 + recipientAddress: address,
493 + transactionNote: note))
494 + : await transactionDescriptionBox.add(TransactionDescription(
495 + id: descriptionKey,
496 + transactionNote: note));
497 }
498
499 state = TransactionCommitted();
lib/view_model/transaction_details_view_model.dart
+4 -2
@@ -110,9 +110,11 @@ abstract class TransactionDetailsViewModelBase with Store {
110 } catch (e) {}
111 }));
112
113 + final descriptionKey = '${transactionInfo.txHash}_${wallet.walletAddresses.primaryAddress}';
114 +
115 final description = transactionDescriptionBox.values.firstWhere(
114 - (val) => val.id == transactionInfo.txHash,
115 - orElse: () => TransactionDescription(id: transactionInfo.txHash));
116 + (val) => val.id == descriptionKey || val.id == transactionInfo.txHash,
117 + orElse: () => TransactionDescription(id: descriptionKey));
118
119 items.add(TextFieldListItem(
120 title: S.current.note_tap_to_change,