transaction description key id address (#1755)

* transaction description key id+address

* minor fix[skip ci]

* fix backward compatibility

* add monero primary address
This commit is contained in:
Serhii 2024-10-18 05:58:57 +03:00 committed by GitHub
parent 6c9de67599
commit 5c2735be42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 32 additions and 6 deletions

View file

@ -23,7 +23,7 @@ abstract class WalletAddresses {
return _localAddress ?? address;
}
String? get primaryAddress => null;
String get primaryAddress;
String? _localAddress;

View file

@ -17,6 +17,9 @@ abstract class EVMChainWalletAddressesBase extends WalletAddresses with Store {
@observable
String address;
@override
String get primaryAddress => address;
@override
Future<void> init() async {
address = walletInfo.address;

View file

@ -29,6 +29,9 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store {
@observable
String address;
@override
String get primaryAddress => getAddress(accountIndex: account?.id ?? 0, addressIndex: 0);
@override
String get latestAddress {
var addressIndex = subaddress_list.numSubaddresses(account?.id??0) - 1;

View file

@ -18,6 +18,9 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
@observable
String address;
@override
String get primaryAddress => address;
@observable
NanoAccount? account;

View file

@ -14,6 +14,9 @@ abstract class SolanaWalletAddressesBase extends WalletAddresses with Store {
@override
String address;
@override
String get primaryAddress => address;
@override
Future<void> init() async {
address = walletInfo.address;

View file

@ -17,6 +17,9 @@ abstract class TronWalletAddressesBase extends WalletAddresses with Store {
@observable
String address;
@override
String get primaryAddress => address;
@override
Future<void> init() async {
address = walletInfo.address;

View file

@ -29,6 +29,9 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store {
@observable
String address;
@override
String get primaryAddress => getAddress(accountIndex: account?.id ?? 0, addressIndex: 0);
@override
String get latestAddress {
var addressIndex = subaddress_list.numSubaddresses(account?.id??0) - 1;

View file

@ -482,12 +482,18 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
nano!.updateTransactions(wallet);
}
if (pendingTransaction!.id.isNotEmpty) {
final descriptionKey = '${pendingTransaction!.id}_${wallet.walletAddresses.primaryAddress}';
_settingsStore.shouldSaveRecipientAddress
? await transactionDescriptionBox.add(TransactionDescription(
id: pendingTransaction!.id, recipientAddress: address, transactionNote: note))
: await transactionDescriptionBox
.add(TransactionDescription(id: pendingTransaction!.id, transactionNote: note));
id: descriptionKey,
recipientAddress: address,
transactionNote: note))
: await transactionDescriptionBox.add(TransactionDescription(
id: descriptionKey,
transactionNote: note));
}
state = TransactionCommitted();

View file

@ -110,9 +110,11 @@ abstract class TransactionDetailsViewModelBase with Store {
} catch (e) {}
}));
final descriptionKey = '${transactionInfo.txHash}_${wallet.walletAddresses.primaryAddress}';
final description = transactionDescriptionBox.values.firstWhere(
(val) => val.id == transactionInfo.txHash,
orElse: () => TransactionDescription(id: transactionInfo.txHash));
(val) => val.id == descriptionKey || val.id == transactionInfo.txHash,
orElse: () => TransactionDescription(id: descriptionKey));
items.add(TextFieldListItem(
title: S.current.note_tap_to_change,