Merge branch 'rebuildHQWorkflow'
This commit is contained in:
commit
2e484d4373
|
@ -26,27 +26,40 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
bool walletIsGenerated = true;
|
||||
|
||||
TextEditingController mnemonicController = TextEditingController();
|
||||
TextEditingController pubkey = TextEditingController();
|
||||
TextEditingController pin = TextEditingController();
|
||||
|
||||
Future storeWallet(NewWallet wallet, _name, BuildContext context) async {
|
||||
final Directory walletNameDirectory =
|
||||
Directory('${walletsDirectory.path}/$_name');
|
||||
final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
|
||||
final walletPubkey = File('${walletNameDirectory.path}/pubkey');
|
||||
Future storeWallet(NewWallet wallet, String _name, BuildContext context,
|
||||
{bool isHD = false}) async {
|
||||
int nbrWallet = 0;
|
||||
Directory walletNbrDirectory;
|
||||
do {
|
||||
nbrWallet++;
|
||||
walletNbrDirectory = Directory('${walletsDirectory.path}/$nbrWallet');
|
||||
} while (await walletNbrDirectory.exists());
|
||||
|
||||
if (await walletNameDirectory.exists()) {
|
||||
print('Ce wallet existe déjà, impossible de le créer.');
|
||||
_showWalletExistDialog(context);
|
||||
return 'Exist: DENY';
|
||||
final walletFile = File('${walletNbrDirectory.path}/wallet.dewif');
|
||||
|
||||
await walletNbrDirectory.create();
|
||||
await walletFile.writeAsString(wallet.dewif);
|
||||
|
||||
final configFile = File('${walletNbrDirectory.path}/config.txt');
|
||||
|
||||
if (isHD) {
|
||||
final int _derivationNbr = 3;
|
||||
List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
|
||||
dewif: wallet.dewif,
|
||||
secretCode: wallet.pin,
|
||||
accountsIndex: [_derivationNbr]);
|
||||
String _pubkey = _pubkeysTmp[0];
|
||||
|
||||
await configFile
|
||||
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
||||
} else {
|
||||
await configFile.writeAsString('$nbrWallet:$_name');
|
||||
}
|
||||
|
||||
await walletNameDirectory.create();
|
||||
await walletFile.writeAsString('${wallet.dewif}');
|
||||
await walletPubkey.writeAsString('${wallet.publicKey}');
|
||||
|
||||
Navigator.pop(context, true);
|
||||
Navigator.pop(context, wallet.publicKey);
|
||||
Navigator.pop(context, true);
|
||||
// notifyListeners();
|
||||
|
||||
return _name;
|
||||
|
@ -107,35 +120,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _showWalletExistDialog(BuildContext context) async {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('Ce nom existe déjà'),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Text('Veuillez choisir un autre nom pour votre portefeuille.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("J'ai compris"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
askedWordColor = Colors.green[500];
|
||||
isAskedWordValid = true;
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> generateMnemonic() async {
|
||||
try {
|
||||
generatedMnemonic = await DubpRust.genMnemonic(language: Language.french);
|
||||
|
@ -173,7 +157,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
}
|
||||
|
||||
mnemonicController.text = generatedMnemonic;
|
||||
pubkey.text = this.actualWallet.publicKey;
|
||||
pin.text = this.actualWallet.pin;
|
||||
// notifyListeners();
|
||||
|
||||
|
@ -190,7 +173,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
// notifyListeners();
|
||||
}
|
||||
|
||||
Future<Uint8List> printWallet(String _title, String _pubkey) async {
|
||||
Future<Uint8List> printWallet(String _title) async {
|
||||
final ByteData fontData =
|
||||
await rootBundle.load("assets/OpenSans-Regular.ttf");
|
||||
final pw.Font ttf = pw.Font.ttf(fontData.buffer.asByteData());
|
||||
|
@ -204,12 +187,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
|||
pageFormat: PdfPageFormat.a4,
|
||||
build: (context) {
|
||||
return pw.Column(children: <pw.Widget>[
|
||||
pw.Text("Clé publique:",
|
||||
style: pw.TextStyle(fontSize: 20, font: ttf)),
|
||||
pw.SizedBox(height: 10),
|
||||
pw.Text(_pubkey,
|
||||
style: pw.TextStyle(fontSize: 15, font: ttf),
|
||||
textAlign: pw.TextAlign.center),
|
||||
pw.SizedBox(height: 20),
|
||||
pw.Text("Phrase de restauration:",
|
||||
style: pw.TextStyle(fontSize: 20, font: ttf)),
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:gecko/globals.dart';
|
|||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyWalletsProvider with ChangeNotifier {
|
||||
Map listWallets = Map();
|
||||
String listWallets;
|
||||
|
||||
bool checkIfWalletExist() {
|
||||
if (appPath == null) {
|
||||
|
@ -25,25 +25,33 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
|
||||
Future importWallet() async {}
|
||||
|
||||
Map getAllWalletsNames() {
|
||||
if (listWallets.isNotEmpty) {
|
||||
listWallets.clear();
|
||||
String getAllWalletsNames() {
|
||||
final bool _isWalletsExists = checkIfWalletExist();
|
||||
if (!_isWalletsExists) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (listWallets != null && listWallets.isNotEmpty) {
|
||||
listWallets = '';
|
||||
}
|
||||
if (listWallets == null) {
|
||||
listWallets = '';
|
||||
}
|
||||
|
||||
// int i = 0;
|
||||
walletsDirectory
|
||||
.listSync(recursive: false, followLinks: false)
|
||||
.forEach((wallet) {
|
||||
String _name = wallet.path.split('/').last;
|
||||
List _pubkeyList = File(wallet.path + '/pubkey').readAsLinesSync();
|
||||
String _pubkey = _pubkeyList[0];
|
||||
listWallets[_name] = _pubkey;
|
||||
// i++;
|
||||
|
||||
// for (var _wallets in listWallets) {
|
||||
// _wallets.pubkey =
|
||||
// }
|
||||
.forEach((_wallet) {
|
||||
File _walletConfig = File('${_wallet.path}/config.txt');
|
||||
_walletConfig.readAsLinesSync().forEach((element) {
|
||||
if (listWallets != '') {
|
||||
listWallets += '\n';
|
||||
}
|
||||
listWallets += element;
|
||||
// listWallets += "${element.split(':')[0]}:${element.split(':')[1]}:${element.split(':')[2]}"
|
||||
});
|
||||
});
|
||||
|
||||
return listWallets;
|
||||
}
|
||||
|
||||
|
@ -56,6 +64,7 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
if (_answer) {
|
||||
await walletsDirectory.delete(recursive: true);
|
||||
await walletsDirectory.create();
|
||||
notifyListeners();
|
||||
Navigator.pop(context);
|
||||
}
|
||||
return 0;
|
||||
|
@ -72,8 +81,8 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Êtes-vous sûr de vouloir supprimer tous vos portefeuilles ?'),
|
||||
title:
|
||||
Text('Êtes-vous sûr de vouloir supprimer tous vos trousseaux ?'),
|
||||
content: SingleChildScrollView(child: Text('')),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
|
@ -99,6 +108,30 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
);
|
||||
}
|
||||
|
||||
Future<void> generateNewDerivation(
|
||||
context, String _name, int _walletNbr) async {
|
||||
int _newDerivationNbr;
|
||||
final _walletConfig =
|
||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
||||
|
||||
if (await _walletConfig.readAsString() == '') {
|
||||
_newDerivationNbr = 3;
|
||||
} else {
|
||||
String _lastWallet =
|
||||
await _walletConfig.readAsLines().then((value) => value.last);
|
||||
int _lastDerivation = int.parse(_lastWallet.split(':')[2]);
|
||||
_newDerivationNbr = _lastDerivation + 3;
|
||||
}
|
||||
|
||||
await _walletConfig.writeAsString('\n$_walletNbr:$_name:$_newDerivationNbr',
|
||||
mode: FileMode.append);
|
||||
|
||||
print(await _walletConfig.readAsString());
|
||||
notifyListeners();
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
void rebuildWidget() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
|
||||
Future<NewWallet> get badWallet => null;
|
||||
|
||||
Future _getPubkeyFromDewif(_dewif, _pin, _pinLenght) async {
|
||||
Future _getPubkeyFromDewif(
|
||||
String _dewif, _pin, int _pinLenght, int derivation) async {
|
||||
String _pubkey;
|
||||
RegExp regExp = new RegExp(
|
||||
r'^[A-Z0-9]+$',
|
||||
|
@ -30,7 +31,9 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
return 'false';
|
||||
}
|
||||
try {
|
||||
_pubkey = await DubpRust.getDewifPublicKey(dewif: _dewif, pin: _pin);
|
||||
List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
|
||||
dewif: _dewif, secretCode: _pin, accountsIndex: [derivation]);
|
||||
_pubkey = _pubkeysTmp[0];
|
||||
this.pubkey.text = _pubkey;
|
||||
notifyListeners();
|
||||
|
||||
|
@ -50,23 +53,21 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
Future readLocalWallet(String _name, String _pin, _pinLenght) async {
|
||||
Future readLocalWallet(int _walletNbr, String _name, String _pin,
|
||||
int _pinLenght, int derivation) async {
|
||||
isWalletUnlock = false;
|
||||
try {
|
||||
File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif');
|
||||
File _walletFile =
|
||||
File('${walletsDirectory.path}/$_walletNbr/wallet.dewif');
|
||||
String _localDewif = await _walletFile.readAsString();
|
||||
String _localPubkey;
|
||||
|
||||
if ((_localPubkey =
|
||||
await _getPubkeyFromDewif(_localDewif, _pin, _pinLenght)) !=
|
||||
if ((_localPubkey = await _getPubkeyFromDewif(
|
||||
_localDewif, _pin, _pinLenght, derivation)) !=
|
||||
'false') {
|
||||
this.pubkey.text = _localPubkey;
|
||||
isWalletUnlock = true;
|
||||
notifyListeners();
|
||||
print('GET BIP32 accounts publickeys from this dewif');
|
||||
List _hdWallets = await DubpRust.getBip32DewifAccountsPublicKeys(
|
||||
dewif: _localDewif, secretCode: _pin, accountsIndex: [0, 1, 2]);
|
||||
print(_hdWallets);
|
||||
|
||||
return _localDewif;
|
||||
} else {
|
||||
|
@ -79,8 +80,9 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
int getPinLenght(_name) {
|
||||
File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif');
|
||||
int getPinLenght(_walletNbr) {
|
||||
File _walletFile =
|
||||
File('${walletsDirectory.path}/$_walletNbr/wallet.dewif');
|
||||
String _localDewif = _walletFile.readAsStringSync();
|
||||
|
||||
final int _pinLenght = DubpRust.getDewifSecretCodeLen(
|
||||
|
@ -89,17 +91,27 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
return _pinLenght;
|
||||
}
|
||||
|
||||
Future _renameWallet(_walletName, _newName) async {
|
||||
final _walletFile = Directory('${walletsDirectory.path}/$_walletName');
|
||||
Future _renameWallet(_walletName, _newName, _walletNbr, _derivation) async {
|
||||
final _walletConfig =
|
||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
||||
|
||||
try {
|
||||
_walletFile.rename('${walletsDirectory.path}/$_newName');
|
||||
} catch (e) {
|
||||
print('ERREUR lors du renommage du wallet: $e');
|
||||
}
|
||||
String newConfig =
|
||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||
int _index = lines.indexOf('$_walletNbr:$_walletName:$_derivation');
|
||||
lines.removeWhere(
|
||||
(element) => element == '$_walletNbr:$_walletName:$_derivation');
|
||||
lines.insert(_index, '$_walletNbr:$_newName:$_derivation');
|
||||
|
||||
return lines.join('\n');
|
||||
});
|
||||
|
||||
await _walletConfig.delete();
|
||||
await _walletConfig.writeAsString(newConfig);
|
||||
_newWalletName.text = '';
|
||||
}
|
||||
|
||||
Future<bool> renameWalletAlerte(context, _walletName) async {
|
||||
Future<bool> renameWalletAlerte(
|
||||
context, _walletName, _walletNbr, _derivation) async {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: true, // user must tap button!
|
||||
|
@ -125,12 +137,12 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
TextButton(
|
||||
child: Text("Valider"),
|
||||
onPressed: () {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_renameWallet(_walletName, this._newWalletName.text);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _renameWallet(_walletName, this._newWalletName.text,
|
||||
_walletNbr, _derivation);
|
||||
});
|
||||
// notifyListeners();
|
||||
Navigator.pop(context, true);
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -139,21 +151,26 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
);
|
||||
}
|
||||
|
||||
Future<int> deleteWallet(context, _name) async {
|
||||
try {
|
||||
final _walletFile = Directory('${walletsDirectory.path}/$_name');
|
||||
print('DELETE THAT ?: $_walletFile');
|
||||
Future<int> deleteWallet(context, _walletNbr, _name, _derivation) async {
|
||||
final bool _answer = await _confirmDeletingWallet(context, _name);
|
||||
|
||||
final bool _answer = await _confirmDeletingWallet(context, _name);
|
||||
if (_answer) {
|
||||
final _walletConfig =
|
||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
||||
|
||||
if (_answer) {
|
||||
await _walletFile.delete(recursive: true);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
return 0;
|
||||
} catch (e) {
|
||||
return 1;
|
||||
String newConfig =
|
||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||
lines.removeWhere(
|
||||
(element) => element.contains('$_walletNbr:$_name:$_derivation'));
|
||||
|
||||
return lines.join('\n');
|
||||
});
|
||||
|
||||
await _walletConfig.delete();
|
||||
await _walletConfig.writeAsString(newConfig);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Future<bool> _confirmDeletingWallet(context, _walletName) async {
|
||||
|
@ -167,8 +184,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Vous pourrez restaurer ce portefeuille à tout moment grace à votre phrase de restauration.'),
|
||||
Text('Vous pourrez restaurer ce portefeuille plus tard.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -78,7 +78,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
errorBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Monospace')),
|
||||
if (_historyProvider.pubkey != '')
|
||||
historyQuery(context, _historyProvider),
|
||||
]));
|
||||
|
@ -273,7 +276,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
subtitle: Text(
|
||||
truncate(repository[2], 20,
|
||||
omission: "...", position: TruncatePosition.end),
|
||||
style: TextStyle(fontSize: 11.0),
|
||||
style: TextStyle(fontSize: 11.0, fontFamily: 'Monospace'),
|
||||
textAlign: TextAlign.center),
|
||||
trailing: Text("${repository[3]} Ğ1",
|
||||
style: TextStyle(fontSize: 14.0),
|
||||
|
|
|
@ -17,7 +17,6 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
NewWallet generatedWallet;
|
||||
|
||||
TextEditingController _mnemonicController = TextEditingController();
|
||||
TextEditingController _pubkey = TextEditingController();
|
||||
TextEditingController _inputRestoreWord = TextEditingController();
|
||||
TextEditingController walletName = TextEditingController();
|
||||
FocusNode _wordFocus = FocusNode();
|
||||
|
@ -30,7 +29,6 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
Provider.of<MyWalletsProvider>(context);
|
||||
|
||||
this._mnemonicController.text = generatedMnemonic;
|
||||
this._pubkey.text = generatedWallet.publicKey;
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
_generateWalletProvider.isAskedWordValid = false;
|
||||
|
@ -49,38 +47,21 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
}),
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Text('Enregistrer ce portefeuille'),
|
||||
child: Text('Enregistrer ce trousseau'),
|
||||
)),
|
||||
body: Center(
|
||||
child: Column(children: <Widget>[
|
||||
SizedBox(height: 15),
|
||||
Text(
|
||||
'Votre clé publique est :',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
TextField(
|
||||
enabled: false,
|
||||
controller: this._pubkey,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
'Quel est le ${_generateWalletProvider.nbrWord + 1}ème mot de votre phrase de restauration ?',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
Container(
|
||||
width: 360,
|
||||
child: Text(
|
||||
'Quel est le ${_generateWalletProvider.nbrWord + 1}ème mot de votre phrase de restauration ?',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
)),
|
||||
TextFormField(
|
||||
focusNode: _wordFocus,
|
||||
autofocus: true,
|
||||
|
@ -99,14 +80,16 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
color: _generateWalletProvider.askedWordColor,
|
||||
fontWeight: FontWeight.w500)),
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
'Choisissez un nom pour votre portefeuille :',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
Container(
|
||||
width: 360,
|
||||
child: Text(
|
||||
'Choisissez un nom pour votre premier portefeuille :',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 17.0,
|
||||
color: Colors.grey[600],
|
||||
fontWeight: FontWeight.w400),
|
||||
)),
|
||||
TextFormField(
|
||||
focusNode: _generateWalletProvider.walletNameFocus,
|
||||
inputFormatters: [
|
||||
|
@ -145,7 +128,8 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
|
|||
await _generateWalletProvider.storeWallet(
|
||||
generatedWallet,
|
||||
walletName.text,
|
||||
context);
|
||||
context,
|
||||
isHD: true);
|
||||
_generateWalletProvider.isAskedWordValid =
|
||||
false;
|
||||
_generateWalletProvider.askedWordColor =
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:gecko/models/generateWallets.dart';
|
||||
import 'package:gecko/models/walletOptions.dart';
|
||||
import 'package:gecko/screens/myWallets/confirmWalletStorage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:printing/printing.dart';
|
||||
|
@ -15,7 +13,6 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
String currentText = "";
|
||||
var pinColor = Colors.grey[300];
|
||||
|
||||
GlobalKey _toolTipPubkey = GlobalKey();
|
||||
GlobalKey _toolTipSentence = GlobalKey();
|
||||
GlobalKey _toolTipSecret = GlobalKey();
|
||||
|
||||
|
@ -23,8 +20,6 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
GenerateWalletsProvider _generateWalletProvider =
|
||||
Provider.of<GenerateWalletsProvider>(context);
|
||||
WalletOptionsProvider _walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context);
|
||||
_generateWalletProvider.generateMnemonic();
|
||||
print('IS GENERATED ? : ' +
|
||||
_generateWalletProvider.walletIsGenerated.toString());
|
||||
|
@ -32,7 +27,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
appBar: AppBar(
|
||||
title: SizedBox(
|
||||
height: 22,
|
||||
child: Text('Générer un portefeuille'),
|
||||
child: Text('Générer un trousseau'),
|
||||
)),
|
||||
floatingActionButton: Container(
|
||||
height: 80.0,
|
||||
|
@ -53,26 +48,6 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
toolTips(_toolTipPubkey, 'Clé publique:',
|
||||
"C'est votre RIB en Ğ1, les gens l'utiliseront pour vous payer"),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: _generateWalletProvider.pubkey.text));
|
||||
_walletOptions.snackCopyKey(ctx);
|
||||
},
|
||||
child: TextField(
|
||||
enabled: false,
|
||||
controller: _generateWalletProvider.pubkey,
|
||||
maxLines: 1,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: InputDecoration(),
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Monospace'))),
|
||||
SizedBox(height: 8),
|
||||
toolTips(_toolTipSentence, 'Phrase de restauration:',
|
||||
"Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"),
|
||||
TextField(
|
||||
|
@ -137,7 +112,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
: null,
|
||||
child: Text('Enregistrer ce portefeuille',
|
||||
child: Text('Enregistrer ce trousseau',
|
||||
style: TextStyle(fontSize: 20))),
|
||||
SizedBox(height: 20),
|
||||
GestureDetector(
|
||||
|
@ -146,9 +121,7 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return PrintWallet(
|
||||
_generateWalletProvider.generatedMnemonic,
|
||||
_generateWalletProvider
|
||||
.actualWallet.publicKey);
|
||||
_generateWalletProvider.generatedMnemonic);
|
||||
}),
|
||||
);
|
||||
},
|
||||
|
@ -194,10 +167,9 @@ class GenerateWalletsScreen extends StatelessWidget {
|
|||
|
||||
// ignore: must_be_immutable
|
||||
class PrintWallet extends StatelessWidget {
|
||||
PrintWallet(this.sentence, this.pubkey);
|
||||
PrintWallet(this.sentence);
|
||||
|
||||
final String sentence;
|
||||
final String pubkey;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -205,10 +177,9 @@ class PrintWallet extends StatelessWidget {
|
|||
Provider.of<GenerateWalletsProvider>(context);
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: Text('Imprimer ce portefeuille')),
|
||||
appBar: AppBar(title: Text('Imprimer ce trousseau')),
|
||||
body: PdfPreview(
|
||||
build: (format) =>
|
||||
_generateWalletProvider.printWallet(sentence, pubkey),
|
||||
build: (format) => _generateWalletProvider.printWallet(sentence),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:dubp/dubp.dart';
|
||||
import 'package:gecko/models/myWallets.dart';
|
||||
import 'package:gecko/models/walletOptions.dart';
|
||||
import 'package:gecko/screens/myWallets/changePin.dart';
|
||||
import 'dart:async';
|
||||
import 'package:pin_code_fields/pin_code_fields.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -11,9 +10,15 @@ import 'package:flutter/services.dart';
|
|||
|
||||
// ignore: must_be_immutable
|
||||
class WalletOptions extends StatelessWidget with ChangeNotifier {
|
||||
WalletOptions({Key keyMyWallets, @required this.walletName})
|
||||
WalletOptions(
|
||||
{Key keyMyWallets,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
: super(key: keyMyWallets);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
int derivation;
|
||||
|
||||
StreamController<ErrorAnimationType> errorController;
|
||||
TextEditingController _enterPin = TextEditingController();
|
||||
|
@ -34,7 +39,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
errorController = StreamController<ErrorAnimationType>();
|
||||
// _walletOptions.isWalletUnlock = false;
|
||||
|
||||
final int _pinLenght = _walletOptions.getPinLenght(this.walletName);
|
||||
final int _pinLenght = _walletOptions.getPinLenght(this.walletNbr);
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () {
|
||||
|
@ -100,7 +105,10 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
),
|
||||
onPressed: () => _walletOptions
|
||||
.renameWalletAlerte(
|
||||
context, walletName)
|
||||
context,
|
||||
walletName,
|
||||
walletNbr,
|
||||
derivation)
|
||||
.then((_result) {
|
||||
if (_result == true) {
|
||||
WidgetsBinding.instance
|
||||
|
@ -113,6 +121,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
_myWalletProvider
|
||||
.rebuildWidget();
|
||||
});
|
||||
Navigator.pop(
|
||||
context, true);
|
||||
}
|
||||
}),
|
||||
child: Text(
|
||||
|
@ -125,38 +135,14 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
width: 300,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 5,
|
||||
primary: Color(
|
||||
0xffFFD68E), //Color(0xffFFD68E), // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () {
|
||||
// changePin(widget.walletName, this.walletPin);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return ChangePinScreen(
|
||||
walletName: walletName,
|
||||
oldPin: this.walletPin);
|
||||
}),
|
||||
);
|
||||
},
|
||||
child: Text('Changer mon code secret',
|
||||
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, walletName);
|
||||
await _walletOptions.deleteWallet(context,
|
||||
walletNbr, walletName, derivation);
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
_myWalletProvider.listWallets =
|
||||
|
@ -244,9 +230,11 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
|
|||
print("Completed");
|
||||
final resultWallet =
|
||||
await _walletOptions.readLocalWallet(
|
||||
this.walletNbr,
|
||||
this.walletName,
|
||||
_pin.toUpperCase(),
|
||||
_pinLenght);
|
||||
_pinLenght,
|
||||
this.derivation);
|
||||
if (resultWallet == 'bad') {
|
||||
errorController.add(ErrorAnimationType
|
||||
.shake); // Triggering error shake animation
|
||||
|
|
|
@ -7,6 +7,8 @@ import 'package:provider/provider.dart';
|
|||
|
||||
// ignore: must_be_immutable
|
||||
class WalletsHome extends StatelessWidget {
|
||||
final _derivationKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MyWalletsProvider myWalletProvider =
|
||||
|
@ -27,12 +29,11 @@ class WalletsHome extends StatelessWidget {
|
|||
child: FloatingActionButton(
|
||||
heroTag: "buttonGenerateWallet",
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return GenerateWalletsScreen();
|
||||
}),
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return addNewDerivation(context, 1);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 40.0,
|
||||
|
@ -63,7 +64,7 @@ class WalletsHome extends StatelessWidget {
|
|||
return GenerateWalletsScreen();
|
||||
}),
|
||||
),
|
||||
child: Text('Générer un portefeuille',
|
||||
child: Text('Générer un trousseau',
|
||||
style: TextStyle(fontSize: 20))),
|
||||
SizedBox(height: 15),
|
||||
Center(
|
||||
|
@ -86,32 +87,94 @@ class WalletsHome extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget myWalletsList(BuildContext context) {
|
||||
MyWalletsProvider myWalletProvider =
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
|
||||
List _listWallets = [];
|
||||
myWalletProvider.listWallets.forEach((_name, _pubkey) {
|
||||
_listWallets.add(_name);
|
||||
});
|
||||
final bool isWalletsExists = _myWalletProvider.checkIfWalletExist();
|
||||
|
||||
return Column(children: <Widget>[
|
||||
if (!isWalletsExists) {
|
||||
return Text('');
|
||||
}
|
||||
|
||||
if (_myWalletProvider.listWallets == '') {
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Veuillez générer votre premier portefeuille',
|
||||
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
||||
)));
|
||||
}
|
||||
|
||||
List _listWallets = _myWalletProvider.listWallets.split('\n');
|
||||
|
||||
return Expanded(
|
||||
child: ListView(children: <Widget>[
|
||||
SizedBox(height: 8),
|
||||
for (String _repository in _listWallets)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.all(5.0),
|
||||
contentPadding: const EdgeInsets.only(left: 7.0),
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text("0 Ğ1", style: TextStyle(fontSize: 14.0))),
|
||||
title: Text(_repository, style: TextStyle(fontSize: 16.0)),
|
||||
subtitle: Text(myWalletProvider.listWallets[_repository],
|
||||
style: TextStyle(fontSize: 11.0)),
|
||||
// subtitle: Text(_repository.split(':')[3],
|
||||
// style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
|
||||
title:
|
||||
Text(_repository.split(':')[1], style: TextStyle(fontSize: 16.0)),
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return WalletOptions(walletName: _repository);
|
||||
return WalletOptions(
|
||||
walletNbr: int.parse(_repository.split(':')[0]),
|
||||
walletName: _repository.split(':')[1],
|
||||
derivation: int.parse(_repository.split(':')[2]));
|
||||
}));
|
||||
},
|
||||
)
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
Widget addNewDerivation(context, int _walletNbr) {
|
||||
final TextEditingController _newDerivationName = TextEditingController();
|
||||
MyWalletsProvider _myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
|
||||
return AlertDialog(
|
||||
content: Stack(
|
||||
overflow: Overflow.visible,
|
||||
children: <Widget>[
|
||||
Form(
|
||||
key: _derivationKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text('Nom du portefeuille:'),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
controller: _newDerivationName,
|
||||
textAlign: TextAlign.center,
|
||||
autofocus: true,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: RaisedButton(
|
||||
child: Text("Créer"),
|
||||
color: Color(0xffFFD68E),
|
||||
onPressed: () async {
|
||||
await _myWalletProvider
|
||||
.generateNewDerivation(
|
||||
context, _newDerivationName.text, _walletNbr)
|
||||
.then((_) => _newDerivationName.text == '');
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ class SettingsScreen extends StatelessWidget {
|
|||
.redAccent, //Color(0xffFFD68E), // background
|
||||
onPrimary: Colors.black, // foreground
|
||||
),
|
||||
onPressed: () => {
|
||||
onPressed: () async => {
|
||||
print('Suppression de tous les wallets'),
|
||||
_myWallets.deleteAllWallet(context)
|
||||
await _myWallets.deleteAllWallet(context)
|
||||
},
|
||||
child: Text(
|
||||
"EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA",
|
||||
|
|
Loading…
Reference in New Issue