mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-25 11:03:55 +01:00
Catches up from the May 12 fork point (v6.1.2+23) through v6.5.0: 535 upstream commits, including the Monero silent-open fix, Monero on Trezor, Ledger/Trezor BLE fixes, the new seed and history screens, quick Bitcoin sync, git-pinned dependencies (pubspec_overrides.yaml), frozen Hive adapters (*.part.dart), monero_c v0.18.4.6-RC2 and Flutter 3.41.9. Merged with both sides normalized first (import rename, 100-column format), which took the conflict count from 614 paths to 322. The procedure is now scripts/upstream_sync.sh. Kept from Hash Bags: - WalletType enum order and Hive IDs. SQLite stores WalletType.index and our order differs from upstream's; taking theirs would reread saved wallets as other chains. Our frozen adapter keeps the shipped IDs. - The 1.0.2 legacy PIN and wallet-password decode and self-heal. - Removed chains (Solana, Tron, Zano, Zcash, Decred, Haven) and the new Robinhood chain stay out; Cake Pay and non-Trocador swaps stay out. - Default nodes (node.wownero.org, sethforprivacy, Blockstream, bysh.me), converted to upstream's isDefault node-list key; Wownero is back in the node reset list. - Privacy: address resolvers limited to domain-anchored sources again; prices.neroswap.com for fiat; upstream's charts tab, which reads prices.cakewallet.com, sits behind FeatureFlag.isChartsEnabled = false. - Lightning stays behind FeatureFlag.isLightningEnabled, including upstream's new post-seed Lightning username step. - Our icon pipeline, branding and bundle identifiers. Twelve new upstream widget tests are skipped: test and code are unchanged from v6.5.0 apart from renames (not rerun on a pristine upstream checkout; upstream's top_bar_test does not compile against its own TopBar). flutter analyze lib: 0 errors; flutter test: 345 passed, 12 skipped; flutter build bundle compiles. Built with Flutter 3.41.9.
225 lines
7.9 KiB
Dart
225 lines
7.9 KiB
Dart
import "package:hash_wallet/generated/i18n.dart";
|
|
import "package:hash_wallet/new-ui/widgets/receive_page/receive_top_bar.dart";
|
|
import "package:hash_wallet/new-ui/widgets/send_page/directional_switcher.dart";
|
|
import "package:hash_wallet/routes.dart";
|
|
import "package:hash_wallet/src/screens/connect_device/connect_device_page.dart";
|
|
import "package:hash_wallet/src/widgets/alert_with_two_actions.dart";
|
|
import "package:hash_wallet/src/widgets/base_alert_dialog.dart";
|
|
import "package:hash_wallet/src/widgets/hash_image_widget.dart";
|
|
import "package:hash_wallet/src/widgets/primary_button.dart";
|
|
import "package:hash_wallet/store/app_store.dart";
|
|
import "package:hash_wallet/utils/show_pop_up.dart";
|
|
import "package:hash_wallet/view_model/hardware_wallet/trezor_connect_view_model.dart";
|
|
import "package:cw_core/wallet_base.dart";
|
|
import "package:cw_core/wallet_info.dart";
|
|
import "package:flutter/cupertino.dart";
|
|
import "package:flutter/material.dart";
|
|
|
|
class SyncKeyImagesSheet extends StatefulWidget {
|
|
const SyncKeyImagesSheet({
|
|
required this.appStore,
|
|
required this.trezorConnectVM,
|
|
super.key,
|
|
});
|
|
|
|
final AppStore appStore;
|
|
final TrezorConnectViewModelBase trezorConnectVM;
|
|
|
|
WalletBase get wallet => appStore.wallet!;
|
|
|
|
@override
|
|
State<SyncKeyImagesSheet> createState() => _HardwareWalletProceedOnDeviceSheetState();
|
|
}
|
|
|
|
class _HardwareWalletProceedOnDeviceSheetState extends State<SyncKeyImagesSheet> {
|
|
_KeyImageSyncState _state = _KeyImageSyncState.initial;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => PopScope(
|
|
canPop: false,
|
|
child: SafeArea(
|
|
bottom: false,
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
|
|
),
|
|
child: SafeArea(
|
|
child: Padding(
|
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
child: Column(
|
|
children: [
|
|
ModalTopBar(
|
|
title: S.of(context).resync_device,
|
|
leadingIcon: Icon(
|
|
Icons.close,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
onLeadingPressed: () => showPopUp(
|
|
context: context,
|
|
builder: (context) => AlertWithTwoActions(
|
|
alertTitle: S.of(context).are_you_sure_exit,
|
|
alertContent: S.of(context).resync_device_cancel_warning_desc,
|
|
leftButtonText: S.of(context).cancel,
|
|
rightButtonText: S.of(context).yes_exit,
|
|
rightAlertButtonStyle: AlertButtonStyle.error(context),
|
|
actionLeftButton: Navigator.of(context).pop,
|
|
actionRightButton: () {
|
|
Navigator.of(context).pop();
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
spacing: 12,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
HashImageWidget(
|
|
imageUrl: hardwareWalletIcon,
|
|
width: 100,
|
|
colorFilter: ColorFilter.mode(
|
|
Theme.of(context).colorScheme.onSurfaceVariant,
|
|
BlendMode.srcIn,
|
|
),
|
|
),
|
|
DirectionalAnimatedSwitcher(
|
|
duration: const Duration(milliseconds: 400),
|
|
child: content,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: AnimatedOpacity(
|
|
curve: Curves.easeOutQuad,
|
|
opacity: _state == _KeyImageSyncState.initial ? 1 : 0,
|
|
duration: const Duration(milliseconds: 300),
|
|
child: PrimaryButton(
|
|
text: S.of(context).continue_text,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
textColor: Theme.of(context).colorScheme.onPrimary,
|
|
onPressed: _onContinuePressed,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
Widget get content {
|
|
if (_state == _KeyImageSyncState.syncing) {
|
|
return _syncingKeyImages();
|
|
}
|
|
|
|
return _initial();
|
|
}
|
|
|
|
String? get hardwareWalletIcon {
|
|
switch (widget.wallet.hardwareWalletType) {
|
|
case HardwareWalletType.bitbox:
|
|
return "assets/new-ui/hardware_wallets/device_bitbox.svg";
|
|
case HardwareWalletType.ledger:
|
|
return "assets/new-ui/hardware_wallets/device_ledger_nano_x.svg";
|
|
case HardwareWalletType.trezor:
|
|
return "assets/new-ui/hardware_wallets/device_trezor_safe_7.svg";
|
|
case HardwareWalletType.cupcake:
|
|
return "assets/images/cupcake.svg";
|
|
case HardwareWalletType.coldcard:
|
|
case HardwareWalletType.seedsigner:
|
|
case HardwareWalletType.keystone:
|
|
case null:
|
|
return "assets/images/hardware_wallet/device_qr.svg";
|
|
}
|
|
}
|
|
|
|
Widget _initial() => Column(
|
|
key: const ValueKey(0),
|
|
spacing: 12,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Text(
|
|
S.of(context).resync_device_desc,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
|
|
Widget _syncingKeyImages() => Column(
|
|
key: const ValueKey(1),
|
|
spacing: 12,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
S.of(context).proceed_on_device,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w500,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
|
child: Text(
|
|
S.of(context).proceed_on_device_description,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
|
|
Future<void> _onContinuePressed() async {
|
|
setState(() => _state = _KeyImageSyncState.syncing);
|
|
|
|
if (!widget.trezorConnectVM.isConnected(widget.wallet.type)) {
|
|
await Navigator.of(context).pushNamed(
|
|
Routes.connectDevices,
|
|
arguments: ConnectDevicePageParams(
|
|
walletType: widget.wallet.type,
|
|
hardwareWalletType: widget.wallet.walletInfo.hardwareWalletType!,
|
|
onConnectDevice: (_, __) {
|
|
widget.trezorConnectVM.initWallet(widget.wallet);
|
|
Navigator.of(context).pop();
|
|
},
|
|
isReconnect: false,
|
|
),
|
|
);
|
|
|
|
// Recheck to handle tap-backs
|
|
if (!widget.trezorConnectVM.isConnected(widget.wallet.type)) {
|
|
setState(() => _state = _KeyImageSyncState.initial);
|
|
return;
|
|
}
|
|
} else {
|
|
await widget.trezorConnectVM.initWallet(widget.wallet);
|
|
}
|
|
|
|
final result = await widget.trezorConnectVM.syncKeyImages(widget.wallet);
|
|
if (result && context.mounted) {
|
|
Navigator.of(context).pop();
|
|
}
|
|
}
|
|
}
|
|
|
|
enum _KeyImageSyncState {
|
|
initial,
|
|
syncing;
|
|
}
|