diff --git a/cw_core/lib/wallet_addresses.dart b/cw_core/lib/wallet_addresses.dart index 27b5468c5..632eb1332 100644 --- a/cw_core/lib/wallet_addresses.dart +++ b/cw_core/lib/wallet_addresses.dart @@ -36,4 +36,6 @@ abstract class WalletAddresses { print(e.toString()); } } -} \ No newline at end of file + + bool containsAddress(String address) => addressesMap.containsKey(address); +} diff --git a/cw_haven/lib/haven_wallet_addresses.dart b/cw_haven/lib/haven_wallet_addresses.dart index ff6b6aa3f..eeeb763cf 100644 --- a/cw_haven/lib/haven_wallet_addresses.dart +++ b/cw_haven/lib/haven_wallet_addresses.dart @@ -63,14 +63,14 @@ abstract class HavenWalletAddressesBase extends WalletAddressesWithAccount + addressInfos[account?.id ?? 0]?.any((it) => it.address == address) ?? false; +} diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 75c1df89e..83219af5b 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -57,9 +57,7 @@ abstract class MoneroWalletBase walletAddresses = MoneroWalletAddresses(walletInfo, transactionHistory); _onAccountChangeReaction = reaction((_) => walletAddresses.account, (Account? account) { - if (account == null) { - return; - } + if (account == null) return; balance = ObservableMap.of({ currency: MoneroBalance( @@ -67,6 +65,7 @@ abstract class MoneroWalletBase unlockedBalance: monero_wallet.getUnlockedBalance(accountIndex: account.id)) }); _updateSubAddress(isEnabledAutoGenerateSubaddress, account: account); + _askForUpdateTransactionHistory(); }); reaction((_) => isEnabledAutoGenerateSubaddress, (bool enabled) { @@ -362,9 +361,7 @@ abstract class MoneroWalletBase } @override - Future changePassword(String password) async { - monero_wallet.setPasswordSync(password); - } + Future changePassword(String password) async => monero_wallet.setPasswordSync(password); Future getNodeHeight() async => monero_wallet.getNodeHeight(); @@ -499,9 +496,8 @@ abstract class MoneroWalletBase } } - String getSubaddressLabel(int accountIndex, int addressIndex) { - return monero_wallet.getSubaddressLabel(accountIndex, addressIndex); - } + String getSubaddressLabel(int accountIndex, int addressIndex) => + monero_wallet.getSubaddressLabel(accountIndex, addressIndex); List _getAllTransactionsOfAccount(int? accountIndex) => transaction_history .getAllTransactions() diff --git a/cw_monero/lib/monero_wallet_addresses.dart b/cw_monero/lib/monero_wallet_addresses.dart index a9da3d5d4..f74e7dd5b 100644 --- a/cw_monero/lib/monero_wallet_addresses.dart +++ b/cw_monero/lib/monero_wallet_addresses.dart @@ -1,11 +1,11 @@ +import 'package:cw_core/account.dart'; import 'package:cw_core/address_info.dart'; +import 'package:cw_core/subaddress.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_info.dart'; -import 'package:cw_core/account.dart'; import 'package:cw_monero/api/wallet.dart'; import 'package:cw_monero/monero_account_list.dart'; import 'package:cw_monero/monero_subaddress_list.dart'; -import 'package:cw_core/subaddress.dart'; import 'package:cw_monero/monero_transaction_history.dart'; import 'package:mobx/mobx.dart'; @@ -112,4 +112,8 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store { subaddress = subaddressList.subaddresses.last; address = subaddress!.address; } + + @override + bool containsAddress(String address) => + addressInfos[account?.id ?? 0]?.any((it) => it.address == address) ?? false; } diff --git a/lib/exchange/trade.dart b/lib/exchange/trade.dart index 3e557d39e..4eb48c248 100644 --- a/lib/exchange/trade.dart +++ b/lib/exchange/trade.dart @@ -27,6 +27,7 @@ class Trade extends HiveObject { this.password, this.providerId, this.providerName, + this.fromWalletAddress }) { if (provider != null) providerRaw = provider.raw; @@ -101,6 +102,9 @@ class Trade extends HiveObject { @HiveField(16) String? providerName; + @HiveField(17) + String? fromWalletAddress; + static Trade fromMap(Map map) { return Trade( id: map['id'] as String, @@ -110,7 +114,9 @@ class Trade extends HiveObject { createdAt: map['date'] != null ? DateTime.fromMillisecondsSinceEpoch(map['date'] as int) : null, amount: map['amount'] as String, - walletId: map['wallet_id'] as String); + walletId: map['wallet_id'] as String, + fromWalletAddress: map['from_wallet_address'] as String? + ); } Map toMap() { @@ -121,7 +127,8 @@ class Trade extends HiveObject { 'output': to.serialize(), 'date': createdAt != null ? createdAt!.millisecondsSinceEpoch : null, 'amount': amount, - 'wallet_id': walletId + 'wallet_id': walletId, + 'from_wallet_address': fromWalletAddress }; } diff --git a/lib/monero/cw_monero.dart b/lib/monero/cw_monero.dart index 4f45bc974..1de7b8452 100644 --- a/lib/monero/cw_monero.dart +++ b/lib/monero/cw_monero.dart @@ -120,8 +120,6 @@ class CWMoneroWalletDetails extends MoneroWalletDetails { @computed @override MoneroBalance get balance { - final moneroWallet = _wallet as MoneroWallet; - final balance = moneroWallet.balance; throw Exception('Unimplemented'); // return MoneroBalance(); //return MoneroBalance( @@ -132,14 +130,10 @@ class CWMoneroWalletDetails extends MoneroWalletDetails { class CWMonero extends Monero { @override - MoneroAccountList getAccountList(Object wallet) { - return CWMoneroAccountList(wallet); - } + MoneroAccountList getAccountList(Object wallet) => CWMoneroAccountList(wallet); @override - MoneroSubaddressList getSubaddressList(Object wallet) { - return CWMoneroSubaddressList(wallet); - } + MoneroSubaddressList getSubaddressList(Object wallet) => CWMoneroSubaddressList(wallet); @override TransactionHistoryBase getTransactionHistory(Object wallet) { @@ -148,19 +142,13 @@ class CWMonero extends Monero { } @override - MoneroWalletDetails getMoneroWalletDetails(Object wallet) { - return CWMoneroWalletDetails(wallet); - } + MoneroWalletDetails getMoneroWalletDetails(Object wallet) => CWMoneroWalletDetails(wallet); @override - int getHeigthByDate({required DateTime date}) { - return getMoneroHeigthByDate(date: date); - } + int getHeightByDate({required DateTime date}) => getMoneroHeigthByDate(date: date); @override - TransactionPriority getDefaultTransactionPriority() { - return MoneroTransactionPriority.automatic; - } + TransactionPriority getDefaultTransactionPriority() => MoneroTransactionPriority.automatic; @override TransactionPriority getMoneroTransactionPrioritySlow() => MoneroTransactionPriority.slow; @@ -170,14 +158,11 @@ class CWMonero extends Monero { MoneroTransactionPriority.automatic; @override - TransactionPriority deserializeMoneroTransactionPriority({required int raw}) { - return MoneroTransactionPriority.deserialize(raw: raw); - } + TransactionPriority deserializeMoneroTransactionPriority({required int raw}) => + MoneroTransactionPriority.deserialize(raw: raw); @override - List getTransactionPriorities() { - return MoneroTransactionPriority.all; - } + List getTransactionPriorities() => MoneroTransactionPriority.all; @override List getMoneroWordList(String language) { @@ -209,41 +194,37 @@ class CWMonero extends Monero { @override WalletCredentials createMoneroRestoreWalletFromKeysCredentials( - {required String name, - required String spendKey, - required String viewKey, - required String address, - required String password, - required String language, - required int height}) { - return MoneroRestoreWalletFromKeysCredentials( - name: name, - spendKey: spendKey, - viewKey: viewKey, - address: address, - password: password, - language: language, - height: height); - } + {required String name, + required String spendKey, + required String viewKey, + required String address, + required String password, + required String language, + required int height}) => + MoneroRestoreWalletFromKeysCredentials( + name: name, + spendKey: spendKey, + viewKey: viewKey, + address: address, + password: password, + language: language, + height: height); @override WalletCredentials createMoneroRestoreWalletFromSeedCredentials( - {required String name, - required String password, - required int height, - required String mnemonic}) { - return MoneroRestoreWalletFromSeedCredentials( - name: name, password: password, height: height, mnemonic: mnemonic); - } + {required String name, + required String password, + required int height, + required String mnemonic}) => + MoneroRestoreWalletFromSeedCredentials( + name: name, password: password, height: height, mnemonic: mnemonic); @override WalletCredentials createMoneroNewWalletCredentials({ required String name, required String language, - String? password, - }) { - return MoneroNewWalletCredentials(name: name, password: password, language: language); - } + String? password}) => + MoneroNewWalletCredentials(name: name, password: password, language: language); @override Map getKeys(Object wallet) { @@ -259,43 +240,37 @@ class CWMonero extends Monero { @override Object createMoneroTransactionCreationCredentials( - {required List outputs, required TransactionPriority priority}) { - return MoneroTransactionCreationCredentials( - outputs: outputs - .map((out) => OutputInfo( - fiatAmount: out.fiatAmount, - cryptoAmount: out.cryptoAmount, - address: out.address, - note: out.note, - sendAll: out.sendAll, - extractedAddress: out.extractedAddress, - isParsedAddress: out.isParsedAddress, - formattedCryptoAmount: out.formattedCryptoAmount)) - .toList(), - priority: priority as MoneroTransactionPriority); - } + {required List outputs, required TransactionPriority priority}) => + MoneroTransactionCreationCredentials( + outputs: outputs + .map((out) => OutputInfo( + fiatAmount: out.fiatAmount, + cryptoAmount: out.cryptoAmount, + address: out.address, + note: out.note, + sendAll: out.sendAll, + extractedAddress: out.extractedAddress, + isParsedAddress: out.isParsedAddress, + formattedCryptoAmount: out.formattedCryptoAmount)) + .toList(), + priority: priority as MoneroTransactionPriority); @override Object createMoneroTransactionCreationCredentialsRaw( - {required List outputs, required TransactionPriority priority}) { - return MoneroTransactionCreationCredentials( - outputs: outputs, priority: priority as MoneroTransactionPriority); - } + {required List outputs, required TransactionPriority priority}) => + MoneroTransactionCreationCredentials( + outputs: outputs, priority: priority as MoneroTransactionPriority); @override - String formatterMoneroAmountToString({required int amount}) { - return moneroAmountToString(amount: amount); - } + String formatterMoneroAmountToString({required int amount}) => + moneroAmountToString(amount: amount); @override - double formatterMoneroAmountToDouble({required int amount}) { - return moneroAmountToDouble(amount: amount); - } + double formatterMoneroAmountToDouble({required int amount}) => + moneroAmountToDouble(amount: amount); @override - int formatterMoneroParseAmount({required String amount}) { - return moneroParseAmount(amount: amount); - } + int formatterMoneroParseAmount({required String amount}) => moneroParseAmount(amount: amount); @override Account getCurrentAccount(Object wallet) { @@ -312,9 +287,7 @@ class CWMonero extends Monero { } @override - void onStartup() { - monero_wallet_api.onStartup(); - } + void onStartup() => monero_wallet_api.onStartup(); @override int getTransactionInfoAccountId(TransactionInfo tx) { @@ -324,9 +297,8 @@ class CWMonero extends Monero { @override WalletService createMoneroWalletService( - Box walletInfoSource, Box unspentCoinSource) { - return MoneroWalletService(walletInfoSource, unspentCoinSource); - } + Box walletInfoSource, Box unspentCoinSource) => + MoneroWalletService(walletInfoSource, unspentCoinSource); @override String getTransactionAddress(Object wallet, int accountIndex, int addressIndex) { diff --git a/lib/src/widgets/blockchain_height_widget.dart b/lib/src/widgets/blockchain_height_widget.dart index 2ba0a3406..221f87446 100644 --- a/lib/src/widgets/blockchain_height_widget.dart +++ b/lib/src/widgets/blockchain_height_widget.dart @@ -36,16 +36,13 @@ class BlockchainHeightState extends State { restoreHeightController.addListener(() { if (restoreHeightController.text.isNotEmpty) { widget.onHeightOrDateEntered?.call(true); - } - else { + } else { widget.onHeightOrDateEntered?.call(false); dateController.text = ''; } try { - _changeHeight(restoreHeightController.text != null && - restoreHeightController.text.isNotEmpty - ? int.parse(restoreHeightController.text) - : 0); + _changeHeight( + restoreHeightController.text.isNotEmpty ? int.parse(restoreHeightController.text) : 0); } catch (_) { _changeHeight(0); } @@ -117,7 +114,7 @@ class BlockchainHeightState extends State { ); } - Future _selectDate(BuildContext context) async { + Future _selectDate(BuildContext context) async { final now = DateTime.now(); final date = await getDate( context: context, @@ -126,7 +123,7 @@ class BlockchainHeightState extends State { lastDate: now); if (date != null) { - final height = monero!.getHeigthByDate(date: date); + final height = monero!.getHeightByDate(date: date); setState(() { dateController.text = DateFormat('yyyy-MM-dd').format(date); restoreHeightController.text = '$height'; diff --git a/lib/store/dashboard/trade_filter_store.dart b/lib/store/dashboard/trade_filter_store.dart index 799e8b951..4e901aa5e 100644 --- a/lib/store/dashboard/trade_filter_store.dart +++ b/lib/store/dashboard/trade_filter_store.dart @@ -1,7 +1,7 @@ -import 'package:cw_core/wallet_base.dart'; -import 'package:mobx/mobx.dart'; import 'package:cake_wallet/exchange/exchange_provider_description.dart'; import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart'; +import 'package:cw_core/wallet_base.dart'; +import 'package:mobx/mobx.dart'; part'trade_filter_store.g.dart'; @@ -87,29 +87,31 @@ abstract class TradeFilterStoreBase with Store { } List filtered({required List trades, required WalletBase wallet}) { - final _trades = - trades.where((item) => item.trade.walletId == wallet.id).toList(); + final _trades = trades + .where((item) => item.trade.walletId == wallet.id && isTradeInAccount(item, wallet)) + .toList(); final needToFilter = !displayAllTrades; return needToFilter ? _trades - .where((item) => - (displayXMRTO && - item.trade.provider == ExchangeProviderDescription.xmrto) || - (displaySideShift && - item.trade.provider == ExchangeProviderDescription.sideShift) || - (displayChangeNow && - item.trade.provider == - ExchangeProviderDescription.changeNow) || - (displayMorphToken && - item.trade.provider == - ExchangeProviderDescription.morphToken) - ||(displaySimpleSwap && - item.trade.provider == - ExchangeProviderDescription.simpleSwap) - ||(displayTrocador && item.trade.provider == ExchangeProviderDescription.trocador) - ||(displayExolix && item.trade.provider == ExchangeProviderDescription.exolix)) - .toList() + .where((item) => + (displayXMRTO && item.trade.provider == ExchangeProviderDescription.xmrto) || + (displaySideShift && + item.trade.provider == ExchangeProviderDescription.sideShift) || + (displayChangeNow && + item.trade.provider == ExchangeProviderDescription.changeNow) || + (displayMorphToken && + item.trade.provider == ExchangeProviderDescription.morphToken) || + (displaySimpleSwap && + item.trade.provider == ExchangeProviderDescription.simpleSwap) || + (displayTrocador && item.trade.provider == ExchangeProviderDescription.trocador) || + (displayExolix && item.trade.provider == ExchangeProviderDescription.exolix)) + .toList() : _trades; } -} \ No newline at end of file + + bool isTradeInAccount(TradeListItem item, WalletBase wallet) => + item.trade.fromWalletAddress == null + ? true + : wallet.walletAddresses.containsAddress(item.trade.fromWalletAddress!); +} diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 03f0aa9a8..fbb2fc76f 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -1,36 +1,36 @@ import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart'; +import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/entities/buy_provider_types.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart'; -import 'package:cake_wallet/store/anonpay/anonpay_transactions_store.dart'; -import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart'; -import 'package:cake_wallet/view_model/settings/sync_mode.dart'; -import 'package:cake_wallet/wallet_type_utils.dart'; -import 'package:cw_core/transaction_history.dart'; -import 'package:cw_core/balance.dart'; -import 'package:cake_wallet/entities/balance_display_mode.dart'; -import 'package:cw_core/transaction_info.dart'; import 'package:cake_wallet/exchange/exchange_provider_description.dart'; -import 'package:cake_wallet/store/settings_store.dart'; +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/monero/monero.dart'; +import 'package:cake_wallet/store/anonpay/anonpay_transactions_store.dart'; +import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/dashboard/orders_store.dart'; +import 'package:cake_wallet/store/dashboard/trade_filter_store.dart'; +import 'package:cake_wallet/store/dashboard/trades_store.dart'; +import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart'; +import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/yat/yat_store.dart'; import 'package:cake_wallet/utils/mobx.dart'; +import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; +import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/filter_item.dart'; +import 'package:cake_wallet/view_model/dashboard/formatted_item_list.dart'; import 'package:cake_wallet/view_model/dashboard/order_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/trade_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/transaction_list_item.dart'; -import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; -import 'package:mobx/mobx.dart'; -import 'package:cw_core/wallet_base.dart'; +import 'package:cake_wallet/view_model/settings/sync_mode.dart'; +import 'package:cake_wallet/wallet_type_utils.dart'; +import 'package:cw_core/balance.dart'; import 'package:cw_core/sync_status.dart'; +import 'package:cw_core/transaction_history.dart'; +import 'package:cw_core/transaction_info.dart'; +import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; -import 'package:cake_wallet/store/app_store.dart'; -import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/store/dashboard/trades_store.dart'; -import 'package:cake_wallet/store/dashboard/trade_filter_store.dart'; -import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart'; -import 'package:cake_wallet/view_model/dashboard/formatted_item_list.dart'; -import 'package:cake_wallet/monero/monero.dart'; +import 'package:mobx/mobx.dart'; part 'dashboard_view_model.g.dart'; @@ -47,69 +47,69 @@ abstract class DashboardViewModelBase with Store { required this.yatStore, required this.ordersStore, required this.anonpayTransactionsStore}) - : hasSellAction = false, - hasBuyAction = false, - hasExchangeAction = false, - isShowFirstYatIntroduction = false, - isShowSecondYatIntroduction = false, - isShowThirdYatIntroduction = false, - filterItems = { - S.current.transactions: [ - FilterItem( - value: () => transactionFilterStore.displayAll, - caption: S.current.all_transactions, - onChanged: transactionFilterStore.toggleAll), - FilterItem( - value: () => transactionFilterStore.displayIncoming, - caption: S.current.incoming, - onChanged:transactionFilterStore.toggleIncoming), - FilterItem( - value: () => transactionFilterStore.displayOutgoing, - caption: S.current.outgoing, - onChanged: transactionFilterStore.toggleOutgoing), - // FilterItem( - // value: () => false, - // caption: S.current.transactions_by_date, - // onChanged: null), - ], - S.current.trades: [ - FilterItem( - value: () => tradeFilterStore.displayAllTrades, - caption: S.current.all_trades, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.all)), - FilterItem( - value: () => tradeFilterStore.displayChangeNow, - caption: ExchangeProviderDescription.changeNow.title, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.changeNow)), - FilterItem( - value: () => tradeFilterStore.displaySideShift, - caption: ExchangeProviderDescription.sideShift.title, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.sideShift)), - FilterItem( - value: () => tradeFilterStore.displaySimpleSwap, - caption: ExchangeProviderDescription.simpleSwap.title, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.simpleSwap)), - FilterItem( - value: () => tradeFilterStore.displayTrocador, - caption: ExchangeProviderDescription.trocador.title, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.trocador)), - FilterItem( - value: () => tradeFilterStore.displayExolix, - caption: ExchangeProviderDescription.exolix.title, - onChanged: () => tradeFilterStore - .toggleDisplayExchange(ExchangeProviderDescription.exolix)), - ] - }, - subname = '', - name = appStore.wallet!.name, - type = appStore.wallet!.type, - transactions = ObservableList(), - wallet = appStore.wallet! { + : hasSellAction = false, + hasBuyAction = false, + hasExchangeAction = false, + isShowFirstYatIntroduction = false, + isShowSecondYatIntroduction = false, + isShowThirdYatIntroduction = false, + filterItems = { + S.current.transactions: [ + FilterItem( + value: () => transactionFilterStore.displayAll, + caption: S.current.all_transactions, + onChanged: transactionFilterStore.toggleAll), + FilterItem( + value: () => transactionFilterStore.displayIncoming, + caption: S.current.incoming, + onChanged: transactionFilterStore.toggleIncoming), + FilterItem( + value: () => transactionFilterStore.displayOutgoing, + caption: S.current.outgoing, + onChanged: transactionFilterStore.toggleOutgoing), + // FilterItem( + // value: () => false, + // caption: S.current.transactions_by_date, + // onChanged: null), + ], + S.current.trades: [ + FilterItem( + value: () => tradeFilterStore.displayAllTrades, + caption: S.current.all_trades, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.all)), + FilterItem( + value: () => tradeFilterStore.displayChangeNow, + caption: ExchangeProviderDescription.changeNow.title, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.changeNow)), + FilterItem( + value: () => tradeFilterStore.displaySideShift, + caption: ExchangeProviderDescription.sideShift.title, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.sideShift)), + FilterItem( + value: () => tradeFilterStore.displaySimpleSwap, + caption: ExchangeProviderDescription.simpleSwap.title, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.simpleSwap)), + FilterItem( + value: () => tradeFilterStore.displayTrocador, + caption: ExchangeProviderDescription.trocador.title, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.trocador)), + FilterItem( + value: () => tradeFilterStore.displayExolix, + caption: ExchangeProviderDescription.exolix.title, + onChanged: () => + tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.exolix)), + ] + }, + subname = '', + name = appStore.wallet!.name, + type = appStore.wallet!.type, + transactions = ObservableList(), + wallet = appStore.wallet! { name = wallet.name; type = wallet.type; isShowFirstYatIntroduction = false; @@ -222,9 +222,8 @@ abstract class DashboardViewModelBase with Store { BalanceDisplayMode get balanceDisplayMode => appStore.settingsStore.balanceDisplayMode; @computed - bool get shouldShowMarketPlaceInDashboard { - return appStore.settingsStore.shouldShowMarketPlaceInDashboard; - } + bool get shouldShowMarketPlaceInDashboard => + appStore.settingsStore.shouldShowMarketPlaceInDashboard; @computed List get trades => diff --git a/lib/view_model/dashboard/trade_list_item.dart b/lib/view_model/dashboard/trade_list_item.dart index d83445308..964ba4ffa 100644 --- a/lib/view_model/dashboard/trade_list_item.dart +++ b/lib/view_model/dashboard/trade_list_item.dart @@ -1,25 +1,18 @@ +import 'package:cake_wallet/entities/balance_display_mode.dart'; import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/dashboard/action_list_item.dart'; -import 'package:cake_wallet/entities/balance_display_mode.dart'; class TradeListItem extends ActionListItem { - TradeListItem({ - required this.trade, - required this.settingsStore}); + TradeListItem({required this.trade, required this.settingsStore}); final Trade trade; final SettingsStore settingsStore; BalanceDisplayMode get displayMode => settingsStore.balanceDisplayMode; - String get tradeFormattedAmount { - return trade.amount != null - ? displayMode == BalanceDisplayMode.hiddenBalance - ? '---' - : trade.amountFormatted() - : trade.amount; - } + String get tradeFormattedAmount => + displayMode == BalanceDisplayMode.hiddenBalance ? '---' : trade.amountFormatted(); @override DateTime get date => trade.createdAt!; diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 8692b193b..704e5c029 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -491,6 +491,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with final trade = await provider.createTrade(request: request, isFixedRateMode: isFixedRateMode); trade.walletId = wallet.id; + trade.fromWalletAddress = wallet.walletAddresses.address; tradesStore.setTrade(trade); await trades.add(trade); tradeState = TradeIsCreatedSuccessfully(trade: trade); diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index 81f521d27..257bae1fd 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -1,4 +1,3 @@ -import 'package:cake_wallet/nano/nano.dart'; import 'package:cake_wallet/store/app_store.dart'; import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/transaction_info.dart'; @@ -194,7 +193,7 @@ abstract class WalletKeysViewModelBase with Store { int _getRestoreHeightByTransactions(WalletType type, DateTime date) { if (type == WalletType.monero) { - return monero!.getHeigthByDate(date: date); + return monero!.getHeightByDate(date: date); } else if (type == WalletType.haven) { return haven!.getHeightByDate(date: date); } diff --git a/tool/configure.dart b/tool/configure.dart index 90e275994..bc32581a6 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -235,7 +235,7 @@ abstract class Monero { String getSubaddressLabel(Object wallet, int accountIndex, int addressIndex); - int getHeigthByDate({required DateTime date}); + int getHeightByDate({required DateTime date}); TransactionPriority getDefaultTransactionPriority(); TransactionPriority getMoneroTransactionPrioritySlow(); TransactionPriority getMoneroTransactionPriorityAutomatic();