Fixes for monero transaction history.

M committed Sep 21, 2020 at 19:56 UTC 2b05eedfc63271870a6dc0ed681caab88ba529c9
9 files changed +74 -24
android/app/src/main/kotlin/com/cakewallet/cake_wallet/MainActivity.kt new
+6
@@ -0,0 +1,6 @@
1 +package com.cakewallet.cake_wallet
2 +
3 +import io.flutter.embedding.android.FlutterActivity
4 +
5 +class MainActivity: FlutterActivity() {
6 +}
ios/Flutter/.last_build_id
+1 -1
@@ -1 +1 @@
1 -1ec95e8df881a4b938eb38fddbcc8f19
\ No newline at end of file
1 +09c81fe0a3d701eb6da3bd2c6fc5ec65
\ No newline at end of file
ios/Podfile
+1 -1
@@ -1,5 +1,5 @@
1 # Uncomment this line to define a global platform for your project
2 -# platform :ios, '9.0'
2 +platform :ios, '9.0'
3
4 # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 ENV['COCOAPODS_DISABLE_STATS'] = 'true'
ios/Podfile.lock
+1 -1
@@ -117,6 +117,6 @@ SPEC CHECKSUMS:
117 SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699
118 url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
119
120 -PODFILE CHECKSUM: 6856e7141d486377eb0aa3b6d88e4b952e4ff514
120 +PODFILE CHECKSUM: ade2ba43f8c2af4060c025bfd25a553d068ab914
121
122 COCOAPODS: 1.9.3
ios/Runner.xcodeproj/project.pbxproj
+3 -3
@@ -351,7 +351,7 @@
351 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
352 GCC_WARN_UNUSED_FUNCTION = YES;
353 GCC_WARN_UNUSED_VARIABLE = YES;
354 - IPHONEOS_DEPLOYMENT_TARGET = 9.0;
354 + IPHONEOS_DEPLOYMENT_TARGET = 11.0;
355 MTL_ENABLE_DEBUG_INFO = NO;
356 SDKROOT = iphoneos;
357 SUPPORTED_PLATFORMS = iphoneos;
@@ -439,7 +439,7 @@
439 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
440 GCC_WARN_UNUSED_FUNCTION = YES;
441 GCC_WARN_UNUSED_VARIABLE = YES;
442 - IPHONEOS_DEPLOYMENT_TARGET = 9.0;
442 + IPHONEOS_DEPLOYMENT_TARGET = 11.0;
443 MTL_ENABLE_DEBUG_INFO = YES;
444 ONLY_ACTIVE_ARCH = YES;
445 SDKROOT = iphoneos;
@@ -488,7 +488,7 @@
488 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
489 GCC_WARN_UNUSED_FUNCTION = YES;
490 GCC_WARN_UNUSED_VARIABLE = YES;
491 - IPHONEOS_DEPLOYMENT_TARGET = 9.0;
491 + IPHONEOS_DEPLOYMENT_TARGET = 11.0;
492 MTL_ENABLE_DEBUG_INFO = NO;
493 SDKROOT = iphoneos;
494 SUPPORTED_PLATFORMS = iphoneos;
lib/entities/ios_legacy_helper.dart
+15
@@ -0,0 +1,15 @@
1 +import 'dart:async';
2 +import 'package:flutter/foundation.dart';
3 +import 'package:flutter/services.dart';
4 +
5 +const platform =
6 + const MethodChannel('com.cakewallet.cakewallet/legacy_wallet_migration');
7 +
8 +Future<String> readTradeList(
9 + {@required String key, @required String salt}) async =>
10 + await platform.invokeMethod('read_trade_list', {'key': key, 'salt': salt});
11 +
12 +Future<String> readEncryptedFile(String url,
13 + {@required String key, @required String salt}) async =>
14 + await platform.invokeMethod(
15 + 'read_encrypted_file', {'url': url, 'key': key, 'salt': salt});
lib/monero/monero_transaction_history.dart
+5 -2
@@ -3,7 +3,6 @@ import 'package:mobx/mobx.dart';
3 import 'package:cw_monero/transaction_history.dart'
4 as monero_transaction_history;
5 import 'package:cake_wallet/core/transaction_history.dart';
6 -import 'package:cake_wallet/entities/transaction_info.dart';
6 import 'package:cake_wallet/monero/monero_transaction_info.dart';
7
8 part 'monero_transaction_history.g.dart';
@@ -44,5 +43,9 @@ abstract class MoneroTransactionHistoryBase
43 @override
44 void fetchTransactionsAsync(
45 void Function(MoneroTransactionInfo transaction) onTransactionLoaded,
47 - {void Function() onFinished}) {}
46 + {void Function() onFinished}) async {
47 + final transactions = await fetchTransactions();
48 + transactions.values.forEach((tx) => onTransactionLoaded(tx));
49 + onFinished?.call();
50 + }
51 }
lib/monero/monero_wallet.dart
+17 -16
@@ -1,20 +1,22 @@
1 -import 'package:cake_wallet/entities/wallet_info.dart';
2 -import 'package:cake_wallet/monero/monero_transaction_creation_credentials.dart';
1 import 'package:flutter/foundation.dart';
2 import 'package:mobx/mobx.dart';
3 import 'package:cw_monero/wallet.dart';
4 import 'package:cw_monero/wallet.dart' as monero_wallet;
5 +import 'package:cw_monero/transaction_history.dart' as transaction_history;
6 +import 'package:cake_wallet/monero/monero_transaction_creation_credentials.dart';
7 +import 'package:cake_wallet/monero/pending_monero_transaction.dart';
8 import 'package:cake_wallet/monero/monero_wallet_keys.dart';
9 import 'package:cake_wallet/monero/monero_balance.dart';
10 import 'package:cake_wallet/monero/monero_transaction_history.dart';
11 import 'package:cake_wallet/monero/monero_subaddress_list.dart';
12 import 'package:cake_wallet/monero/monero_account_list.dart';
12 -import 'package:cake_wallet/core/wallet_base.dart';
13 -import 'package:cake_wallet/entities/sync_status.dart';
13 import 'package:cake_wallet/monero/account.dart';
14 import 'package:cake_wallet/monero/subaddress.dart';
16 -import 'package:cake_wallet/entities/node.dart';
15 import 'package:cake_wallet/core/pending_transaction.dart';
16 +import 'package:cake_wallet/core/wallet_base.dart';
17 +import 'package:cake_wallet/entities/sync_status.dart';
18 +import 'package:cake_wallet/entities/wallet_info.dart';
19 +import 'package:cake_wallet/entities/node.dart';
20 import 'package:cake_wallet/entities/transaction_priority.dart';
21
22 part 'monero_wallet.g.dart';
@@ -134,15 +136,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
136 @override
137 Future<PendingTransaction> createTransaction(Object credentials) async {
138 final _credentials = credentials as MoneroTransactionCreationCredentials;
137 - // final transactionDescription = await transaction_history.createTransaction(
138 - // address: _credentials.address,
139 - // paymentId: _credentials.paymentId,
140 - // amount: _credentials.amount,
141 - // priorityRaw: _credentials.priority.serialize(),
142 - // accountIndex: _account.value.id);
143 -
144 - // return PendingTransaction.fromTransactionDescription(
145 - // transactionDescription);
139 + final pendingTransactionDescription =
140 + await transaction_history.createTransaction(
141 + address: _credentials.address,
142 + paymentId: _credentials.paymentId,
143 + amount: _credentials.amount,
144 + priorityRaw: _credentials.priority.serialize(),
145 + accountIndex: account.id);
146 +
147 + return PendingMoneroTransaction(pendingTransactionDescription);
148 }
149
150 @override
@@ -243,8 +245,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
245 }
246 }
247
246 - void _askForUpdateTransactionHistory() =>
247 - null; // await getHistory().update();
248 + void _askForUpdateTransactionHistory() => transactionHistory.updateAsync();
249
250 int _getFullBalance() =>
251 monero_wallet.getFullBalance(accountIndex: account.id);
lib/monero/pending_monero_transaction.dart new
+25
@@ -0,0 +1,25 @@
1 +import 'package:cw_monero/structs/pending_transaction.dart';
2 +import 'package:cw_monero/transaction_history.dart'
3 + as monero_transaction_history;
4 +import 'package:cake_wallet/entities/crypto_currency.dart';
5 +import 'package:cake_wallet/core/amount_converter.dart';
6 +import 'package:cake_wallet/core/pending_transaction.dart';
7 +
8 +class PendingMoneroTransaction with PendingTransaction {
9 + PendingMoneroTransaction(this.pendingTransactionDescription);
10 +
11 + final PendingTransactionDescription pendingTransactionDescription;
12 +
13 + @override
14 + String get amountFormatted => AmountConverter.amountIntToString(
15 + CryptoCurrency.xmr, pendingTransactionDescription.amount);
16 +
17 + @override
18 + String get feeFormatted => AmountConverter.amountIntToString(
19 + CryptoCurrency.xmr, pendingTransactionDescription.fee);
20 +
21 + @override
22 + Future<void> commit() async =>
23 + monero_transaction_history.commitTransactionFromPointerAddress(
24 + address: pendingTransactionDescription.pointerAddress);
25 +}