Merge remote-tracking branch 'origin/arti' into fusion

This commit is contained in:
sneurlax 2023-09-18 11:16:13 -05:00
commit ef43bc802d
10 changed files with 274 additions and 191 deletions

View file

@ -34,7 +34,9 @@ if (keystorePropertiesFile.exists()) {
android {
compileSdkVersion 33
ndkVersion = "21.1.6352462"
// ndkVersion = "21.1.6352462"
// ndkVersion = "25.2.9519653"
ndkVersion = "23.1.7779620"
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@ -49,7 +51,9 @@ android {
applicationId "com.cypherstack.stackwallet"
minSdkVersion 23
targetSdkVersion 33
ndkVersion = "21.1.6352462"
// ndkVersion = "21.1.6352462"
// ndkVersion = "25.2.9519653"
ndkVersion = "23.1.7779620"
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View file

@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

File diff suppressed because one or more lines are too long

View file

@ -75,7 +75,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const StackDialog(
return StackDialog(
title: "What is Tor?",
message:
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
@ -83,6 +83,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
" to obscure the origin and destination of data.",
rightButton: SecondaryButton(
label: "Close",
onPressed: Navigator.of(context).pop,
),
);
},
@ -144,7 +145,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const StackDialog(
return StackDialog(
title: "What is Tor killswitch?",
message:
"A security feature that protects your information from accidental exposure by"
@ -152,6 +153,8 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
" connection is disrupted or compromised.",
rightButton: SecondaryButton(
label: "Close",
onPressed:
Navigator.of(context).pop,
),
);
},
@ -243,54 +246,31 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
}
}
Color _color(
TorConnectionStatus status,
StackColors colors,
) {
switch (status) {
case TorConnectionStatus.disconnected:
return colors.textSubtitle3;
case TorConnectionStatus.connected:
return colors.accentColorGreen;
case TorConnectionStatus.connecting:
return colors.accentColorYellow;
}
}
String _label(
TorConnectionStatus status,
) {
switch (status) {
case TorConnectionStatus.disconnected:
return "CONNECT";
case TorConnectionStatus.connected:
return "STOP";
case TorConnectionStatus.connecting:
return "CONNECTING";
}
}
void _playConnecting() async {
Future<void> _playConnecting() async {
await _play(
from: "connection-start",
to: "connection-end",
from: "connecting-start",
to: "connecting-end",
repeat: true,
);
}
void _playConnected() async {
Future<void> _playConnectingDone() async {
await _play(
from: "connection-end",
to: "disconnection-start",
from: "connecting-end",
to: "connected-start",
repeat: false,
);
}
Future<void> _playConnected() async {
await _play(
from: "connected-start",
to: "connected-end",
repeat: true,
);
}
void _playDisconnect() async {
Future<void> _playDisconnect() async {
await _play(
from: "disconnection-start",
to: "disconnection-end",
@ -308,6 +288,8 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
final start = composition.getMarker(from)!.start;
final end = composition.getMarker(to)!.start;
controller1.value = start;
if (repeat) {
await controller1.repeat(
min: start,
@ -348,19 +330,20 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
final width = MediaQuery.of(context).size.width / 1.5;
return TorSubscription(
onTorStatusChanged: (status) {
onTorStatusChanged: (status) async {
_status = status;
switch (_status) {
case TorConnectionStatus.disconnected:
_playDisconnect();
await _playDisconnect();
break;
case TorConnectionStatus.connected:
_playConnected();
await _playConnectingDone();
await _playConnected();
break;
case TorConnectionStatus.connecting:
_playConnecting();
await _playConnecting();
break;
}
},
@ -381,21 +364,8 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
// height: width,
onLoaded: (composition) {
_completer.complete(composition);
// setState(() {
controller1.duration = composition.duration;
// TODO: clean up (waiting for updated onion lottie animation file)
// });
print(
"=======================================================");
composition.markers.forEach((e) {
print(e.name);
});
print(
"=======================================================");
//
if (_status == TorConnectionStatus.connected) {
_playConnected();
} else if (_status == TorConnectionStatus.connecting) {
@ -404,19 +374,7 @@ class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
},
),
),
Text(
_label(
_status,
),
style: STextStyles.pageTitleH2(
context,
).copyWith(
color: _color(
_status,
Theme.of(context).extension<StackColors>()!,
),
),
)
const UpperCaseTorText(),
],
),
),
@ -546,6 +504,78 @@ class _TorButtonState extends ConsumerState<TorButton> {
}
}
class UpperCaseTorText extends ConsumerStatefulWidget {
const UpperCaseTorText({super.key});
@override
ConsumerState<UpperCaseTorText> createState() => _UpperCaseTorTextState();
}
class _UpperCaseTorTextState extends ConsumerState<UpperCaseTorText> {
late TorConnectionStatus _status;
Color _color(
TorConnectionStatus status,
StackColors colors,
) {
switch (status) {
case TorConnectionStatus.disconnected:
return colors.textSubtitle3;
case TorConnectionStatus.connected:
return colors.accentColorGreen;
case TorConnectionStatus.connecting:
return colors.accentColorYellow;
}
}
String _label(
TorConnectionStatus status,
) {
switch (status) {
case TorConnectionStatus.disconnected:
return "CONNECT";
case TorConnectionStatus.connected:
return "STOP";
case TorConnectionStatus.connecting:
return "CONNECTING";
}
}
@override
void initState() {
_status = ref.read(pTorService).status;
super.initState();
}
@override
Widget build(BuildContext context) {
return TorSubscription(
onTorStatusChanged: (status) {
setState(() {
_status = status;
});
},
child: Text(
_label(
_status,
),
style: STextStyles.pageTitleH2(
context,
).copyWith(
color: _color(
_status,
Theme.of(context).extension<StackColors>()!,
),
),
));
}
}
/// Connect to the Tor network.
///
/// This method is called when the user taps the "Connect" button.

View file

@ -219,8 +219,21 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.end,
MainAxisAlignment
.spaceBetween,
children: [
Padding(
padding:
const EdgeInsets.only(
left: 32,
),
child: Text(
"What is Tor?",
style:
STextStyles.desktopH2(
context),
),
),
DesktopDialogCloseButton(
onPressedOverride: () =>
Navigator.of(context)
@ -229,20 +242,13 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
],
),
Padding(
padding: const EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"What is Tor?",
style:
STextStyles.desktopH2(
context),
padding: const EdgeInsets.only(
top: 12,
left: 32,
bottom: 32,
right: 32,
),
const SizedBox(
height: 20,
),
Text(
child: Text(
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
" to remain anonymous by routing internet traffic through a series of layered nodes,"
" to obscure the origin and destination of data.",
@ -251,13 +257,10 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
context)
.copyWith(
color: Theme.of(context)
.extension<
StackColors>()!
.extension<StackColors>()!
.textDark3,
),
),
],
),
),
],
),
@ -289,12 +292,11 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
children: [
Row(
children: [
RichText(
textAlign: TextAlign.start,
text: TextSpan(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextSpan(
text: "Tor killswitch",
Text(
"Tor killswitch",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
@ -302,8 +304,13 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
.extension<StackColors>()!
.textDark),
),
TextSpan(
text: "\nWhat is Tor killswitch?",
const SizedBox(
height: 8,
),
RichText(
textAlign: TextAlign.start,
text: TextSpan(
text: "What is Tor killswitch?",
style: STextStyles.richLink(context).copyWith(
fontSize: 14,
),
@ -321,8 +328,20 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.end,
MainAxisAlignment
.spaceBetween,
children: [
Padding(
padding:
const EdgeInsets.only(
left: 32,
),
child: Text(
"What is Tor killswitch?",
style: STextStyles
.desktopH2(context),
),
),
DesktopDialogCloseButton(
onPressedOverride: () =>
Navigator.of(context)
@ -332,20 +351,13 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
),
Padding(
padding:
const EdgeInsets.all(20),
child: Column(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
"What is Tor killswitch?",
style: STextStyles
.desktopH2(context),
const EdgeInsets.only(
top: 12,
left: 32,
bottom: 32,
right: 32,
),
const SizedBox(
height: 20,
),
Text(
child: Text(
"A security feature that protects your information from accidental exposure by"
" disconnecting your device from the Tor network if the"
" connection is disrupted or compromised.",
@ -353,15 +365,12 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
.desktopTextMedium(
context)
.copyWith(
color: Theme.of(
context)
color: Theme.of(context)
.extension<
StackColors>()!
.textDark3,
),
),
],
),
),
],
),
@ -370,8 +379,8 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
);
},
),
],
),
],
),
],
),

View file

@ -1662,9 +1662,11 @@ packages:
tor_ffi_plugin:
dependency: "direct main"
description:
path: "crypto_plugins/tor"
relative: true
source: path
path: "."
ref: "8a26a160bdc4dcac2ba5a0350a151a345d1dead9"
resolved-ref: "8a26a160bdc4dcac2ba5a0350a151a345d1dead9"
url: "https://github.com/cypherstack/tor.git"
source: git
version: "0.0.1"
tuple:
dependency: "direct main"

View file

@ -58,7 +58,9 @@ dependencies:
ref: 081ca1863c2feba00c35bb5b297902f12f499941
tor_ffi_plugin:
path: ./crypto_plugins/tor
git:
url: https://github.com/cypherstack/tor.git
ref: 8a26a160bdc4dcac2ba5a0350a151a345d1dead9
# Utility plugins
http: ^0.13.0

View file

@ -5,6 +5,7 @@ import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
import 'package:stackwallet/electrumx_rpc/rpc.dart';
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart';
import 'package:stackwallet/services/tor_service.dart';
import 'package:stackwallet/utilities/prefs.dart';
@ -1528,7 +1529,8 @@ void main() {
.thenAnswer((_) => false); // Or true, shouldn't matter.
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => false);
when(mockTorService.status)
.thenAnswer((_) => TorConnectionStatus.disconnected);
final client = ElectrumX(
host: "some server",
@ -1551,7 +1553,7 @@ void main() {
verify(mockPrefs.useTor).called(1);
verifyNever(mockPrefs.torKillSwitch);
verifyNoMoreInteractions(mockPrefs);
verifyNever(mockTorService.enabled);
verifyNever(mockTorService.status);
verifyNoMoreInteractions(mockTorService);
});
@ -1575,8 +1577,9 @@ void main() {
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => false);
when(mockTorService.proxyInfo).thenAnswer((_) => (
when(mockTorService.status)
.thenAnswer((_) => TorConnectionStatus.disconnected);
when(mockTorService.getProxyInfo()).thenAnswer((_) => (
host: InternetAddress('1.2.3.4'),
port: -1
)); // Port is set to -1 until Tor is enabled.
@ -1601,8 +1604,8 @@ void main() {
verify(mockPrefs.useTor).called(1);
verify(mockPrefs.torKillSwitch).called(1);
verifyNoMoreInteractions(mockPrefs);
verify(mockTorService.enabled).called(1);
verifyNever(mockTorService.proxyInfo);
verify(mockTorService.status).called(1);
verifyNever(mockTorService.getProxyInfo());
verifyNoMoreInteractions(mockTorService);
});
@ -1628,8 +1631,9 @@ void main() {
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => true);
when(mockTorService.proxyInfo)
when(mockTorService.status)
.thenAnswer((_) => TorConnectionStatus.connected);
when(mockTorService.getProxyInfo())
.thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42));
final client = ElectrumX(
@ -1653,8 +1657,8 @@ void main() {
verify(mockPrefs.useTor).called(1);
verifyNever(mockPrefs.torKillSwitch);
verifyNoMoreInteractions(mockPrefs);
verify(mockTorService.enabled).called(1);
verify(mockTorService.proxyInfo).called(1);
verify(mockTorService.status).called(1);
verify(mockTorService.getProxyInfo()).called(1);
verifyNoMoreInteractions(mockTorService);
});
@ -1685,7 +1689,8 @@ void main() {
when(mockPrefs.torKillSwitch).thenAnswer((_) => true);
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => false);
when(mockTorService.status)
.thenAnswer((_) => TorConnectionStatus.disconnected);
final client = ElectrumX(
host: "some server",
@ -1712,7 +1717,7 @@ void main() {
verify(mockPrefs.useTor).called(1);
verify(mockPrefs.torKillSwitch).called(1);
verifyNoMoreInteractions(mockPrefs);
verify(mockTorService.enabled).called(1);
verify(mockTorService.status).called(1);
verifyNoMoreInteractions(mockTorService);
});
@ -1740,7 +1745,8 @@ void main() {
when(mockPrefs.torKillSwitch).thenAnswer((_) => false);
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
final mockTorService = MockTorService();
when(mockTorService.enabled).thenAnswer((_) => false);
when(mockTorService.status)
.thenAnswer((_) => TorConnectionStatus.disconnected);
final client = ElectrumX(
host: "some server",
@ -1763,7 +1769,7 @@ void main() {
verify(mockPrefs.useTor).called(1);
verify(mockPrefs.torKillSwitch).called(1);
verifyNoMoreInteractions(mockPrefs);
verify(mockTorService.enabled).called(1);
verify(mockTorService.status).called(1);
verifyNoMoreInteractions(mockTorService);
});
});

View file

@ -9,13 +9,15 @@ import 'dart:ui' as _i10;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2;
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'
as _i12;
import 'package:stackwallet/services/tor_service.dart' as _i11;
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8;
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7;
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9;
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6;
import 'package:stackwallet/utilities/prefs.dart' as _i5;
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i12;
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i13;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@ -659,27 +661,40 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
}
@override
bool get enabled => (super.noSuchMethod(
Invocation.getter(#enabled),
returnValue: false,
) as bool);
_i12.TorConnectionStatus get status => (super.noSuchMethod(
Invocation.getter(#status),
returnValue: _i12.TorConnectionStatus.disconnected,
) as _i12.TorConnectionStatus);
@override
({_i3.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
Invocation.getter(#proxyInfo),
({_i3.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
Invocation.method(
#getProxyInfo,
[],
),
returnValue: (
host: _FakeInternetAddress_2(
this,
Invocation.getter(#proxyInfo),
Invocation.method(
#getProxyInfo,
[],
),
),
port: 0
),
) as ({_i3.InternetAddress host, int port}));
@override
void init({_i12.Tor? mockableOverride}) => super.noSuchMethod(
void init({
required String? torDataDirPath,
_i13.Tor? mockableOverride,
}) =>
super.noSuchMethod(
Invocation.method(
#init,
[],
{#mockableOverride: mockableOverride},
{
#torDataDirPath: torDataDirPath,
#mockableOverride: mockableOverride,
},
),
returnValueForMissingStub: null,
);
@ -695,7 +710,7 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
@override
_i4.Future<void> disable() => (super.noSuchMethod(
Invocation.method(
#stop,
#disable,
[],
),
returnValue: _i4.Future<void>.value(),

View file

@ -12,6 +12,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5;
import 'package:mockito/mockito.dart' as _i1;
import 'package:stackwallet/models/node_model.dart' as _i18;
import 'package:stackwallet/services/coins/manager.dart' as _i6;
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'
as _i20;
import 'package:stackwallet/services/node_service.dart' as _i3;
import 'package:stackwallet/services/tor_service.dart' as _i19;
import 'package:stackwallet/services/wallets.dart' as _i9;
@ -23,7 +25,7 @@ import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i15;
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
as _i7;
import 'package:stackwallet/utilities/prefs.dart' as _i13;
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i20;
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i21;
import 'package:tuple/tuple.dart' as _i11;
// ignore_for_file: type=lint
@ -1025,27 +1027,40 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
}
@override
bool get enabled => (super.noSuchMethod(
Invocation.getter(#enabled),
returnValue: false,
) as bool);
_i20.TorConnectionStatus get status => (super.noSuchMethod(
Invocation.getter(#status),
returnValue: _i20.TorConnectionStatus.disconnected,
) as _i20.TorConnectionStatus);
@override
({_i8.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
Invocation.getter(#proxyInfo),
({_i8.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
Invocation.method(
#getProxyInfo,
[],
),
returnValue: (
host: _FakeInternetAddress_5(
this,
Invocation.getter(#proxyInfo),
Invocation.method(
#getProxyInfo,
[],
),
),
port: 0
),
) as ({_i8.InternetAddress host, int port}));
@override
void init({_i20.Tor? mockableOverride}) => super.noSuchMethod(
void init({
required String? torDataDirPath,
_i21.Tor? mockableOverride,
}) =>
super.noSuchMethod(
Invocation.method(
#init,
[],
{#mockableOverride: mockableOverride},
{
#torDataDirPath: torDataDirPath,
#mockableOverride: mockableOverride,
},
),
returnValueForMissingStub: null,
);
@ -1061,7 +1076,7 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
@override
_i12.Future<void> disable() => (super.noSuchMethod(
Invocation.method(
#stop,
#disable,
[],
),
returnValue: _i12.Future<void>.value(),