forked from SteveJosephh21/beldex-master-node-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Beldex-Coin/dev
- Loading branch information
Showing
23 changed files
with
667 additions
and
194 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
10 changes: 8 additions & 2 deletions
10
android/app/src/main/kotlin/io/beldex/master_node_monitor/MainActivity.kt
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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
package io.beldex.master_node_monitor | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
import androidx.annotation.NonNull; | ||
import io.flutter.embedding.android.FlutterFragmentActivity | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugins.GeneratedPluginRegistrant | ||
|
||
class MainActivity: FlutterActivity() { | ||
class MainActivity: FlutterFragmentActivity() { | ||
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { | ||
GeneratedPluginRegistrant.registerWith(flutterEngine); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
android/app/src/main/res/drawable-v24/launch_background.xml
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- Modify this file to customize your launch splash screen --> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@color/ic_launcher_background" /> | ||
|
||
<!-- You can insert your own image assets here --> | ||
<item | ||
android:width="250dp" | ||
android:height="250dp" | ||
android:gravity="center" | ||
android:drawable="@drawable/ic_launcher_foreground" /> | ||
</layer-list> |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Modify this file to customize your launch splash screen --> | ||
<?xml version="1.0" encoding="utf-8"?><!-- Modify this file to customize your launch splash screen --> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@color/ic_launcher_background" /> | ||
|
||
<!-- You can insert your own image assets here --> | ||
<!-- <item> | ||
<bitmap | ||
android:gravity="center" | ||
android:src="@mipmap/launch_image" /> | ||
</item> --> | ||
<item | ||
android:width="250dp" | ||
android:height="250dp" | ||
android:gravity="center" | ||
android:drawable="@drawable/ic_launcher_foreground" /> | ||
</layer-list> |
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 |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
version: 1.0.0 | ||
changes: | ||
- Initial release | ||
- | ||
version: 1.0.1 | ||
changes: | ||
- Updated support for Android version 13 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,51 @@ | ||
import 'dart:convert'; | ||
import 'dart:ffi'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:http/http.dart' as http; | ||
|
||
@HiveType(typeId: 1) | ||
class CheckMasterNode extends HiveObject { | ||
CheckMasterNode(this.uri,this.publicKey); | ||
|
||
CheckMasterNode.fromMap(Map map) : uri = (map['uri'] ?? '') as String,publicKey = (map['publicKey'] ?? '') as String; | ||
|
||
static const boxName = 'CheckMasterNodes'; | ||
|
||
@HiveField(0) | ||
String uri; | ||
|
||
@HiveField(1) | ||
String publicKey; | ||
|
||
Future<bool> isOnline() async { | ||
try { | ||
final resBody = await sendRPCRequest('get_master_nodes',{'master_node_pubkeys':[publicKey]}); | ||
if(resBody['result']['master_node_states']!=null){ | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
Future<Map<String, dynamic>> sendRPCRequest(String method, Map<String, dynamic> params) async { | ||
Map<String, dynamic> resultBody; | ||
|
||
final requestBody = params != null | ||
? {'jsonrpc': '2.0', 'id': '0', 'method': method, 'params': params} | ||
: {'jsonrpc': '2.0', 'id': '0', 'method': method}; | ||
|
||
final url = Uri.http(uri, '/json_rpc'); | ||
final headers = {'Content-type': 'application/json'}; | ||
final body = json.encode(requestBody); | ||
final response = await http.post(url, headers: headers, body: body); | ||
final newBody = response.body.replaceAllMapped( | ||
RegExp(r'("swarm_id":)(\d+)'), | ||
(match) => '${match.group(1)}"${match.group(2)}"'); | ||
|
||
resultBody = json.decode(newBody) as Map<String, dynamic>; | ||
return resultBody; | ||
} | ||
} |
Oops, something went wrong.