mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
Generic enhancements (#1435)
* Disable Ledger for MacOS * increase update duration for Solana [skip ci] * change tron default Node Update build number * Add disabling tron grid to privacy settings * update monero.com versions [skip ci]
This commit is contained in:
@@ -2,27 +2,34 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cake_wallet/utils/device_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:ledger_flutter/ledger_flutter.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class LedgerViewModel {
|
||||
final Ledger ledger = Ledger(
|
||||
options: LedgerOptions(
|
||||
scanMode: ScanMode.balanced,
|
||||
maxScanDuration: const Duration(minutes: 5),
|
||||
),
|
||||
onPermissionRequest: (_) async {
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.bluetoothAdvertise,
|
||||
].request();
|
||||
late final Ledger ledger;
|
||||
|
||||
return statuses.values.where((status) => status.isDenied).isEmpty;
|
||||
},
|
||||
);
|
||||
LedgerViewModel() {
|
||||
if (DeviceInfo.instance.isMobile) {
|
||||
ledger = Ledger(
|
||||
options: LedgerOptions(
|
||||
scanMode: ScanMode.balanced,
|
||||
maxScanDuration: const Duration(minutes: 5),
|
||||
),
|
||||
onPermissionRequest: (_) async {
|
||||
Map<Permission, PermissionStatus> statuses = await [
|
||||
Permission.bluetoothScan,
|
||||
Permission.bluetoothConnect,
|
||||
Permission.bluetoothAdvertise,
|
||||
].request();
|
||||
|
||||
return statuses.values.where((status) => status.isDenied).isEmpty;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> connectLedger(LedgerDevice device) async {
|
||||
await ledger.connect(device);
|
||||
|
||||
@@ -7,19 +7,14 @@ import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'link_view_model.g.dart';
|
||||
|
||||
class LinkViewModel = LinkViewModelBase with _$LinkViewModel;
|
||||
|
||||
abstract class LinkViewModelBase with Store {
|
||||
LinkViewModelBase({
|
||||
class LinkViewModel {
|
||||
LinkViewModel({
|
||||
required this.settingsStore,
|
||||
required this.appStore,
|
||||
required this.authenticationStore,
|
||||
required this.navigatorKey,
|
||||
}) {}
|
||||
});
|
||||
|
||||
final SettingsStore settingsStore;
|
||||
final AppStore appStore;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/tron/tron.dart';
|
||||
import 'package:cw_core/balance.dart';
|
||||
import 'package:cw_core/transaction_history.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
@@ -70,6 +71,9 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
@computed
|
||||
bool get usePolygonScan => _settingsStore.usePolygonScan;
|
||||
|
||||
@computed
|
||||
bool get useTronGrid => _settingsStore.useTronGrid;
|
||||
|
||||
@computed
|
||||
bool get lookupTwitter => _settingsStore.lookupsTwitter;
|
||||
|
||||
@@ -92,6 +96,8 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
|
||||
bool get canUsePolygonScan => _wallet.type == WalletType.polygon;
|
||||
|
||||
bool get canUseTronGrid => _wallet.type == WalletType.tron;
|
||||
|
||||
@action
|
||||
void setShouldSaveRecipientAddress(bool value) =>
|
||||
_settingsStore.shouldSaveRecipientAddress = value;
|
||||
@@ -143,4 +149,10 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
_settingsStore.usePolygonScan = value;
|
||||
polygon!.updatePolygonScanUsageState(_wallet, value);
|
||||
}
|
||||
|
||||
@action
|
||||
void setUseTronGrid(bool value) {
|
||||
_settingsStore.useTronGrid = value;
|
||||
tron!.updateTronGridUsageState(_wallet, value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user