Merge branch 'implementTransactions'
This commit is contained in:
commit
21deb6b922
|
@ -1,4 +1,6 @@
|
|||
import 'dart:io';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
// Files paths
|
||||
|
@ -7,14 +9,18 @@ Directory walletsDirectory;
|
|||
File defaultWalletFile;
|
||||
File currentChestFile;
|
||||
|
||||
String defaultWallet;
|
||||
WalletData defaultWallet;
|
||||
String appVersion;
|
||||
SharedPreferences prefs;
|
||||
String endPointGVA;
|
||||
int ramSys;
|
||||
|
||||
String cesiumPod = "https://g1.data.le-sou.org";
|
||||
// String cesiumPod = "https://g1.data.le-sou.org";
|
||||
String cesiumPod = "https://g1.data.e-is.pro";
|
||||
|
||||
// Responsive ratios
|
||||
bool isTall;
|
||||
double ratio;
|
||||
|
||||
// Logger
|
||||
var log = Logger();
|
||||
|
|
|
@ -44,6 +44,7 @@ Future<void> main() async {
|
|||
await _homeProvider.getAppPath();
|
||||
await _homeProvider.createDefaultAvatar();
|
||||
await _walletsProvider.initWalletFolder();
|
||||
_walletsProvider.getDefaultWallet();
|
||||
appVersion = await _homeProvider.getAppVersion();
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
// final HiveStore _store =
|
||||
|
|
|
@ -68,7 +68,6 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
List queryOptions = await _buildQuery(_pubkey);
|
||||
final response = await http.post((Uri.parse(queryOptions[0])),
|
||||
body: queryOptions[1], headers: queryOptions[2]);
|
||||
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||
final responseJson = json.decode(response.body);
|
||||
if (responseJson['hits']['hits'].toString() == '[]') {
|
||||
return '';
|
||||
|
@ -79,7 +78,6 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
return '';
|
||||
}
|
||||
_name = responseJson['hits']['hits'][0]['_source']['title'];
|
||||
print(_name);
|
||||
|
||||
return _name;
|
||||
}
|
||||
|
@ -88,7 +86,6 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
List queryOptions = await _buildQuery(_pubkey);
|
||||
final response = await http.post((Uri.parse(queryOptions[0])),
|
||||
body: queryOptions[1], headers: queryOptions[2]);
|
||||
// print('RESULT CESIUM QUERY: ${response.body}'); //For debug
|
||||
final responseJson = json.decode(response.body);
|
||||
if (responseJson['hits']['hits'].toString() == '[]') {
|
||||
return [File(appPath.path + '/default_avatar.png')];
|
||||
|
@ -103,21 +100,10 @@ class CesiumPlusProvider with ChangeNotifier {
|
|||
|
||||
var avatarFile =
|
||||
File('${(await getTemporaryDirectory()).path}/avatar$iAvatar.png');
|
||||
// final bool _isAvatarExist = await avatarFile.exists();
|
||||
// if (_isAvatarExist) {
|
||||
// await avatarFile.delete();
|
||||
// }
|
||||
await avatarFile.writeAsBytes(base64.decode(_avatar));
|
||||
iAvatar++;
|
||||
isComplete = true;
|
||||
|
||||
return [avatarFile];
|
||||
}
|
||||
|
||||
// isNameComplete() {
|
||||
// while (isComplete == false) {
|
||||
// print(isComplete);
|
||||
// Duration(milliseconds: 50);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class ChangePinProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
return newWalletFile;
|
||||
} catch (e) {
|
||||
print('Impossible de changer le code PIN.');
|
||||
log.e('Impossible de changer le code PIN.');
|
||||
return badWallet;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class ChangePinProvider with ChangeNotifier {
|
|||
final Directory walletNameDirectory =
|
||||
Directory('${walletsDirectory.path}/$_name');
|
||||
final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
|
||||
print(_newWalletFile);
|
||||
|
||||
walletFile.writeAsString('${_newWalletFile.dewif}');
|
||||
Navigator.pop(context);
|
||||
|
|
|
@ -79,8 +79,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
|
||||
final runesAsked = _mnemo.split(' ')[nbrWord].runes;
|
||||
List<int> runesAskedUnaccent = [];
|
||||
print(runesAsked);
|
||||
print(value.runes);
|
||||
for (int i in runesAsked) {
|
||||
if (i == 768 || i == 769 || i == 770 || i == 771) {
|
||||
continue;
|
||||
|
@ -92,11 +90,11 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
utf8.decode(runesAskedUnaccent).toLowerCase();
|
||||
final String unaccentedInputWord = removeDiacritics(value).toLowerCase();
|
||||
|
||||
print("Is $unaccentedAskedWord equal to input $unaccentedInputWord ?");
|
||||
log.i("Is $unaccentedAskedWord equal to input $unaccentedInputWord ?");
|
||||
if (unaccentedAskedWord == unaccentedInputWord ||
|
||||
value == 'triche' ||
|
||||
value == '3.14') {
|
||||
print('Word is OK');
|
||||
log.d('Word is OK');
|
||||
isAskedWordValid = true;
|
||||
askedWordColor = Colors.green[600];
|
||||
// walletNameFocus.nextFocus();
|
||||
|
@ -155,7 +153,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
||||
walletIsGenerated = true;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
log.e(e);
|
||||
}
|
||||
return generatedMnemonic;
|
||||
}
|
||||
|
@ -168,7 +166,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
secretCodeType: SecretCodeType.letters,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
log.e(e);
|
||||
}
|
||||
|
||||
mnemonicController.text = generatedMnemonic;
|
||||
|
@ -240,7 +238,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
cesiumPubkey.text = _walletPubkey;
|
||||
pin.text = actualWallet.pin;
|
||||
isPinChanged = true;
|
||||
print(_walletPubkey);
|
||||
log.d(_walletPubkey);
|
||||
}
|
||||
|
||||
Future importWallet(context, _cesiumID, _cesiumPWD) async {
|
||||
|
@ -291,20 +289,13 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
int _nbr = 1;
|
||||
|
||||
for (word in _sentance.split(' ')) {
|
||||
// print(word);
|
||||
_wordsList.add("$_nbr:$word");
|
||||
_nbr++;
|
||||
}
|
||||
// notifyListeners();
|
||||
|
||||
return _wordsList;
|
||||
}
|
||||
|
||||
// void makeError() {
|
||||
// var tata = File(appPath.path + '/ddfhjftjfg');
|
||||
// tata.readAsLinesSync();
|
||||
// }
|
||||
|
||||
void reloadBuild() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dubp/dubp.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
|
@ -26,6 +29,8 @@ class HistoryProvider with ChangeNotifier {
|
|||
bool isHistoryScreen = false;
|
||||
String historySwitchButtun = "Voir l'historique";
|
||||
String rawSvg;
|
||||
TextEditingController payAmount = TextEditingController();
|
||||
TextEditingController payComment = TextEditingController();
|
||||
|
||||
Future scan(context) async {
|
||||
await Permission.camera.request();
|
||||
|
@ -33,7 +38,7 @@ class HistoryProvider with ChangeNotifier {
|
|||
try {
|
||||
barcode = await scanner.scan();
|
||||
} catch (e) {
|
||||
print(e);
|
||||
log.e(e);
|
||||
return 'false';
|
||||
}
|
||||
if (barcode != null) {
|
||||
|
@ -45,6 +50,29 @@ class HistoryProvider with ChangeNotifier {
|
|||
return barcode;
|
||||
}
|
||||
|
||||
Future<String> pay(BuildContext context, String pinCode) async {
|
||||
// MyWalletsProvider _myWalletProvider = MyWalletsProvider();
|
||||
List dewifList = await File(
|
||||
walletsDirectory.path + '/${defaultWallet.chest}/wallet.dewif')
|
||||
.readAsLines();
|
||||
String dewif = dewifList[0];
|
||||
try {
|
||||
await DubpRust.simplePaymentFromTransparentAccount(
|
||||
accountIndex: defaultWallet.derivation,
|
||||
amount: double.parse(payAmount.text),
|
||||
txComment: payComment.text,
|
||||
dewif: dewif,
|
||||
gvaEndpoint: endPointGVA,
|
||||
secretCode: pinCode,
|
||||
recipient: pubkey);
|
||||
return "Success";
|
||||
} catch (e) {
|
||||
log.e("ERROR DUBP PAYMENTS");
|
||||
log.e(e);
|
||||
return "Payments errors: $e";
|
||||
}
|
||||
}
|
||||
|
||||
String isPubkey(context, pubkey, {bool goHistory}) {
|
||||
HomeProvider _homeProvider =
|
||||
Provider.of<HomeProvider>(context, listen: false);
|
||||
|
@ -57,7 +85,7 @@ class HistoryProvider with ChangeNotifier {
|
|||
if (regExp.hasMatch(pubkey) == true &&
|
||||
pubkey.length > 42 &&
|
||||
pubkey.length < 45) {
|
||||
print("C'est une pubkey !!!");
|
||||
log.d("C'est une pubkey !!!");
|
||||
|
||||
this.pubkey = pubkey;
|
||||
getShortPubkey(pubkey);
|
||||
|
@ -105,6 +133,7 @@ class HistoryProvider with ChangeNotifier {
|
|||
return pubkeyShort;
|
||||
}
|
||||
|
||||
// poka: Do99s6wQR2JLfhirPdpAERSjNbmjjECzGxHNJMiNKT3P
|
||||
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
|
||||
// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn
|
||||
// Matograine portefeuille: 9p5nHsES6xujFR7pw2yGy4PLKKHgWsMvsDHaHF64Uj25.
|
||||
|
@ -142,8 +171,6 @@ class HistoryProvider with ChangeNotifier {
|
|||
final date = formatter.format(dateBrut);
|
||||
transBC[i].add(transaction['writtenTime']);
|
||||
transBC[i].add(date);
|
||||
// print(
|
||||
// "DEBUG date et comment: ${date.toString()} -- ${transaction['comment'].toString()}");
|
||||
final int amountBrut = int.parse(output.split(':')[0]);
|
||||
final base = int.parse(output.split(':')[1]);
|
||||
final int applyBase = base - currentBase;
|
||||
|
@ -176,9 +203,6 @@ class HistoryProvider with ChangeNotifier {
|
|||
pageInfo = result.data['txsHistoryBc']['both']['pageInfo'];
|
||||
|
||||
fetchMoreCursor = pageInfo['endCursor'];
|
||||
print('hasPreviousPage: ' + pageInfo['hasPreviousPage'].toString());
|
||||
print('hasNextPage: ' + pageInfo['hasNextPage'].toString());
|
||||
|
||||
if (fetchMoreCursor != null) {
|
||||
opts = FetchMoreOptions(
|
||||
variables: {'cursor': fetchMoreCursor},
|
||||
|
@ -196,12 +220,12 @@ class HistoryProvider with ChangeNotifier {
|
|||
);
|
||||
}
|
||||
|
||||
print(
|
||||
log.d(
|
||||
"###### DEBUG H Parse blockchainTX list. Cursor: $fetchMoreCursor ######");
|
||||
if (fetchMoreCursor != null) {
|
||||
transBC = parseHistory(blockchainTX, _pubkey);
|
||||
} else {
|
||||
print("###### DEBUG H - Début de l'historique");
|
||||
log.i("###### DEBUG H - Début de l'historique");
|
||||
}
|
||||
|
||||
return opts;
|
||||
|
|
|
@ -53,10 +53,10 @@ class HomeProvider with ChangeNotifier {
|
|||
|
||||
do {
|
||||
i++;
|
||||
print(i.toString() + ' ème essai de recherche de endpoint GVA.');
|
||||
print('Try GVA endpoint: ${_listEndpoints[i]}');
|
||||
log.d(i.toString() + ' ème essai de recherche de endpoint GVA.');
|
||||
log.d('Try GVA endpoint: ${_listEndpoints[i]}');
|
||||
if (i > 2) {
|
||||
print('NO VALID GVA ENDPOINT FOUND');
|
||||
log.e('NO VALID GVA ENDPOINT FOUND');
|
||||
_endpoint = 'HS';
|
||||
break;
|
||||
}
|
||||
|
@ -71,21 +71,21 @@ class HomeProvider with ChangeNotifier {
|
|||
_endpoint = _listEndpoints[i];
|
||||
_statusCode = response.statusCode;
|
||||
} on TimeoutException catch (_) {
|
||||
print('This endpoint is timeout, next');
|
||||
log.e('This endpoint is timeout, next');
|
||||
_statusCode = 50;
|
||||
continue;
|
||||
} on SocketException catch (_) {
|
||||
print('This endpoint is a bad endpoint, next');
|
||||
log.e('This endpoint is a bad endpoint, next');
|
||||
_statusCode = 70;
|
||||
continue;
|
||||
} on Exception {
|
||||
print('Unknown error');
|
||||
log.e('Unknown error');
|
||||
_statusCode = 60;
|
||||
continue;
|
||||
}
|
||||
} while (_statusCode != 400);
|
||||
|
||||
print('ENDPOINT: ' + _endpoint);
|
||||
log.i('ENDPOINT: ' + _endpoint);
|
||||
return _endpoint;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,12 @@ import 'package:gecko/globals.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyWalletsProvider with ChangeNotifier {
|
||||
String listWallets;
|
||||
List<WalletData> listWallets = [];
|
||||
String pinCode;
|
||||
int pinLenght;
|
||||
|
||||
Future initWalletFolder() async {
|
||||
getDefaultWallet();
|
||||
// getDefaultWallet();
|
||||
|
||||
final bool isWalletFolderExist = await walletsDirectory.exists();
|
||||
if (!isWalletFolderExist) {
|
||||
|
@ -30,6 +32,7 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,67 +52,61 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
final String _walletList = getAllWalletsNames(0);
|
||||
final List _walletList = readAllWallets(0);
|
||||
|
||||
if (_walletList == '') {
|
||||
print('No wallets detected');
|
||||
if (_walletList.isEmpty) {
|
||||
log.i('No wallets detected');
|
||||
return false;
|
||||
} else {
|
||||
print('Some wallets have been detected.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String getAllWalletsNames(int _chest) {
|
||||
if (listWallets != null && listWallets.isNotEmpty) {
|
||||
listWallets = '';
|
||||
}
|
||||
if (listWallets == null) {
|
||||
listWallets = '';
|
||||
}
|
||||
List readAllWallets(int _chest) {
|
||||
// log.d(walletsDirectory.path);
|
||||
|
||||
print(walletsDirectory.path);
|
||||
listWallets = [];
|
||||
|
||||
// int i = 0;
|
||||
File _walletConfig = File('${walletsDirectory.path}/$_chest/list.conf');
|
||||
_walletConfig.readAsLinesSync().forEach((element) {
|
||||
if (listWallets != '') {
|
||||
listWallets += '\n';
|
||||
}
|
||||
listWallets += element;
|
||||
// listWallets += "${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"
|
||||
listWallets.add(WalletData(element));
|
||||
});
|
||||
print(listWallets);
|
||||
|
||||
log.i(listWallets.toString());
|
||||
return listWallets;
|
||||
}
|
||||
|
||||
WalletData getWalletData(String _id) {
|
||||
int chest = int.parse(_id.split(':')[0]);
|
||||
final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf');
|
||||
|
||||
return WalletData(_walletConfig
|
||||
.readAsLinesSync()
|
||||
.firstWhere((element) => element.startsWith(_id)));
|
||||
}
|
||||
|
||||
void getDefaultWallet() {
|
||||
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
||||
|
||||
bool isdefaultWalletFile = defaultWalletFile.existsSync();
|
||||
|
||||
if (!isdefaultWalletFile) {
|
||||
if (!defaultWalletFile.existsSync()) {
|
||||
File(defaultWalletFile.path).createSync();
|
||||
defaultWalletFile.writeAsStringSync("0:0");
|
||||
}
|
||||
|
||||
try {
|
||||
defaultWallet = defaultWalletFile.readAsStringSync();
|
||||
} catch (e) {
|
||||
defaultWallet = '0:0';
|
||||
}
|
||||
if (defaultWallet == '') defaultWallet = '0:0';
|
||||
defaultWallet = getWalletData(defaultWalletFile.readAsStringSync());
|
||||
}
|
||||
|
||||
Future<int> deleteAllWallet(context) async {
|
||||
try {
|
||||
print('DELETE THAT ?: $walletsDirectory');
|
||||
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();
|
||||
notifyListeners();
|
||||
Navigator.pop(context);
|
||||
|
@ -143,7 +140,7 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
onPressed: () {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider.getAllWalletsNames(getCurrentChest());
|
||||
_myWalletProvider.readAllWallets(getCurrentChest());
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
Navigator.pop(context, true);
|
||||
|
@ -177,7 +174,6 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
'\n0:$_newWalletNbr:$_name:$_newDerivationNbr',
|
||||
mode: FileMode.append);
|
||||
|
||||
print(await _walletConfig.readAsString());
|
||||
notifyListeners();
|
||||
|
||||
Navigator.pop(context);
|
||||
|
@ -187,3 +183,37 @@ 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) {
|
||||
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]);
|
||||
}
|
||||
|
||||
// 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}";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
@ -7,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:truncate/truncate.dart';
|
||||
import 'package:qrscan/qrscan.dart' as scanner;
|
||||
|
@ -36,9 +38,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
);
|
||||
|
||||
if (regExp.hasMatch(_pin) == true && _pin.length == _pinLenght) {
|
||||
print("Le format du code PIN est correct.");
|
||||
} else {
|
||||
print('Format de code PIN invalide');
|
||||
return 'false';
|
||||
}
|
||||
if (derivation != -1) {
|
||||
|
@ -51,8 +51,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
|
||||
return _pubkey;
|
||||
} catch (e) {
|
||||
print('Bad PIN code !');
|
||||
print(e);
|
||||
log.w('Bad PIN code !\n' + e);
|
||||
notifyListeners();
|
||||
|
||||
return 'false';
|
||||
|
@ -64,8 +63,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
return _pubkey;
|
||||
} catch (e) {
|
||||
print('Bad PIN code !');
|
||||
print(e);
|
||||
log.w('Bad PIN code !\n' + e);
|
||||
notifyListeners();
|
||||
|
||||
return 'false';
|
||||
|
@ -74,15 +72,17 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
|
||||
Future readLocalWallet(
|
||||
int _walletNbr, String _pin, int _pinLenght, int derivation) async {
|
||||
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 _localPubkey;
|
||||
// log.d("_wallet:");
|
||||
log.d(_pin);
|
||||
|
||||
if ((_localPubkey = await _getPubkeyFromDewif(
|
||||
_localDewif, _pin, _pinLenght, derivation)) !=
|
||||
_localDewif, _pin, _pinLenght, _wallet.derivation)) !=
|
||||
'false') {
|
||||
this.pubkey.text = _localPubkey;
|
||||
isWalletUnlock = true;
|
||||
|
@ -93,7 +93,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
throw 'Bad pubkey';
|
||||
}
|
||||
} catch (e) {
|
||||
print('ERROR READING FILE: $e');
|
||||
log.e('ERROR READING FILE: $e');
|
||||
this.pubkey.clear();
|
||||
// notifyListeners();
|
||||
return 'bad';
|
||||
|
@ -110,7 +110,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
throw false;
|
||||
}
|
||||
} catch (e) {
|
||||
print('ERROR READING FILE: $e');
|
||||
log.e('ERROR READING FILE: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -136,27 +136,15 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
String newConfig =
|
||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||
int nbrLines = lines.length;
|
||||
// print(lines);
|
||||
// print(nbrLines);
|
||||
// int _index = lines.indexOf('0:$_walletNbr:$_walletName:$_derivation');
|
||||
if (nbrLines != 1) {
|
||||
for (String wLine in lines) {
|
||||
String wID = "${wLine.split(':')[0]}:${wLine.split(':')[1]}";
|
||||
print(
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
print(wLine);
|
||||
String deri = wLine.split(':')[3];
|
||||
print("($wID == $_walletID ???");
|
||||
if (wID == _walletID) {
|
||||
lines.remove(wLine);
|
||||
lines.add('$_walletID:$_newName:$deri');
|
||||
// return '$_walletID:$_newName:$deri';
|
||||
print('OOUUUUUUUIIIIIIIIIIIIIIIIIII');
|
||||
}
|
||||
}
|
||||
// lines.removeWhere((element) =>
|
||||
// '${element.split(':')[0]}:${element.split(':')[1]}' == _walletID);
|
||||
// lines.add('$_walletID:$_newName:$deri');
|
||||
return lines.join('\n');
|
||||
} else {
|
||||
return 'true';
|
||||
|
@ -229,17 +217,16 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
return nameState;
|
||||
}
|
||||
|
||||
Future<int> deleteWallet(context, _walletNbr, _name, _derivation) async {
|
||||
final bool _answer = await _confirmDeletingWallet(context, _name);
|
||||
Future<int> deleteWallet(context, wallet) async {
|
||||
final bool _answer = await _confirmDeletingWallet(context, wallet.name);
|
||||
|
||||
if (_answer) {
|
||||
final _walletConfig = File('${walletsDirectory.path}/0/list.conf');
|
||||
|
||||
if (_derivation != -1) {
|
||||
if (wallet.derivation != -1) {
|
||||
String newConfig =
|
||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||
lines.removeWhere((element) =>
|
||||
element.contains('0:$_walletNbr:$_name:$_derivation'));
|
||||
lines.removeWhere((element) => element.contains(wallet.inLine()));
|
||||
|
||||
return lines.join('\n');
|
||||
});
|
||||
|
@ -247,7 +234,8 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
await _walletConfig.delete();
|
||||
await _walletConfig.writeAsString(newConfig);
|
||||
} else {
|
||||
final _walletFile = Directory('${walletsDirectory.path}/$_walletNbr');
|
||||
final _walletFile =
|
||||
Directory('${walletsDirectory.path}/${wallet.number}');
|
||||
await _walletFile.delete(recursive: true);
|
||||
}
|
||||
Navigator.popUntil(
|
||||
|
@ -308,7 +296,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
// notifyListeners();
|
||||
return newWalletFile;
|
||||
} catch (e) {
|
||||
print('Impossible de changer le code PIN.');
|
||||
log.e('Impossible de changer le code PIN.');
|
||||
return badWallet;
|
||||
}
|
||||
}
|
||||
|
@ -317,7 +305,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
final Directory walletNameDirectory =
|
||||
Directory('${walletsDirectory.path}/$_name');
|
||||
final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
|
||||
print(_newWalletFile);
|
||||
|
||||
walletFile.writeAsString('${_newWalletFile.dewif}');
|
||||
Navigator.pop(context);
|
||||
|
@ -374,7 +361,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
_image = File(pickedFile.path);
|
||||
return _image;
|
||||
} else {
|
||||
print('No image selected.');
|
||||
log.w('No image selected.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:gecko/models/queries.dart';
|
|||
import 'package:gecko/models/history.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:gecko/screens/myWallets/unlockingWallet.dart';
|
||||
import 'dart:ui';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -33,8 +34,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
|
||||
this._outputPubkey.text = _historyProvider.pubkey;
|
||||
print('Build pubkey : ' + _historyProvider.pubkey);
|
||||
// _historyProvider.snackNode(context);
|
||||
log.i('Build pubkey : ' + _historyProvider.pubkey);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {});
|
||||
|
||||
return Scaffold(
|
||||
|
@ -57,7 +57,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
autofocus: true,
|
||||
controller: _homeProvider.searchQuery,
|
||||
onChanged: (text) {
|
||||
print("Clé tappé: $text");
|
||||
log.d("Clé tappé: $text");
|
||||
final String searchResult =
|
||||
_historyProvider.isPubkey(context, text);
|
||||
if (searchResult != '') {
|
||||
|
@ -113,7 +113,6 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
// HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
CesiumPlusProvider _cesiumPlusProvider =
|
||||
Provider.of<CesiumPlusProvider>(context);
|
||||
print("I'M HERE 1");
|
||||
bool _isFirstExec = true;
|
||||
return Expanded(
|
||||
child: Column(
|
||||
|
@ -130,18 +129,14 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
},
|
||||
),
|
||||
builder: (QueryResult result, {fetchMore, refetch}) {
|
||||
print("I'M HERE 2 ! $_isFirstExec");
|
||||
// print(result.source.isEager);
|
||||
|
||||
if (result.isLoading && result.data == null) {
|
||||
print("I'M HERE 3 !");
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
if (result.hasException) {
|
||||
print('Error GVA: ' + result.exception.toString());
|
||||
log.e('Error GVA: ' + result.exception.toString());
|
||||
return Column(children: <Widget>[
|
||||
SizedBox(height: 50),
|
||||
Text(
|
||||
|
@ -315,7 +310,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
// ),
|
||||
_historyProvider.isHistoryScreen
|
||||
? historyView(context, result)
|
||||
: payView(context),
|
||||
: payView(context, _historyProvider),
|
||||
],
|
||||
))),
|
||||
onNotification: (t) {
|
||||
|
@ -332,9 +327,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
));
|
||||
}
|
||||
|
||||
Widget payView(context) {
|
||||
TextEditingController payComment = new TextEditingController();
|
||||
|
||||
Widget payView(context, HistoryProvider _historyProvider) {
|
||||
return Stack(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: <Widget>[
|
||||
|
@ -344,26 +337,34 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
Text('Commentaire:'),
|
||||
Text('Commentaire:', style: TextStyle(fontSize: 20.0)),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
controller: payComment,
|
||||
controller: _historyProvider.payComment,
|
||||
maxLines: 2,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontSize: 22,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold))),
|
||||
SizedBox(height: 20),
|
||||
Text('Montant (Ğ1):'),
|
||||
Text('Montant (DU/Ğ1):', style: TextStyle(fontSize: 20.0)),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
style: TextStyle(fontSize: 22),
|
||||
controller: _historyProvider.payAmount,
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 1,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(vertical: 25.0, horizontal: 10.0),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10.0)),
|
||||
),
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.allow(RegExp(r'(^\d*\.?\d*)'))
|
||||
],
|
||||
|
@ -375,9 +376,15 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
style: OutlinedButton.styleFrom(
|
||||
side: BorderSide(width: 2, color: Color(0xffD28928))),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
_formKey.currentState.save();
|
||||
}
|
||||
// if (_formKey.currentState.validate()) {
|
||||
// _formKey.currentState.save();
|
||||
// }
|
||||
// _historyProvider.pay(payAmount.text, payComment.text);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
wallet: defaultWallet, action: "pay");
|
||||
}));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:gecko/models/history.dart';
|
|||
import 'package:gecko/models/home.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:gecko/screens/myWallets/unlockingWallet.dart';
|
||||
import 'package:gecko/screens/onBoarding/0_noKeychainFound.dart';
|
||||
import 'dart:ui';
|
||||
import 'package:gecko/screens/settings.dart';
|
||||
|
@ -97,7 +98,7 @@ class HomeScreen extends StatelessWidget {
|
|||
autofocus: true,
|
||||
controller: _homeProvider.searchQuery,
|
||||
onChanged: (text) {
|
||||
print("Clé tappé: $text");
|
||||
log.d("Clé tappé: $text");
|
||||
final String searchResult =
|
||||
_historyProvider.isPubkey(context, text);
|
||||
if (searchResult != '') {
|
||||
|
@ -270,8 +271,17 @@ class HomeScreen extends StatelessWidget {
|
|||
height: 57)),
|
||||
onTap: () {
|
||||
isWalletsExists
|
||||
? Navigator.pushNamed(
|
||||
context, '/mywallets')
|
||||
? Navigator.push(context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return UnlockingWallet(
|
||||
wallet: defaultWallet,
|
||||
action: "mywallets",
|
||||
);
|
||||
}))
|
||||
|
||||
// Navigator.pushNamed(
|
||||
// context, '/mywallets')
|
||||
: Navigator.push(context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
|
|
|
@ -138,8 +138,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider.getAllWalletsNames(
|
||||
_currentChest);
|
||||
_myWalletProvider
|
||||
.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
Provider.of<GenerateWalletsProvider>(context);
|
||||
_generateWalletProvider.generateMnemonic();
|
||||
|
||||
// _generateWalletProvider.makeError();
|
||||
print('IS GENERATED ? : ' +
|
||||
_generateWalletProvider.walletIsGenerated.toString());
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: SizedBox(
|
||||
|
|
|
@ -48,7 +48,6 @@ class ImportWalletScreen extends StatelessWidget {
|
|||
_debounce.cancel();
|
||||
_debounce =
|
||||
Timer(const Duration(milliseconds: 200), () {
|
||||
print("ID Cesium tappé: $text");
|
||||
_generateWalletProvider
|
||||
.generateCesiumWalletPubkey(text,
|
||||
_generateWalletProvider.cesiumPWD.text)
|
||||
|
@ -86,7 +85,6 @@ class ImportWalletScreen extends StatelessWidget {
|
|||
_debounce.cancel();
|
||||
_debounce =
|
||||
Timer(const Duration(milliseconds: 200), () {
|
||||
print("ID Cesium tappé: $text");
|
||||
_generateWalletProvider
|
||||
.generateCesiumWalletPubkey(
|
||||
_generateWalletProvider.cesiumID.text,
|
||||
|
|
|
@ -2,26 +2,21 @@ 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/walletOptions.dart';
|
||||
import 'package:gecko/screens/commonElements.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/screens/myWallets/walletOptions.dart';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
// import 'package:gecko/models/home.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class UnlockingWallet extends StatelessWidget {
|
||||
UnlockingWallet(
|
||||
{Key keyUnlockWallet,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
{Key keyUnlockWallet, @required this.wallet, @required this.action})
|
||||
: super(key: keyUnlockWallet);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
int derivation;
|
||||
WalletData wallet;
|
||||
String action;
|
||||
|
||||
// ignore: close_sinks
|
||||
StreamController<ErrorAnimationType> errorController;
|
||||
|
@ -29,6 +24,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
bool hasError = false;
|
||||
var pinColor = Color(0xffF9F9F1);
|
||||
var walletPin = '';
|
||||
String resultPay;
|
||||
|
||||
Future<NewWallet> get badWallet => null;
|
||||
|
||||
|
@ -37,7 +33,9 @@ class UnlockingWallet extends StatelessWidget {
|
|||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
final int _pinLenght = _walletOptions.getPinLenght(this.walletNbr);
|
||||
|
||||
log.d("defaultWallet: " + defaultWallet.toString());
|
||||
final int _pinLenght = _walletOptions.getPinLenght(wallet.number);
|
||||
errorController = StreamController<ErrorAnimationType>();
|
||||
|
||||
return Scaffold(
|
||||
|
@ -57,7 +55,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
SizedBox(height: 50),
|
||||
pinForm(context, _pinLenght, walletNbr, derivation),
|
||||
pinForm(context, _pinLenght, wallet.number, wallet.derivation),
|
||||
]),
|
||||
),
|
||||
GestureDetector(
|
||||
|
@ -80,6 +78,9 @@ class UnlockingWallet extends StatelessWidget {
|
|||
TextEditingController _enterPin = TextEditingController();
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
||||
|
||||
return Form(
|
||||
key: formKey,
|
||||
|
@ -128,12 +129,13 @@ class UnlockingWallet extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
onCompleted: (_pin) async {
|
||||
print("Completed");
|
||||
log.d("Completed");
|
||||
_myWalletProvider.pinCode = _pin;
|
||||
final resultWallet = await _walletOptions.readLocalWallet(
|
||||
this.walletNbr,
|
||||
_pin.toUpperCase(),
|
||||
_pinLenght,
|
||||
this.derivation);
|
||||
context, this.wallet, _pin.toUpperCase(), _pinLenght);
|
||||
// _myWalletProvider.pinCode = _pin.toUpperCase();
|
||||
_myWalletProvider.pinLenght = _pinLenght;
|
||||
|
||||
if (resultWallet == 'bad') {
|
||||
errorController.add(ErrorAnimationType
|
||||
.shake); // Triggering error shake animation
|
||||
|
@ -143,22 +145,48 @@ class UnlockingWallet extends StatelessWidget {
|
|||
} else {
|
||||
pinColor = Colors.green[400];
|
||||
// await Future.delayed(Duration(milliseconds: 50));
|
||||
Navigator.push(
|
||||
formKey.currentContext,
|
||||
SmoothTransition(
|
||||
page: WalletOptions(
|
||||
walletNbr: walletNbr,
|
||||
walletName: walletName,
|
||||
derivation: derivation)));
|
||||
if (action == "mywallets") {
|
||||
Navigator.pushNamed(formKey.currentContext, '/mywallets');
|
||||
} else if (action == "pay") {
|
||||
print("Go payments");
|
||||
resultPay =
|
||||
await _historyProvider.pay(context, _pin.toUpperCase());
|
||||
await _paymentsResult(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
if (pinColor != Color(0xFFA4B600)) {
|
||||
pinColor = Color(0xFFA4B600);
|
||||
}
|
||||
print(value);
|
||||
},
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _paymentsResult(context) {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: true, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(resultPay == "Success"
|
||||
? 'Paiement effecuté avec succès !'
|
||||
: "Une erreur s'est produite lors du paiement"),
|
||||
content: SingleChildScrollView(child: Text('')),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:gecko/models/walletOptions.dart';
|
||||
import 'dart:async';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class WalletOptionsOld extends StatelessWidget with ChangeNotifier {
|
||||
WalletOptionsOld(
|
||||
{Key keyMyWallets,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
: super(key: keyMyWallets);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
int derivation;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
print("Build walletOptions");
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
|
||||
// _walletOptions.isWalletUnlock = false;
|
||||
print("Is unlock ? ${_walletOptions.isWalletUnlock}");
|
||||
|
||||
final int _currentChest = _myWalletProvider.getCurrentChest();
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
_walletOptions.isWalletUnlock = false;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
_walletOptions.isWalletUnlock = false;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Text(walletName),
|
||||
)),
|
||||
body: Builder(
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
Expanded(
|
||||
child: Column(children: <Widget>[
|
||||
SizedBox(height: 15),
|
||||
Text(
|
||||
'Clé publique:',
|
||||
style: TextStyle(
|
||||
fontSize: 15.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
SizedBox(height: 15),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: _walletOptions.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: Text(
|
||||
_walletOptions.pubkey.text,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Monospace'),
|
||||
)),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
width: 300,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 5,
|
||||
primary: Color(
|
||||
0xffFFD68E), //Color(0xffFFD68E), // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () => _walletOptions
|
||||
.renameWalletAlerte(
|
||||
context,
|
||||
walletName,
|
||||
walletNbr,
|
||||
derivation)
|
||||
.then((_result) {
|
||||
if (_result == true) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
_myWalletProvider
|
||||
.listWallets =
|
||||
_myWalletProvider
|
||||
.getAllWalletsNames(
|
||||
_currentChest);
|
||||
_myWalletProvider
|
||||
.rebuildWidget();
|
||||
});
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName(
|
||||
'/mywallets'),
|
||||
);
|
||||
}
|
||||
}),
|
||||
child: Text('Renommer ce portefeuille',
|
||||
style: TextStyle(fontSize: 20)))))),
|
||||
SizedBox(height: 30),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
width: 300,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 6,
|
||||
primary: Colors
|
||||
.redAccent, //Color(0xffFFD68E), // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () async {
|
||||
await _walletOptions.deleteWallet(context,
|
||||
walletNbr, walletName, derivation);
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider
|
||||
.getAllWalletsNames(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
},
|
||||
child: Text('Supprimer ce portefeuille',
|
||||
style: TextStyle(fontSize: 20)))),
|
||||
SizedBox(height: 50),
|
||||
Text(
|
||||
'Portefeuille déverrouillé',
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15),
|
||||
),
|
||||
SizedBox(height: 10)
|
||||
])),
|
||||
]),
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -7,28 +7,20 @@ import 'package:gecko/models/myWallets.dart';
|
|||
import 'package:gecko/models/queries.dart';
|
||||
import 'package:gecko/models/walletOptions.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'dart:async';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class WalletOptions extends StatelessWidget {
|
||||
WalletOptions(
|
||||
{Key keyMyWallets,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
WalletOptions({Key keyMyWallets, @required this.wallet})
|
||||
: super(key: keyMyWallets);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
int derivation;
|
||||
WalletData wallet;
|
||||
int _nbrLinesName = 1;
|
||||
bool _isNewNameValid = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
print("Build walletOptions");
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
|
@ -41,9 +33,9 @@ class WalletOptions extends StatelessWidget {
|
|||
|
||||
if (_walletOptions.nameController.text == null ||
|
||||
_isNewNameValid == false) {
|
||||
_walletOptions.nameController.text = walletName;
|
||||
_walletOptions.nameController.text = wallet.name;
|
||||
} else {
|
||||
walletName = _walletOptions.nameController.text;
|
||||
wallet.name = _walletOptions.nameController.text;
|
||||
}
|
||||
|
||||
_walletOptions.nameController.text.length >= 15
|
||||
|
@ -52,15 +44,16 @@ class WalletOptions extends StatelessWidget {
|
|||
if (_walletOptions.nameController.text.length >= 26 && isTall)
|
||||
_nbrLinesName = 3;
|
||||
|
||||
_walletOptions.walletID = '0:$walletNbr';
|
||||
_walletOptions.walletID = '0:${wallet.number}';
|
||||
|
||||
_myWalletProvider.getDefaultWallet();
|
||||
|
||||
defaultWallet == _walletOptions.walletID
|
||||
? _walletOptions.isDefaultWallet = true
|
||||
: _walletOptions.isDefaultWallet = false;
|
||||
_walletOptions.isDefaultWallet =
|
||||
(defaultWallet.id() == _walletOptions.walletID);
|
||||
|
||||
// print(_walletOptions.generateQRcode(_walletOptions.pubkey.text));
|
||||
int currentChest = _myWalletProvider.getCurrentChest();
|
||||
|
||||
log.d("Wallet options: $currentChest:${wallet.number}");
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
|
@ -68,9 +61,8 @@ class WalletOptions extends StatelessWidget {
|
|||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
Navigator.pushNamed(context, '/mywallets');
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
|
@ -83,9 +75,8 @@ class WalletOptions extends StatelessWidget {
|
|||
_walletOptions.isBalanceBlur = true;
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
ModalRoute.withName('/mywallets'),
|
||||
);
|
||||
Navigator.pushNamed(context, '/mywallets');
|
||||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
|
@ -113,7 +104,6 @@ class WalletOptions extends StatelessWidget {
|
|||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.changeAvatar();
|
||||
print('CHANGE AVATAR');
|
||||
},
|
||||
child: Image.asset(
|
||||
'assets/chopp-gecko2.png',
|
||||
|
@ -121,7 +111,6 @@ class WalletOptions extends StatelessWidget {
|
|||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.changeAvatar();
|
||||
print('CHANGE AVATAR');
|
||||
},
|
||||
child: Column(children: <Widget>[
|
||||
Image.asset(
|
||||
|
@ -129,14 +118,12 @@ class WalletOptions extends StatelessWidget {
|
|||
),
|
||||
SizedBox(height: 100)
|
||||
])),
|
||||
// SizedBox(width: 20),
|
||||
Column(children: <Widget>[
|
||||
Row(children: <Widget>[
|
||||
Column(children: <Widget>[
|
||||
SizedBox(
|
||||
width: 260,
|
||||
child: TextField(
|
||||
// autofocus: true,
|
||||
focusNode: _walletOptions.walletNameFocus,
|
||||
enabled: _walletOptions.isEditing,
|
||||
controller: _walletOptions.nameController,
|
||||
|
@ -174,8 +161,6 @@ class WalletOptions extends StatelessWidget {
|
|||
return Text('Loading');
|
||||
}
|
||||
|
||||
print(result);
|
||||
|
||||
// List repositories = result.data['viewer']['repositories']['nodes'];
|
||||
String wBalanceUD;
|
||||
if (result.data['balance'] == null) {
|
||||
|
@ -252,7 +237,7 @@ class WalletOptions extends StatelessWidget {
|
|||
// .addPostFrameCallback((_) {
|
||||
// _myWalletProvider.listWallets =
|
||||
// _myWalletProvider
|
||||
// .getAllWalletsNames(
|
||||
// .readAllWallets(
|
||||
// _currentChest);
|
||||
// _myWalletProvider.rebuildWidget();
|
||||
// });
|
||||
|
@ -369,10 +354,9 @@ class WalletOptions extends StatelessWidget {
|
|||
InkWell(
|
||||
onTap: !_walletOptions.isDefaultWallet
|
||||
? () {
|
||||
defaultWallet = '0:$walletNbr';
|
||||
_walletOptions
|
||||
.defAsDefaultWallet(_walletOptions.walletID);
|
||||
_myWalletProvider.getAllWalletsNames(_currentChest);
|
||||
defaultWallet = wallet;
|
||||
_walletOptions.defAsDefaultWallet(wallet.id());
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
|
@ -399,11 +383,10 @@ class WalletOptions extends StatelessWidget {
|
|||
SizedBox(height: 17 * ratio),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await _walletOptions.deleteWallet(
|
||||
context, walletNbr, walletName, derivation);
|
||||
await _walletOptions.deleteWallet(context, wallet);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
_myWalletProvider.getAllWalletsNames(_currentChest);
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_myWalletProvider.rebuildWidget();
|
||||
});
|
||||
},
|
||||
|
@ -419,7 +402,7 @@ class WalletOptions extends StatelessWidget {
|
|||
])),
|
||||
]),
|
||||
),
|
||||
)),
|
||||
);
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ import 'package:gecko/globals.dart';
|
|||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:gecko/models/walletOptions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/screens/myWallets/unlockingWallet.dart';
|
||||
import 'package:gecko/screens/commonElements.dart';
|
||||
import 'package:gecko/screens/myWallets/walletOptions.dart';
|
||||
import 'package:gecko/screens/onBoarding/0_noKeychainFound.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -24,18 +25,33 @@ class WalletsHome extends StatelessWidget {
|
|||
final int _currentChest = myWalletProvider.getCurrentChest();
|
||||
|
||||
myWalletProvider.listWallets =
|
||||
myWalletProvider.getAllWalletsNames(_currentChest);
|
||||
myWalletProvider.readAllWallets(_currentChest);
|
||||
final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
|
||||
|
||||
if (myWalletProvider.listWallets != '') {
|
||||
firstWalletDerivation =
|
||||
int.parse(myWalletProvider.listWallets.split('\n')[0].split(':')[3]);
|
||||
if (myWalletProvider.listWallets.isEmpty) {
|
||||
firstWalletDerivation = myWalletProvider.listWallets[0].derivation;
|
||||
|
||||
myWalletProvider.getDefaultWallet();
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
return Future<bool>.value(true);
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: Colors.black),
|
||||
onPressed: () {
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
}),
|
||||
title: Text('Mes portefeuilles',
|
||||
style: TextStyle(color: Colors.grey[850])),
|
||||
backgroundColor: Color(0xffFFD58D),
|
||||
|
@ -64,12 +80,14 @@ class WalletsHome extends StatelessWidget {
|
|||
body: SafeArea(
|
||||
child: !isWalletsExists
|
||||
? NoKeyChainScreen()
|
||||
: myWalletsTiles(context)));
|
||||
: myWalletsTiles(context))));
|
||||
}
|
||||
|
||||
Widget myWalletsTiles(BuildContext context) {
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
|
||||
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
||||
|
||||
|
@ -77,7 +95,7 @@ class WalletsHome extends StatelessWidget {
|
|||
return Text('');
|
||||
}
|
||||
|
||||
if (_myWalletProvider.listWallets == '') {
|
||||
if (_myWalletProvider.listWallets.isEmpty) {
|
||||
return Expanded(
|
||||
child: Column(children: <Widget>[
|
||||
Center(
|
||||
|
@ -88,11 +106,7 @@ class WalletsHome extends StatelessWidget {
|
|||
]));
|
||||
}
|
||||
|
||||
List _listWallets = _myWalletProvider.listWallets.split('\n');
|
||||
// final int nbrOfWallets = _listWallets.length;
|
||||
// print(_listWallets);
|
||||
// print("${_listWallets[0].split(':')[0]}:${_listWallets[0].split(':')[2]}");
|
||||
// print(defaultWallet);
|
||||
List _listWallets = _myWalletProvider.listWallets;
|
||||
|
||||
return GridView.count(
|
||||
crossAxisCount: 2,
|
||||
|
@ -100,18 +114,27 @@ class WalletsHome extends StatelessWidget {
|
|||
crossAxisSpacing: 0,
|
||||
mainAxisSpacing: 0,
|
||||
children: <Widget>[
|
||||
for (String _repository in _listWallets)
|
||||
for (WalletData _repository in _listWallets)
|
||||
Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
walletNbr: int.parse(_repository.split(':')[1]),
|
||||
walletName: _repository.split(':')[2],
|
||||
derivation: int.parse(_repository.split(':')[3]));
|
||||
}));
|
||||
onTap: () async {
|
||||
await _walletOptions.readLocalWallet(
|
||||
context,
|
||||
_repository,
|
||||
_myWalletProvider.pinCode,
|
||||
_myWalletProvider.pinLenght);
|
||||
Navigator.push(
|
||||
context,
|
||||
SmoothTransition(
|
||||
page: WalletOptions(
|
||||
wallet: _repository,
|
||||
)));
|
||||
|
||||
// Navigator.push(context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return UnlockingWallet(wallet: _repository);
|
||||
// }));
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
|
@ -137,9 +160,7 @@ class WalletsHome extends StatelessWidget {
|
|||
)),
|
||||
ListTile(
|
||||
// contentPadding: const EdgeInsets.only(left: 7.0),
|
||||
tileColor:
|
||||
"${_repository.split(':')[0]}:${_repository.split(':')[1]}" ==
|
||||
defaultWallet
|
||||
tileColor: _repository.id() == defaultWallet.id()
|
||||
? Color(0xffD28928)
|
||||
: Color(0xffFFD58D),
|
||||
// leading: Text('IMAGE'),
|
||||
|
@ -150,26 +171,22 @@ class WalletsHome extends StatelessWidget {
|
|||
child: Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 5),
|
||||
child: Text(_repository.split(':')[2],
|
||||
child: Text(_repository.name,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color:
|
||||
"${_repository.split(':')[0]}:${_repository.split(':')[1]}" ==
|
||||
defaultWallet
|
||||
color: _repository.id() ==
|
||||
defaultWallet.id()
|
||||
? Color(0xffF9F9F1)
|
||||
: Colors.black)))),
|
||||
// dense: true,
|
||||
onTap: () {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
walletNbr:
|
||||
int.parse(_repository.split(':')[1]),
|
||||
walletName: _repository.split(':')[2],
|
||||
derivation:
|
||||
int.parse(_repository.split(':')[3]));
|
||||
}));
|
||||
Navigator.push(
|
||||
context,
|
||||
SmoothTransition(
|
||||
page: WalletOptions(
|
||||
wallet: _repository,
|
||||
)));
|
||||
},
|
||||
)
|
||||
]))))
|
||||
|
|
|
@ -110,17 +110,13 @@ class OnboardingStepFourteen extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
onCompleted: (_pin) async {
|
||||
print("Completed");
|
||||
// final resultWallet = await _walletOptions.readLocalWallet(
|
||||
// _walletNbr, _pin.toUpperCase(), _pinLenght, _derivation);
|
||||
final bool resultWallet = await _walletOptions.checkPinOK(
|
||||
generatedWallet.dewif, _pin.toUpperCase(), _pinLenght);
|
||||
if (resultWallet) {
|
||||
pinColor = Colors.green[500];
|
||||
print(generatedWallet.pin);
|
||||
await _generateWalletProvider.storeHDWChest(
|
||||
generatedWallet, 'Mon portefeuille courant', context);
|
||||
_myWalletProvider.getAllWalletsNames(_currentChest);
|
||||
_myWalletProvider.readAllWallets(_currentChest);
|
||||
_walletOptions.reloadBuild();
|
||||
_myWalletProvider.rebuildWidget();
|
||||
Navigator.push(
|
||||
|
@ -140,7 +136,6 @@ class OnboardingStepFourteen extends StatelessWidget {
|
|||
if (pinColor != Color(0xFFA4B600)) {
|
||||
pinColor = Color(0xFFA4B600);
|
||||
}
|
||||
print(value);
|
||||
},
|
||||
)),
|
||||
);
|
||||
|
|
|
@ -5,6 +5,7 @@ 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';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
|
@ -85,7 +86,7 @@ class SettingsScreen extends StatelessWidget {
|
|||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () async => {
|
||||
print('Suppression de tous les wallets'),
|
||||
log.i('Suppression de tous les wallets'),
|
||||
await _myWallets.deleteAllWallet(context)
|
||||
},
|
||||
child: Text(
|
||||
|
|
|
@ -344,7 +344,7 @@ packages:
|
|||
name: logger
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.4"
|
||||
version: "1.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -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.1+22
|
||||
version: 0.0.1+23
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
@ -37,7 +37,7 @@ dependencies:
|
|||
sync_http: ^0.2.0
|
||||
crypto: ^3.0.0
|
||||
fast_base58:
|
||||
logger: ^0.9.4
|
||||
logger: ^1.0.0
|
||||
flutter_logs: ^2.1.3
|
||||
sentry: ^4.0.4
|
||||
sentry_flutter: ^4.0.4
|
||||
|
|
Loading…
Reference in New Issue