Cw linux direct input password build changes (#1091)

* chore: build changes

* refactor: better solution to `nice()` problem

* fix: errors trying to open documents file

* fix: haven wallet class

* chore: use forked device_display_brightness
This commit is contained in:
Rafael Saes 2023-09-22 11:50:51 -03:00 committed by GitHub
parent 9c0d0955a7
commit 5827a8977c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 49 additions and 39 deletions

View file

@ -75,7 +75,6 @@ android {
shrinkResources false shrinkResources false
minifyEnabled false minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }

View file

@ -1,12 +1,12 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.21' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.3' classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.gms:google-services:4.3.8' classpath 'com.google.gms:google-services:4.3.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }

View file

@ -3,24 +3,24 @@ import 'package:path_provider/path_provider.dart';
String? _rootDirPath; String? _rootDirPath;
void setRootDirFromEnv() void setRootDirFromEnv() => _rootDirPath = Platform.environment['CAKE_WALLET_DIR'];
=> _rootDirPath = Platform.environment['CAKE_WALLET_DIR'];
Future<Directory> getAppDir({String appName = 'cake_wallet'}) async { Future<Directory> getAppDir({String appName = 'cake_wallet'}) async {
Directory dir; Directory dir;
if (_rootDirPath != null && _rootDirPath!.isNotEmpty) { if (_rootDirPath != null && _rootDirPath!.isNotEmpty) {
dir = Directory.fromUri(Uri.file(_rootDirPath!)); dir = Directory.fromUri(Uri.file(_rootDirPath!));
dir.create(recursive: true); dir.create(recursive: true);
} else { } else {
dir = await getApplicationDocumentsDirectory(); if (Platform.isLinux) {
final appDirPath = '/home/${Platform.environment['USER']}/.$appName';
dir = Directory.fromUri(Uri.file(appDirPath));
await dir.create(recursive: true);
} else {
dir = await getApplicationDocumentsDirectory();
}
}
if (Platform.isLinux) { return dir;
final appDirPath = '${dir.path}/$appName'; }
dir = Directory.fromUri(Uri.file(appDirPath));
await dir.create(recursive: true);
}
}
return dir;
}

View file

@ -2,14 +2,14 @@ group 'com.cakewallet.cw_haven'
version '1.0-SNAPSHOT' version '1.0-SNAPSHOT'
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

View file

@ -38,9 +38,10 @@ class HavenWallet = HavenWalletBase with _$HavenWallet;
abstract class HavenWalletBase abstract class HavenWalletBase
extends WalletBase<MoneroBalance, HavenTransactionHistory, HavenTransactionInfo> with Store { extends WalletBase<MoneroBalance, HavenTransactionHistory, HavenTransactionInfo> with Store {
HavenWalletBase({required WalletInfo walletInfo}) HavenWalletBase({required WalletInfo walletInfo, String? password})
: balance = ObservableMap.of(getHavenBalance(accountIndex: 0)), : balance = ObservableMap.of(getHavenBalance(accountIndex: 0)),
_isTransactionUpdating = false, _isTransactionUpdating = false,
_password = password ?? '',
_hasSyncAfterStartup = false, _hasSyncAfterStartup = false,
walletAddresses = HavenWalletAddresses(walletInfo), walletAddresses = HavenWalletAddresses(walletInfo),
syncStatus = NotConnectedSyncStatus(), syncStatus = NotConnectedSyncStatus(),
@ -56,6 +57,7 @@ abstract class HavenWalletBase
} }
static const int _autoSaveInterval = 30; static const int _autoSaveInterval = 30;
final String _password;
@override @override
HavenWalletAddresses walletAddresses; HavenWalletAddresses walletAddresses;
@ -111,7 +113,7 @@ abstract class HavenWalletBase
_onAccountChangeReaction?.reaction.dispose(); _onAccountChangeReaction?.reaction.dispose();
_autoSaveTimer?.cancel(); _autoSaveTimer?.cancel();
} }
@override @override
Future<void> connectToNode({required Node node}) async { Future<void> connectToNode({required Node node}) async {
try { try {
@ -414,4 +416,7 @@ abstract class HavenWalletBase
print(e.toString()); print(e.toString());
} }
} }
@override
String get password => _password;
} }

View file

@ -2,14 +2,14 @@ group 'com.cakewallet.monero'
version '1.0-SNAPSHOT' version '1.0-SNAPSHOT'
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.4' classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

View file

@ -388,7 +388,7 @@ extern "C"
FUNCTION_VISABILITY_ATTRIBUTE FUNCTION_VISABILITY_ATTRIBUTE
bool load_wallet(char *path, char *password, int32_t nettype) bool load_wallet(char *path, char *password, int32_t nettype)
{ {
nice(19); (void) nice(19);
Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype); Monero::NetworkType networkType = static_cast<Monero::NetworkType>(nettype);
Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager(); Monero::WalletManager *walletManager = Monero::WalletManagerFactory::getWalletManager();
Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType); Monero::Wallet *wallet = walletManager->openWallet(std::string(path), std::string(password), networkType);
@ -488,7 +488,7 @@ extern "C"
FUNCTION_VISABILITY_ATTRIBUTE FUNCTION_VISABILITY_ATTRIBUTE
bool connect_to_node(char *error) bool connect_to_node(char *error)
{ {
nice(19); (void) nice(19);
bool is_connected = get_current_wallet()->connectToDaemon(); bool is_connected = get_current_wallet()->connectToDaemon();
if (!is_connected) if (!is_connected)
@ -502,7 +502,7 @@ extern "C"
FUNCTION_VISABILITY_ATTRIBUTE FUNCTION_VISABILITY_ATTRIBUTE
bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *socksProxyAddress, char *error) bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *socksProxyAddress, char *error)
{ {
nice(19); (void) nice(19);
Monero::Wallet *wallet = get_current_wallet(); Monero::Wallet *wallet = get_current_wallet();
std::string _login = ""; std::string _login = "";
@ -592,7 +592,7 @@ extern "C"
char **preferred_inputs, uint32_t preferred_inputs_size, char **preferred_inputs, uint32_t preferred_inputs_size,
Utf8Box &error, PendingTransactionRaw &pendingTransaction) Utf8Box &error, PendingTransactionRaw &pendingTransaction)
{ {
nice(19); (void) nice(19);
std::set<std::string> _preferred_inputs; std::set<std::string> _preferred_inputs;
@ -642,7 +642,7 @@ extern "C"
char **preferred_inputs, uint32_t preferred_inputs_size, char **preferred_inputs, uint32_t preferred_inputs_size,
Utf8Box &error, PendingTransactionRaw &pendingTransaction) Utf8Box &error, PendingTransactionRaw &pendingTransaction)
{ {
nice(19); (void) nice(19);
std::vector<std::string> _addresses; std::vector<std::string> _addresses;
std::vector<uint64_t> _amounts; std::vector<uint64_t> _amounts;

View file

@ -2,14 +2,14 @@ group 'com.cakewallet.cw_shared_external'
version '1.0-SNAPSHOT' version '1.0-SNAPSHOT'
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

View file

@ -4,6 +4,7 @@ import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/pathForWallet.dart';
import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cw_core/root_dir.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -181,7 +182,7 @@ Future<void> defaultSettingsMigration(
} }
Future<void> _validateWalletInfoBoxData(Box<WalletInfo> walletInfoSource) async { Future<void> _validateWalletInfoBoxData(Box<WalletInfo> walletInfoSource) async {
final root = await getApplicationDocumentsDirectory(); final root = await getAppDir();
for (var type in WalletType.values) { for (var type in WalletType.values) {
if (type == WalletType.none) { if (type == WalletType.none) {

View file

@ -6,7 +6,7 @@ import 'package:cake_wallet/.secrets.g.dart' as secrets;
import 'package:cake_wallet/ionia/ionia_api.dart'; import 'package:cake_wallet/ionia/ionia_api.dart';
import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_gift_card.dart';
import 'package:cake_wallet/ionia/ionia_category.dart'; import 'package:cake_wallet/ionia/ionia_category.dart';
import 'package:platform_device_id/platform_device_id.dart'; // import 'package:platform_device_id/platform_device_id.dart';
class IoniaService { class IoniaService {
IoniaService(this.secureStorage, this.ioniaApi); IoniaService(this.secureStorage, this.ioniaApi);
@ -112,9 +112,11 @@ class IoniaService {
required String currency}) async { required String currency}) async {
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!; final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!; final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
final deviceId = await PlatformDeviceId.getDeviceId; // TODO: deprecated
// final deviceId = await PlatformDeviceId.getDeviceId;
final deviceId = '';
return ioniaApi.purchaseGiftCard( return ioniaApi.purchaseGiftCard(
requestedUUID: deviceId!, requestedUUID: deviceId,
merchId: merchId, merchId: merchId,
amount: amount, amount: amount,
currency: currency, currency: currency,
@ -169,4 +171,4 @@ class IoniaService {
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!; final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
return ioniaApi.getPaymentStatus(username: username, password: password, clientId: clientId, orderId: orderId, paymentId: paymentId); return ioniaApi.getPaymentStatus(username: username, password: password, clientId: clientId, orderId: orderId, paymentId: paymentId);
} }
} }

View file

@ -57,9 +57,12 @@ dependencies:
unorm_dart: ^0.2.0 unorm_dart: ^0.2.0
# check unorm_dart for usage and for replace # check unorm_dart for usage and for replace
permission_handler: ^10.0.0 permission_handler: ^10.0.0
device_display_brightness: ^0.0.6 device_display_brightness:
git:
url: https://github.com/cake-tech/device_display_brightness.git
ref: master
workmanager: ^0.5.1 workmanager: ^0.5.1
platform_device_id: ^1.0.1 # platform_device_id: ^1.0.1
wakelock_plus: ^1.1.1 wakelock_plus: ^1.1.1
flutter_mailer: ^2.0.2 flutter_mailer: ^2.0.2
device_info_plus: 8.1.0 device_info_plus: 8.1.0