-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add logic code in background for initialized node
- Loading branch information
1 parent
331c751
commit 7cd1b30
Showing
10 changed files
with
298 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:io'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:gui/src/core/utils/daemon_manager/bloc/daemon_state.dart'; | ||
import 'package:path/path.dart' show dirname; | ||
|
||
class DaemonCubit extends Cubit<DaemonState> { | ||
DaemonCubit() : super(DaemonInitial()); | ||
|
||
Future<void> runPactusDaemon({ | ||
// required String workingDirectory, | ||
required String command, | ||
required List<String> arguments, | ||
}) async { | ||
emit(DaemonLoading()); | ||
|
||
try { | ||
// Get the directory of the script | ||
final scriptDir = dirname(Platform.script.toFilePath()); | ||
|
||
final targetPath = '$scriptDir/lib/src/core/native_resources/linux/'; | ||
|
||
// print('scriptDir: $targetPath'); | ||
|
||
final result = | ||
await Process.run(command, arguments, workingDirectory: targetPath); | ||
if (result.exitCode == 0) { | ||
// دستور با موفقیت اجرا شد | ||
emit(DaemonSuccess('${result.stdout}')); | ||
} else { | ||
// دستور با خطا مواجه شد | ||
emit(DaemonError('${result.stderr}')); | ||
} | ||
} on Exception catch (e) { | ||
// برخورد با خطای استثنا | ||
emit(DaemonError('Exception occurred: $e')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
abstract class DaemonState {} | ||
|
||
class DaemonInitial extends DaemonState {} | ||
|
||
class DaemonLoading extends DaemonState {} | ||
|
||
class DaemonSuccess extends DaemonState { | ||
DaemonSuccess(this.output); | ||
final String output; | ||
} | ||
|
||
class DaemonError extends DaemonState { | ||
DaemonError(this.error); | ||
final String error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class NodeConfigData { | ||
// Private constructor | ||
NodeConfigData._internal(); | ||
// Singleton instance | ||
static final NodeConfigData instance = NodeConfigData._internal(); | ||
|
||
// Private variables | ||
String? _workingDirectory; | ||
String? _restorationSeed; | ||
String? _password; | ||
String? _validatorQty; | ||
|
||
// Getters | ||
String get workingDirectory => _workingDirectory ?? ''; | ||
String get restorationSeed => _restorationSeed ?? ''; | ||
String get password => _password ?? ''; | ||
String get validatorQty => _validatorQty ?? ''; | ||
|
||
// Setters | ||
set workingDirectory(String value) { | ||
_workingDirectory = value; | ||
} | ||
|
||
set restorationSeed(String value) { | ||
_restorationSeed = value; | ||
} | ||
|
||
set password(String value) { | ||
_password = value; | ||
} | ||
|
||
set validatorQty(String value) { | ||
_validatorQty = value; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.