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:
Omar Hatem
2024-05-08 17:26:57 +03:00
committed by GitHub
parent baad7f7469
commit 12e3001b3a
51 changed files with 217 additions and 138 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002';
const nanoDefaultNodeUri = 'rpc.nano.to';
const nanoDefaultPowNodeUri = 'rpc.nano.to';
const solanaDefaultNodeUri = 'rpc.ankr.com';
const tronDefaultNodeUri = 'api.trongrid.io';
const tronDefaultNodeUri = 'tron-rpc.publicnode.com:443';
const newCakeWalletBitcoinUri = 'btc-electrum.cakewallet.com:50002';
Future<void> defaultSettingsMigration(
+1
View File
@@ -56,6 +56,7 @@ class PreferencesKey {
static const pinNativeTokenAtTop = 'pin_native_token_at_top';
static const useEtherscan = 'use_etherscan';
static const usePolygonScan = 'use_polygonscan';
static const useTronGrid = 'use_trongrid';
static const defaultNanoRep = 'default_nano_representative';
static const defaultBananoRep = 'default_banano_representative';
static const lookupsTwitter = 'looks_up_twitter';
@@ -19,15 +19,15 @@ class ThorChainExchangeProvider extends ExchangeProvider {
...(CryptoCurrency.all
.where((element) => ![
CryptoCurrency.btc,
CryptoCurrency.eth,
// CryptoCurrency.eth,
CryptoCurrency.ltc,
CryptoCurrency.bch,
CryptoCurrency.aave,
CryptoCurrency.dai,
CryptoCurrency.gusd,
CryptoCurrency.usdc,
CryptoCurrency.usdterc20,
CryptoCurrency.wbtc,
// CryptoCurrency.aave,
// CryptoCurrency.dai,
// CryptoCurrency.gusd,
// CryptoCurrency.usdc,
// CryptoCurrency.usdterc20,
// CryptoCurrency.wbtc, // TODO: temporarily commented until https://github.com/cake-tech/cake_wallet/pull/1436 is merged
].contains(element))
.toList())
];
@@ -7,6 +7,7 @@ import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/option_tile.dart';
import 'package:cake_wallet/themes/extensions/option_tile_theme.dart';
import 'package:cake_wallet/utils/device_info.dart';
import 'package:cake_wallet/utils/permission_handler.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
@@ -56,17 +57,18 @@ class RestoreOptionsPage extends BasePage {
description: S.of(context).restore_description_from_backup,
),
),
Padding(
padding: EdgeInsets.only(top: 24),
child: OptionTile(
onPressed: () => Navigator.pushNamed(
context, Routes.restoreWalletFromHardwareWallet,
arguments: isNewInstall),
image: imageLedger,
title: S.of(context).restore_title_from_hardware_wallet,
description: S.of(context).restore_description_from_hardware_wallet,
if (DeviceInfo.instance.isMobile)
Padding(
padding: EdgeInsets.only(top: 24),
child: OptionTile(
onPressed: () => Navigator.pushNamed(
context, Routes.restoreWalletFromHardwareWallet,
arguments: isNewInstall),
image: imageLedger,
title: S.of(context).restore_title_from_hardware_wallet,
description: S.of(context).restore_description_from_hardware_wallet,
),
),
),
Padding(
padding: EdgeInsets.only(top: 24),
child: OptionTile(
@@ -103,6 +103,14 @@ class PrivacyPage extends BasePage {
_privacySettingsViewModel.setUsePolygonScan(value);
},
),
if (_privacySettingsViewModel.canUseTronGrid)
SettingsSwitcherCell(
title: S.current.trongrid_history,
value: _privacySettingsViewModel.useTronGrid,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setUseTronGrid(value);
},
),
SettingsCellWithArrow(
title: S.current.domain_looks_up,
handler: (context) => Navigator.of(context).pushNamed(Routes.domainLookupsPage),
+12
View File
@@ -99,6 +99,7 @@ abstract class SettingsStoreBase with Store {
required this.pinNativeTokenAtTop,
required this.useEtherscan,
required this.usePolygonScan,
required this.useTronGrid,
required this.defaultNanoRep,
required this.defaultBananoRep,
required this.lookupsTwitter,
@@ -397,6 +398,11 @@ abstract class SettingsStoreBase with Store {
(bool usePolygonScan) =>
_sharedPreferences.setBool(PreferencesKey.usePolygonScan, usePolygonScan));
reaction(
(_) => useTronGrid,
(bool useTronGrid) =>
_sharedPreferences.setBool(PreferencesKey.useTronGrid, useTronGrid));
reaction((_) => defaultNanoRep,
(String nanoRep) => _sharedPreferences.setString(PreferencesKey.defaultNanoRep, nanoRep));
@@ -674,6 +680,9 @@ abstract class SettingsStoreBase with Store {
@observable
bool usePolygonScan;
@observable
bool useTronGrid;
@observable
String defaultNanoRep;
@@ -846,6 +855,7 @@ abstract class SettingsStoreBase with Store {
: defaultSeedPhraseLength;
final useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
final usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
final useTronGrid = sharedPreferences.getBool(PreferencesKey.useTronGrid) ?? true;
final defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
final defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
final lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
@@ -1090,6 +1100,7 @@ abstract class SettingsStoreBase with Store {
pinNativeTokenAtTop: pinNativeTokenAtTop,
useEtherscan: useEtherscan,
usePolygonScan: usePolygonScan,
useTronGrid: useTronGrid,
defaultNanoRep: defaultNanoRep,
defaultBananoRep: defaultBananoRep,
lookupsTwitter: lookupsTwitter,
@@ -1227,6 +1238,7 @@ abstract class SettingsStoreBase with Store {
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
useTronGrid = sharedPreferences.getBool(PreferencesKey.useTronGrid) ?? true;
defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
+5
View File
@@ -111,4 +111,9 @@ class CWTron extends Tron {
@override
String? getTronTRC20EstimatedFee(WalletBase wallet) => (wallet as TronWallet).trc20EstimatedFee;
@override
void updateTronGridUsageState(WalletBase wallet, bool isEnabled) {
(wallet as TronWallet).updateScanProviderUsageState(isEnabled);
}
}
@@ -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);
+3 -8
View File
@@ -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);
}
}