Fix conflicts with main

This commit is contained in:
OmarHatem 2023-09-07 22:52:03 +03:00
parent bdb3ec2048
commit 665770c733
12 changed files with 197 additions and 172 deletions

View file

@ -17,7 +17,7 @@ class BitcoinWalletService extends WalletService<
BitcoinNewWalletCredentials,
BitcoinRestoreWalletFromSeedCredentials,
BitcoinRestoreWalletFromWIFCredentials> {
BitcoinWalletService(this.walletInfoSource, this.unspentCoinsInfoSource);
BitcoinWalletService(this.walletInfoSource, this.unspentCoinsInfoSource, this.isDirect);
final Box<WalletInfo> walletInfoSource;
final Box<UnspentCoinsInfo> unspentCoinsInfoSource;
@ -74,7 +74,8 @@ class BitcoinWalletService extends WalletService<
password: password,
name: currentName,
walletInfo: currentWalletInfo,
unspentCoinsInfo: unspentCoinsInfoSource);
unspentCoinsInfo: unspentCoinsInfoSource,
encryptionFileUtils: encryptionFileUtilsFor(isDirect));
await currentWallet.renameWalletFiles(newName);

View file

@ -26,7 +26,6 @@ import 'package:cw_ethereum/ethereum_transaction_info.dart';
import 'package:cw_ethereum/ethereum_transaction_model.dart';
import 'package:cw_ethereum/ethereum_transaction_priority.dart';
import 'package:cw_ethereum/ethereum_wallet_addresses.dart';
import 'package:cw_ethereum/file.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:hive/hive.dart';
import 'package:hex/hex.dart';

View file

@ -7,26 +7,24 @@ import 'package:cw_core/wallet_type.dart';
import 'package:shared_preferences/shared_preferences.dart';
class WalletLoadingService {
WalletLoadingService(
this.sharedPreferences, this.keyService, this.walletServiceFactory);
WalletLoadingService(this.sharedPreferences, this.keyService, this.walletServiceFactory);
final SharedPreferences sharedPreferences;
final KeyService keyService;
final WalletService Function(WalletType type) walletServiceFactory;
Future<void> renameWallet(
WalletType type, String name, String newName) async {
Future<void> renameWallet(WalletType type, String name, String newName,
{String? password}) async {
final walletService = walletServiceFactory.call(type);
final password = await keyService.getWalletPassword(walletName: name);
final walletPassword = password ?? (await keyService.getWalletPassword(walletName: name));
// Save the current wallet's password to the new wallet name's key
await keyService.saveWalletPassword(
walletName: newName, password: password);
await keyService.saveWalletPassword(walletName: newName, password: walletPassword);
// Delete previous wallet name from keyService to keep only new wallet's name
// otherwise keeps duplicate (old and new names)
await keyService.deleteWalletPassword(walletName: name);
await walletService.rename(name, password, newName);
await walletService.rename(name, walletPassword, newName);
// set shared preferences flag based on previous wallet name
if (type == WalletType.monero) {
@ -37,10 +35,10 @@ class WalletLoadingService {
}
}
Future<WalletBase> load(WalletType type, String name) async {
Future<WalletBase> load(WalletType type, String name, {String? password}) async {
final walletService = walletServiceFactory.call(type);
final password = await keyService.getWalletPassword(walletName: name);
final wallet = await walletService.openWallet(name, password);
final walletPassword = password ?? (await keyService.getWalletPassword(walletName: name));
final wallet = await walletService.openWallet(name, walletPassword);
if (type == WalletType.monero) {
await updateMoneroWalletPassword(wallet);
@ -61,11 +59,9 @@ class WalletLoadingService {
// Save new generated password with backup key for case where
// wallet will change password, but it will fail to update in secure storage
final bakWalletName = '#__${wallet.name}_bak__#';
await keyService.saveWalletPassword(
walletName: bakWalletName, password: password);
await keyService.saveWalletPassword(walletName: bakWalletName, password: password);
await wallet.changePassword(password);
await keyService.saveWalletPassword(
walletName: wallet.name, password: password);
await keyService.saveWalletPassword(walletName: wallet.name, password: password);
isPasswordUpdated = true;
await sharedPreferences.setBool(key, isPasswordUpdated);
}

View file

@ -195,8 +195,6 @@ import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/view_model/wallet_restoration_from_seed_vm.dart';
import 'package:cake_wallet/view_model/wallet_restoration_from_keys_vm.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:cake_wallet/core/wallet_creation_service.dart';
import 'package:cake_wallet/store/app_store.dart';

View file

@ -7,7 +7,7 @@ import 'package:cw_core/wallet_base.dart';
import 'package:cw_core/balance.dart';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/sync_status.dart';
import 'package:wakelock/wakelock.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
ReactionDisposer? _onWalletSyncStatusChangeReaction;
@ -27,10 +27,10 @@ void startWalletSyncStatusChangeReaction(
}
}
if (status is SyncingSyncStatus) {
await Wakelock.enable();
await WakelockPlus.enable();
}
if (status is SyncedSyncStatus || status is FailedSyncStatus) {
await Wakelock.disable();
await WakelockPlus.disable();
}
} catch(e) {
print(e.toString());

View file

@ -54,7 +54,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
_languageSelectorKey = GlobalKey<SeedLanguageSelectorState>(),
_nameController = TextEditingController(),
_passwordController = _walletNewVM.hasWalletPassword ? TextEditingController() : null,
_repeatedPasswordController = _walletNewVM.hasWalletPassword ? TextEditingController() : null;
_repeatedPasswordController =
_walletNewVM.hasWalletPassword ? TextEditingController() : null;
static const aspectRatioImage = 1.22;
@ -128,15 +129,20 @@ class _WalletNameFormState extends State<WalletNameForm> {
hintStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<NewWalletTheme>()!.hintTextColor),
color:
Theme.of(context).extension<NewWalletTheme>()!.hintTextColor),
hintText: S.of(context).wallet_name,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).extension<NewWalletTheme>()!.underlineColor,
color: Theme.of(context)
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context).extension<NewWalletTheme>()!.underlineColor,
color: Theme.of(context)
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0),
),
suffixIcon: Semantics(
@ -163,7 +169,9 @@ class _WalletNameFormState extends State<WalletNameForm> {
height: 34,
child: Image.asset(
'assets/images/refresh_icon.png',
color: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonIconColor,
color: Theme.of(context)
.extension<SendPageTheme>()!
.textFieldButtonIconColor,
),
),
),
@ -171,8 +179,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
),
validator: WalletNameValidator(),
),
if (_walletNewVM.hasWalletPassword)
...[TextFormField(
if (_walletNewVM.hasWalletPassword) ...[
TextFormField(
onChanged: (value) => _walletNewVM.walletPassword = value,
controller: _passwordController,
textAlign: TextAlign.center,
@ -180,29 +188,33 @@ class _WalletNameFormState extends State<WalletNameForm> {
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
decoration: InputDecoration(
hintStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme!.headline2!.color!),
color:
Theme.of(context).extension<NewWalletTheme>()!.hintTextColor,
),
hintText: S.of(context).password,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0)),
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0,
),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0),
)
)
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0,
),
),
),
),
TextFormField(
onChanged: (value) => _walletNewVM.repeatedWalletPassword = value,
@ -212,30 +224,35 @@ class _WalletNameFormState extends State<WalletNameForm> {
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme!.headline6!.color!),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
decoration: InputDecoration(
hintStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme!.headline2!.color!),
color:
Theme.of(context).extension<NewWalletTheme>()!.hintTextColor,
),
hintText: S.of(context).repeate_wallet_password,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0)),
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0,
),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme!
.headline2!
.decorationColor!,
width: 1.0),
)
)
)],
.extension<NewWalletTheme>()!
.underlineColor,
width: 1.0,
),
),
),
),
],
],
),
),

View file

@ -4,6 +4,8 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
import 'package:cake_wallet/src/screens/wallet_unlock/wallet_unlock_arguments.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:flutter/cupertino.dart';
@ -12,12 +14,9 @@ import 'package:cake_wallet/view_model/wallet_unlock_view_model.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
class WalletUnlockPage extends StatefulWidget {
WalletUnlockPage(
this.walletUnlockViewModel,
this.onAuthenticationFinished,
this.authPasswordHandler,
this.walletUnlockViewModel, this.onAuthenticationFinished, this.authPasswordHandler,
{required this.closable});
final WalletUnlockViewModel walletUnlockViewModel;
@ -30,13 +29,11 @@ class WalletUnlockPage extends StatefulWidget {
}
class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
WalletUnlockPageState()
: _passwordController = TextEditingController();
WalletUnlockPageState() : _passwordController = TextEditingController();
final TextEditingController _passwordController;
final _key = GlobalKey<ScaffoldState>();
final _backArrowImageDarkTheme =
Image.asset('assets/images/close_button.png');
final _backArrowImageDarkTheme = Image.asset('assets/images/close_button.png');
ReactionDisposer? _reaction;
Flushbar<void>? _authBar;
Flushbar<void>? _progressBar;
@ -44,8 +41,7 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
@override
void initState() {
_reaction ??=
reaction((_) => widget.walletUnlockViewModel.state, (ExecutionState state) {
_reaction ??= reaction((_) => widget.walletUnlockViewModel.state, (ExecutionState state) {
if (state is ExecutedSuccessfullyState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.onAuthenticationFinished(true, this);
@ -56,24 +52,22 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
if (state is IsExecutingState) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// null duration to make it indefinite until its disposed
_authBar =
createBar<void>(S.of(context).authentication, duration: null)
..show(context);
_authBar = createBar<void>(S.of(context).authentication, duration: null)..show(context);
});
}
if (state is FailureState) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
dismissFlushBar(_authBar);
showBar<void>(
context, S.of(context).failed_authentication(state.error));
showBar<void>(context, S.of(context).failed_authentication(state.error));
widget.onAuthenticationFinished(false, this);
});
}
});
_passwordControllerListener = () => widget.walletUnlockViewModel.setPassword(_passwordController.text);
_passwordControllerListener =
() => widget.walletUnlockViewModel.setPassword(_passwordController.text);
if (_passwordControllerListener != null) {
_passwordController.addListener(_passwordControllerListener!);
@ -96,8 +90,7 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
@override
void changeProcessText(String text) {
dismissFlushBar(_authBar);
_progressBar = createBar<void>(text, duration: null)
..show(_key.currentContext!);
_progressBar = createBar<void>(text, duration: null)..show(_key.currentContext!);
}
@override
@ -153,21 +146,27 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
resizeToAvoidBottomInset: false,
body: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint),
constraints: BoxConstraints(
maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: Column(
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(widget.walletUnlockViewModel.walletName,
Text(
widget.walletUnlockViewModel.walletName,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme.titleLarge!.color!)),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
),
SizedBox(height: 24),
Form(
child: TextFormField(
@ -178,39 +177,42 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryTextTheme.titleLarge!.color!),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
decoration: InputDecoration(
hintStyle: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.displayMedium!.color!),
color: Theme.of(context).extension<NewWalletTheme>()!.hintTextColor,
),
hintText: S.of(context).enter_wallet_password,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme
.displayMedium!
.decorationColor!,
width: 1.0)),
color: Theme.of(context).extension<NewWalletTheme>()!.underlineColor,
width: 1.0,
),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Theme.of(context)
.accentTextTheme
.displayMedium!
.decorationColor!,
width: 1.0),
)
)))])),
color: Theme.of(context).extension<NewWalletTheme>()!.underlineColor,
width: 1.0,
),
),
),
),
),
],
),
),
Padding(
padding: EdgeInsets.only(bottom: 24),
child: Observer(
builder: (_) =>
LoadingPrimaryButton(
builder: (_) => LoadingPrimaryButton(
onPressed: () async {
if (widget.authPasswordHandler != null) {
try {
await widget.authPasswordHandler!(widget
.walletUnlockViewModel.password);
await widget
.authPasswordHandler!(widget.walletUnlockViewModel.password);
widget.walletUnlockViewModel.success();
} catch (e) {
widget.walletUnlockViewModel.failure(e);
@ -224,8 +226,13 @@ class WalletUnlockPageState extends AuthPageState<WalletUnlockPage> {
color: Colors.green,
textColor: Colors.white,
isLoading: widget.walletUnlockViewModel.state is IsExecutingState,
isDisabled: widget.walletUnlockViewModel.state is IsExecutingState)))
]))
));
isDisabled: widget.walletUnlockViewModel.state is IsExecutingState),
),
),
],
),
),
),
);
}
}

View file

@ -8,6 +8,7 @@
#include <cw_monero/cw_monero_plugin.h>
#include <devicelocale/devicelocale_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <platform_device_id_linux/platform_device_id_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
@ -18,6 +19,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) devicelocale_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DevicelocalePlugin");
devicelocale_plugin_register_with_registrar(devicelocale_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) platform_device_id_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PlatformDeviceIdLinuxPlugin");
platform_device_id_linux_plugin_register_with_registrar(platform_device_id_linux_registrar);

View file

@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
cw_monero
devicelocale
flutter_secure_storage_linux
platform_device_id_linux
url_launcher_linux
)

View file

@ -9,6 +9,7 @@ import connectivity_plus_macos
import cw_monero
import device_info_plus
import devicelocale
import flutter_secure_storage_macos
import in_app_review
import package_info_plus
import path_provider_foundation
@ -17,13 +18,14 @@ import platform_device_id_macos
import share_plus_macos
import shared_preferences_foundation
import url_launcher_macos
import wakelock_macos
import wakelock_plus
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
CwMoneroPlugin.register(with: registry.registrar(forPlugin: "CwMoneroPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
@ -32,5 +34,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
}

View file

@ -29,7 +29,7 @@ dependencies:
hive_flutter: ^1.1.0
local_auth: ^2.1.0
local_auth_android: 1.0.21
package_info_plus: ^3.1.0
package_info_plus: ^4.1.0
devicelocale:
git:
url: https://github.com/cake-tech/flutter-devicelocale
@ -60,7 +60,7 @@ dependencies:
device_display_brightness: ^0.0.6
workmanager: ^0.5.1
platform_device_id: ^1.0.1
wakelock: ^0.6.2
wakelock_plus: ^1.1.1
flutter_mailer: ^2.0.2
device_info_plus: 8.1.0
base32: 2.1.3

View file

@ -20,8 +20,8 @@ Future<void> main(List<String> args) async {
await generateMonero(hasMonero);
await generateHaven(hasHaven);
await generateEthereum(hasEthereum);
await generatePubspec(hasMonero: hasMonero, hasBitcoin: hasBitcoin, hasHaven: hasHaven, hasFlutterSecureStorage: !excludeFlutterSecureStorage);
await generateWalletTypes(hasMonero: hasMonero, hasBitcoin: hasBitcoin, hasHaven: hasHaven);
await generatePubspec(hasMonero: hasMonero, hasBitcoin: hasBitcoin, hasHaven: hasHaven, hasEthereum: hasEthereum, hasFlutterSecureStorage: !excludeFlutterSecureStorage);
await generateWalletTypes(hasMonero: hasMonero, hasBitcoin: hasBitcoin, hasHaven: hasHaven, hasEthereum: hasEthereum);
await injectSecureStorage(!excludeFlutterSecureStorage);
}
@ -579,8 +579,8 @@ Future<void> generatePubspec({
git:
url: https://github.com/cake-tech/flutter_secure_storage.git
path: flutter_secure_storage
ref: cake-6.0.0
version: 6.0.0
ref: cake-8.0.0
version: 8.0.0
""";
const cwEthereum = """
cw_ethereum: