Merge branch 'main' into zano-pr

This commit is contained in:
cyan 2024-11-13 17:40:01 +01:00 committed by GitHub
commit 2df5e8e6e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 23 additions and 14 deletions

View file

@ -47,10 +47,6 @@ void enableLedgerExchange(monero.wallet ptr, LedgerConnection connection) {
void keepAlive(LedgerConnection connection) {
if (connection.connectionType == ConnectionType.ble) {
UniversalBle.onConnectionChange = (String deviceId, bool isConnected) {
print("[Monero] Ledger Disconnected");
_ledgerKeepAlive?.cancel();
};
_ledgerKeepAlive = Timer.periodic(Duration(seconds: 10), (_) async {
try {
UniversalBle.setNotifiable(

View file

@ -146,6 +146,11 @@ class MoneroWalletService extends WalletService<
password: password);
final isValid = wallet.walletAddresses.validate();
if (wallet.isHardwareWallet) {
wallet.setLedgerConnection(gLedger!);
gLedger = null;
}
if (!isValid) {
await restoreOrResetWalletFiles(name);
wallet.close(shouldCleanup: false);

View file

@ -41,7 +41,8 @@ class AddressResolver {
'kresus',
'anime',
'manga',
'binanceus'
'binanceus',
'xmr',
];
static String? extractAddressByType({required String raw, required CryptoCurrency type}) {

View file

@ -402,6 +402,10 @@ class CWMonero extends Monero {
moneroWallet.setLedgerConnection(connection);
}
void resetLedgerConnection() {
disableLedgerExchange();
}
@override
void setGlobalLedgerConnection(ledger.LedgerConnection connection) {
gLedger = connection;

View file

@ -10,9 +10,6 @@ import 'package:cw_core/transaction_history.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:mobx/mobx.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/reactions/check_connection.dart';
import 'package:cake_wallet/reactions/on_wallet_sync_status_change.dart';
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
@ -65,10 +62,6 @@ void startCurrentWalletChangeReaction(
startWalletSyncStatusChangeReaction(wallet, fiatConversionStore);
startCheckConnectionReaction(wallet, settingsStore);
await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
await getIt
.get<SharedPreferences>()
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
if (wallet.type == WalletType.monero ||
wallet.type == WalletType.wownero ||

View file

@ -1,8 +1,10 @@
import 'package:cake_wallet/core/wallet_connect/web3wallet_service.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/reactions/wallet_connect.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/wallet_base.dart';
@ -11,6 +13,7 @@ import 'package:cake_wallet/store/wallet_list_store.dart';
import 'package:cake_wallet/store/authentication_store.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/node_list_store.dart';
import 'package:shared_preferences/shared_preferences.dart';
part 'app_store.g.dart';
@ -47,5 +50,9 @@ abstract class AppStoreBase with Store {
getIt.get<Web3WalletService>().create();
await getIt.get<Web3WalletService>().init();
}
await getIt.get<SharedPreferences>().setString(PreferencesKey.currentWalletName, wallet.name);
await getIt
.get<SharedPreferences>()
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
}
}

View file

@ -98,7 +98,9 @@ abstract class LedgerViewModelBase with Store {
print('Ledger Device State Changed: $event');
if (event == sdk.BleConnectionState.disconnected) {
_connection = null;
_connectionChangeListener?.cancel();
if (type == WalletType.monero) {
monero!.resetLedgerConnection();
}
}
});
}

View file

@ -420,6 +420,7 @@ abstract class Monero {
WalletService createMoneroWalletService(Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource);
Map<String, String> pendingTransactionInfo(Object transaction);
void setLedgerConnection(Object wallet, ledger.LedgerConnection connection);
void resetLedgerConnection();
void setGlobalLedgerConnection(ledger.LedgerConnection connection);
}