mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-18 07:51:36 +02:00
qualified import of config
This commit is contained in:
@@ -19,14 +19,10 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'config/prototype.dart';
|
||||
import 'config/cyberwow.dart' as cryptoConfig;
|
||||
|
||||
final Logger log = new Logger('Default');
|
||||
|
||||
const config = cryptoConfig.config;
|
||||
const c = cryptoConfig.config;
|
||||
|
||||
const arch = 'arm64';
|
||||
// const arch = 'x86_64';
|
||||
|
||||
@@ -23,7 +23,8 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'rpc/rpc.dart' as rpc;
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
import '../logging.dart';
|
||||
|
||||
Future<bool> isConnected() async {
|
||||
final _outPeers = await rpc.outgoingConnectionsCount();
|
||||
@@ -37,7 +38,7 @@ Future<bool> isConnected() async {
|
||||
Future<bool> isSynced() async {
|
||||
final _targetHeight = await rpc.targetHeight();
|
||||
final _height = await rpc.height();
|
||||
return _targetHeight >= 0 && _targetHeight <= _height && _height > minimumHeight;
|
||||
return _targetHeight >= 0 && _targetHeight <= _height && _height > config.minimumHeight;
|
||||
}
|
||||
|
||||
Future<bool> isNotSynced() async {
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'dart:async';
|
||||
import 'rpc/rpc.dart' as rpc;
|
||||
|
||||
import '../config.dart';
|
||||
import '../logging.dart';
|
||||
|
||||
typedef GetNotificationFunc = AppLifecycleState Function();
|
||||
|
||||
|
||||
@@ -25,13 +25,14 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../config.dart';
|
||||
import '../../config.dart' as config;
|
||||
import '../../helper.dart';
|
||||
import '../../logging.dart';
|
||||
|
||||
int rpcID = 0;
|
||||
|
||||
Future<http.Response> rpcHTTP(String method) async {
|
||||
final url = 'http://${host}:${config.port}/json_rpc';
|
||||
final url = 'http://${config.host}:${config.c.port}/json_rpc';
|
||||
|
||||
rpcID += 1;
|
||||
|
||||
|
||||
@@ -25,11 +25,12 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../config.dart';
|
||||
import '../../config.dart' as config;
|
||||
import '../../helper.dart';
|
||||
import '../../logging.dart';
|
||||
|
||||
Future<http.Response> rpc2(String method) async {
|
||||
final url = 'http://${host}:${config.port}/${method}';
|
||||
final url = 'http://${config.host}:${config.c.port}/${method}';
|
||||
|
||||
var response;
|
||||
try {
|
||||
|
||||
@@ -27,14 +27,15 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'helper.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
import '../logging.dart';
|
||||
|
||||
Stream<String> runBinary (String name) async* {
|
||||
final newPath = await getBinaryPath(name);
|
||||
|
||||
final appDocDir = await getApplicationDocumentsDirectory();
|
||||
final appDocPath = appDocDir.path;
|
||||
final binDir = new Directory(appDocDir.path + "/" + config.appPath);
|
||||
final binDir = new Directory(appDocDir.path + "/" + config.c.appPath);
|
||||
|
||||
await binDir.create();
|
||||
|
||||
@@ -54,7 +55,7 @@ Stream<String> runBinary (String name) async* {
|
||||
"--data-dir",
|
||||
binDir.path,
|
||||
"--non-interactive",
|
||||
] + extraArgs + config.extraArgs;
|
||||
] + extraArgs + config.c.extraArgs;
|
||||
|
||||
log.info('args: ' + args.toString());
|
||||
|
||||
@@ -63,7 +64,7 @@ Stream<String> runBinary (String name) async* {
|
||||
yield line;
|
||||
}
|
||||
|
||||
if (isEmu) return;
|
||||
if (config.isEmu) return;
|
||||
|
||||
// the app should never reach here
|
||||
log.severe('Daemon is gone!');
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
final Logger log = new Logger('Default');
|
||||
@@ -28,7 +28,8 @@ import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
import 'state.dart';
|
||||
import 'config.dart';
|
||||
import 'config.dart' as config;
|
||||
import 'logging.dart';
|
||||
import 'controller/loading.dart';
|
||||
import 'controller/syncing.dart';
|
||||
import 'widget/loading.dart';
|
||||
@@ -112,11 +113,11 @@ class _CyberWOW_PageState extends State<CyberWOW_Page> with WidgetsBindingObserv
|
||||
}
|
||||
|
||||
Future<void> buildStateMachine(BlankState _blankState) async {
|
||||
final loadingText = config.splash;
|
||||
final loadingText = config.c.splash;
|
||||
LoadingState _loadingState = await _blankState.next(loadingText);
|
||||
|
||||
final binName = config.outputBin;
|
||||
final resourcePath = 'native/output/' + arch + '/' + binName;
|
||||
final binName = config.c.outputBin;
|
||||
final resourcePath = 'native/output/' + config.arch + '/' + binName;
|
||||
final bundle = DefaultAssetBundle.of(context);
|
||||
final loading = deployBinary(bundle, resourcePath, binName);
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ import 'controller/rpc/rpc.dart' as rpc;
|
||||
import 'controller/rpc/rpc2.dart' as rpc;
|
||||
import 'controller/daemon.dart' as daemon;
|
||||
import 'controller/refresh.dart' as refresh;
|
||||
import 'config.dart';
|
||||
import 'config.dart' as config;
|
||||
import 'logging.dart';
|
||||
|
||||
abstract class AppState {
|
||||
T use<T>
|
||||
@@ -113,7 +114,7 @@ class LoadingState extends HookedState {
|
||||
|
||||
for (String char in chars) {
|
||||
append(char);
|
||||
await Future.delayed(Duration(milliseconds: config.splashDelay), () => "1");
|
||||
await Future.delayed(Duration(milliseconds: config.c.splashDelay), () => "1");
|
||||
}
|
||||
|
||||
await Future.delayed(const Duration(seconds: 2), () => "1");
|
||||
@@ -127,7 +128,7 @@ class LoadingState extends HookedState {
|
||||
}
|
||||
}
|
||||
|
||||
final outputBinExists = await binaryExists(config.outputBin);
|
||||
final outputBinExists = await binaryExists(config.c.outputBin);
|
||||
if (outputBinExists) {
|
||||
await load();
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
|
||||
Widget buildBlank(BuildContext context, BlankState state) {
|
||||
return Scaffold(
|
||||
body: Container
|
||||
(
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
|
||||
Widget buildLoading(BuildContext context, LoadingState state) {
|
||||
return Scaffold(
|
||||
@@ -33,7 +33,7 @@ Widget buildLoading(BuildContext context, LoadingState state) {
|
||||
body: Container
|
||||
(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
child: Align
|
||||
(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -55,7 +55,7 @@ Widget buildLoading(BuildContext context, LoadingState state) {
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
|
||||
Widget buildReSyncing(BuildContext context, ReSyncingState state) {
|
||||
return Scaffold
|
||||
@@ -35,7 +35,7 @@ Widget buildReSyncing(BuildContext context, ReSyncingState state) {
|
||||
body: Container
|
||||
(
|
||||
// padding: const EdgeInsets.all(10.0),
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
child: Align
|
||||
(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -58,7 +58,7 @@ Widget buildReSyncing(BuildContext context, ReSyncingState state) {
|
||||
(
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 11,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -22,14 +22,14 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
import '../helper.dart';
|
||||
|
||||
Widget summary(SyncedState state) {
|
||||
return Container
|
||||
(
|
||||
padding: EdgeInsets.only(bottom: 10.0),
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
child: Align
|
||||
(
|
||||
alignment: Alignment.center,
|
||||
@@ -64,7 +64,7 @@ Widget summary(SyncedState state) {
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
key: ValueKey<int>(state.height),
|
||||
)
|
||||
@@ -95,7 +95,7 @@ Widget rpcView(String title, String body) {
|
||||
return Container
|
||||
(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
child: Align
|
||||
(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -127,12 +127,12 @@ Widget rpcView(String title, String body) {
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 1,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
margin: const EdgeInsets.only(bottom: 20, top: 20),
|
||||
),
|
||||
Text
|
||||
@@ -142,7 +142,7 @@ Widget rpcView(String title, String body) {
|
||||
(
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 11,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -22,7 +22,7 @@ along with CyberWOW. If not, see <https://www.gnu.org/licenses/>.
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../state.dart';
|
||||
import '../config.dart';
|
||||
import '../config.dart' as config;
|
||||
|
||||
Widget buildSyncing(BuildContext context, SyncingState state) {
|
||||
return Scaffold
|
||||
@@ -35,7 +35,7 @@ Widget buildSyncing(BuildContext context, SyncingState state) {
|
||||
body: Container
|
||||
(
|
||||
// padding: const EdgeInsets.all(10.0),
|
||||
color: config.backgroundColor,
|
||||
color: config.c.backgroundColor,
|
||||
child: Align
|
||||
(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -58,7 +58,7 @@ Widget buildSyncing(BuildContext context, SyncingState state) {
|
||||
(
|
||||
fontFamily: 'RobotoMono',
|
||||
fontSize: 11,
|
||||
color: config.textColor,
|
||||
color: config.c.textColor,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user