Skip to content
Snippets Groups Projects
Commit 3b6eb642 authored by fred's avatar fred
Browse files

upgrade from source

parents db437750 67231b8b
No related branches found
No related tags found
No related merge requests found
Showing
with 3296 additions and 167 deletions
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
.buildlog/ .buildlog/
.history .history
.svn/ .svn/
.env
.env.dev
.env.*
# IntelliJ related # IntelliJ related
*.iml *.iml
......
...@@ -81,6 +81,10 @@ flutter test ...@@ -81,6 +81,10 @@ flutter test
### Build & deploy ### Build & deploy
#### Prerequisites
Create a `.env` configuration file (and `.env-dev` for development) in the root of the project. Use the `dot.env.sample` file as template.
#### Build for web #### Build for web
Use first this command to enable web support: Use first this command to enable web support:
......
...@@ -44,7 +44,6 @@ linter: ...@@ -44,7 +44,6 @@ linter:
- always_declare_return_types - always_declare_return_types
- always_put_control_body_on_new_line - always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
- always_specify_types - always_specify_types
# - always_use_package_imports # we do this commonly # - always_use_package_imports # we do this commonly
- annotate_overrides - annotate_overrides
...@@ -74,7 +73,6 @@ linter: ...@@ -74,7 +73,6 @@ linter:
- avoid_renaming_method_parameters - avoid_renaming_method_parameters
- avoid_return_types_on_setters - avoid_return_types_on_setters
# - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated # - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
- avoid_returning_null_for_future
- avoid_returning_null_for_void - avoid_returning_null_for_void
# - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives # - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
- avoid_setters_without_getters - avoid_setters_without_getters
......
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties() def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties') def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) { if (localPropertiesFile.exists()) {
...@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { ...@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
} }
} }
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode') def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) { if (flutterVersionCode == null) {
flutterVersionCode = '1' flutterVersionCode = '1'
...@@ -21,10 +22,6 @@ if (flutterVersionName == null) { ...@@ -21,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0' flutterVersionName = '1.0'
} }
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 34 compileSdkVersion 34
...@@ -54,6 +51,3 @@ flutter { ...@@ -54,6 +51,3 @@ flutter {
source '../..' source '../..'
} }
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
buildscript {
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects { allprojects {
repositories { repositories {
google() google()
...@@ -21,6 +8,8 @@ allprojects { ...@@ -21,6 +8,8 @@ allprojects {
rootProject.buildDir = '../build' rootProject.buildDir = '../build'
subprojects { subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}" project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
......
include ':app' pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties") includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
def properties = new Properties()
assert localPropertiesFile.exists() repositories {
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } google()
mavenCentral()
gradlePluginPortal()
}
}
def flutterSdkPath = properties.getProperty("flutter.sdk") plugins {
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" id "dev.flutter.flutter-plugin-loader" version "1.0.0"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" id "com.android.application" version "7.2.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.20" apply false
}
include ":app"
This diff is collapsed.
This diff is collapsed.
...@@ -249,7 +249,9 @@ ...@@ -249,7 +249,9 @@
"please_confirm_delete": "Sind Sie sicher?", "please_confirm_delete": "Sind Sie sicher?",
"please_confirm_delete_desc": "Sind Sie sicher, dass Sie diese Brieftasche löschen wollen?", "please_confirm_delete_desc": "Sind Sie sicher, dass Sie diese Brieftasche löschen wollen?",
"please_confirm_delete_desc_g1nkgo": "Sind Sie sicher, dass Sie diese Brieftasche löschen wollen? Wenn Sie das tun und keine Sicherungskopie haben, verlieren Sie den Zugriff auf die Brieftasche und das darin gespeicherte Geld.", "please_confirm_delete_desc_g1nkgo": "Sind Sie sicher, dass Sie diese Brieftasche löschen wollen? Wenn Sie das tun und keine Sicherungskopie haben, verlieren Sie den Zugriff auf die Brieftasche und das darin gespeicherte Geld.",
"please_confirm_sent_multi_desc": "Sind Sie sicher, dass Sie {amount} {currency} an alle zahlen wollen?", "please_confirm_sent_multi_desc": "Sind Sie sicher, dass Sie {amount} {currency} an {people} Leute zahlen wollen?",
"multi_pay_results": "Ergebnisse der Zahlungen", "multi_pay_results": "Ergebnisse der Zahlungen",
"multi_pay_results_desc": "{success} Erfolg, {fail} fehlgeschlagen" "multi_pay_results_desc": "{success} Erfolg, {fail} fehlgeschlagen",
"Insufficient balance in your wallet": "Unzureichendes Guthaben in Ihrer Brieftasche",
"others_and_someone": "{others} und {someone}"
} }
...@@ -120,7 +120,6 @@ ...@@ -120,7 +120,6 @@
"form_contact_name_validation_pub_key": "Please enter a valid public key", "form_contact_name_validation_pub_key": "Please enter a valid public key",
"form_contact_notes": "Notes", "form_contact_notes": "Notes",
"form_contact_pub_key": "Public key", "form_contact_pub_key": "Public key",
"long_press_to_edit": "Slide to select this contact. Tap and hold to edit",
"payment_error": "Payment error", "payment_error": "Payment error",
"payment_error_desc": "Oops! the payment failed. More details: {error}", "payment_error_desc": "Oops! the payment failed. More details: {error}",
"payment_error_retry": "Oops! the payment failed. Please retry in some minutes.", "payment_error_retry": "Oops! the payment failed. Please retry in some minutes.",
...@@ -249,5 +248,6 @@ ...@@ -249,5 +248,6 @@
"multi_pay_results": "Payments results", "multi_pay_results": "Payments results",
"multi_pay_results_desc": "{success} success, {fail} failed", "multi_pay_results_desc": "{success} success, {fail} failed",
"You can't send money to yourself.": "You can't send money to yourself.", "You can't send money to yourself.": "You can't send money to yourself.",
"others_and_someone": "{others} and {someone}" "others_and_someone": "{others} and {someone}",
"account_info": "Account information"
} }
...@@ -122,7 +122,6 @@ ...@@ -122,7 +122,6 @@
"form_contact_name_validation": "Por favor, ingresa un nombre", "form_contact_name_validation": "Por favor, ingresa un nombre",
"form_contact_name_validation_pub_key": "Por favor, ingresa una clave pública valida", "form_contact_name_validation_pub_key": "Por favor, ingresa una clave pública valida",
"form_contact_notes": "Notas", "form_contact_notes": "Notas",
"long_press_to_edit": "Desliza para seleccionar este contacto. Mantén pulsado para editar",
"form_contact_pub_key": "Clave pública", "form_contact_pub_key": "Clave pública",
"reloading_nodes": "Refrescando nodos del tipo {type}", "reloading_nodes": "Refrescando nodos del tipo {type}",
"payment_error": "Error en el pago", "payment_error": "Error en el pago",
...@@ -254,5 +253,6 @@ ...@@ -254,5 +253,6 @@
"multi_pay_results": "Resultados de los pagos", "multi_pay_results": "Resultados de los pagos",
"multi_pay_results_desc": "{success} pagos exitosos, {fail} fallidos", "multi_pay_results_desc": "{success} pagos exitosos, {fail} fallidos",
"others_and_someone": "{others} y {someone}", "others_and_someone": "{others} y {someone}",
"search_multiuser_hint": "Mantén pulsado si quieres pagar a varias personas a la vez" "search_multiuser_hint": "Mantén pulsado si quieres pagar a varias personas a la vez",
"account_info": "Información de la cuenta"
} }
# Create some similar file to this and name them .env and .env.dev
CURRENCY=g1
SENTRY_DSN=https://306345cb87ee4e1cbbe9023fb4afc5fc@sentry.comunes.org/6
# Nodes space-separated
#
# v1
# The duniter nodes are only used at boot time, later it tries to calculate periodically the nodes
# that are available with the less latency
DUNITER_NODES=https://g1.duniter.fr https://g1.le-sou.org https://g1.cgeek.fr https://g1.monnaielibreoccitanie.org https://g1.duniter.fr https://g1.le-sou.org https://g1.cgeek.fr
CESIUM_PLUS_NODES=https://g1.data.le-sou.org https://g1.data.e-is.pro https://g1.data.presles.fr https://g1.data.mithril.re https://g1.data.brussels.ovh https://g1.data.pini.fr
GVA_NODES=https://g1v1.p2p.legal:443/gva https://g1.asycn.io:443/gva https://duniter.pini.fr:443/gva
#
# v2
ENDPOINTS=wss://1000i100.fr/ws wss://gdev.librelois.fr/ws wss://gdev.p2p.legal/ws wss://gdev.coinduf.eu/ws wss://vit.fdn.org/ws wss://gdev.cgeek.fr/ws wss://gdev.pini.fr/ws
DUNITER_INDEXER_NODES=https://gdev-indexer.p2p.legal/v1/graphql https://hasura.gdev.coinduf.eu/v1/graphql http://gdev-hasura.cgeek.fr/v1/graphql
GITLAB_TOKEN=something
import 'package:flutter/material.dart';
const ColorScheme lightColorScheme = ColorScheme(
brightness: Brightness.light,
primary: Color(0xFF526600),
onPrimary: Color(0xFFFFFFFF),
primaryContainer: Color(0xFFD4ED7F),
onPrimaryContainer: Color(0xFF171E00),
secondary: Color(0xFF5B6146),
onSecondary: Color(0xFFFFFFFF),
secondaryContainer: Color(0xFFE0E6C4),
onSecondaryContainer: Color(0xFF191E08),
tertiary: Color(0xFF516600),
onTertiary: Color(0xFFFFFFFF),
tertiaryContainer: Color(0xFFC7F333),
onTertiaryContainer: Color(0xFF161E00),
error: Color(0xFFBA1A1A),
errorContainer: Color(0xFFFFDAD6),
onError: Color(0xFFFFFFFF),
onErrorContainer: Color(0xFF410002),
background: Color(0xFFFEFCF4),
onBackground: Color(0xFF1B1C17),
surface: Color(0xFFFEFCF4),
onSurface: Color(0xFF1B1C17),
surfaceVariant: Color(0xFFE3E4D3),
onSurfaceVariant: Color(0xFF46483C),
outline: Color(0xFF77786B),
onInverseSurface: Color(0xFFF3F1E9),
inverseSurface: Color(0xFF30312B),
inversePrimary: Color(0xFFB8D166),
shadow: Color(0xFF000000),
surfaceTint: Color(0xFF526600),
outlineVariant: Color(0xFFC7C8B8),
scrim: Color(0xFF000000),
);
const ColorScheme darkColorScheme = ColorScheme(
brightness: Brightness.dark,
primary: Color(0xFFB8D166),
onPrimary: Color(0xFF293500),
primaryContainer: Color(0xFF3D4D00),
onPrimaryContainer: Color(0xFFD4ED7F),
secondary: Color(0xFFC4CAA9),
onSecondary: Color(0xFF2D331B),
secondaryContainer: Color(0xFF444930),
onSecondaryContainer: Color(0xFFE0E6C4),
tertiary: Color(0xFFACD605),
onTertiary: Color(0xFF283500),
tertiaryContainer: Color(0xFF3C4D00),
onTertiaryContainer: Color(0xFFC7F333),
error: Color(0xFFFFB4AB),
errorContainer: Color(0xFF93000A),
onError: Color(0xFF690005),
onErrorContainer: Color(0xFFFFDAD6),
background: Color(0xFF1B1C17),
onBackground: Color(0xFFE4E3DA),
surface: Color(0xFF1B1C17),
onSurface: Color(0xFFE4E3DA),
surfaceVariant: Color(0xFF46483C),
onSurfaceVariant: Color(0xFFC7C8B8),
outline: Color(0xFF909283),
onInverseSurface: Color(0xFF1B1C17),
inverseSurface: Color(0xFFE4E3DA),
inversePrimary: Color(0xFF526600),
shadow: Color(0xFF000000),
surfaceTint: Color(0xFFB8D166),
outlineVariant: Color(0xFF46483C),
scrim: Color(0xFF000000),
);
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import 'is_json_serializable.dart';
part 'node.g.dart'; part 'node.g.dart';
@JsonSerializable() @JsonSerializable()
class Node extends Equatable implements IsJsonSerializable<Node> { class Node extends Equatable {
const Node( const Node(
{required this.url, {required this.url,
this.latency = 99999, this.latency = 99999,
...@@ -35,43 +32,10 @@ class Node extends Equatable implements IsJsonSerializable<Node> { ...@@ -35,43 +32,10 @@ class Node extends Equatable implements IsJsonSerializable<Node> {
return 'node url: $url latency: $latency errors: $errors currentBlock: $currentBlock'; return 'node url: $url latency: $latency errors: $errors currentBlock: $currentBlock';
} }
@override
Map<String, dynamic> toJson() => _$NodeToJson(this); Map<String, dynamic> toJson() => _$NodeToJson(this);
@override
Node fromJson(Map<String, dynamic> json) => Node.fromJson(json); Node fromJson(Map<String, dynamic> json) => Node.fromJson(json);
@override @override
List<Object?> get props => <dynamic>[url]; List<Object?> get props => <dynamic>[url];
} }
List<Node> _splitList(String list) =>
list.split(' ').map((String url) => Node(url: url)).toList();
List<Node> _readDotNodeConfig(String entry) => _splitList(dotenv.env[entry]!);
List<Node> defaultDuniterNodes = <Node>{
..._readDotNodeConfig('DUNITER_NODES'),
..._splitList(
'duniter.pini.fr duniter.g1.pfouque.xyz fania.g1server.net g1.brussels.ovh g1.cgeek.fr g1.computhings.be g1.cuates.net g1.geragc.es g1.madeirawonders.com g1.rendall.fr g1.trentesaux.fr gibraleon.g1server.net vit.fdn.org')
}.toList();
List<Node> defaultCesiumPlusNodes = <Node>{
..._readDotNodeConfig('CESIUM_PLUS_NODES'),
..._splitList(
'https://g1.data.brussels.ovh https://g1.data.e-is.pro https://g1.data.mithril.re https://g1.data.pini.fr https://g1.data.presles.fr https://g1.data.geragc.es')
}.toList();
List<Node> defaultGvaNodes = <Node>{
..._readDotNodeConfig('GVA_NODES'),
..._splitList(
'https://g1.cuates.net/gva https://g1.madeirawonders.com/gva https://g1.brussels.ovh/gva https://g1.geragc.es/gva https://gva.seeds4c.org/gva')
}.toList();
// We test local duniter node in dev mode
/* List<Node> defaultGvaNodes = kReleaseMode
? readDotNodeConfig('GVA_NODES')
: <Node>[const Node(url: 'http://localhost:30901/gva/')]
..addAll(readDotNodeConfig('GVA_NODES'));
// List<Node> defaultGvaNodes = readDotNodeConfig('GVA_NODES');
: <Node>[const Node(url: 'http://localhost:30901/gva/')]
..addAll(readDotNodeConfig('GVA_NODES')); */
...@@ -25,6 +25,10 @@ class NodeListCubit extends HydratedCubit<NodeListState> { ...@@ -25,6 +25,10 @@ class NodeListCubit extends HydratedCubit<NodeListState> {
emit(state.copyWith(duniterNodes: nodes)); emit(state.copyWith(duniterNodes: nodes));
} }
void setDuniterIndexerNodes(List<Node> nodes) {
emit(state.copyWith(duniterIndexerNodes: nodes));
}
void setCesiumPlusNodes(List<Node> nodes) { void setCesiumPlusNodes(List<Node> nodes) {
emit(state.copyWith(cesiumPlusNodes: nodes)); emit(state.copyWith(cesiumPlusNodes: nodes));
} }
...@@ -33,12 +37,20 @@ class NodeListCubit extends HydratedCubit<NodeListState> { ...@@ -33,12 +37,20 @@ class NodeListCubit extends HydratedCubit<NodeListState> {
emit(state.copyWith(gvaNodes: nodes)); emit(state.copyWith(gvaNodes: nodes));
} }
void setEndpointNodes(List<Node> nodes) {
emit(state.copyWith(endpointNodes: nodes));
}
List<Node> get duniterNodes => state.duniterNodes; List<Node> get duniterNodes => state.duniterNodes;
List<Node> get cesiumPlusNodes => state.cesiumPlusNodes; List<Node> get cesiumPlusNodes => state.cesiumPlusNodes;
List<Node> get gvaNodes => state.gvaNodes; List<Node> get gvaNodes => state.gvaNodes;
List<Node> get endpointNodes => state.endpointNodes;
List<Node> get duniterIndexerNodes => state.duniterIndexerNodes;
@override @override
NodeListState? fromJson(Map<String, dynamic> json) => NodeListState? fromJson(Map<String, dynamic> json) =>
NodeListState.fromJson(json); NodeListState.fromJson(json);
...@@ -53,6 +65,8 @@ class NodeListCubit extends HydratedCubit<NodeListState> { ...@@ -53,6 +65,8 @@ class NodeListCubit extends HydratedCubit<NodeListState> {
gvaNodes: state.gvaNodes, gvaNodes: state.gvaNodes,
duniterNodes: state.duniterNodes, duniterNodes: state.duniterNodes,
cesiumPlusNodes: state.cesiumPlusNodes, cesiumPlusNodes: state.cesiumPlusNodes,
endpointNodes: state.endpointNodes,
duniterIndexerNodes: state.duniterIndexerNodes,
isLoading: state.isLoading)); isLoading: state.isLoading));
} }
} }
...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; ...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
import 'node.dart'; import 'node.dart';
import 'node_lists_default.dart';
part 'node_list_state.g.dart'; part 'node_list_state.g.dart';
...@@ -15,25 +16,55 @@ class NodeListState extends Equatable { ...@@ -15,25 +16,55 @@ class NodeListState extends Equatable {
{List<Node>? duniterNodes, {List<Node>? duniterNodes,
List<Node>? cesiumPlusNodes, List<Node>? cesiumPlusNodes,
List<Node>? gvaNodes, List<Node>? gvaNodes,
List<Node>? endpointNodes,
List<Node>? duniterIndexerNodes,
this.currentGvaNode, this.currentGvaNode,
bool? isLoading}) bool? isLoading})
: duniterNodes = duniterNodes ?? defaultDuniterNodes, : duniterNodes = duniterNodes ?? defaultDuniterNodes,
cesiumPlusNodes = cesiumPlusNodes ?? defaultCesiumPlusNodes, cesiumPlusNodes = cesiumPlusNodes ?? defaultCesiumPlusNodes,
gvaNodes = gvaNodes ?? defaultGvaNodes, gvaNodes = gvaNodes ?? defaultGvaNodes,
endpointNodes = endpointNodes ?? defaultEndPointNodes,
duniterIndexerNodes = duniterIndexerNodes ?? defaultDuniterIndexerNodes,
isLoading = isLoading ?? false; isLoading = isLoading ?? false;
factory NodeListState.fromJson(Map<String, dynamic> json) => factory NodeListState.fromJson(Map<String, dynamic> json) =>
_$NodeListStateFromJson(json); _$NodeListStateFromJson(json);
@JsonKey(fromJson: _nodesFromJson, toJson: _nodesToJson)
final List<Node> duniterNodes; final List<Node> duniterNodes;
@JsonKey(fromJson: _nodesFromJson, toJson: _nodesToJson)
final List<Node> cesiumPlusNodes; final List<Node> cesiumPlusNodes;
@JsonKey(fromJson: _nodesFromJson, toJson: _nodesToJson)
final List<Node> gvaNodes; final List<Node> gvaNodes;
@JsonKey(fromJson: _nodesFromJson, toJson: _nodesToJson)
final List<Node> endpointNodes;
@JsonKey(fromJson: _nodesFromJson, toJson: _nodesToJson)
final List<Node> duniterIndexerNodes;
final bool isLoading; final bool isLoading;
@JsonKey(fromJson: _nodeFromJson, toJson: _nodeToJson)
final Node? currentGvaNode; final Node? currentGvaNode;
@override @override
List<Object?> get props => List<Object?> get props => <Object>[
<Object>[duniterNodes, cesiumPlusNodes, gvaNodes, isLoading]; duniterNodes,
cesiumPlusNodes,
gvaNodes,
endpointNodes,
duniterIndexerNodes,
isLoading
];
Map<String, dynamic> toJson() => _$NodeListStateToJson(this); Map<String, dynamic> toJson() => _$NodeListStateToJson(this);
static Node? _nodeFromJson(Map<String, dynamic>? json) =>
json != null ? Node.fromJson(json) : null;
static Map<String, dynamic>? _nodeToJson(Node? node) => node?.toJson();
static List<Node> _nodesFromJson(List<dynamic> json) => json
.map((dynamic item) => Node.fromJson(item as Map<String, dynamic>))
.toList();
static List<Map<String, dynamic>> _nodesToJson(List<Node> nodes) =>
nodes.map((Node item) => item.toJson()).toList();
} }
...@@ -13,6 +13,10 @@ abstract class _$NodeListStateCWProxy { ...@@ -13,6 +13,10 @@ abstract class _$NodeListStateCWProxy {
NodeListState gvaNodes(List<Node>? gvaNodes); NodeListState gvaNodes(List<Node>? gvaNodes);
NodeListState endpointNodes(List<Node>? endpointNodes);
NodeListState duniterIndexerNodes(List<Node>? duniterIndexerNodes);
NodeListState currentGvaNode(Node? currentGvaNode); NodeListState currentGvaNode(Node? currentGvaNode);
NodeListState isLoading(bool? isLoading); NodeListState isLoading(bool? isLoading);
...@@ -27,6 +31,8 @@ abstract class _$NodeListStateCWProxy { ...@@ -27,6 +31,8 @@ abstract class _$NodeListStateCWProxy {
List<Node>? duniterNodes, List<Node>? duniterNodes,
List<Node>? cesiumPlusNodes, List<Node>? cesiumPlusNodes,
List<Node>? gvaNodes, List<Node>? gvaNodes,
List<Node>? endpointNodes,
List<Node>? duniterIndexerNodes,
Node? currentGvaNode, Node? currentGvaNode,
bool? isLoading, bool? isLoading,
}); });
...@@ -49,6 +55,14 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy { ...@@ -49,6 +55,14 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy {
@override @override
NodeListState gvaNodes(List<Node>? gvaNodes) => this(gvaNodes: gvaNodes); NodeListState gvaNodes(List<Node>? gvaNodes) => this(gvaNodes: gvaNodes);
@override
NodeListState endpointNodes(List<Node>? endpointNodes) =>
this(endpointNodes: endpointNodes);
@override
NodeListState duniterIndexerNodes(List<Node>? duniterIndexerNodes) =>
this(duniterIndexerNodes: duniterIndexerNodes);
@override @override
NodeListState currentGvaNode(Node? currentGvaNode) => NodeListState currentGvaNode(Node? currentGvaNode) =>
this(currentGvaNode: currentGvaNode); this(currentGvaNode: currentGvaNode);
...@@ -68,6 +82,8 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy { ...@@ -68,6 +82,8 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy {
Object? duniterNodes = const $CopyWithPlaceholder(), Object? duniterNodes = const $CopyWithPlaceholder(),
Object? cesiumPlusNodes = const $CopyWithPlaceholder(), Object? cesiumPlusNodes = const $CopyWithPlaceholder(),
Object? gvaNodes = const $CopyWithPlaceholder(), Object? gvaNodes = const $CopyWithPlaceholder(),
Object? endpointNodes = const $CopyWithPlaceholder(),
Object? duniterIndexerNodes = const $CopyWithPlaceholder(),
Object? currentGvaNode = const $CopyWithPlaceholder(), Object? currentGvaNode = const $CopyWithPlaceholder(),
Object? isLoading = const $CopyWithPlaceholder(), Object? isLoading = const $CopyWithPlaceholder(),
}) { }) {
...@@ -84,6 +100,14 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy { ...@@ -84,6 +100,14 @@ class _$NodeListStateCWProxyImpl implements _$NodeListStateCWProxy {
? _value.gvaNodes ? _value.gvaNodes
// ignore: cast_nullable_to_non_nullable // ignore: cast_nullable_to_non_nullable
: gvaNodes as List<Node>?, : gvaNodes as List<Node>?,
endpointNodes: endpointNodes == const $CopyWithPlaceholder()
? _value.endpointNodes
// ignore: cast_nullable_to_non_nullable
: endpointNodes as List<Node>?,
duniterIndexerNodes: duniterIndexerNodes == const $CopyWithPlaceholder()
? _value.duniterIndexerNodes
// ignore: cast_nullable_to_non_nullable
: duniterIndexerNodes as List<Node>?,
currentGvaNode: currentGvaNode == const $CopyWithPlaceholder() currentGvaNode: currentGvaNode == const $CopyWithPlaceholder()
? _value.currentGvaNode ? _value.currentGvaNode
// ignore: cast_nullable_to_non_nullable // ignore: cast_nullable_to_non_nullable
...@@ -108,26 +132,27 @@ extension $NodeListStateCopyWith on NodeListState { ...@@ -108,26 +132,27 @@ extension $NodeListStateCopyWith on NodeListState {
NodeListState _$NodeListStateFromJson(Map<String, dynamic> json) => NodeListState _$NodeListStateFromJson(Map<String, dynamic> json) =>
NodeListState( NodeListState(
duniterNodes: (json['duniterNodes'] as List<dynamic>?) duniterNodes: NodeListState._nodesFromJson(json['duniterNodes'] as List),
?.map((e) => Node.fromJson(e as Map<String, dynamic>)) cesiumPlusNodes:
.toList(), NodeListState._nodesFromJson(json['cesiumPlusNodes'] as List),
cesiumPlusNodes: (json['cesiumPlusNodes'] as List<dynamic>?) gvaNodes: NodeListState._nodesFromJson(json['gvaNodes'] as List),
?.map((e) => Node.fromJson(e as Map<String, dynamic>)) endpointNodes:
.toList(), NodeListState._nodesFromJson(json['endpointNodes'] as List),
gvaNodes: (json['gvaNodes'] as List<dynamic>?) duniterIndexerNodes:
?.map((e) => Node.fromJson(e as Map<String, dynamic>)) NodeListState._nodesFromJson(json['duniterIndexerNodes'] as List),
.toList(), currentGvaNode: NodeListState._nodeFromJson(
currentGvaNode: json['currentGvaNode'] == null json['currentGvaNode'] as Map<String, dynamic>?),
? null
: Node.fromJson(json['currentGvaNode'] as Map<String, dynamic>),
isLoading: json['isLoading'] as bool?, isLoading: json['isLoading'] as bool?,
); );
Map<String, dynamic> _$NodeListStateToJson(NodeListState instance) => Map<String, dynamic> _$NodeListStateToJson(NodeListState instance) =>
<String, dynamic>{ <String, dynamic>{
'duniterNodes': instance.duniterNodes, 'duniterNodes': NodeListState._nodesToJson(instance.duniterNodes),
'cesiumPlusNodes': instance.cesiumPlusNodes, 'cesiumPlusNodes': NodeListState._nodesToJson(instance.cesiumPlusNodes),
'gvaNodes': instance.gvaNodes, 'gvaNodes': NodeListState._nodesToJson(instance.gvaNodes),
'endpointNodes': NodeListState._nodesToJson(instance.endpointNodes),
'duniterIndexerNodes':
NodeListState._nodesToJson(instance.duniterIndexerNodes),
'isLoading': instance.isLoading, 'isLoading': instance.isLoading,
'currentGvaNode': instance.currentGvaNode, 'currentGvaNode': NodeListState._nodeToJson(instance.currentGvaNode),
}; };
import 'package:flutter/foundation.dart';
import '../../env.dart';
import 'node.dart';
import 'node_type.dart';
List<Node> _splitList(String list) =>
list.split(' ').map((String url) => Node(url: url)).toList();
List<Node> _readDotNodeConfig(String entry) => _splitList(entry);
List<Node> defaultDuniterNodes = <Node>{
..._readDotNodeConfig(Env.duniterNodes),
..._splitList(
'duniter.pini.fr duniter.g1.pfouque.xyz fania.g1server.net g1.brussels.ovh g1.cgeek.fr g1.computhings.be g1.cuates.net g1.geragc.es g1.madeirawonders.com g1.rendall.fr g1.trentesaux.fr gibraleon.g1server.net vit.fdn.org')
}.toList();
List<Node> defaultCesiumPlusNodes = <Node>{
..._readDotNodeConfig(Env.cesiumPlusNodes),
..._splitList(
'https://g1.data.brussels.ovh https://g1.data.e-is.pro https://g1.data.mithril.re https://g1.data.pini.fr https://g1.data.presles.fr https://g1.data.geragc.es')
}.toList();
List<Node> defaultGvaNodes = <Node>{
..._readDotNodeConfig(Env.gvaNodes),
..._splitList(
'https://g1.cuates.net/gva https://g1.madeirawonders.com/gva https://g1.brussels.ovh/gva https://g1.geragc.es/gva https://gva.seeds4c.org/gva')
}.toList();
List<Node> defaultEndPointNodes = <Node>{
// For doing tests of faulty nodes
if (kDebugMode) const Node(url: 'wss://just-testing-a-wrong-node.com/ws'),
..._readDotNodeConfig(Env.endPoints),
}.toList();
List<Node> defaultDuniterIndexerNodes = <Node>{
..._readDotNodeConfig(Env.duniterIndexerNodes),
}.toList();
List<Node> defaultNodes(NodeType type) {
switch (type) {
case NodeType.duniter:
return defaultDuniterNodes;
case NodeType.cesiumPlus:
return defaultCesiumPlusNodes;
case NodeType.gva:
return defaultGvaNodes;
case NodeType.endpoint:
return defaultEndPointNodes;
case NodeType.duniterIndexer:
return defaultDuniterIndexerNodes;
}
}
// We test local duniter node in dev mode
/* List<Node> defaultGvaNodes = kReleaseMode
? readDotNodeConfig('GVA_NODES')
: <Node>[const Node(url: 'http://localhost:30901/gva/')]
..addAll(readDotNodeConfig('GVA_NODES'));
// List<Node> defaultGvaNodes = readDotNodeConfig('GVA_NODES');
: <Node>[const Node(url: 'http://localhost:30901/gva/')]
..addAll(readDotNodeConfig('GVA_NODES')); */
...@@ -21,15 +21,21 @@ class NodeManager { ...@@ -21,15 +21,21 @@ class NodeManager {
final List<Node> duniterNodes = <Node>[]; final List<Node> duniterNodes = <Node>[];
final List<Node> cesiumPlusNodes = <Node>[]; final List<Node> cesiumPlusNodes = <Node>[];
final List<Node> gvaNodes = <Node>[]; final List<Node> gvaNodes = <Node>[];
final List<Node> endpointNodes = <Node>[];
final List<Node> duniterIndexerNodes = <Node>[];
void loadFromCubit(NodeListCubit cubit) { void loadFromCubit(NodeListCubit cubit) {
NodeManagerObserver.instance.cubit = cubit; NodeManagerObserver.instance.cubit = cubit;
duniterNodes.clear(); duniterNodes.clear();
cesiumPlusNodes.clear(); cesiumPlusNodes.clear();
gvaNodes.clear(); gvaNodes.clear();
endpointNodes.clear();
duniterIndexerNodes.clear();
duniterNodes.addAll(cubit.duniterNodes); duniterNodes.addAll(cubit.duniterNodes);
cesiumPlusNodes.addAll(cubit.cesiumPlusNodes); cesiumPlusNodes.addAll(cubit.cesiumPlusNodes);
gvaNodes.addAll(cubit.gvaNodes); gvaNodes.addAll(cubit.gvaNodes);
endpointNodes.addAll(cubit.endpointNodes);
duniterIndexerNodes.addAll(cubit.duniterIndexerNodes);
} }
void updateNodes(NodeType type, List<Node> newNodes, {bool notify = true}) { void updateNodes(NodeType type, List<Node> newNodes, {bool notify = true}) {
...@@ -69,7 +75,11 @@ class NodeManager { ...@@ -69,7 +75,11 @@ class NodeManager {
? duniterNodes ? duniterNodes
: type == NodeType.cesiumPlus : type == NodeType.cesiumPlus
? cesiumPlusNodes ? cesiumPlusNodes
: gvaNodes; : type == NodeType.endpoint
? endpointNodes
: type == NodeType.duniterIndexer
? duniterIndexerNodes
: gvaNodes;
void addNode(NodeType type, Node node, {bool notify = true}) { void addNode(NodeType type, Node node, {bool notify = true}) {
final List<Node> nodes = _getList(type); final List<Node> nodes = _getList(type);
...@@ -181,6 +191,8 @@ class NodeManagerObserver { ...@@ -181,6 +191,8 @@ class NodeManagerObserver {
cubit.setDuniterNodes(nodeManager.duniterNodes); cubit.setDuniterNodes(nodeManager.duniterNodes);
cubit.setCesiumPlusNodes(nodeManager.cesiumPlusNodes); cubit.setCesiumPlusNodes(nodeManager.cesiumPlusNodes);
cubit.setGvaNodes(nodeManager.gvaNodes); cubit.setGvaNodes(nodeManager.gvaNodes);
cubit.setEndpointNodes(nodeManager.endpointNodes);
cubit.setDuniterIndexerNodes(nodeManager.duniterIndexerNodes);
} }
void setCurrentGvaNode(Node node) => cubit.setCurrentGvaNode(node); void setCurrentGvaNode(Node node) => cubit.setCurrentGvaNode(node);
......
enum NodeType { duniter, cesiumPlus, gva } enum NodeType { duniter, cesiumPlus, gva, endpoint, duniterIndexer }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment