Merge branch 'importCesiumWallets'
This commit is contained in:
commit
1893502e6b
|
@ -11,6 +11,7 @@ import 'package:sentry_flutter/sentry_flutter.dart' as sentry;
|
||||||
import 'package:pdf/pdf.dart';
|
import 'package:pdf/pdf.dart';
|
||||||
import 'package:pdf/widgets.dart' as pw;
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
import 'package:printing/printing.dart';
|
import 'package:printing/printing.dart';
|
||||||
|
import 'package:truncate/truncate.dart';
|
||||||
|
|
||||||
class GenerateWalletsProvider with ChangeNotifier {
|
class GenerateWalletsProvider with ChangeNotifier {
|
||||||
GenerateWalletsProvider();
|
GenerateWalletsProvider();
|
||||||
|
@ -20,6 +21,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
FocusNode walletNameFocus = FocusNode();
|
FocusNode walletNameFocus = FocusNode();
|
||||||
Color askedWordColor = Colors.black;
|
Color askedWordColor = Colors.black;
|
||||||
bool isAskedWordValid = false;
|
bool isAskedWordValid = false;
|
||||||
|
|
||||||
int nbrWord;
|
int nbrWord;
|
||||||
|
|
||||||
String generatedMnemonic;
|
String generatedMnemonic;
|
||||||
|
@ -28,9 +30,23 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
TextEditingController mnemonicController = TextEditingController();
|
TextEditingController mnemonicController = TextEditingController();
|
||||||
TextEditingController pin = TextEditingController();
|
TextEditingController pin = TextEditingController();
|
||||||
|
|
||||||
|
// Import wallet
|
||||||
|
TextEditingController cesiumID = TextEditingController();
|
||||||
|
TextEditingController cesiumPWD = TextEditingController();
|
||||||
|
TextEditingController cesiumPubkey = TextEditingController();
|
||||||
|
bool isCesiumIDVisible = false;
|
||||||
|
bool isCesiumPWDVisible = false;
|
||||||
|
bool canImport = false;
|
||||||
|
bool isPinChanged = false;
|
||||||
|
|
||||||
Future storeWallet(NewWallet wallet, String _name, BuildContext context,
|
Future storeWallet(NewWallet wallet, String _name, BuildContext context,
|
||||||
{bool isHD = false}) async {
|
{bool isHD = false}) async {
|
||||||
int nbrWallet = 0;
|
int nbrWallet;
|
||||||
|
if (isHD) {
|
||||||
|
nbrWallet = 0;
|
||||||
|
} else {
|
||||||
|
nbrWallet = 1;
|
||||||
|
}
|
||||||
Directory walletNbrDirectory;
|
Directory walletNbrDirectory;
|
||||||
do {
|
do {
|
||||||
nbrWallet++;
|
nbrWallet++;
|
||||||
|
@ -54,13 +70,18 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
await configFile
|
await configFile
|
||||||
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
||||||
|
Navigator.pop(context, true);
|
||||||
} else {
|
} else {
|
||||||
await configFile.writeAsString('$nbrWallet:$_name');
|
final int _derivationNbr = -1;
|
||||||
|
String _pubkey = await DubpRust.getDewifPublicKey(
|
||||||
|
dewif: wallet.dewif,
|
||||||
|
pin: wallet.pin,
|
||||||
|
);
|
||||||
|
await configFile
|
||||||
|
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
Navigator.pop(context, true);
|
|
||||||
// notifyListeners();
|
|
||||||
|
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
@ -163,14 +184,17 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
return this.actualWallet;
|
return this.actualWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePinCode() async {
|
Future<void> changePinCode({bool reload}) async {
|
||||||
this.actualWallet = await DubpRust.changeDewifPin(
|
actualWallet = await DubpRust.changeDewifPin(
|
||||||
dewif: this.actualWallet.dewif,
|
dewif: actualWallet.dewif,
|
||||||
oldPin: this.actualWallet.pin,
|
oldPin: actualWallet.pin,
|
||||||
);
|
);
|
||||||
|
|
||||||
pin.text = this.actualWallet.pin;
|
pin.text = actualWallet.pin;
|
||||||
// notifyListeners();
|
isPinChanged = true;
|
||||||
|
if (reload) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> printWallet(String _title) async {
|
Future<Uint8List> printWallet(String _title) async {
|
||||||
|
@ -210,4 +234,54 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
return pdf.save();
|
return pdf.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> generateCesiumWalletPubkey(
|
||||||
|
String _cesiumID, String _cesiumPWD) async {
|
||||||
|
actualWallet = await DubpRust.genWalletFromDeprecatedSaltPassword(
|
||||||
|
salt: _cesiumID, password: _cesiumPWD);
|
||||||
|
String _walletPubkey = await DubpRust.getLegacyPublicKey(
|
||||||
|
salt: _cesiumID, password: _cesiumPWD);
|
||||||
|
|
||||||
|
cesiumPubkey.text = _walletPubkey;
|
||||||
|
print(_walletPubkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future importWallet(context, _cesiumID, _cesiumPWD) async {
|
||||||
|
String _walletPubkey = await DubpRust.getLegacyPublicKey(
|
||||||
|
salt: _cesiumID, password: _cesiumPWD);
|
||||||
|
String shortPubkey = truncate(_walletPubkey, 9,
|
||||||
|
omission: "...", position: TruncatePosition.end);
|
||||||
|
await storeWallet(
|
||||||
|
actualWallet, 'Portefeuille Cesium - $shortPubkey', context);
|
||||||
|
cesiumID.text = '';
|
||||||
|
cesiumPWD.text = '';
|
||||||
|
cesiumPubkey.text = '';
|
||||||
|
canImport = false;
|
||||||
|
isPinChanged = false;
|
||||||
|
pin.text = '';
|
||||||
|
isCesiumIDVisible = false;
|
||||||
|
isCesiumPWDVisible = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cesiumIDisVisible() {
|
||||||
|
isCesiumIDVisible = !isCesiumIDVisible;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cesiumPWDisVisible() {
|
||||||
|
isCesiumPWDVisible = !isCesiumPWDVisible;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void showPinIfEmpty() {
|
||||||
|
if (!isPinChanged) {
|
||||||
|
changePinCode(reload: true);
|
||||||
|
isPinChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reloadBuild() {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,6 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future importWallet() async {}
|
|
||||||
|
|
||||||
String getAllWalletsNames() {
|
String getAllWalletsNames() {
|
||||||
final bool _isWalletsExists = checkIfWalletExist();
|
final bool _isWalletsExists = checkIfWalletExist();
|
||||||
if (!_isWalletsExists) {
|
if (!_isWalletsExists) {
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:dubp/dubp.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:sentry/sentry.dart' as sentry;
|
|
||||||
import 'package:gecko/globals.dart';
|
import 'package:gecko/globals.dart';
|
||||||
|
|
||||||
class WalletOptionsProvider with ChangeNotifier {
|
class WalletOptionsProvider with ChangeNotifier {
|
||||||
|
@ -30,26 +29,35 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
print('Format de code PIN invalide');
|
print('Format de code PIN invalide');
|
||||||
return 'false';
|
return 'false';
|
||||||
}
|
}
|
||||||
try {
|
if (derivation != -1) {
|
||||||
List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
|
try {
|
||||||
dewif: _dewif, secretCode: _pin, accountsIndex: [derivation]);
|
List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
|
||||||
_pubkey = _pubkeysTmp[0];
|
dewif: _dewif, secretCode: _pin, accountsIndex: [derivation]);
|
||||||
this.pubkey.text = _pubkey;
|
_pubkey = _pubkeysTmp[0];
|
||||||
notifyListeners();
|
this.pubkey.text = _pubkey;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
return _pubkey;
|
return _pubkey;
|
||||||
} catch (e, stack) {
|
} catch (e) {
|
||||||
print('Bad PIN code !');
|
print('Bad PIN code !');
|
||||||
print(e);
|
print(e);
|
||||||
if (kReleaseMode) {
|
notifyListeners();
|
||||||
await sentry.Sentry.captureException(
|
|
||||||
e,
|
return 'false';
|
||||||
stackTrace: stack,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
notifyListeners();
|
} else {
|
||||||
|
try {
|
||||||
|
_pubkey = await DubpRust.getDewifPublicKey(dewif: _dewif, pin: _pin);
|
||||||
|
this.pubkey.text = _pubkey;
|
||||||
|
notifyListeners();
|
||||||
|
return _pubkey;
|
||||||
|
} catch (e) {
|
||||||
|
print('Bad PIN code !');
|
||||||
|
print(e);
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
return 'false';
|
return 'false';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,12 +105,17 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
|
|
||||||
String newConfig =
|
String newConfig =
|
||||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||||
|
int nbrLines = lines.length;
|
||||||
int _index = lines.indexOf('$_walletNbr:$_walletName:$_derivation');
|
int _index = lines.indexOf('$_walletNbr:$_walletName:$_derivation');
|
||||||
lines.removeWhere(
|
print(nbrLines);
|
||||||
(element) => element == '$_walletNbr:$_walletName:$_derivation');
|
if (nbrLines != 1) {
|
||||||
lines.insert(_index, '$_walletNbr:$_newName:$_derivation');
|
lines.removeWhere((element) =>
|
||||||
|
element.contains('$_walletNbr:$_walletName:$_derivation'));
|
||||||
return lines.join('\n');
|
lines.insert(_index, '$_walletNbr:$_newName:$_derivation');
|
||||||
|
return lines.join('\n');
|
||||||
|
} else {
|
||||||
|
return '$_walletNbr:$_newName:$_derivation';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await _walletConfig.delete();
|
await _walletConfig.delete();
|
||||||
|
@ -158,16 +171,21 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
final _walletConfig =
|
final _walletConfig =
|
||||||
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
File('${walletsDirectory.path}/$_walletNbr/config.txt');
|
||||||
|
|
||||||
String newConfig =
|
if (_derivation != -1) {
|
||||||
await _walletConfig.readAsLines().then((List<String> lines) {
|
String newConfig =
|
||||||
lines.removeWhere(
|
await _walletConfig.readAsLines().then((List<String> lines) {
|
||||||
(element) => element.contains('$_walletNbr:$_name:$_derivation'));
|
lines.removeWhere(
|
||||||
|
(element) => element.contains('$_walletNbr:$_name:$_derivation'));
|
||||||
|
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
await _walletConfig.delete();
|
await _walletConfig.delete();
|
||||||
await _walletConfig.writeAsString(newConfig);
|
await _walletConfig.writeAsString(newConfig);
|
||||||
|
} else {
|
||||||
|
final _walletFile = Directory('${walletsDirectory.path}/$_walletNbr');
|
||||||
|
await _walletFile.delete(recursive: true);
|
||||||
|
}
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -83,7 +83,8 @@ class GenerateWalletsScreen extends StatelessWidget {
|
||||||
icon: Icon(Icons.replay),
|
icon: Icon(Icons.replay),
|
||||||
color: Color(0xffD28928),
|
color: Color(0xffD28928),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_generateWalletProvider.changePinCode();
|
_generateWalletProvider.changePinCode(
|
||||||
|
reload: false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -0,0 +1,240 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gecko/models/generateWallets.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/models/myWallets.dart';
|
||||||
|
import 'package:gecko/models/walletOptions.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ImportWalletScreen extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
GlobalKey _toolTipSecret = GlobalKey();
|
||||||
|
Timer _debounce;
|
||||||
|
GenerateWalletsProvider _generateWalletProvider =
|
||||||
|
Provider.of<GenerateWalletsProvider>(context);
|
||||||
|
MyWalletsProvider _myWalletProvider =
|
||||||
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
WalletOptionsProvider _walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
|
|
||||||
|
_generateWalletProvider.showPinIfEmpty();
|
||||||
|
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () {
|
||||||
|
_generateWalletProvider.cesiumID.text = '';
|
||||||
|
_generateWalletProvider.cesiumPWD.text = '';
|
||||||
|
_generateWalletProvider.cesiumPubkey.text = '';
|
||||||
|
_generateWalletProvider.pin.text = '';
|
||||||
|
_generateWalletProvider.canImport = false;
|
||||||
|
_generateWalletProvider.isPinChanged = false;
|
||||||
|
_generateWalletProvider.isCesiumIDVisible = false;
|
||||||
|
_generateWalletProvider.isCesiumPWDVisible = false;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
|
return Future<bool>.value(true);
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back, color: Colors.black),
|
||||||
|
onPressed: () {
|
||||||
|
_generateWalletProvider.cesiumID.text = '';
|
||||||
|
_generateWalletProvider.cesiumPWD.text = '';
|
||||||
|
_generateWalletProvider.cesiumPubkey.text = '';
|
||||||
|
_generateWalletProvider.pin.text = '';
|
||||||
|
_generateWalletProvider.canImport = false;
|
||||||
|
_generateWalletProvider.isPinChanged = false;
|
||||||
|
_generateWalletProvider.isCesiumIDVisible = false;
|
||||||
|
_generateWalletProvider.isCesiumPWDVisible = false;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
title: SizedBox(
|
||||||
|
height: 22,
|
||||||
|
child: Text('Importer un portefeuille'),
|
||||||
|
)),
|
||||||
|
body: Builder(
|
||||||
|
builder: (ctx) => SafeArea(
|
||||||
|
child: Column(children: <Widget>[
|
||||||
|
SizedBox(height: 20),
|
||||||
|
TextFormField(
|
||||||
|
onChanged: (text) {
|
||||||
|
if (_debounce?.isActive ?? false)
|
||||||
|
// _generateWalletProvider.canImport = false;
|
||||||
|
// _generateWalletProvider.reloadBuild();
|
||||||
|
_debounce.cancel();
|
||||||
|
_debounce =
|
||||||
|
Timer(const Duration(milliseconds: 200), () {
|
||||||
|
print("ID Cesium tappé: $text");
|
||||||
|
_generateWalletProvider
|
||||||
|
.generateCesiumWalletPubkey(text,
|
||||||
|
_generateWalletProvider.cesiumPWD.text)
|
||||||
|
.then((value) {
|
||||||
|
_generateWalletProvider.canImport = true;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
controller: _generateWalletProvider.cesiumID,
|
||||||
|
obscureText: !_generateWalletProvider
|
||||||
|
.isCesiumIDVisible, //This will obscure text dynamically
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Entrez votre identifiant Cesium',
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_generateWalletProvider.isCesiumIDVisible
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_generateWalletProvider.cesiumIDisVisible();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
TextFormField(
|
||||||
|
onChanged: (text) {
|
||||||
|
if (_debounce?.isActive ?? false)
|
||||||
|
// _generateWalletProvider.canImport = false;
|
||||||
|
// _generateWalletProvider.reloadBuild();
|
||||||
|
_debounce.cancel();
|
||||||
|
_debounce =
|
||||||
|
Timer(const Duration(milliseconds: 200), () {
|
||||||
|
print("ID Cesium tappé: $text");
|
||||||
|
_generateWalletProvider
|
||||||
|
.generateCesiumWalletPubkey(
|
||||||
|
_generateWalletProvider.cesiumID.text,
|
||||||
|
text)
|
||||||
|
.then((value) {
|
||||||
|
_generateWalletProvider.canImport = true;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
controller: _generateWalletProvider.cesiumPWD,
|
||||||
|
obscureText: !_generateWalletProvider
|
||||||
|
.isCesiumPWDVisible, //This will obscure text dynamically
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Entrez votre mot de passe Cesium',
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_generateWalletProvider.isCesiumPWDVisible
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_generateWalletProvider.cesiumPWDisVisible();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Clipboard.setData(ClipboardData(
|
||||||
|
text: _generateWalletProvider
|
||||||
|
.cesiumPubkey.text));
|
||||||
|
_walletOptions.snackCopyKey(ctx);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
_generateWalletProvider.cesiumPubkey.text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Monospace'),
|
||||||
|
)),
|
||||||
|
SizedBox(height: 20),
|
||||||
|
toolTips(_toolTipSecret, 'Code secret:',
|
||||||
|
"Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"),
|
||||||
|
Container(
|
||||||
|
child: Stack(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
children: <Widget>[
|
||||||
|
TextField(
|
||||||
|
enabled: false,
|
||||||
|
controller: _generateWalletProvider.pin,
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
decoration: InputDecoration(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 30.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.replay),
|
||||||
|
color: Color(0xffD28928),
|
||||||
|
onPressed: () {
|
||||||
|
_generateWalletProvider.changePinCode(
|
||||||
|
reload: true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(height: 30),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: Color(0xffFFD68E), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: _generateWalletProvider.canImport &&
|
||||||
|
_generateWalletProvider.isPinChanged
|
||||||
|
? () {
|
||||||
|
_generateWalletProvider
|
||||||
|
.importWallet(
|
||||||
|
context,
|
||||||
|
_generateWalletProvider
|
||||||
|
.cesiumID.text,
|
||||||
|
_generateWalletProvider
|
||||||
|
.cesiumPWD.text)
|
||||||
|
.then((value) {
|
||||||
|
_myWalletProvider.rebuildWidget();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: Text('Importer ce portefeuille Cesium',
|
||||||
|
style: TextStyle(fontSize: 20))),
|
||||||
|
]),
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget toolTips(_key, _text, _message) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
final dynamic _toolTip = _key.currentState;
|
||||||
|
_toolTip.ensureTooltipVisible();
|
||||||
|
},
|
||||||
|
child: Tooltip(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
key: _key,
|
||||||
|
showDuration: Duration(seconds: 5),
|
||||||
|
message: _message,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(width: 20),
|
||||||
|
Column(children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
width: 30,
|
||||||
|
height: 25,
|
||||||
|
child: Icon(Icons.info_outline,
|
||||||
|
size: 22, color: Color(0xffD28928))),
|
||||||
|
SizedBox(height: 1)
|
||||||
|
]),
|
||||||
|
Text(
|
||||||
|
_text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 15.0,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
SizedBox(width: 45)
|
||||||
|
])));
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import 'package:gecko/models/myWallets.dart';
|
||||||
import 'package:gecko/models/walletOptions.dart';
|
import 'package:gecko/models/walletOptions.dart';
|
||||||
import 'package:gecko/screens/myWallets/generateWallets.dart';
|
import 'package:gecko/screens/myWallets/generateWallets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/importWallet.dart';
|
||||||
import 'package:gecko/screens/myWallets/walletOptions.dart';
|
import 'package:gecko/screens/myWallets/walletOptions.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -78,7 +79,12 @@ class WalletsHome extends StatelessWidget {
|
||||||
primary: Color(0xffFFD68E), // background
|
primary: Color(0xffFFD68E), // background
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () => myWalletProvider.importWallet(),
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return ImportWalletScreen();
|
||||||
|
}),
|
||||||
|
),
|
||||||
child: Text('Importer un portefeuille existant',
|
child: Text('Importer un portefeuille existant',
|
||||||
style: TextStyle(fontSize: 20))),
|
style: TextStyle(fontSize: 20))),
|
||||||
])),
|
])),
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
import 'package:gecko/models/myWallets.dart';
|
import 'package:gecko/models/myWallets.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/generateWallets.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:gecko/screens/myWallets/importWallet.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class SettingsScreen extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
String generatedMnemonic;
|
String generatedMnemonic;
|
||||||
|
@ -28,18 +31,56 @@ class SettingsScreen extends StatelessWidget {
|
||||||
child: Text('Paramètres'),
|
child: Text('Paramètres'),
|
||||||
)),
|
)),
|
||||||
body: Column(children: <Widget>[
|
body: Column(children: <Widget>[
|
||||||
|
SizedBox(height: 40),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: 500,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 5,
|
||||||
|
primary: Color(0xFFFFCA6F), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return ImportWalletScreen();
|
||||||
|
}),
|
||||||
|
).then((value) => {
|
||||||
|
if (value == true) {Navigator.pop(context)}
|
||||||
|
}),
|
||||||
|
child: Text("Importer un portefeuille Cesium",
|
||||||
|
style: TextStyle(fontSize: 15)))),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: 500,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 5,
|
||||||
|
primary: Color(0xFFFFCA6F), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return GenerateWalletsScreen();
|
||||||
|
}),
|
||||||
|
).then((value) => {
|
||||||
|
if (value == true) {Navigator.pop(context)}
|
||||||
|
}),
|
||||||
|
child: Text("Générer un nouveau trousseau",
|
||||||
|
style: TextStyle(fontSize: 15)))),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
width: 1000,
|
width: 500,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
primary: Colors
|
primary: Colors.redAccent, // background
|
||||||
.redAccent, //Color(0xffFFD68E), // background
|
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () async => {
|
onPressed: () async => {
|
||||||
|
|
|
@ -49,3 +49,34 @@ pub(super) fn sign(salt: &str, password: &str, msg: &str) -> String {
|
||||||
.sign(msg.as_bytes())
|
.sign(msg.as_bytes())
|
||||||
.to_base64()
|
.to_base64()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_dewif_legacy() -> Result<(), DubpError> {
|
||||||
|
let wallet = gen_dewif_from_legacy(
|
||||||
|
"g1",
|
||||||
|
"salt".to_owned(),
|
||||||
|
"pass".to_owned(),
|
||||||
|
false,
|
||||||
|
SecretCodeType::Letters,
|
||||||
|
1_000_000_000,
|
||||||
|
)?;
|
||||||
|
let dewif = &wallet[0];
|
||||||
|
let secret_code = &wallet[1];
|
||||||
|
let pubkey = &wallet[2];
|
||||||
|
|
||||||
|
assert_eq!(pubkey, "3YumN7F7D8c2hmkHLHf3ZD8wc3tBHiECEK9zLPkaJtAF");
|
||||||
|
|
||||||
|
assert_eq!(get_pubkey("salt", "pass"), pubkey.to_owned());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
crate::dewif::get_pubkey(Currency::from(G1_CURRENCY), &dewif, &secret_code)?,
|
||||||
|
pubkey.to_owned()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -256,8 +256,8 @@ class DubpRust {
|
||||||
singleCompletePort<String, String>(completer, callback: _handleErr);
|
singleCompletePort<String, String>(completer, callback: _handleErr);
|
||||||
native.get_legacy_pubkey(
|
native.get_legacy_pubkey(
|
||||||
sendPort.nativePort,
|
sendPort.nativePort,
|
||||||
Utf8.toUtf8(password),
|
|
||||||
Utf8.toUtf8(salt),
|
Utf8.toUtf8(salt),
|
||||||
|
Utf8.toUtf8(password),
|
||||||
);
|
);
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: A new Flutter project.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# 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
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.1+4
|
version: 0.0.1+5
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue