From be01b239019ac88cff71f1156bc1875f4428dbc5 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 12 Sep 2021 07:12:24 +0200 Subject: [PATCH 01/11] Change to mono gva endpoint (not enough GVA endpoints available, and there probably won't be more given the substrate migration) --- lib/main.dart | 3 +- linux/.gitignore | 1 - linux/CMakeLists.txt | 106 ------------------- linux/flutter/CMakeLists.txt | 91 ---------------- linux/flutter/generated_plugin_registrant.cc | 13 --- linux/flutter/generated_plugin_registrant.h | 13 --- linux/flutter/generated_plugins.cmake | 16 --- linux/main.cc | 6 -- linux/my_application.cc | 104 ------------------ linux/my_application.h | 18 ---- 10 files changed, 2 insertions(+), 369 deletions(-) delete mode 100644 linux/.gitignore delete mode 100644 linux/CMakeLists.txt delete mode 100644 linux/flutter/CMakeLists.txt delete mode 100644 linux/flutter/generated_plugin_registrant.cc delete mode 100644 linux/flutter/generated_plugin_registrant.h delete mode 100644 linux/flutter/generated_plugins.cmake delete mode 100644 linux/main.cc delete mode 100644 linux/my_application.cc delete mode 100644 linux/my_application.h diff --git a/lib/main.dart b/lib/main.dart index f6f81a6..5a91e11 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,7 +51,8 @@ Future main() async { // await HiveStore.open(path: '${appPath.path}/gqlCache'); // Get a valid GVA endpoint - endPointGVA = await _homeProvider.getValidEndpoint(); + endPointGVA = 'https://g1.librelois.fr/gva'; + // await _homeProvider.getValidEndpoint(); // if (endPointGVA == 'HS') { // _homeProvider.playSound('faché', 0.8); diff --git a/linux/.gitignore b/linux/.gitignore deleted file mode 100644 index d3896c9..0000000 --- a/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt deleted file mode 100644 index 88a58f4..0000000 --- a/linux/CMakeLists.txt +++ /dev/null @@ -1,106 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(runner LANGUAGES CXX) - -set(BINARY_NAME "gecko") -set(APPLICATION_ID "com.example.gecko") - -cmake_policy(SET CMP0063 NEW) - -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Configure build options. -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") -endif() - -# Compilation settings that should be applied to most targets. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_14) - target_compile_options(${TARGET} PRIVATE -Wall -Werror) - target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") - target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") -endfunction() - -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") - -# Flutter library and tool build rules. -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) - -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") - -# Application build -add_executable(${BINARY_NAME} - "main.cc" - "my_application.cc" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" -) -apply_standard_settings(${BINARY_NAME}) -target_link_libraries(${BINARY_NAME} PRIVATE flutter) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) -add_dependencies(${BINARY_NAME} flutter_assemble) -# Only the install-generated bundle's copy of the executable will launch -# correctly, since the resources must in the right relative locations. To avoid -# people trying to run the unbundled copy, put it in a subdirectory instead of -# the default top-level location. -set_target_properties(${BINARY_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" -) - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# By default, "installing" just makes a relocatable bundle in the build -# directory. -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -# Start with a clean build bundle directory every time. -install(CODE " - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") - " COMPONENT Runtime) - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -if(PLUGIN_BUNDLED_LIBRARIES) - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() diff --git a/linux/flutter/CMakeLists.txt b/linux/flutter/CMakeLists.txt deleted file mode 100644 index 6dc9705..0000000 --- a/linux/flutter/CMakeLists.txt +++ /dev/null @@ -1,91 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. - -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), -# which isn't available in 3.10. -function(list_prepend LIST_NAME PREFIX) - set(NEW_LIST "") - foreach(element ${${LIST_NAME}}) - list(APPEND NEW_LIST "${PREFIX}${element}") - endforeach(element) - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) -endfunction() - -# === Flutter Library === -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) -pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid) -pkg_check_modules(LZMA REQUIRED IMPORTED_TARGET liblzma) - -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "fl_basic_message_channel.h" - "fl_binary_codec.h" - "fl_binary_messenger.h" - "fl_dart_project.h" - "fl_engine.h" - "fl_json_message_codec.h" - "fl_json_method_codec.h" - "fl_message_codec.h" - "fl_method_call.h" - "fl_method_channel.h" - "fl_method_codec.h" - "fl_method_response.h" - "fl_plugin_registrar.h" - "fl_plugin_registry.h" - "fl_standard_message_codec.h" - "fl_standard_method_codec.h" - "fl_string_codec.h" - "fl_value.h" - "fl_view.h" - "flutter_linux.h" -) -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") -target_link_libraries(flutter INTERFACE - PkgConfig::GTK - PkgConfig::GLIB - PkgConfig::GIO - PkgConfig::BLKID - PkgConfig::LZMA -) -add_dependencies(flutter flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" - ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} -) diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 5235232..0000000 --- a/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated file. Do not edit. -// - -#include "generated_plugin_registrant.h" - -#include - -void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) printing_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "PrintingPlugin"); - printing_plugin_register_with_registrar(printing_registrar); -} diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index 9bf7478..0000000 --- a/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated file. Do not edit. -// - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake deleted file mode 100644 index c637089..0000000 --- a/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST - printing -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) diff --git a/linux/main.cc b/linux/main.cc deleted file mode 100644 index e7c5c54..0000000 --- a/linux/main.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include "my_application.h" - -int main(int argc, char** argv) { - g_autoptr(MyApplication) app = my_application_new(); - return g_application_run(G_APPLICATION(app), argc, argv); -} diff --git a/linux/my_application.cc b/linux/my_application.cc deleted file mode 100644 index a420ace..0000000 --- a/linux/my_application.cc +++ /dev/null @@ -1,104 +0,0 @@ -#include "my_application.h" - -#include -#ifdef GDK_WINDOWING_X11 -#include -#endif - -#include "flutter/generated_plugin_registrant.h" - -struct _MyApplication { - GtkApplication parent_instance; - char** dart_entrypoint_arguments; -}; - -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) - -// Implements GApplication::activate. -static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); - GtkWindow* window = - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - - // Use a header bar when running in GNOME as this is the common style used - // by applications and is the setup most users will be using (e.g. Ubuntu - // desktop). - // If running on X and not using GNOME then just use a traditional title bar - // in case the window manager does more exotic layout, e.g. tiling. - // If running on Wayland assume the header bar will work (may need changing - // if future cases occur). - gboolean use_header_bar = TRUE; -#ifdef GDK_WINDOWING_X11 - GdkScreen *screen = gtk_window_get_screen(window); - if (GDK_IS_X11_SCREEN(screen)) { - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { - use_header_bar = FALSE; - } - } -#endif - if (use_header_bar) { - GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "gecko"); - gtk_header_bar_set_show_close_button(header_bar, TRUE); - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); - } - else { - gtk_window_set_title(window, "gecko"); - } - - gtk_window_set_default_size(window, 1280, 720); - gtk_widget_show(GTK_WIDGET(window)); - - g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); - - FlView* view = fl_view_new(project); - gtk_widget_show(GTK_WIDGET(view)); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); - - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); - - gtk_widget_grab_focus(GTK_WIDGET(view)); -} - -// Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) { - MyApplication* self = MY_APPLICATION(application); - // Strip out the first argument as it is the binary name. - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); - - g_autoptr(GError) error = nullptr; - if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; - } - - g_application_activate(application); - *exit_status = 0; - - return TRUE; -} - -// Implements GObject::dispose. -static void my_application_dispose(GObject *object) { - MyApplication* self = MY_APPLICATION(object); - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); -} - -static void my_application_class_init(MyApplicationClass* klass) { - G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; -} - -static void my_application_init(MyApplication* self) {} - -MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - nullptr)); -} diff --git a/linux/my_application.h b/linux/my_application.h deleted file mode 100644 index 72271d5..0000000 --- a/linux/my_application.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FLUTTER_MY_APPLICATION_H_ -#define FLUTTER_MY_APPLICATION_H_ - -#include - -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, - GtkApplication) - -/** - * my_application_new: - * - * Creates a new Flutter-based application. - * - * Returns: a new #MyApplication. - */ -MyApplication* my_application_new(); - -#endif // FLUTTER_MY_APPLICATION_H_ From 1e728418a1c6c680995e24e65aef544a2c85bfe6 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 12 Sep 2021 07:15:51 +0200 Subject: [PATCH 02/11] Start hive integration --- .gitignore | 3 +++ lib/main.dart | 5 +++++ pubspec.lock | 4 ++-- pubspec.yaml | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0e4fa11..557066e 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,6 @@ packages/dubp_rs/lib/ffi.dart /target pubkeys.txt + +# Linux builds +linux/ diff --git a/lib/main.dart b/lib/main.dart index 5a91e11..c106d40 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -28,6 +28,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:gecko/screens/myWallets/walletsHome.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; +import 'package:hive/hive.dart'; import 'package:provider/provider.dart'; import 'package:flutter/foundation.dart'; import 'package:responsive_framework/responsive_framework.dart'; @@ -47,6 +48,10 @@ Future main() async { // _walletsProvider.getDefaultWallet(); appVersion = await _homeProvider.getAppVersion(); prefs = await SharedPreferences.getInstance(); + + Hive.init(appPath.path); + await Hive.openBox("walletBox"); + // final HiveStore _store = // await HiveStore.open(path: '${appPath.path}/gqlCache'); diff --git a/pubspec.lock b/pubspec.lock index 9f72618..e13954a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -349,12 +349,12 @@ packages: source: hosted version: "5.0.0" hive: - dependency: transitive + dependency: "direct main" description: name: hive url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.4" http: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 9b605a6..d92f9d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: sdk: flutter test: ^1.17.10 unorm_dart: ^0.2.0 + hive: ^2.0.4 flutter_icons: android: "ic_launcher" From d1ffe2a5dc050379b2698665918908cd04ab291d Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 5 Nov 2021 18:25:21 +0100 Subject: [PATCH 03/11] Add test for renaming first created derivation: failed state --- pubspec.lock | 130 +++++++++++++++++++------------------- pubspec.yaml | 70 ++++++++++---------- test_driver/app_test.dart | 33 ++++++++-- 3 files changed, 128 insertions(+), 105 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e13954a..b781f23 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "20.0.0" + version: "30.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "2.7.0" archive: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.3.0" async: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.3.5" clock: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: connectivity_plus url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.4.0" connectivity_plus_linux: dependency: transitive description: @@ -112,7 +112,7 @@ packages: name: connectivity_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.1" connectivity_plus_platform_interface: dependency: transitive description: @@ -133,14 +133,14 @@ packages: name: connectivity_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" convert: dependency: transitive description: name: convert url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" coverage: dependency: transitive description: @@ -154,7 +154,7 @@ packages: name: cross_file url: "https://pub.dartlang.org" source: hosted - version: "0.3.1+5" + version: "0.3.2" crypto: dependency: "direct main" description: @@ -168,7 +168,7 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.5.4" + version: "0.5.6" dubp: dependency: "direct main" description: @@ -189,14 +189,14 @@ packages: name: fast_base58 url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.2.1" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.2" file: dependency: transitive description: @@ -210,7 +210,7 @@ packages: name: file_utils url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" flutter: dependency: "direct main" description: flutter @@ -227,7 +227,7 @@ packages: name: flutter_launcher_icons url: "https://pub.dartlang.org" source: hosted - version: "0.9.0" + version: "0.9.2" flutter_logs: dependency: "direct main" description: @@ -241,7 +241,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.4" flutter_svg: dependency: "direct main" description: @@ -277,7 +277,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" globbing: dependency: transitive description: @@ -361,7 +361,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.0" + version: "0.13.4" http_multi_server: dependency: transitive description: @@ -382,28 +382,28 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.8" image_gallery_saver: dependency: "direct main" description: name: image_gallery_saver url: "https://pub.dartlang.org" source: hosted - version: "1.6.9" + version: "1.7.1" image_picker: dependency: "direct main" description: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.4" + version: "0.8.4+4" image_picker_for_web: dependency: transitive description: name: image_picker_for_web url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" image_picker_platform_interface: dependency: transitive description: @@ -424,14 +424,14 @@ packages: name: io url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.3" isolate: dependency: transitive description: name: isolate url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.1.1" jdenticon_dart: dependency: "direct main" description: @@ -459,7 +459,7 @@ packages: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" matcher: dependency: transitive description: @@ -480,7 +480,7 @@ packages: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" nested: dependency: transitive description: @@ -501,7 +501,7 @@ packages: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" normalize: dependency: transitive description: @@ -515,7 +515,7 @@ packages: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" package_info: dependency: "direct main" description: @@ -529,42 +529,42 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.3.0" package_info_plus_linux: dependency: transitive description: name: package_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.3" package_info_plus_macos: dependency: transitive description: name: package_info_plus_macos url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.3.0" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.2" package_info_plus_web: dependency: transitive description: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.4" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.4" path: dependency: transitive description: @@ -578,7 +578,7 @@ packages: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.5.1+1" path_parsing: dependency: transitive description: @@ -592,21 +592,21 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.6" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" path_provider_platform_interface: dependency: transitive description: @@ -620,21 +620,21 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.3" pdf: dependency: "direct main" description: name: pdf url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "3.6.1" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.11.1" permission_handler: dependency: "direct main" description: @@ -648,21 +648,21 @@ packages: name: permission_handler_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.6.1" + version: "3.7.0" petitparser: dependency: transitive description: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "4.3.0" + version: "4.4.0" pin_code_fields: dependency: "direct main" description: name: pin_code_fields url: "https://pub.dartlang.org" source: hosted - version: "6.0.2" + version: "6.1.0" platform: dependency: transitive description: @@ -676,7 +676,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" pool: dependency: transitive description: @@ -690,7 +690,7 @@ packages: name: printing url: "https://pub.dartlang.org" source: hosted - version: "5.5.0" + version: "5.6.0" process: dependency: transitive description: @@ -704,21 +704,21 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "6.0.1" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" qr: dependency: transitive description: name: qr url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" qrscan: dependency: "direct main" description: @@ -739,7 +739,7 @@ packages: name: responsive_framework url: "https://pub.dartlang.org" source: hosted - version: "0.1.4" + version: "0.1.5" rxdart: dependency: transitive description: @@ -753,35 +753,35 @@ packages: name: sentry url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "6.1.0" sentry_flutter: dependency: "direct main" description: name: sentry_flutter url: "https://pub.dartlang.org" source: hosted - version: "6.0.0" + version: "6.1.0" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.8" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_platform_interface: dependency: transitive description: @@ -795,21 +795,21 @@ packages: name: shared_preferences_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" shelf_packages_handler: dependency: transitive description: @@ -823,7 +823,7 @@ packages: name: shelf_static url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" shelf_web_socket: dependency: transitive description: @@ -898,7 +898,7 @@ packages: name: system_info url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" term_glyph: dependency: transitive description: @@ -954,7 +954,7 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.5" vector_math: dependency: transitive description: @@ -975,14 +975,14 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" webdriver: dependency: transitive description: @@ -1003,7 +1003,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.2.10" xdg_directories: dependency: transitive description: @@ -1017,7 +1017,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.3.0" + version: "5.3.1" yaml: dependency: transitive description: @@ -1027,4 +1027,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.14.0 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index d92f9d6..c9aa99b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,47 +11,47 @@ environment: sdk: ">=2.7.0 <3.0.0" dependencies: - flutter: - sdk: flutter + bubble: ^1.2.1 + crypto: ^3.0.1 dubp: path: packages/dubp_rs - flutter_launcher_icons: "^0.9.0" - qrscan: ^0.3.2 - permission_handler: ^8.1.6 - image_gallery_saver: ^1.6.9 - image_picker: ^0.8.4 - # graphql_flutter: ^4.0.1 #^3.1.0 - graphql_flutter: ^5.0.0 - provider: ^6.0.0 - truncate: ^3.0.1 - path_provider: ^2.0.3 - intl: ^0.17.0 - pin_code_fields: ^6.0.2 - http: ^0.13.0 - super_tooltip: ^1.0.1 - package_info: ^2.0.2 - xml: ^5.3.0 - pdf: ^3.5.0 - printing: ^5.5.0 - shared_preferences: ^2.0.7 - sync_http: ^0.3.0 - crypto: ^3.0.1 fast_base58: ^0.2.0 - logger: ^1.1.0 - flutter_logs: ^2.1.4 - sentry: ^6.0.0 - sentry_flutter: ^6.0.0 - bubble: ^1.2.1 - flutter_svg: ^0.22.0 - responsive_framework: ^0.1.4 - responsive_builder: ^0.4.1 - jdenticon_dart: ^2.0.0 - # audioplayers: ^0.18.1 + flutter: + sdk: flutter flutter_driver: sdk: flutter - test: ^1.17.10 - unorm_dart: ^0.2.0 + flutter_launcher_icons: ^0.9.0 + flutter_logs: ^2.1.4 + flutter_svg: ^0.22.0 + graphql_flutter: ^5.0.0 hive: ^2.0.4 + http: ^0.13.0 + image_gallery_saver: ^1.6.9 + image_picker: ^0.8.4 + intl: ^0.17.0 + jdenticon_dart: ^2.0.0 + logger: ^1.1.0 + package_info: ^2.0.2 + path_provider: ^2.0.3 + pdf: ^3.5.0 + permission_handler: 8.1.6 + pin_code_fields: ^6.0.2 + printing: ^5.5.0 + provider: ^6.0.0 + qrscan: ^0.3.2 + responsive_builder: ^0.4.1 + responsive_framework: ^0.1.4 + sentry: ^6.0.0 + sentry_flutter: ^6.0.0 + shared_preferences: ^2.0.7 + super_tooltip: ^1.0.1 + sync_http: ^0.3.0 + test: ^1.17.10 + # test_api: ^0.4.7 + # test: ^1.19.3 + truncate: ^3.0.1 + unorm_dart: ^0.2.0 + xml: ^5.3.0 flutter_icons: android: "ic_launcher" diff --git a/test_driver/app_test.dart b/test_driver/app_test.dart index 0083329..7bcf48b 100644 --- a/test_driver/app_test.dart +++ b/test_driver/app_test.dart @@ -254,13 +254,32 @@ void main() { "Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !"); }); - test('My wallets - Create a derivations, open thems, tap all buttons', ( - {timeout: Timeout.none}) async { + test('My wallets - Rename first derivation', ( + {timeout: const Duration(seconds: 2)}) async { await tapOn('goWalletHome'); expect(await getText('myWallets'), "Mes portefeuilles"); await sleep(300); + // Go to first derivation and rename it + await driver.tap(find.text('Mon portefeuille courant')); + await sleep(300); + await tapOn('renameWallet'); + await sleep(100); + await tapOn('walletName'); + await sleep(100); + await driver.enterText('Renommage wallet 1'); + await sleep(300); + await tapOn('renameWallet'); + await sleep(400); + await driver.waitFor(find.text('Renommage wallet 1'), timeout: timeout); + // expect(await getText('walletName'), "Renommage wallet 1"); + await goBack(); + }); + + test('My wallets - Create a derivations, open thems, tap all buttons', ( + {timeout: const Duration(seconds: 2)}) async { + await driver.waitFor(find.text('Renommage wallet 1'), timeout: timeout); // Add a second derivation await createDerivation('Derivation 2'); @@ -301,8 +320,10 @@ void main() { await deleteWallet(true); }); - test('My wallets - Extra tests', ({timeout: Timeout.none}) async { + test('My wallets - Extra tests', ( + {timeout: const Duration(seconds: 2)}) async { // Add derivation 5,6 and 7 + await driver.waitFor(find.text('Derivation 4'), timeout: timeout); await createDerivation('Derivation 5'); await createDerivation('Derivation 6'); await createDerivation('Derivation 7'); @@ -377,7 +398,8 @@ void main() { }); test('Search - Search Pi profile, navigate in history transactions', ( - {timeout: Timeout.none}) async { + {timeout: const Duration(seconds: 2)}) async { + await driver.waitFor(find.text('Derivation 20'), timeout: timeout); await goBack(); await goBack(); await sleep(200); @@ -408,7 +430,8 @@ void main() { }, timeout: Timeout(Duration(minutes: globalTimeout))); test('Wallet generation - Fast wallets generations', ( - {timeout: Timeout.none}) async { + {timeout: const Duration(seconds: 2)}) async { + await driver.waitFor(find.text('Commentaire:'), timeout: timeout); await goBack(); await goBack(); await deleteAllWallets(); From b3efa766d6628ea18eaf00821d286dba2db13c08 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 5 Nov 2021 19:37:19 +0100 Subject: [PATCH 04/11] Fix renamming first derivation --- lib/models/walletOptions.dart | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index b3dc420..35953ee 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -136,20 +136,15 @@ class WalletOptionsProvider with ChangeNotifier { String newConfig = await _walletConfig.readAsLines().then((List lines) { - int nbrLines = lines.length; - if (nbrLines != 1) { - for (String wLine in lines) { - String wID = "${wLine.split(':')[0]}:${wLine.split(':')[1]}"; - String deri = wLine.split(':')[3]; - if (wID == _walletID) { - lines.remove(wLine); - lines.add('$_walletID:$_newName:$deri'); - } + for (String wLine in lines) { + String wID = "${wLine.split(':')[0]}:${wLine.split(':')[1]}"; + String deri = wLine.split(':')[3]; + if (wID == _walletID) { + lines.remove(wLine); + lines.add('$_walletID:$_newName:$deri'); } - return lines.join('\n'); - } else { - return 'true'; } + return lines.join('\n'); }); await _walletConfig.delete(); From 574cb50f82efce734e1f22618e8a93eff8628f5e Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 6 Nov 2021 03:34:48 +0100 Subject: [PATCH 05/11] WIP: Migrate test_driver to integration_test --- integration_test/app_test_integration.dart | 447 +++++++++++++++++++++ lib/screens/myWallets/walletsHome.dart | 1 + pubspec.lock | 5 + pubspec.yaml | 4 +- 4 files changed, 456 insertions(+), 1 deletion(-) create mode 100644 integration_test/app_test_integration.dart diff --git a/integration_test/app_test_integration.dart b/integration_test/app_test_integration.dart new file mode 100644 index 0000000..eeec460 --- /dev/null +++ b/integration_test/app_test_integration.dart @@ -0,0 +1,447 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:gecko/main.dart' as app; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + int globalTimeout = 2; + group( + 'Gecko end-to-end tests', + () { + // First, define the Finders and use them to locate widgets from the + // test suite. Note: the Strings provided to the `byValueKey` method must + // be the same as the Strings we used for the Keys in step 1. + // final manageWalletsFinder = find.byKey(Key('manageWallets')); + // final buttonFinder = find.byValueKey('increment'); + + // FlutterDriver driver; + WidgetTester tester; + String pinCode; + + // *** Global functions *** // + + // Easy get text + Future getText(String text) async { + Text resultText = tester.firstWidget(find.byKey(Key(text))); + // Text pinCodeText = generatedPinFinder.evaluate().single.widget as Text; + + return resultText.data; + } + + // Function to tap the widget by key + Future tapOn(String key) async { + await tester.tap(find.byKey(Key(key))); + } + + // Function to go back to previous screen + Future goBack() async { + await Process.run( + 'adb', + ['shell', 'input', 'keyevent', 'KEYCODE_BACK'], + runInShell: true, + ); + } + + // Easy sleep + Future sleep(int _time) async { + await Future.delayed(Duration(milliseconds: _time)); + } + + // Test if widget exist on screen, return a boolean + Future isPresent(String text, + {Duration timeout = const Duration(seconds: 1)}) async { + try { + expect(text, findsOneWidget); + return true; + } catch (exception) { + return false; + } + } + + // Create a derivation + Future createDerivation(String _name) async { + await tapOn('addDerivation'); + await sleep(100); + + await tester.enterText(find.byKey(Key('DerivationNameKey')), _name); + + await tapOn('validDerivation'); + await sleep(300); + } + + // Delete a derivation + Future deleteWallet(bool _confirm) async { + await tapOn('deleteWallet'); + await sleep(100); + _confirm + ? await tapOn('confirmDeleting') + : await tapOn('cancelDeleting'); + await sleep(300); + } + + // Delete all wallets + Future deleteAllWallets() async { + await tester.tap(find.byKey(Key('drawerMenu'))); + await sleep(300); + await tester.tap(find.byKey(Key('parameters'))); + await sleep(300); + await tester.tap(find.byKey(Key('deleteAllWallets'))); + await sleep(300); + await tester.tap(find.byKey(Key('confirmDeletingAllWallets'))); + await sleep(300); + } + + // Fast creation of new Keychain + Future createNewKeychain(String name) async { + await tapOn('drawerMenu'); + await sleep(300); + await tapOn('parameters'); + await sleep(300); + await tapOn('generateKeychain'); + expect(find.text(''), findsOneWidget); + + pinCode = await getText('generatedPin'); + + await tapOn('storeKeychain'); + await sleep(100); + await tester.enterText(find.byKey(Key('askedWord')), 'triche'); + await tapOn('walletName'); + await tester.enterText(find.byKey(Key('walletName')), 'name'); + await tapOn('confirmStorage'); + await sleep(300); + return pinCode; + } + + // *** Begin of tests *** // + + testWidgets('OnBoarding - Open wallets management', ( + WidgetTester tester, { + timeout: Timeout.none, + }) async { + app.main(); + await tester.pumpAndSettle(); + + // expect("y'a pas de lézard !", findsOneWidget); + await tester.tap(find.byKey(Key('manageWallets'))); + + print( + '####################################################################'); + + // If a wallet exist, go to delete theme all + await tester.pumpAndSettle(); + if (!await isPresent( + "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.")) { + await tester.pumpAndSettle(); + // await tester.pageBack(); + await goBack(); + + await sleep(500); + await deleteAllWallets(); + + await sleep(300); + await tester.tap(find.byKey(Key('manageWallets'))); + } + + await tester.pumpAndSettle(); + + // Verify onboarding is starting, with text + expect( + "Je ne connais pour l’instant aucun de vos portefeuilles.\n\nVous pouvez en créer un nouveau, ou bien importer un portefeuille Cesium existant.", + findsOneWidget); + }); + + // test('OnBoarding - Go to create restore sentance', ( + // {timeout: Timeout.none}) async { + // await tapOn('goStep1'); + // await tapOn('goStep2'); + // await tapOn('goStep3'); + // await tapOn('goStep4'); + // await tapOn('goStep5'); + // await tapOn('goStep6'); + + // expect( + // "J’ai généré votre phrase de restauration !\nTâchez de la garder bien secrète, car elle permet à quiconque la connaît d’accéder à tous vos portefeuilles.", + // findsOneWidget); + // }); + + // test('OnBoarding - Generate sentance and confirme it', ( + // {timeout: Timeout.none}) async { + // await tapOn('goStep7'); + + // await tester.pumpAndSettle(); + + // Future selectWord() async { + // List words = [for (var i = 1; i <= 13; i += 1) i]; + + // for (var j = 1; j < 13; j++) { + // words[j] = await getText('word$j'); + // } + // expect(await getText('step7'), + // "C'est le moment de noter votre phrase !"); + + // await tapOn('goStep8'); + // await sleep(200); + + // String goodWord = words[int.parse( + // await getText('askedWord'), + // )]; + + // // Enter the expected word + // await tester.enterText(find.byKey(Key('inputWord')), goodWord); + + // // Check if word is valid + // expect(find.text("C'est le bon mot !"), findsOneWidget); + + // // Continue onboarding workflow + // await tapOn('goStep9'); + // } + + // await selectWord(); + + // //Go back 2 times to mnemonic generation screen + // await goBack(); + // await goBack(); + // await sleep(100); + + // // Generate 3 times mnemonic + // await tapOn('generateMnemonic'); + // await tapOn('generateMnemonic'); + // await tapOn('generateMnemonic'); + // await sleep(500); + + // await selectWord(); + // }); + // test('OnBoarding - Generate secret code and confirm it', ( + // {timeout: Timeout.none}) async { + // expect(await getText('step9'), + // "Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole."); + + // await tapOn('goStep10'); + // await tapOn('goStep11'); + + // while (await getText('generatedPin') == '') { + // print('Waiting for pin code generation...'); + // await sleep(100); + // } + + // // Change secret code 4 times + // for (int i = 0; i < 4; i++) await tapOn('changeSecretCode'); + + // await sleep(500); + // pinCode = await getText('generatedPin'); + + // await tapOn('goStep12'); + // await sleep(300); + + // // //Enter bad secret code + // // await tester.enterText('abcde'); + // // await tapOn('formKey'); + // // await sleep(1500); + // // await tapOn('formKey2'); + + // //Enter good secret code + // await tester.enterText(find.byKey(Key('formKey2')), pinCode); + + // expect(await getText('step13'), + // "Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !"); + // }); + + // test('My wallets - Rename first derivation', ( + // {timeout: const Duration(seconds: 2)}) async { + // await tapOn('goWalletHome'); + + // expect(await getText('myWallets'), "Mes portefeuilles"); + // await sleep(300); + + // // Go to first derivation and rename it + // await tester.tap(find.text('Mon portefeuille courant')); + // await sleep(300); + // await tapOn('renameWallet'); + // await sleep(100); + // await tapOn('walletName'); + // await sleep(100); + // await tester.enterText( + // find.byKey(Key('walletName')), 'Renommage wallet 1'); + // await sleep(300); + // await tapOn('renameWallet'); + // await sleep(400); + // expect('Renommage wallet 1', findsOneWidget); + // await goBack(); + // }); + + // test('My wallets - Create a derivations, open thems, tap all buttons', ( + // {timeout: const Duration(seconds: 2)}) async { + // expect('Renommage wallet 1', findsOneWidget); + + // // Add a second derivation + // await createDerivation('Derivation 2'); + + // // Go to second derivation options + // await tester.tap(find.text('Derivation 2')); + // await sleep(100); + + // // Test options + // await tapOn('displayBalance'); + // await tapOn('displayHistory'); + // await sleep(300); + // await goBack(); + // await tapOn('displayBalance'); + // await sleep(100); + // await tapOn('displayBalance'); + // await sleep(100); + // await tapOn('displayBalance'); + // await tapOn('setDefaultWallet'); + // await sleep(50); + // await tapOn('copyPubkey'); + // expect('Cette clé publique a été copié dans votre presse-papier.', + // findsOneWidget); + // await goBack(); + + // // Add a third derivation + // await createDerivation('Derivation 3'); + + // // Add a fourth derivation + // await createDerivation('Derivation 4'); + // await sleep(50); + + // // Go to third derivation options + // await tester.tap(find.text('Derivation 3')); + // await sleep(100); + // await tapOn('displayBalance'); + + // // Delete third derivation + // await deleteWallet(true); + // }); + + // test('My wallets - Extra tests', ( + // {timeout: const Duration(seconds: 2)}) async { + // // Add derivation 5,6 and 7 + // expect('Derivation 4', findsOneWidget); + // await createDerivation('Derivation 5'); + // await createDerivation('Derivation 6'); + // await createDerivation('Derivation 7'); + + // // Go home and come back to my wallets view + // await goBack(); + // await sleep(100); + // await tapOn('manageWallets'); + // await sleep(200); + // //Enter secret code + // await tester.enterText(find.byKey(Key('formKey')), pinCode); + // await sleep(200); + + // // Go to derivation 6 and delete it + // await tester.tap(find.text('Derivation 6')); + // await sleep(100); + // await deleteWallet(true); + + // // Go to 2nd derivation and check if it's de default + // await tester.tap(find.text('Derivation 2')); + // expect('Ce portefeuille est celui par defaut', findsOneWidget); + // await tapOn('setDefaultWallet'); + // await sleep(100); + // expect('Ce portefeuille est celui par defaut', findsOneWidget); + // await sleep(300); + + // // Display history, copy pubkey, go back and rename wallet name + // await tapOn('displayHistory'); + // await sleep(400); + // await tapOn('copyPubkey'); + // expect('Cette clé publique a été copié dans votre presse-papier.', + // findsOneWidget); + // await sleep(800); + // await goBack(); + // await sleep(300); + // await tapOn('renameWallet'); + // await sleep(100); + // await tapOn('walletName'); + // await sleep(100); + // await tester.enterText( + // find.byKey(Key('walletName')), 'Renommage wallet 2'); + // await sleep(300); + // await tapOn('renameWallet'); + // await sleep(400); + // await goBack(); + // expect('Renommage wallet 2', findsOneWidget); + // await createDerivation('Derivation 8'); + // await createDerivation('Derivation 9'); + // await createDerivation('Derivation 10'); + // await createDerivation('Derivation 11'); + // await createDerivation('Derivation 12'); + // await createDerivation('Derivation 13'); + // await createDerivation('Derivation 14'); + // await createDerivation('Derivation 15'); + // await createDerivation('Derivation 16'); + // await createDerivation('Derivation 17'); + // await createDerivation('Derivation 18'); + // await createDerivation('Derivation 19'); + // await createDerivation('Derivation 20'); + // await sleep(400); + + // // Scroll the wallet screen until Derivation 20 and open it + // await tester.scrollUntilVisible(find.byKey(Key('listWallets')), -300.0); + + // expect('Derivation 20', findsOneWidget); + // await sleep(400); + // await tester.tap(find.text('Derivation 20')); + // await tapOn('copyPubkey'); + // }); + + // test('Search - Search Pi profile, navigate in history transactions', ( + // {timeout: const Duration(seconds: 2)}) async { + // expect('Derivation 20', findsOneWidget); + // await goBack(); + // await goBack(); + // await sleep(200); + // await tapOn('searchIcon'); + // await sleep(400); + // await tester.enterText(find.byKey(Key('searchInput')), + // 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'); + // await sleep(100); + // await tapOn('copyPubkey'); + // await sleep(500); + // await tapOn('switchPayHistory'); + // await sleep(1200); + // // await tester.scrollIntoView(find.byValueKey('listTransactions')); + // await tester.scrollUntilVisible( + // find.byKey(Key('listTransactions')), + // -600.0, + // ); + // await sleep(100); + // await tapOn('transaction33'); + // expect('Commentaire:', findsOneWidget); + + // // Want to paste pubkey copied, but doesn't work actualy with flutter driver: https://github.com/flutter/flutter/issues/47448 + // // final ClipboardData pubkeyCopied = + // // await Clipboard.getData(Clipboard.kTextPlain); + // // await tester.enterText(pubkeyCopied.text); + + // await sleep(300); + // }, timeout: Timeout(Duration(minutes: globalTimeout))); + + // test('Wallet generation - Fast wallets generations', ( + // {timeout: const Duration(seconds: 2)}) async { + // expect('Commentaire:', findsOneWidget); + // await goBack(); + // await goBack(); + // await deleteAllWallets(); + // await sleep(100); + // final String pincode = await createNewKeychain('Fast wallet'); + // await sleep(100); + // await tapOn('manageWallets'); + // await sleep(200); + // await tester.enterText(find.byKey(Key('formKey')), pinCode); + // await sleep(100); + // await createDerivation('Derivation 2'); + // await sleep(100); + // await tester.tap(find.text('Fast wallet')); + // expect('Fast wallet', findsOneWidget); + // // Wait 3 seconds at the end + // await sleep(3000); + // }); + }, + ); +} diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index dbd5234..7241b6a 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -216,6 +216,7 @@ class WalletsHome extends StatelessWidget { Padding( padding: EdgeInsets.all(8.0), child: TextFormField( + key: Key('DerivationNameKey'), controller: _newDerivationName, textAlign: TextAlign.center, autofocus: true, diff --git a/pubspec.lock b/pubspec.lock index b781f23..e964108 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -411,6 +411,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.1" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" intl: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index c9aa99b..104c88c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: Pay with G1. # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.2+6 +version: 0.0.2+7 environment: sdk: ">=2.7.0 <3.0.0" @@ -62,6 +62,8 @@ flutter_icons: dev_dependencies: flutter_test: sdk: flutter + integration_test: + sdk: flutter # The following section is specific to Flutter. flutter: From e14f55746ef144d0ab824a31e5da4c7135f94c32 Mon Sep 17 00:00:00 2001 From: poka Date: Sat, 6 Nov 2021 20:19:27 +0100 Subject: [PATCH 06/11] Fix appbar color --- android/app/src/main/AndroidManifest.xml | 9 --------- ...ntegration.dart => app_test_integration.dart.disable} | 0 lib/main.dart | 4 ++++ pubspec.yaml | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) rename integration_test/{app_test_integration.dart => app_test_integration.dart.disable} (100%) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3600761..f366490 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -29,15 +29,6 @@ android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> - - diff --git a/integration_test/app_test_integration.dart b/integration_test/app_test_integration.dart.disable similarity index 100% rename from integration_test/app_test_integration.dart rename to integration_test/app_test_integration.dart.disable diff --git a/lib/main.dart b/lib/main.dart index c106d40..6d930ec 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -147,6 +147,10 @@ class Gecko extends StatelessWidget { background: Container(color: Color(0xFFF5F5F5))), title: 'Ğecko', theme: ThemeData( + appBarTheme: AppBarTheme( + color: const Color(0xffFFD58D), + foregroundColor: const Color(0xFF000000), + ), primaryColor: Color(0xffFFD58D), textTheme: TextTheme( bodyText1: TextStyle(), diff --git a/pubspec.yaml b/pubspec.yaml index 104c88c..4402017 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,7 +36,7 @@ dependencies: pdf: ^3.5.0 permission_handler: 8.1.6 pin_code_fields: ^6.0.2 - printing: ^5.5.0 + printing: ^5.6.0 provider: ^6.0.0 qrscan: ^0.3.2 responsive_builder: ^0.4.1 From 5296ab107b7f6f394b334cf2e0b3b7c994529c23 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 7 Nov 2021 04:21:51 +0100 Subject: [PATCH 07/11] dubp: ignore classes with only static members --- packages/dubp_rs/lib/dubp.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/dubp_rs/lib/dubp.dart b/packages/dubp_rs/lib/dubp.dart index 80b663f..b6d1d30 100644 --- a/packages/dubp_rs/lib/dubp.dart +++ b/packages/dubp_rs/lib/dubp.dart @@ -67,6 +67,7 @@ enum WalletType { bip32Ed25519, } +// ignore: avoid_classes_with_only_static_members /// DUBP Rust utilities /// /// All the functions of this package are static methods of this From 0c55cdc14130d46c2d7c4ee263fc0a0e3d72c1e2 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 7 Nov 2021 04:23:05 +0100 Subject: [PATCH 08/11] WIP: remplace file storage with Hive boxes storage --- lib/globals.dart | 9 +- lib/main.dart | 16 +- lib/models/changePin.dart | 12 +- lib/models/generateWallets.dart | 42 +--- lib/models/history.dart | 7 +- lib/models/home.dart | 12 -- lib/models/myWallets.dart | 187 ++++-------------- lib/models/walletData.dart | 36 ++++ lib/models/walletData.g.dart | 50 +++++ lib/models/walletOptions.dart | 77 ++------ lib/screens/home.dart | 6 + .../myWallets/confirmWalletStorage.dart | 4 +- lib/screens/myWallets/unlockingWallet.dart | 2 +- lib/screens/myWallets/walletOptions.dart | 5 +- lib/screens/myWallets/walletsHome.dart | 1 + lib/screens/onBoarding/12.dart | 4 +- pubspec.lock | 147 ++++++++++++++ pubspec.yaml | 3 + 18 files changed, 329 insertions(+), 291 deletions(-) create mode 100644 lib/models/walletData.dart create mode 100644 lib/models/walletData.g.dart diff --git a/lib/globals.dart b/lib/globals.dart index 5110f28..9a29df7 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -1,19 +1,20 @@ import 'dart:io'; -import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletData.dart'; +import 'package:hive/hive.dart'; import 'package:logger/logger.dart'; import 'package:shared_preferences/shared_preferences.dart'; // Files paths Directory appPath; -Directory walletsDirectory; -File defaultWalletFile; -File currentChestFile; WalletData defaultWallet; String appVersion; SharedPreferences prefs; String endPointGVA; int ramSys; +Box walletBox; +Box chestBox; +Box configBox; // String cesiumPod = "https://g1.data.le-sou.org"; String cesiumPod = "https://g1.data.e-is.pro"; diff --git a/lib/main.dart b/lib/main.dart index 6d930ec..b04164d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -22,13 +22,15 @@ import 'package:gecko/models/generateWallets.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/home.dart'; import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:gecko/models/walletOptions.dart'; import 'package:gecko/screens/home.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:gecko/screens/myWallets/walletsHome.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; -import 'package:hive/hive.dart'; +import 'package:hive_flutter/hive_flutter.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:flutter/foundation.dart'; import 'package:responsive_framework/responsive_framework.dart'; @@ -41,16 +43,18 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); HomeProvider _homeProvider = HomeProvider(); - MyWalletsProvider _walletsProvider = MyWalletsProvider(); - await _homeProvider.getAppPath(); + appPath = await getApplicationDocumentsDirectory(); await _homeProvider.createDefaultAvatar(); - await _walletsProvider.initWalletFolder(); // _walletsProvider.getDefaultWallet(); appVersion = await _homeProvider.getAppVersion(); prefs = await SharedPreferences.getInstance(); - Hive.init(appPath.path); - await Hive.openBox("walletBox"); + // Configure Hive and open boxes + await Hive.initFlutter(appPath.path); + Hive.registerAdapter(WalletDataAdapter()); + walletBox = await Hive.openBox("walletBox"); + chestBox = await Hive.openBox("chestBox"); + configBox = await Hive.openBox("configBox"); // final HiveStore _store = // await HiveStore.open(path: '${appPath.path}/gqlCache'); diff --git a/lib/models/changePin.dart b/lib/models/changePin.dart index 06fd9b5..5af359a 100644 --- a/lib/models/changePin.dart +++ b/lib/models/changePin.dart @@ -1,4 +1,3 @@ -import 'dart:io'; import 'package:dubp/dubp.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -13,9 +12,7 @@ class ChangePinProvider with ChangeNotifier { Future changePin(_name, _oldPin) async { try { - final _walletFile = Directory('${walletsDirectory.path}/$_name'); - final _dewif = - File(_walletFile.path + '/wallet.dewif').readAsLinesSync()[0]; + final _dewif = chestBox.get(0); NewWallet newWalletFile = await DubpRust.changeDewifPin( dewif: _dewif, @@ -32,12 +29,9 @@ class ChangePinProvider with ChangeNotifier { } } - Future storeWallet(context, _name, _newWalletFile) async { - final Directory walletNameDirectory = - Directory('${walletsDirectory.path}/$_name'); - final walletFile = File('${walletNameDirectory.path}/wallet.dewif'); + Future storeWallet(context, _name, NewWallet _newWalletFile) async { + chestBox.put(0, _newWalletFile.dewif); - walletFile.writeAsString('${_newWalletFile.dewif}'); Navigator.pop(context); return _name; } diff --git a/lib/models/generateWallets.dart b/lib/models/generateWallets.dart index 19e13d9..8899751 100644 --- a/lib/models/generateWallets.dart +++ b/lib/models/generateWallets.dart @@ -1,4 +1,3 @@ -import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; import 'package:dubp/dubp.dart'; @@ -6,6 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:pdf/pdf.dart'; import 'package:pdf/widgets.dart' as pw; import 'package:printing/printing.dart'; @@ -38,40 +38,14 @@ class GenerateWalletsProvider with ChangeNotifier { bool canImport = false; bool isPinChanged = false; - Future storeHDWChest( + void storeHDWChest( NewWallet _wallet, String _name, BuildContext context) async { - // Directory walletDirectory; - - final Directory hdDirectory = Directory('${walletsDirectory.path}/0'); - await hdDirectory.create(); - - final configFile = File('${hdDirectory.path}/list.conf'); - File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf'); - - final dewifFile = File('${hdDirectory.path}/wallet.dewif'); - - // List _lastConfig = []; - // _lastConfig = await masterConfigFile.readAsLines(); - // final int _lastDerivation = int.parse(_lastConfig.last.split(':')[2]); - // final int _derivationNbr = _lastDerivation + 3; - - final int _derivationNbr = 3; - List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys( - dewif: _wallet.dewif, - secretCode: _wallet.pin, - accountsIndex: [_derivationNbr]); - String _pubkey = _pubkeysTmp[0]; - - await configFile.writeAsString('0:0:$_name:$_derivationNbr:$_pubkey'); - await dewifFile.writeAsString(_wallet.dewif); - bool isCurrentChestExist = _currentChestFile.existsSync(); - if (isCurrentChestExist) { - await _currentChestFile.delete(); - } - await _currentChestFile.create(); - await _currentChestFile.writeAsString('0'); - - return _name; + WalletData myWallet = + WalletData(chest: 0, number: 0, name: _name, derivation: 3); + walletBox.add(myWallet); + chestBox.put(0, _wallet.dewif); + configBox.put('currentChest', 0); + // walletBox.get(1) } void checkAskedWord(String inputWord, String _mnemo) { diff --git a/lib/models/history.dart b/lib/models/history.dart index ff5dd77..9be347c 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:dubp/dubp.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -52,10 +50,7 @@ class HistoryProvider with ChangeNotifier { Future pay(BuildContext context, String pinCode) async { // MyWalletsProvider _myWalletProvider = MyWalletsProvider(); - List dewifList = await File( - walletsDirectory.path + '/${defaultWallet.chest}/wallet.dewif') - .readAsLines(); - String dewif = dewifList[0]; + String dewif = chestBox.get(0); try { await DubpRust.simplePaymentFromTransparentAccount( accountIndex: defaultWallet.derivation, diff --git a/lib/models/home.dart b/lib/models/home.dart index a39fec1..1b67d41 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -11,7 +11,6 @@ import 'package:gecko/globals.dart'; import 'package:gecko/screens/history.dart'; import 'package:gecko/screens/myWallets/walletsHome.dart'; import 'package:package_info/package_info.dart'; -import 'package:path_provider/path_provider.dart'; class HomeProvider with ChangeNotifier { int _currentIndex = 0; @@ -100,17 +99,6 @@ class HomeProvider with ChangeNotifier { return _endpoint; } - Future getAppPath() async { - appPath = await getApplicationDocumentsDirectory(); - walletsDirectory = Directory('${appPath.path}/wallets'); - - bool isWalletFolderExist = await walletsDirectory.exists(); - - if (!isWalletFolderExist) { - await Directory(walletsDirectory.path).create(); - } - } - Future createDefaultAvatar() async { File defaultAvatar = File(appPath.path + '/default_avatar.png'); final bool isAvatarExist = await defaultAvatar.exists(); diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index 6b64310..6191ffd 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -1,8 +1,8 @@ -import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:provider/provider.dart'; class MyWalletsProvider with ChangeNotifier { @@ -10,42 +10,12 @@ class MyWalletsProvider with ChangeNotifier { String pinCode; int pinLenght; - Future initWalletFolder() async { - // getDefaultWallet(); - - final bool isWalletFolderExist = await walletsDirectory.exists(); - if (!isWalletFolderExist) { - await Directory(walletsDirectory.path).create(); - } - - File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf'); - - await _currentChestFile.create(); - await _currentChestFile.writeAsString('0'); - - final bool isChestsExist = - await Directory('${walletsDirectory.path}/0').exists(); - if (!isChestsExist) { - await Directory('${walletsDirectory.path}/0').create(); - await Directory('${walletsDirectory.path}/1').create(); - await File('${walletsDirectory.path}/0/list.conf').create(); - await File('${walletsDirectory.path}/0/order.conf').create(); - await File('${walletsDirectory.path}/1/list.conf').create(); - await File('${walletsDirectory.path}/1/order.conf').create(); - // getDefaultWallet(); - } - await getDefaultWalletAsync(); - } - int getCurrentChest() { - File _currentChestFile = File('${walletsDirectory.path}/currentChest.conf'); - - bool isCurrentChestExist = _currentChestFile.existsSync(); - if (!isCurrentChestExist) { - _currentChestFile.createSync(); - _currentChestFile.writeAsString('0'); + if (configBox.get('currentChest') == null) { + configBox.put('currentChest', 0); } - return int.parse(_currentChestFile.readAsStringSync()); + + return configBox.get('currentChest'); } bool checkIfWalletExist() { @@ -63,89 +33,50 @@ class MyWalletsProvider with ChangeNotifier { } } - List readAllWallets(int _chest) { - // log.d(walletsDirectory.path); - - listWallets = []; - - File _walletConfig = File('${walletsDirectory.path}/$_chest/list.conf'); - _walletConfig.readAsLinesSync().forEach((element) { - listWallets.add(WalletData(element)); + List readAllWallets(int _chest) { + walletBox.toMap().forEach((key, value) { + if (value.chest == _chest) { + listWallets.add(value); + } }); - log.i(listWallets.toString()); return listWallets; } - WalletData getWalletData(String _id) { - // log.d(_id); - if (_id == '') return WalletData(''); - int chest = int.parse(_id.split(':')[0]); - final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf'); + WalletData getWalletData(List _id) { + if (_id.isEmpty) return WalletData(); + int _chest = _id[0]; + int _nbr = _id[1]; - return WalletData(_walletConfig - .readAsLinesSync() - .firstWhere((element) => element.startsWith(_id))); - } + walletBox.toMap().forEach((key, value) { + if (value.chest == _chest && value.number == _nbr) { + return value; + } + }); - Future getWalletDataAsync(String _id) async { - // log.d(_id); - if (_id == '') return WalletData(''); - int chest = int.parse(_id.split(':')[0]); - final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf'); - - List configLines = await _walletConfig.readAsLines(); - //log.d(configLines); - - if (configLines.isEmpty) { - return WalletData(''); - } - - return WalletData( - configLines.firstWhere((element) => element.startsWith(_id))); + return WalletData(); } void getDefaultWallet() { - defaultWalletFile = File('${appPath.path}/defaultWallet'); - - if (!defaultWalletFile.existsSync()) { - File(defaultWalletFile.path).createSync(); - defaultWalletFile.writeAsStringSync("0:0"); - } - - defaultWallet = getWalletData(defaultWalletFile.readAsStringSync()); - } - - Future getDefaultWalletAsync() async { - defaultWalletFile = File('${appPath.path}/defaultWallet'); - - if (!await defaultWalletFile.exists()) { - await File(defaultWalletFile.path).create(); - await defaultWalletFile.writeAsString("0:0"); - } else { - defaultWallet = - await getWalletDataAsync(await defaultWalletFile.readAsString()); + if (configBox.get('defaultWallet') == null) { + configBox.put('defaultWallet', [0, 0]); } + defaultWallet = configBox.get('defaultWallet'); } Future deleteAllWallet(context) async { MyWalletsProvider _myWalletProvider = Provider.of(context, listen: false); try { - log.w('DELETE THAT ?: $walletsDirectory'); + log.w('DELETE ALL WALLETS ?'); final bool _answer = await _confirmDeletingAllWallets(context); if (_answer) { - await walletsDirectory.delete(recursive: true); - await defaultWalletFile.delete(); - await walletsDirectory.create(); - await initWalletFolder(); - // await Future.delayed(Duration(milliseconds: 500)); - // scheduleMicrotask(() { + await walletBox.clear(); + await chestBox.clear(); notifyListeners(); rebuildWidget(); _myWalletProvider.rebuildWidget(); - // }); Navigator.pop(context); } @@ -187,27 +118,26 @@ class MyWalletsProvider with ChangeNotifier { Future generateNewDerivation(context, String _name) async { int _newDerivationNbr; int _newWalletNbr; - final _walletConfig = File('${walletsDirectory.path}/0/list.conf'); + int _chest = 0; + List _walletConfig = readAllWallets(_chest); - if (await _walletConfig.readAsString() == '') { + if (_walletConfig.isEmpty) { _newDerivationNbr = 3; _newWalletNbr = 0; } else { - String _lastWallet = - await _walletConfig.readAsLines().then((value) => value.last); - int _lastDerivation = int.parse(_lastWallet.split(':')[3]); - _newDerivationNbr = _lastDerivation + 3; - - int _lastWalletNbr = int.parse(_lastWallet.split(':')[1]); - _newWalletNbr = _lastWalletNbr + 1; + _newDerivationNbr = _walletConfig.last.derivation + 3; + _newWalletNbr = _walletConfig.last.number + 1; } - await _walletConfig.writeAsString( - '\n0:$_newWalletNbr:$_name:$_newDerivationNbr', - mode: FileMode.append); + WalletData newWallet = WalletData( + chest: _chest, + number: _newWalletNbr, + name: _name, + derivation: _newDerivationNbr); + + await walletBox.add(newWallet); notifyListeners(); - Navigator.pop(context); } @@ -215,44 +145,3 @@ class MyWalletsProvider with ChangeNotifier { notifyListeners(); } } - -// wallet data contains elements identifying wallet -class WalletData { - int chest; - int number; - String name; - int derivation; - - // constructor from ':'-separated string - WalletData(String element) { - if (element != '') { - List parts = element.split(':'); - - this.chest = int.parse(parts[0]); - this.number = int.parse(parts[1]); - this.name = parts[2]; - this.derivation = int.parse(parts[3]); - } - } - - // default wallet - static WalletData defaultWallet() { - return WalletData("0:0:default:3"); - } - - // representation of WalletData when debugging - @override - String toString() { - return this.name; - } - - // creates the ':'-separated string from the WalletData - String inLine() { - return "${this.chest}:${this.number}:${this.name}:${this.derivation}"; - } - - // returns only the id part of the ':'-separated string - String id() { - return "${this.chest}:${this.number}"; - } -} diff --git a/lib/models/walletData.dart b/lib/models/walletData.dart new file mode 100644 index 0000000..c1fbdde --- /dev/null +++ b/lib/models/walletData.dart @@ -0,0 +1,36 @@ +import 'package:hive_flutter/hive_flutter.dart'; + +part 'walletData.g.dart'; + +@HiveType(typeId: 0) +class WalletData extends HiveObject { + @HiveField(0) + int chest; + + @HiveField(1) + int number; + + @HiveField(2) + String name; + + @HiveField(3) + int derivation; + + WalletData({this.chest, this.number, this.name, this.derivation}); + + // representation of WalletData when debugging + @override + String toString() { + return this.name; + } + + // creates the ':'-separated string from the WalletData + String inLine() { + return "${this.chest}:${this.number}:${this.name}:${this.derivation}"; + } + + // returns only the id part of the ':'-separated string + List id() { + return [this.chest, this.number]; + } +} diff --git a/lib/models/walletData.g.dart b/lib/models/walletData.g.dart new file mode 100644 index 0000000..3182ec0 --- /dev/null +++ b/lib/models/walletData.g.dart @@ -0,0 +1,50 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'walletData.dart'; + +// ************************************************************************** +// TypeAdapterGenerator +// ************************************************************************** + +class WalletDataAdapter extends TypeAdapter { + @override + final int typeId = 0; + + @override + WalletData read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + return WalletData( + chest: fields[0] as int, + number: fields[1] as int, + name: fields[2] as String, + derivation: fields[3] as int, + ); + } + + @override + void write(BinaryWriter writer, WalletData obj) { + writer + ..writeByte(4) + ..writeByte(0) + ..write(obj.chest) + ..writeByte(1) + ..write(obj.number) + ..writeByte(2) + ..write(obj.name) + ..writeByte(3) + ..write(obj.derivation); + } + + @override + int get hashCode => typeId.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is WalletDataAdapter && + runtimeType == other.runtimeType && + typeId == other.typeId; +} diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 35953ee..35c9cda 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:image_picker/image_picker.dart'; import 'package:truncate/truncate.dart'; import 'package:qrscan/qrscan.dart' as scanner; @@ -23,7 +24,7 @@ class WalletOptionsProvider with ChangeNotifier { bool isBalanceBlur = true; FocusNode walletNameFocus = FocusNode(); TextEditingController nameController = TextEditingController(); - String walletID; + List walletID; bool isDefaultWallet; Future get badWallet => null; @@ -75,14 +76,8 @@ class WalletOptionsProvider with ChangeNotifier { context, WalletData _wallet, String _pin, int _pinLenght) async { isWalletUnlock = false; try { - File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif'); - String _localDewif = await _walletFile.readAsString(); + String _localDewif = chestBox.get(0); String _localPubkey; - // log.d("$_localDewif $_pin $_pinLenght ${_wallet.derivation}"); - - // String mnemo = await DubpRust.getBip32DewifMnemonic( - // dewif: _localDewif, secretCode: _pin); - // log.d(mnemo.toString()); if ((_localPubkey = await _getPubkeyFromDewif( _localDewif, _pin, _pinLenght, _wallet.derivation)) != @@ -119,8 +114,7 @@ class WalletOptionsProvider with ChangeNotifier { int getPinLenght(_walletNbr) { String _localDewif; if (_walletNbr is int) { - File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif'); - _localDewif = _walletFile.readAsStringSync(); + _localDewif = chestBox.get(0); } else { _localDewif = _walletNbr; } @@ -131,24 +125,13 @@ class WalletOptionsProvider with ChangeNotifier { return _pinLenght; } - Future _renameWallet(_walletID, _newName) async { - final _walletConfig = File('${walletsDirectory.path}/0/list.conf'); + Future _renameWallet(List _walletID, _newName) async { + MyWalletsProvider myWalletClass = MyWalletsProvider(); - String newConfig = - await _walletConfig.readAsLines().then((List lines) { - for (String wLine in lines) { - String wID = "${wLine.split(':')[0]}:${wLine.split(':')[1]}"; - String deri = wLine.split(':')[3]; - if (wID == _walletID) { - lines.remove(wLine); - lines.add('$_walletID:$_newName:$deri'); - } - } - return lines.join('\n'); - }); + WalletData _walletTarget = myWalletClass.getWalletData(_walletID); + _walletTarget.name = _newName; + await walletBox.putAt(_walletTarget.key, _walletTarget); - await _walletConfig.delete(); - await _walletConfig.writeAsString(newConfig); _newWalletName.text = ''; } @@ -193,7 +176,7 @@ class WalletOptionsProvider with ChangeNotifier { ); } - Future editWalletName(_wID) async { + Future editWalletName(List _wID) async { bool nameState; if (isEditing) { if (!nameController.text.contains(':') && @@ -213,27 +196,12 @@ class WalletOptionsProvider with ChangeNotifier { return nameState; } - Future deleteWallet(context, wallet) async { + Future deleteWallet(context, WalletData wallet) async { final bool _answer = await _confirmDeletingWallet(context, wallet.name); if (_answer) { - final _walletConfig = File('${walletsDirectory.path}/0/list.conf'); + walletBox.delete(wallet.key); - if (wallet.derivation != -1) { - String newConfig = - await _walletConfig.readAsLines().then((List lines) { - lines.removeWhere((element) => element.contains(wallet.inLine())); - - return lines.join('\n'); - }); - - await _walletConfig.delete(); - await _walletConfig.writeAsString(newConfig); - } else { - final _walletFile = - Directory('${walletsDirectory.path}/${wallet.number}'); - await _walletFile.delete(recursive: true); - } Navigator.popUntil( context, ModalRoute.withName('/mywallets'), @@ -278,9 +246,7 @@ class WalletOptionsProvider with ChangeNotifier { Future changePin(_name, _oldPin) async { try { - final _walletFile = Directory('${walletsDirectory.path}/$_name'); - final _dewif = - File(_walletFile.path + '/wallet.dewif').readAsLinesSync()[0]; + final _dewif = chestBox.get(0); NewWallet newWalletFile = await DubpRust.changeDewifPin( dewif: _dewif, @@ -297,16 +263,6 @@ class WalletOptionsProvider with ChangeNotifier { } } - Future storeWallet(context, _name, _newWalletFile) async { - final Directory walletNameDirectory = - Directory('${walletsDirectory.path}/$_name'); - final walletFile = File('${walletNameDirectory.path}/wallet.dewif'); - - walletFile.writeAsString('${_newWalletFile.dewif}'); - Navigator.pop(context); - return _name; - } - snackCopyKey(context) { final snackBar = SnackBar( content: @@ -341,13 +297,6 @@ class WalletOptionsProvider with ChangeNotifier { return await scanner.generateBarCode(_pubkey); } - void defAsDefaultWallet(String _id) { - defaultWalletFile.deleteSync(); - defaultWalletFile.createSync(); - defaultWalletFile.writeAsStringSync(_id); - notifyListeners(); - } - Future changeAvatar() async { File _image; final picker = ImagePicker(); diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 1d349a8..f645ebb 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -22,6 +22,12 @@ class HomeScreen extends StatelessWidget { Provider.of(context); final bool isWalletsExists = _myWalletProvider.checkIfWalletExist(); + // walletBox.toMap().forEach((key, value) { + // if (value.chest == 0) { + // print('$key: ${value.derivation}'); + // } + // }); + isTall = false; ratio = 1; if (MediaQuery.of(context).size.height >= 930) { diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirmWalletStorage.dart index 614d071..fcac81a 100644 --- a/lib/screens/myWallets/confirmWalletStorage.dart +++ b/lib/screens/myWallets/confirmWalletStorage.dart @@ -134,8 +134,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { onPressed: (_generateWalletProvider .isAskedWordValid && this.walletName.text != '') - ? () async { - await _generateWalletProvider.storeHDWChest( + ? () { + _generateWalletProvider.storeHDWChest( generatedWallet, walletName.text, context); diff --git a/lib/screens/myWallets/unlockingWallet.dart b/lib/screens/myWallets/unlockingWallet.dart index 1efba3c..6b3022f 100644 --- a/lib/screens/myWallets/unlockingWallet.dart +++ b/lib/screens/myWallets/unlockingWallet.dart @@ -1,9 +1,9 @@ import 'dart:async'; - import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:gecko/models/walletOptions.dart'; import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart index 03944c5..d077f91 100644 --- a/lib/screens/myWallets/walletOptions.dart +++ b/lib/screens/myWallets/walletOptions.dart @@ -5,6 +5,7 @@ import 'package:gecko/globals.dart'; import 'package:gecko/models/history.dart'; import 'package:gecko/models/myWallets.dart'; import 'package:gecko/models/queries.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:gecko/models/walletOptions.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:provider/provider.dart'; @@ -44,7 +45,7 @@ class WalletOptions extends StatelessWidget { if (_walletOptions.nameController.text.length >= 26 && isTall) _nbrLinesName = 3; - _walletOptions.walletID = '0:${wallet.number}'; + _walletOptions.walletID = [0, wallet.number]; _myWalletProvider.getDefaultWallet(); @@ -361,7 +362,7 @@ class WalletOptions extends StatelessWidget { onTap: !_walletOptions.isDefaultWallet ? () { defaultWallet = wallet; - _walletOptions.defAsDefaultWallet(wallet.id()); + configBox.put('defaultWallet', wallet.id()); _myWalletProvider.readAllWallets(_currentChest); } : null, diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index 7241b6a..a4a5819 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -1,6 +1,7 @@ import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/myWallets.dart'; +import 'package:gecko/models/walletData.dart'; import 'package:gecko/models/walletOptions.dart'; import 'package:flutter/material.dart'; import 'package:gecko/screens/commonElements.dart'; diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index 8755f57..732b22a 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -119,10 +119,10 @@ class OnboardingStepFourteen extends StatelessWidget { generatedWallet.dewif, _pin.toUpperCase(), _pinLenght); if (resultWallet) { pinColor = Colors.green[500]; - await _generateWalletProvider.storeHDWChest( + _generateWalletProvider.storeHDWChest( generatedWallet, 'Mon portefeuille courant', context); _myWalletProvider.readAllWallets(_currentChest); - await _myWalletProvider.getDefaultWalletAsync(); + _myWalletProvider.getDefaultWallet(); scheduleMicrotask(() { _walletOptions.reloadBuild(); _myWalletProvider.rebuildWidget(); diff --git a/pubspec.lock b/pubspec.lock index e964108..ee51741 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + build_runner: + dependency: "direct dev" + description: + name: build_runner + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + url: "https://pub.dartlang.org" + source: hosted + version: "7.2.2" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.1.3" characters: dependency: transitive description: @@ -71,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" cli_util: dependency: transitive description: @@ -85,6 +148,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" collection: dependency: transitive description: @@ -162,6 +232,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.1" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.0" dbus: dependency: transitive description: @@ -211,6 +288,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" flutter: dependency: "direct main" description: flutter @@ -348,6 +432,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.0" + graphs: + dependency: transitive + description: + name: graphs + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" hive: dependency: "direct main" description: @@ -355,6 +446,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" + hive_flutter: + dependency: "direct main" + description: + name: hive_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + hive_generator: + dependency: "direct dev" + description: + name: hive_generator + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" http: dependency: "direct main" description: @@ -451,6 +556,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.3.0" logger: dependency: "direct main" description: @@ -717,6 +829,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" qr: dependency: transitive description: @@ -841,6 +960,20 @@ packages: description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" + source_helper: + dependency: transitive + description: + name: source_helper + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" source_map_stack_trace: dependency: transitive description: @@ -876,6 +1009,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" string_scanner: dependency: transitive description: @@ -932,6 +1072,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.0" + timing: + dependency: transitive + description: + name: timing + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" truncate: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 4402017..d6fbafd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: flutter_svg: ^0.22.0 graphql_flutter: ^5.0.0 hive: ^2.0.4 + hive_flutter: ^1.1.0 http: ^0.13.0 image_gallery_saver: ^1.6.9 image_picker: ^0.8.4 @@ -64,6 +65,8 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter + hive_generator: ^1.1.1 + build_runner: ^2.1.2 # The following section is specific to Flutter. flutter: From 6c1fb477998a5f89d3915124ac877b216649ca49 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 7 Nov 2021 06:50:09 +0100 Subject: [PATCH 09/11] Hive migration complete (a few refresh state bugs to fix) --- lib/models/myWallets.dart | 19 ++++++++++++------- lib/screens/myWallets/unlockingWallet.dart | 2 +- lib/screens/myWallets/walletOptions.dart | 2 +- lib/screens/myWallets/walletsHome.dart | 11 ++++++----- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index 6191ffd..ac10889 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; import 'package:gecko/models/walletData.dart'; -import 'package:provider/provider.dart'; class MyWalletsProvider with ChangeNotifier { List listWallets = []; @@ -34,6 +33,7 @@ class MyWalletsProvider with ChangeNotifier { } List readAllWallets(int _chest) { + listWallets.clear(); walletBox.toMap().forEach((key, value) { if (value.chest == _chest) { listWallets.add(value); @@ -47,26 +47,30 @@ class MyWalletsProvider with ChangeNotifier { if (_id.isEmpty) return WalletData(); int _chest = _id[0]; int _nbr = _id[1]; + var _targetedWallet; walletBox.toMap().forEach((key, value) { if (value.chest == _chest && value.number == _nbr) { - return value; + _targetedWallet = value; + return false; } }); - return WalletData(); + return _targetedWallet; } void getDefaultWallet() { + MyWalletsProvider myWalletsProvider = MyWalletsProvider(); + if (configBox.get('defaultWallet') == null) { configBox.put('defaultWallet', [0, 0]); } - defaultWallet = configBox.get('defaultWallet'); + + defaultWallet = myWalletsProvider + .getWalletData(configBox.get('defaultWallet').cast()); } Future deleteAllWallet(context) async { - MyWalletsProvider _myWalletProvider = - Provider.of(context, listen: false); try { log.w('DELETE ALL WALLETS ?'); @@ -74,9 +78,10 @@ class MyWalletsProvider with ChangeNotifier { if (_answer) { await walletBox.clear(); await chestBox.clear(); + await configBox.delete('defaultWallet'); + checkIfWalletExist(); notifyListeners(); rebuildWidget(); - _myWalletProvider.rebuildWidget(); Navigator.pop(context); } diff --git a/lib/screens/myWallets/unlockingWallet.dart b/lib/screens/myWallets/unlockingWallet.dart index 6b3022f..610edc2 100644 --- a/lib/screens/myWallets/unlockingWallet.dart +++ b/lib/screens/myWallets/unlockingWallet.dart @@ -34,7 +34,7 @@ class UnlockingWallet extends StatelessWidget { WalletOptionsProvider _walletOptions = Provider.of(context); - log.d("defaultWallet: " + defaultWallet.toString()); + // log.d("defaultWallet: " + defaultWallet.toString()); final int _pinLenght = _walletOptions.getPinLenght(wallet.number); errorController = StreamController(); diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart index d077f91..cd7eb8c 100644 --- a/lib/screens/myWallets/walletOptions.dart +++ b/lib/screens/myWallets/walletOptions.dart @@ -50,7 +50,7 @@ class WalletOptions extends StatelessWidget { _myWalletProvider.getDefaultWallet(); _walletOptions.isDefaultWallet = - (defaultWallet.id() == _walletOptions.walletID); + (defaultWallet.id()[1] == _walletOptions.walletID[1]); int currentChest = _myWalletProvider.getCurrentChest(); diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index a4a5819..03b0c25 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -166,9 +166,10 @@ class WalletsHome extends StatelessWidget { borderRadius: BorderRadius.vertical( bottom: Radius.circular(12))), // contentPadding: const EdgeInsets.only(left: 7.0), - tileColor: _repository.id() == defaultWallet.id() - ? Color(0xffD28928) - : Color(0xffFFD58D), + tileColor: + _repository.id()[1] == defaultWallet.id()[1] + ? Color(0xffD28928) + : Color(0xffFFD58D), // leading: Text('IMAGE'), // subtitle: Text(_repository.split(':')[3], @@ -181,8 +182,8 @@ class WalletsHome extends StatelessWidget { textAlign: TextAlign.center, style: TextStyle( fontSize: 16.0, - color: _repository.id() == - defaultWallet.id() + color: _repository.id()[1] == + defaultWallet.id()[1] ? Color(0xffF9F9F1) : Colors.black)))), // dense: true, From e4296bedd2a197d1678464f4dbfbe8a7ba4deb09 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 7 Nov 2021 07:25:15 +0100 Subject: [PATCH 10/11] Fix: State refresh when changing default wallet; State refresh whern deleting all wallets; Tests are OK --- lib/main.dart | 4 +++- lib/models/myWallets.dart | 3 --- lib/models/walletOptions.dart | 19 ------------------- lib/screens/myWallets/walletOptions.dart | 1 + lib/screens/settings.dart | 8 +++++++- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index b04164d..90bd4d4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -43,9 +43,9 @@ Future main() async { WidgetsFlutterBinding.ensureInitialized(); HomeProvider _homeProvider = HomeProvider(); + MyWalletsProvider _walletsProvider = MyWalletsProvider(); appPath = await getApplicationDocumentsDirectory(); await _homeProvider.createDefaultAvatar(); - // _walletsProvider.getDefaultWallet(); appVersion = await _homeProvider.getAppVersion(); prefs = await SharedPreferences.getInstance(); @@ -56,6 +56,8 @@ Future main() async { chestBox = await Hive.openBox("chestBox"); configBox = await Hive.openBox("configBox"); + _walletsProvider.getDefaultWallet(); + // final HiveStore _store = // await HiveStore.open(path: '${appPath.path}/gqlCache'); diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index ac10889..3cd63c4 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -79,9 +79,6 @@ class MyWalletsProvider with ChangeNotifier { await walletBox.clear(); await chestBox.clear(); await configBox.delete('defaultWallet'); - checkIfWalletExist(); - notifyListeners(); - rebuildWidget(); Navigator.pop(context); } diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 35c9cda..ba3da48 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -244,25 +244,6 @@ class WalletOptionsProvider with ChangeNotifier { ); } - Future changePin(_name, _oldPin) async { - try { - final _dewif = chestBox.get(0); - - NewWallet newWalletFile = await DubpRust.changeDewifPin( - dewif: _dewif, - oldPin: _oldPin, - ); - - newPin.text = newWalletFile.pin; - ischangedPin = true; - // notifyListeners(); - return newWalletFile; - } catch (e) { - log.e('Impossible de changer le code PIN.'); - return badWallet; - } - } - snackCopyKey(context) { final snackBar = SnackBar( content: diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart index cd7eb8c..121e7c1 100644 --- a/lib/screens/myWallets/walletOptions.dart +++ b/lib/screens/myWallets/walletOptions.dart @@ -364,6 +364,7 @@ class WalletOptions extends StatelessWidget { defaultWallet = wallet; configBox.put('defaultWallet', wallet.id()); _myWalletProvider.readAllWallets(_currentChest); + _myWalletProvider.rebuildWidget(); } : null, child: SizedBox( diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 56a2628..851a4c5 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:dubp/dubp.dart'; import 'package:flutter/services.dart'; +import 'package:gecko/models/home.dart'; import 'package:gecko/models/myWallets.dart'; import 'package:gecko/screens/myWallets/generateWallets.dart'; import 'dart:io'; import 'package:gecko/screens/myWallets/importWallet.dart'; import 'package:gecko/globals.dart'; +import 'package:provider/provider.dart'; // ignore: must_be_immutable class SettingsScreen extends StatelessWidget { @@ -25,6 +27,8 @@ class SettingsScreen extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + HomeProvider _homeProvider = Provider.of(context); + // getAppDirectory(); return Scaffold( appBar: AppBar( @@ -91,7 +95,9 @@ class SettingsScreen extends StatelessWidget { ), onPressed: () async => { log.i('Suppression de tous les wallets'), - await _myWallets.deleteAllWallet(context) + await _myWallets + .deleteAllWallet(context) + .then((v) => _homeProvider.rebuildWidget()) }, child: Text("EFFACER TOUS MES PORTEFEUILLES", style: TextStyle(fontSize: 20)))))), From 8963b50defbca979ad20158efbcbefc252abf864 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 8 Nov 2021 18:29:55 +0100 Subject: [PATCH 11/11] ci: version 0.0.8, switch to stable channel --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a437473..e92115c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ stages: - package .env: - image: axiomteam/gecko-ci:v0.0.7 + image: axiomteam/gecko-ci:v0.0.8 tags: - redshift before_script: