mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-21 10:24:15 +01:00
Generic fixes (#1154)
* Fix White screen issue Bypass node certificate issue * check on Fiat currency only with fiat templates * Add possible missing cache file android error * Dispose exchange state reaction when page is closed * Fix minor chinese translation * Temp remove BCH from robinhood * Minor fixes
This commit is contained in:
@@ -34,7 +34,7 @@ class RobinhoodBuyProvider {
|
||||
case WalletType.bitcoin:
|
||||
return _wallet.signMessage(message, address: _wallet.walletAddresses.address);
|
||||
default:
|
||||
throw Exception("WalletType is not available for Robinhood");
|
||||
throw Exception("WalletType is not available for Robinhood ${_wallet.type}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,63 +191,70 @@ Future<void> defaultSettingsMigration(
|
||||
}
|
||||
|
||||
Future<void> _validateWalletInfoBoxData(Box<WalletInfo> walletInfoSource) async {
|
||||
final root = await getApplicationDocumentsDirectory();
|
||||
try {
|
||||
final root = await getApplicationDocumentsDirectory();
|
||||
|
||||
for (var type in WalletType.values) {
|
||||
if (type == WalletType.none) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String prefix = walletTypeToString(type).toLowerCase();
|
||||
Directory walletsDir = Directory('${root.path}/wallets/$prefix/');
|
||||
|
||||
if (!walletsDir.existsSync()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> walletNames = walletsDir.listSync().map((e) => e.path.split("/").last).toList();
|
||||
|
||||
for (var name in walletNames) {
|
||||
final dir = Directory(await pathForWalletDir(name: name, type: type));
|
||||
|
||||
final walletFiles = dir.listSync();
|
||||
final hasCacheFile = walletFiles.any((element) => element.path.contains("$name/$name"));
|
||||
|
||||
if (!hasCacheFile) {
|
||||
for (var type in WalletType.values) {
|
||||
if (type == WalletType.none) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == WalletType.monero || type == WalletType.haven) {
|
||||
final hasKeysFile = walletFiles.any((element) => element.path.contains(".keys"));
|
||||
String prefix = walletTypeToString(type).toLowerCase();
|
||||
Directory walletsDir = Directory('${root.path}/wallets/$prefix/');
|
||||
|
||||
if (!hasKeysFile) {
|
||||
if (!walletsDir.existsSync()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<String> walletNames = walletsDir.listSync().map((e) => e.path.split("/").last).toList();
|
||||
|
||||
for (var name in walletNames) {
|
||||
final Directory dir;
|
||||
try {
|
||||
dir = Directory(await pathForWalletDir(name: name, type: type));
|
||||
} catch (_) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final walletFiles = dir.listSync();
|
||||
final hasCacheFile = walletFiles.any((element) => element.path.contains("$name/$name"));
|
||||
|
||||
if (!hasCacheFile) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == WalletType.monero || type == WalletType.haven) {
|
||||
final hasKeysFile = walletFiles.any((element) => element.path.contains(".keys"));
|
||||
|
||||
if (!hasKeysFile) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final id = prefix + '_' + name;
|
||||
final exist = walletInfoSource.values.any((el) => el.id == id);
|
||||
|
||||
if (exist) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final walletInfo = WalletInfo.external(
|
||||
id: id,
|
||||
type: type,
|
||||
name: name,
|
||||
isRecovery: true,
|
||||
restoreHeight: 0,
|
||||
date: DateTime.now(),
|
||||
dirPath: dir.path,
|
||||
path: '${dir.path}/$name',
|
||||
address: '',
|
||||
showIntroCakePayCard: false,
|
||||
);
|
||||
|
||||
walletInfoSource.add(walletInfo);
|
||||
}
|
||||
|
||||
final id = prefix + '_' + name;
|
||||
final exist = walletInfoSource.values.any((el) => el.id == id);
|
||||
|
||||
if (exist) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final walletInfo = WalletInfo.external(
|
||||
id: id,
|
||||
type: type,
|
||||
name: name,
|
||||
isRecovery: true,
|
||||
restoreHeight: 0,
|
||||
date: DateTime.now(),
|
||||
dirPath: dir.path,
|
||||
path: '${dir.path}/$name',
|
||||
address: '',
|
||||
showIntroCakePayCard: false,
|
||||
);
|
||||
|
||||
walletInfoSource.add(walletInfo);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> validateBitcoinSavedTransactionPriority(SharedPreferences sharedPreferences) async {
|
||||
|
||||
@@ -52,7 +52,7 @@ class MainActions {
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.ethereum:
|
||||
case WalletType.bitcoinCash:
|
||||
// case WalletType.bitcoinCash: // TODO: add sign message function to BCH first
|
||||
switch (defaultBuyProvider) {
|
||||
case BuyProviderType.AskEachTime:
|
||||
Navigator.pushNamed(context, Routes.buy);
|
||||
|
||||
@@ -91,6 +91,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
|
||||
ReactionDisposer? _exchangeStateReaction;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -103,8 +105,9 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
widget.exchangeTradeViewModel.timer?.cancel();
|
||||
_exchangeStateReaction?.reaction.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -229,7 +232,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
||||
return;
|
||||
}
|
||||
|
||||
reaction((_) => this.widget.exchangeTradeViewModel.sendViewModel.state,
|
||||
_exchangeStateReaction = reaction((_) => this.widget.exchangeTradeViewModel.sendViewModel.state,
|
||||
(ExecutionState state) {
|
||||
if (state is FailureState) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
|
||||
@@ -13,8 +13,7 @@ import 'package:cake_wallet/store/authentication_store.dart';
|
||||
import 'package:cake_wallet/entities/qr_scanner.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:uni_links/uni_links.dart';
|
||||
|
||||
import '../setup_2fa/setup_2fa_enter_code_page.dart';
|
||||
import 'package:cake_wallet/src/screens/setup_2fa/setup_2fa_enter_code_page.dart';
|
||||
|
||||
class Root extends StatefulWidget {
|
||||
Root({
|
||||
|
||||
@@ -413,39 +413,39 @@ class SendPage extends BasePage {
|
||||
if (context.mounted) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
builder: (BuildContext _dialogContext) {
|
||||
return ConfirmSendingAlert(
|
||||
alertTitle: S.of(context).confirm_sending,
|
||||
amount: S.of(context).send_amount,
|
||||
alertTitle: S.of(_dialogContext).confirm_sending,
|
||||
amount: S.of(_dialogContext).send_amount,
|
||||
amountValue: sendViewModel.pendingTransaction!.amountFormatted,
|
||||
fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
|
||||
fee: S.of(context).send_fee,
|
||||
fee: S.of(_dialogContext).send_fee,
|
||||
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
||||
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
|
||||
outputs: sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
rightButtonText: S.of(_dialogContext).ok,
|
||||
leftButtonText: S.of(_dialogContext).cancel,
|
||||
actionRightButton: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(_dialogContext).pop();
|
||||
sendViewModel.commitTransaction();
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
builder: (BuildContext _dialogContext) {
|
||||
return Observer(builder: (_) {
|
||||
final state = sendViewModel.state;
|
||||
|
||||
if (state is FailureState) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(_dialogContext).pop();
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: '',
|
||||
alertContent: S.of(context).send_success(
|
||||
alertContent: S.of(_dialogContext).send_success(
|
||||
sendViewModel.selectedCryptoCurrency.toString()),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonText: S.of(_dialogContext).ok,
|
||||
buttonAction: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(_dialogContext).pop();
|
||||
RequestReviewHandler.requestReview();
|
||||
});
|
||||
}
|
||||
@@ -454,7 +454,7 @@ class SendPage extends BasePage {
|
||||
});
|
||||
});
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(context).pop());
|
||||
actionLeftButton: () => Navigator.of(_dialogContext).pop());
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -472,15 +472,15 @@ class SendPage extends BasePage {
|
||||
|
||||
Future<void> _setInputsFromTemplate(BuildContext context,
|
||||
{required Output output, required Template template}) async {
|
||||
final fiatFromTemplate =
|
||||
FiatCurrency.all.singleWhere((element) => element.title == template.fiatCurrency);
|
||||
|
||||
output.address = template.address;
|
||||
|
||||
if (template.isCurrencySelected) {
|
||||
sendViewModel.setSelectedCryptoCurrency(template.cryptoCurrency);
|
||||
output.setCryptoAmount(template.amount);
|
||||
} else {
|
||||
final fiatFromTemplate =
|
||||
FiatCurrency.all.singleWhere((element) => element.title == template.fiatCurrency);
|
||||
|
||||
sendViewModel.setFiatCurrency(fiatFromTemplate);
|
||||
output.setFiatAmount(template.amountFiat);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user