mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
The big one. Touches 760+ files. Locks in the user's decision to break import-line compatibility with upstream cake-tech/cake_wallet in exchange for a binary named hash_wallet on every platform. Changes: - pubspec_description.yaml: project name cake_wallet -> hash_wallet - 762 Dart files: every 'package:cake_wallet/...' import rewritten to 'package:hash_wallet/...' (lib/, cw_*/lib/, tool/, test/, integration_test/) - linux/CMakeLists.txt: BINARY_NAME cake_wallet -> hash_wallet - windows/CMakeLists.txt: project + BINARY_NAME (CakeWallet -> HashWallet) - windows/runner/Runner.rc: company / file / product strings to Hash Wallet + Such Software LLC copyright - macos/Runner.xcodeproj/project_base.pbxproj: cake_wallet_new.app refs -> hash_wallet.app (macOS output bundle name) - com.suchsoftware.HashWallet.yml (Flatpak): all binary path refs cake_wallet -> hash_wallet (e.g. /app/hash_wallet/hash_wallet) - linux/com.suchsoftware.HashWallet.desktop: Exec=hash_wallet - scripts/android/copy_monero_deps.sh: CW_DIR target path - configure_hash_wallet.sh: error message typo (old filename) INTENTIONALLY UNCHANGED: - cw_* subpackage names (cw_core, cw_bitcoin, cw_wownero, etc.) — they remain as the historical 'cake wallet' naming; renaming them would cascade through every sub-package's internal structure - Method channel name 'com.cake_wallet/native_utils' in iOS/macOS/Android AppDelegates and MainActivity — it's a string identifier that has to match the Dart side exactly. Renaming requires both-sides change; it's internal-only and not user-visible. - ghcr.io/cake-tech/cake_wallet:debian13-... docker image references in build scripts — that's Cake Labs' published image we use as the build environment, not ours. User data directory now follows the new binary name: ~/.local/share/hash_wallet/ (was ~/.local/share/cake_wallet/) ~/.config/hash_wallet/ (was ~/.config/cake_wallet/) Existing users on the old name will need migration if any exist.
144 lines
6.1 KiB
Dart
144 lines
6.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:hash_wallet/di.dart';
|
|
import 'package:hash_wallet/entities/hardware_wallet/require_hardware_wallet_connection.dart';
|
|
import 'package:hash_wallet/entities/load_current_wallet.dart';
|
|
import 'package:hash_wallet/generated/i18n.dart';
|
|
import 'package:hash_wallet/monero/monero.dart';
|
|
import 'package:hash_wallet/routes.dart';
|
|
import 'package:hash_wallet/src/screens/connect_device/connect_device_page.dart';
|
|
import 'package:hash_wallet/src/screens/wallet_connect/services/bottom_sheet_service.dart';
|
|
import 'package:hash_wallet/src/widgets/alert_with_one_action.dart';
|
|
import 'package:hash_wallet/src/widgets/alert_with_two_actions.dart';
|
|
import 'package:hash_wallet/store/authentication_store.dart';
|
|
import 'package:hash_wallet/store/settings_store.dart';
|
|
import 'package:hash_wallet/utils/exception_handler.dart';
|
|
import 'package:hash_wallet/utils/show_pop_up.dart';
|
|
import 'package:hash_wallet/view_model/hardware_wallet/ledger_view_model.dart';
|
|
import 'package:hash_wallet/view_model/link_view_model.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:rxdart/subjects.dart';
|
|
|
|
ReactionDisposer? _onAuthenticationStateChange;
|
|
|
|
dynamic loginError;
|
|
StreamController<dynamic> authenticatedErrorStreamController =
|
|
BehaviorSubject<dynamic>();
|
|
|
|
void startAuthenticationStateChange(
|
|
AuthenticationStore authenticationStore,
|
|
GlobalKey<NavigatorState> navigatorKey,
|
|
) {
|
|
authenticatedErrorStreamController.stream.listen((event) {
|
|
if (authenticationStore.state == AuthenticationState.allowed) {
|
|
ExceptionHandler.showError(event.toString(), delayInSeconds: 3);
|
|
}
|
|
});
|
|
|
|
_onAuthenticationStateChange ??= autorun((_) async {
|
|
final state = authenticationStore.state;
|
|
|
|
if (state == AuthenticationState.installed && !SettingsStoreBase.walletPasswordDirectInput) {
|
|
try {
|
|
if (!(await requireHardwareWalletConnection())) await loadCurrentWallet();
|
|
} catch (error, stack) {
|
|
loginError = error;
|
|
await ExceptionHandler.resetLastPopupDate();
|
|
await ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stack));
|
|
}
|
|
return;
|
|
}
|
|
|
|
if ([AuthenticationState.allowed, AuthenticationState.allowedCreate].contains(state)) {
|
|
if (state == AuthenticationState.allowed && (await requireHardwareWalletConnection())) {
|
|
await navigatorKey.currentState!.pushNamedAndRemoveUntil(
|
|
Routes.connectDevices,
|
|
(route) => false,
|
|
arguments: ConnectDevicePageParams(
|
|
walletType: WalletType.monero,
|
|
hardwareWalletType: HardwareWalletType.ledger,
|
|
onConnectDevice: (context, ledgerVM) async {
|
|
if (ledgerVM is LedgerViewModel) {
|
|
monero!.setGlobalLedgerConnection(ledgerVM.connection);
|
|
} else {
|
|
await showPopUp<void>(
|
|
context: context,
|
|
builder: (context) => AlertWithOneAction(
|
|
alertTitle: "Unexpected Error",
|
|
alertContent:
|
|
"Unexpected Error while trying to connect to the device (UnexpectedViewModel: ${ledgerVM.toString()})",
|
|
buttonText: S.of(context).try_again,
|
|
buttonAction: Navigator.of(context).pop,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
showPopUp<void>(
|
|
context: context,
|
|
builder: (context) => AlertWithOneAction(
|
|
alertTitle: S.of(context).proceed_on_device,
|
|
alertContent: S.of(context).proceed_on_device_description,
|
|
buttonText: S.of(context).cancel,
|
|
alertBarrierDismissible: false,
|
|
buttonAction: () => Navigator.of(context).pop(),
|
|
),
|
|
);
|
|
bool tryOpening = true;
|
|
while (tryOpening) {
|
|
try {
|
|
await loadCurrentWallet();
|
|
tryOpening = false;
|
|
} on Exception catch (e) {
|
|
final ledgerErrorMessage = ledgerVM.interpretErrorCode(e.toString());
|
|
if (ledgerErrorMessage != null) {
|
|
await showPopUp<void>(
|
|
context: context,
|
|
builder: (context) => AlertWithTwoActions(
|
|
alertTitle: "Ledger Error",
|
|
alertContent: ledgerErrorMessage,
|
|
leftButtonText: S.of(context).try_again,
|
|
alertBarrierDismissible: false,
|
|
actionLeftButton: () => Navigator.of(context).pop(),
|
|
rightButtonText: S.of(context).cancel,
|
|
actionRightButton: () {
|
|
tryOpening = false;
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
tryOpening = false;
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|
|
|
|
getIt.get<BottomSheetService>().showNext();
|
|
await navigatorKey.currentState!
|
|
.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
|
},
|
|
allowChangeWallet: true,
|
|
),
|
|
);
|
|
|
|
// await navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.connectDevices, (route) => false, arguments: ConnectDevicePageParams(walletType: walletType, onConnectDevice: onConnectDevice));
|
|
} else {
|
|
navigatorKey.currentState!.pushNamedAndRemoveUntil(Routes.dashboard, (route) => false);
|
|
}
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
final linkViewModel = getIt.get<LinkViewModel>();
|
|
linkViewModel.markReadyToOpenPage();
|
|
});
|
|
|
|
if (!(await authenticatedErrorStreamController.stream.isEmpty)) {
|
|
await ExceptionHandler.showError(
|
|
(await authenticatedErrorStreamController.stream.first).toString());
|
|
authenticatedErrorStreamController.stream.drain();
|
|
}
|
|
}
|
|
});
|
|
}
|