From ca85a45dd6d884dc5ded997be3d40cc1c4fce2a6 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 4 Apr 2021 18:53:32 +0200 Subject: [PATCH 1/5] Fix bug after creating keystore; fix bug when deleting wallet --- lib/models/myWallets.dart | 6 +++++- lib/models/walletOptions.dart | 6 ++---- lib/screens/myWallets/walletsHome.dart | 3 --- lib/screens/onBoarding/12.dart | 1 + pubspec.yaml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index 350c052..5f43a1b 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -97,6 +97,10 @@ class MyWalletsProvider with ChangeNotifier { List configLines = await _walletConfig.readAsLines(); log.d(configLines); + if (configLines.isEmpty) { + return WalletData(''); + } + return WalletData( configLines.firstWhere((element) => element.startsWith(_id))); } @@ -136,7 +140,7 @@ class MyWalletsProvider with ChangeNotifier { await walletsDirectory.create(); // await defaultWalletFile.create(); await initWalletFolder(); - await Future.delayed(Duration(milliseconds: 100)); + await Future.delayed(Duration(milliseconds: 500)); notifyListeners(); rebuildWidget(); Navigator.pop(context); diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 3ee1d97..4381cd0 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -78,15 +78,13 @@ class WalletOptionsProvider with ChangeNotifier { File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif'); String _localDewif = await _walletFile.readAsString(); String _localPubkey; - // log.d("_wallet:"); - log.d(_pin); + // log.d("$_localDewif $_pin $_pinLenght ${_wallet.derivation}"); if ((_localPubkey = await _getPubkeyFromDewif( _localDewif, _pin, _pinLenght, _wallet.derivation)) != 'false') { this.pubkey.text = _localPubkey; isWalletUnlock = true; - // notifyListeners(); return _localDewif; } else { @@ -95,7 +93,6 @@ class WalletOptionsProvider with ChangeNotifier { } catch (e) { log.e('ERROR READING FILE: $e'); this.pubkey.clear(); - // notifyListeners(); return 'bad'; } } @@ -320,6 +317,7 @@ class WalletOptionsProvider with ChangeNotifier { } String getShortPubkey(String pubkey) { + log.d(pubkey); List pubkeyByte = Base58Decode(pubkey); Digest pubkeyS256 = sha256.convert(sha256.convert(pubkeyByte).bytes); String pubkeyCheksum = Base58Encode(pubkeyS256.bytes); diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index ef02103..db25c18 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -18,9 +18,6 @@ class WalletsHome extends StatelessWidget { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); MyWalletsProvider myWalletProvider = Provider.of(context); - WalletOptionsProvider _walletOptions = - Provider.of(context); - _walletOptions.isWalletUnlock = false; final int _currentChest = myWalletProvider.getCurrentChest(); diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index 25cceb1..1999b09 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -110,6 +110,7 @@ class OnboardingStepFourteen extends StatelessWidget { ) ], onCompleted: (_pin) async { + _myWalletProvider.pinCode = _pin; final bool resultWallet = await _walletOptions.checkPinOK( generatedWallet.dewif, _pin.toUpperCase(), _pinLenght); if (resultWallet) { diff --git a/pubspec.yaml b/pubspec.yaml index 2eee357..8d692e1 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+1 +version: 0.0.2+2 environment: sdk: ">=2.7.0 <3.0.0" From 9d5f1daaa585bcfcba03f6e1cb159f0470c91e96 Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 4 Apr 2021 21:17:29 +0200 Subject: [PATCH 2/5] Fix sound in start --- lib/main.dart | 6 ++++++ lib/models/home.dart | 3 --- lib/models/walletOptions.dart | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index b03d66e..5cc481d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -53,6 +53,12 @@ Future main() async { // Get a valid GVA endpoint endPointGVA = await _homeProvider.getValidEndpoint(); + if (endPointGVA == 'HS') { + _homeProvider.playSound('faché'); + } else { + _homeProvider.playSound('start'); + } + if (kReleaseMode && enableSentry) { // CatcherOptions debugOptions = CatcherOptions(DialogReportMode(), [ // SentryHandler(SentryClient(SentryOptions( diff --git a/lib/models/home.dart b/lib/models/home.dart index 1ab7c03..42ec662 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -61,11 +61,8 @@ class HomeProvider with ChangeNotifier { int listLenght = _listEndpoints.length - 1; if (i > listLenght) { log.e('NO VALID GVA ENDPOINT FOUND'); - playSound('faché'); _endpoint = 'HS'; break; - } else { - playSound('start'); } if (i != 0) { await Future.delayed(const Duration(milliseconds: 300)); diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 4381cd0..55974fa 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -157,7 +157,7 @@ class WalletOptionsProvider with ChangeNotifier { context, _walletName, _walletNbr, _derivation) async { return showDialog( context: context, - barrierDismissible: true, // user must tap button! + barrierDismissible: true, builder: (BuildContext context) { return AlertDialog( title: Text('Choisissez un nouveau nom pour ce portefeuille'), From d65864225a683fc68f9b047549407ffe77fcf31f Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 5 Apr 2021 20:48:28 +0200 Subject: [PATCH 3/5] Fix bugs on wallet creation again ... --- lib/main.dart | 4 ++-- lib/models/home.dart | 8 ++++++-- lib/models/myWallets.dart | 17 +++++++---------- lib/models/walletOptions.dart | 6 +++++- lib/screens/myWallets/confirmWalletStorage.dart | 8 +++++++- lib/screens/myWallets/walletsHome.dart | 2 ++ lib/screens/onBoarding/12.dart | 7 +++++-- pubspec.yaml | 2 +- 8 files changed, 35 insertions(+), 19 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5cc481d..bb6931e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,9 +54,9 @@ Future main() async { endPointGVA = await _homeProvider.getValidEndpoint(); if (endPointGVA == 'HS') { - _homeProvider.playSound('faché'); + _homeProvider.playSound('faché', 0.7); } else { - _homeProvider.playSound('start'); + _homeProvider.playSound('start', 0.5); } if (kReleaseMode && enableSentry) { diff --git a/lib/models/home.dart b/lib/models/home.dart index 42ec662..0338ded 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -125,9 +125,9 @@ class HomeProvider with ChangeNotifier { notifyListeners(); } - void playSound(String customSound) async { + void playSound(String customSound, double volume) async { await player.play('$customSound.wav', - volume: 1, mode: PlayerMode.LOW_LATENCY, stayAwake: false); + volume: volume, mode: PlayerMode.LOW_LATENCY, stayAwake: false); } void handleSearchEnd() { @@ -143,4 +143,8 @@ class HomeProvider with ChangeNotifier { notifyListeners(); } + + void rebuildWidget() { + notifyListeners(); + } } diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart index 5f43a1b..7bc4e5f 100644 --- a/lib/models/myWallets.dart +++ b/lib/models/myWallets.dart @@ -129,20 +129,24 @@ class MyWalletsProvider with ChangeNotifier { } Future deleteAllWallet(context) async { + MyWalletsProvider _myWalletProvider = + Provider.of(context, listen: false); try { log.w('DELETE THAT ?: $walletsDirectory'); final bool _answer = await _confirmDeletingAllWallets(context); - if (_answer) { await walletsDirectory.delete(recursive: true); await defaultWalletFile.delete(); await walletsDirectory.create(); - // await defaultWalletFile.create(); await initWalletFolder(); - await Future.delayed(Duration(milliseconds: 500)); + // await Future.delayed(Duration(milliseconds: 500)); + // scheduleMicrotask(() { notifyListeners(); rebuildWidget(); + _myWalletProvider.rebuildWidget(); + // }); + Navigator.pop(context); } return 0; @@ -156,8 +160,6 @@ class MyWalletsProvider with ChangeNotifier { context: context, barrierDismissible: true, // user must tap button! builder: (BuildContext context) { - MyWalletsProvider _myWalletProvider = - Provider.of(context); return AlertDialog( title: Text('Êtes-vous sûr de vouloir supprimer tous vos trousseaux ?'), @@ -172,11 +174,6 @@ class MyWalletsProvider with ChangeNotifier { TextButton( child: Text("Oui"), onPressed: () { - WidgetsBinding.instance.addPostFrameCallback((_) { - _myWalletProvider.listWallets = - _myWalletProvider.readAllWallets(getCurrentChest()); - _myWalletProvider.rebuildWidget(); - }); Navigator.pop(context, true); }, ), diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart index 55974fa..5b43384 100644 --- a/lib/models/walletOptions.dart +++ b/lib/models/walletOptions.dart @@ -8,8 +8,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:gecko/globals.dart'; +import 'package:gecko/models/home.dart'; import 'package:gecko/models/myWallets.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:provider/provider.dart'; import 'package:truncate/truncate.dart'; import 'package:qrscan/qrscan.dart' as scanner; @@ -73,6 +75,8 @@ class WalletOptionsProvider with ChangeNotifier { Future readLocalWallet( context, WalletData _wallet, String _pin, int _pinLenght) async { + HomeProvider _homeProvider = + Provider.of(context, listen: false); isWalletUnlock = false; try { File _walletFile = File('${walletsDirectory.path}/0/wallet.dewif'); @@ -85,12 +89,12 @@ class WalletOptionsProvider with ChangeNotifier { 'false') { this.pubkey.text = _localPubkey; isWalletUnlock = true; - return _localDewif; } else { throw 'Bad pubkey'; } } catch (e) { + _homeProvider.playSound('non', 0.6); log.e('ERROR READING FILE: $e'); this.pubkey.clear(); return 'bad'; diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirmWalletStorage.dart index f8e817e..3669fae 100644 --- a/lib/screens/myWallets/confirmWalletStorage.dart +++ b/lib/screens/myWallets/confirmWalletStorage.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:dubp/dubp.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -140,8 +142,12 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier { _myWalletProvider.listWallets = _myWalletProvider .readAllWallets(_currentChest); - _myWalletProvider.rebuildWidget(); + scheduleMicrotask(() { + _myWalletProvider.rebuildWidget(); + }); }); + Navigator.popUntil( + context, ModalRoute.withName('/')); } : null, child: Text('Confirmer', diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart index db25c18..5105743 100644 --- a/lib/screens/myWallets/walletsHome.dart +++ b/lib/screens/myWallets/walletsHome.dart @@ -31,6 +31,8 @@ class WalletsHome extends StatelessWidget { myWalletProvider.getDefaultWallet(); } + log.d("${myWalletProvider.pinCode},${myWalletProvider.pinLenght}"); + return WillPopScope( onWillPop: () { Navigator.popUntil( diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart index 1999b09..7d10415 100644 --- a/lib/screens/onBoarding/12.dart +++ b/lib/screens/onBoarding/12.dart @@ -111,6 +111,7 @@ class OnboardingStepFourteen extends StatelessWidget { ], onCompleted: (_pin) async { _myWalletProvider.pinCode = _pin; + _myWalletProvider.pinLenght = _pinLenght; final bool resultWallet = await _walletOptions.checkPinOK( generatedWallet.dewif, _pin.toUpperCase(), _pinLenght); if (resultWallet) { @@ -118,9 +119,11 @@ class OnboardingStepFourteen extends StatelessWidget { await _generateWalletProvider.storeHDWChest( generatedWallet, 'Mon portefeuille courant', context); _myWalletProvider.readAllWallets(_currentChest); - _walletOptions.reloadBuild(); - _myWalletProvider.rebuildWidget(); await _myWalletProvider.getDefaultWalletAsync(); + scheduleMicrotask(() { + _walletOptions.reloadBuild(); + _myWalletProvider.rebuildWidget(); + }); Navigator.push( context, FaderTransition( diff --git a/pubspec.yaml b/pubspec.yaml index 8d692e1..268bca8 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+2 +version: 0.0.2+4 environment: sdk: ">=2.7.0 <3.0.0" From 8ff2c3d038fc18f2aa6b021b659d3cc10093596b Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 18 Apr 2021 02:31:47 +0200 Subject: [PATCH 4/5] Retrograde audioplayers for android < v5; Lower starting sound; Go to Sentry 5.0 --- lib/main.dart | 4 ++-- native/dubp_rs/Cargo.toml | 2 +- pubspec.lock | 48 ++++++++++++++++++++++++++++++++++++--- pubspec.yaml | 8 +++---- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index bb6931e..05d9d3a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -54,9 +54,9 @@ Future main() async { endPointGVA = await _homeProvider.getValidEndpoint(); if (endPointGVA == 'HS') { - _homeProvider.playSound('faché', 0.7); + _homeProvider.playSound('faché', 0.8); } else { - _homeProvider.playSound('start', 0.5); + _homeProvider.playSound('start', 0.2); } if (kReleaseMode && enableSentry) { diff --git a/native/dubp_rs/Cargo.toml b/native/dubp_rs/Cargo.toml index 0208e51..4cab015 100644 --- a/native/dubp_rs/Cargo.toml +++ b/native/dubp_rs/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "dubp_rs" -crate-type = ["rlib"] +crate-type = ["cdylib"] [dependencies] allo-isolate = "0.1.6" diff --git a/pubspec.lock b/pubspec.lock index ccf7556..caf3578 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: audioplayers url: "https://pub.dartlang.org" source: hosted - version: "0.18.3" + version: "0.18.0" barcode: dependency: transitive description: @@ -387,6 +387,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.3+2" + package_info_plus: + dependency: transitive + description: + name: package_info_plus + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + package_info_plus_linux: + dependency: transitive + description: + name: package_info_plus_linux + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + package_info_plus_macos: + dependency: transitive + description: + name: package_info_plus_macos + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.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" + package_info_plus_web: + dependency: transitive + description: + name: package_info_plus_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + package_info_plus_windows: + dependency: transitive + description: + name: package_info_plus_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" path: dependency: transitive description: @@ -561,14 +603,14 @@ packages: name: sentry url: "https://pub.dartlang.org" source: hosted - version: "4.1.0-nullsafety.0" + version: "5.0.0" sentry_flutter: dependency: "direct main" description: name: sentry_flutter url: "https://pub.dartlang.org" source: hosted - version: "4.0.4" + version: "5.0.0" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 268bca8..9a82c42 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+4 +version: 0.0.2+5 environment: sdk: ">=2.7.0 <3.0.0" @@ -39,14 +39,14 @@ dependencies: fast_base58: logger: ^1.0.0 flutter_logs: ^2.1.3 - sentry: ^4.0.4 - sentry_flutter: ^4.0.4 + sentry: ^5.0.0 + sentry_flutter: ^5.0.0 bubble: ^1.1.9+1 flutter_svg: ^0.20.0-nullsafety responsive_framework: ^0.0.14 responsive_builder: ^0.3.0 jdenticon_dart: ^2.0.0 - audioplayers: ^0.18.3 + audioplayers: 0.18.0 flutter_icons: android: "ic_launcher" From d3d4d15b444c41604cf673540fbf4d8dcef5f20b Mon Sep 17 00:00:00 2001 From: poka Date: Sun, 18 Apr 2021 13:27:45 +0200 Subject: [PATCH 5/5] audioplayer to version 0.18.1 --- native/dubp_rs/Cargo.toml | 2 +- pubspec.lock | 2 +- pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/dubp_rs/Cargo.toml b/native/dubp_rs/Cargo.toml index 4cab015..0208e51 100644 --- a/native/dubp_rs/Cargo.toml +++ b/native/dubp_rs/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [lib] name = "dubp_rs" -crate-type = ["cdylib"] +crate-type = ["rlib"] [dependencies] allo-isolate = "0.1.6" diff --git a/pubspec.lock b/pubspec.lock index caf3578..6d1b885 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -28,7 +28,7 @@ packages: name: audioplayers url: "https://pub.dartlang.org" source: hosted - version: "0.18.0" + version: "0.18.3" barcode: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9a82c42..89976f8 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+5 +version: 0.0.2+6 environment: sdk: ">=2.7.0 <3.0.0" @@ -46,7 +46,7 @@ dependencies: responsive_framework: ^0.0.14 responsive_builder: ^0.3.0 jdenticon_dart: ^2.0.0 - audioplayers: 0.18.0 + audioplayers: ^0.18.1 flutter_icons: android: "ic_launcher"