diff --git a/assets/chopp-gecko.svg b/assets/chopp-gecko.svg
new file mode 100755
index 0000000..39b6a7b
--- /dev/null
+++ b/assets/chopp-gecko.svg
@@ -0,0 +1,9 @@
+
diff --git a/assets/chopp-gecko2.png b/assets/chopp-gecko2.png
new file mode 100755
index 0000000..6e97b0b
Binary files /dev/null and b/assets/chopp-gecko2.png differ
diff --git a/lib/globals.dart b/lib/globals.dart
index 78a6a02..045c95a 100644
--- a/lib/globals.dart
+++ b/lib/globals.dart
@@ -3,6 +3,8 @@ import 'package:shared_preferences/shared_preferences.dart';
Directory appPath;
Directory walletsDirectory;
+File defaultWalletFile;
+String defaultWallet;
String appVersion;
SharedPreferences prefs;
String endPointGVA;
diff --git a/lib/main.dart b/lib/main.dart
index 50db886..af7109e 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -25,8 +25,10 @@ Future main() async {
WidgetsFlutterBinding.ensureInitialized();
HomeProvider _homeProvider = HomeProvider();
+ MyWalletsProvider _walletsProvider = MyWalletsProvider();
await _homeProvider.getAppPath();
await _homeProvider.createDefaultAvatar();
+ await _walletsProvider.getDefaultWallet();
appVersion = await _homeProvider.getAppVersion();
prefs = await SharedPreferences.getInstance();
final HiveStore _store =
diff --git a/lib/models/generateWallets.dart b/lib/models/generateWallets.dart
index a7bc55d..88b85c2 100644
--- a/lib/models/generateWallets.dart
+++ b/lib/models/generateWallets.dart
@@ -39,50 +39,30 @@ class GenerateWalletsProvider with ChangeNotifier {
bool canImport = false;
bool isPinChanged = false;
- Future storeWallet(NewWallet wallet, String _name, BuildContext context,
- {bool isHD = false}) async {
- int nbrWallet;
- if (isHD) {
- nbrWallet = 0;
- } else {
- nbrWallet = 1;
- }
+ Future storeHDWallet(
+ NewWallet _wallet, String _name, BuildContext context) async {
+ // Directory walletDirectory;
- Directory walletNbrDirectory;
- do {
- nbrWallet++;
- walletNbrDirectory = Directory('${walletsDirectory.path}/$nbrWallet');
- } while (await walletNbrDirectory.exists());
+ final Directory hdDirectory = Directory('${walletsDirectory.path}/0');
+ await hdDirectory.create();
- final walletFile = File('${walletNbrDirectory.path}/wallet.dewif');
+ final configFile = File('${hdDirectory.path}/config.txt');
+ final dewifFile = File('${hdDirectory.path}/wallet.dewif');
- await walletNbrDirectory.create();
- await walletFile.writeAsString(wallet.dewif);
+ // List _lastConfig = [];
+ // _lastConfig = await masterConfigFile.readAsLines();
+ // final int _lastDerivation = int.parse(_lastConfig.last.split(':')[2]);
+ // final int _derivationNbr = _lastDerivation + 3;
- final configFile = File('${walletNbrDirectory.path}/config.txt');
+ final int _derivationNbr = 3;
+ List _pubkeysTmp = await DubpRust.getBip32DewifAccountsPublicKeys(
+ dewif: _wallet.dewif,
+ secretCode: _wallet.pin,
+ accountsIndex: [_derivationNbr]);
+ String _pubkey = _pubkeysTmp[0];
- 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');
- // Navigator.pop(context, true);
- } else {
- 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);
+ await configFile.writeAsString('0:$_name:$_derivationNbr:$_pubkey');
+ await dewifFile.writeAsString(_wallet.dewif);
return _name;
}
@@ -263,8 +243,8 @@ class GenerateWalletsProvider with ChangeNotifier {
salt: _cesiumID, password: _cesiumPWD);
String shortPubkey = truncate(_walletPubkey, 9,
omission: "...", position: TruncatePosition.end);
- await storeWallet(
- actualWallet, 'Portefeuille Cesium - $shortPubkey', context);
+ // await storeWallet(
+ // actualWallet, 'Portefeuille Cesium - $shortPubkey', context);
cesiumID.text = '';
cesiumPWD.text = '';
cesiumPubkey.text = '';
diff --git a/lib/models/myWallets.dart b/lib/models/myWallets.dart
index 4473f87..b0b61ba 100644
--- a/lib/models/myWallets.dart
+++ b/lib/models/myWallets.dart
@@ -13,6 +13,8 @@ class MyWalletsProvider with ChangeNotifier {
return false;
}
+ print(walletsDirectory.listSync());
+
List contents = walletsDirectory.listSync();
if (contents.length == 0) {
print('No wallets detected');
@@ -54,6 +56,23 @@ class MyWalletsProvider with ChangeNotifier {
return listWallets;
}
+ Future getDefaultWallet() async {
+ defaultWalletFile = File('${appPath.path}/defaultWallet');
+
+ bool isdefaultWalletFile = await defaultWalletFile.exists();
+
+ if (!isdefaultWalletFile) {
+ await File(defaultWalletFile.path).create();
+ }
+
+ try {
+ defaultWallet = await defaultWalletFile.readAsString();
+ } catch (e) {
+ defaultWallet = '0:3';
+ }
+ if (defaultWallet == '') defaultWallet = '0:3';
+ }
+
Future deleteAllWallet(context) async {
try {
print('DELETE THAT ?: $walletsDirectory');
@@ -107,11 +126,9 @@ class MyWalletsProvider with ChangeNotifier {
);
}
- Future generateNewDerivation(
- context, String _name, int _walletNbr) async {
+ Future generateNewDerivation(context, String _name) async {
int _newDerivationNbr;
- final _walletConfig =
- File('${walletsDirectory.path}/$_walletNbr/config.txt');
+ final _walletConfig = File('${walletsDirectory.path}/0/config.txt');
if (await _walletConfig.readAsString() == '') {
_newDerivationNbr = 3;
@@ -122,7 +139,7 @@ class MyWalletsProvider with ChangeNotifier {
_newDerivationNbr = _lastDerivation + 3;
}
- await _walletConfig.writeAsString('\n$_walletNbr:$_name:$_newDerivationNbr',
+ await _walletConfig.writeAsString('\n0:$_name:$_newDerivationNbr',
mode: FileMode.append);
print(await _walletConfig.readAsString());
diff --git a/lib/screens/myWallets/confirmWalletStorage.dart b/lib/screens/myWallets/confirmWalletStorage.dart
index 3b6385f..db1566a 100644
--- a/lib/screens/myWallets/confirmWalletStorage.dart
+++ b/lib/screens/myWallets/confirmWalletStorage.dart
@@ -126,11 +126,10 @@ class ConfirmStoreWallet extends StatelessWidget with ChangeNotifier {
.isAskedWordValid &&
this.walletName.text != '')
? () async {
- await _generateWalletProvider.storeWallet(
+ await _generateWalletProvider.storeHDWallet(
generatedWallet,
walletName.text,
- context,
- isHD: true);
+ context);
_generateWalletProvider.isAskedWordValid =
false;
_generateWalletProvider.askedWordColor =
diff --git a/lib/screens/myWallets/walletsHome.dart b/lib/screens/myWallets/walletsHome.dart
index 370cc13..1ab1650 100644
--- a/lib/screens/myWallets/walletsHome.dart
+++ b/lib/screens/myWallets/walletsHome.dart
@@ -1,4 +1,5 @@
import 'package:flutter/services.dart';
+import 'package:gecko/globals.dart';
import 'package:gecko/models/myWallets.dart';
import 'package:gecko/models/walletOptions.dart';
import 'package:flutter/material.dart';
@@ -81,7 +82,9 @@ class WalletsHome extends StatelessWidget {
List _listWallets = _myWalletProvider.listWallets.split('\n');
// final int nbrOfWallets = _listWallets.length;
- print(_listWallets);
+ // print(_listWallets);
+ // print("${_listWallets[0].split(':')[0]}:${_listWallets[0].split(':')[2]}");
+ // print(defaultWallet);
return GridView.count(
crossAxisCount: 2,
@@ -94,27 +97,62 @@ class WalletsHome extends StatelessWidget {
padding: EdgeInsets.all(16),
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(12)),
- child: ListTile(
- // contentPadding: const EdgeInsets.only(left: 7.0),
- tileColor: Colors.green[100],
- // leading: Text('IMAGE'),
+ child: Column(children: [
+ Expanded(
+ child: Container(
+ width: double.infinity,
+ height: double.infinity,
+ decoration: BoxDecoration(
+ gradient: RadialGradient(
+ radius: 1,
+ colors: [
+ Colors.green[100],
+ Colors.green[500],
+ ],
+ )),
+ child:
+ // SvgPicture.asset('assets/chopp-gecko2.png',
+ // semanticsLabel: 'Gecko', height: 48),
+ Image.asset(
+ 'assets/chopp-gecko2.png',
+ ),
+ )),
+ ListTile(
+ // contentPadding: const EdgeInsets.only(left: 7.0),
+ tileColor:
+ "${_repository.split(':')[0]}:${_repository.split(':')[2]}" ==
+ defaultWallet
+ ? Color(0xffD28928)
+ : Color(0xffFFD58D),
+ // leading: Text('IMAGE'),
- // subtitle: Text(_repository.split(':')[3],
- // style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
- title: Center(
- child: Text(_repository.split(':')[1],
- style: TextStyle(fontSize: 16.0))),
- // dense: true,
- onTap: () {
- Navigator.push(context,
- MaterialPageRoute(builder: (context) {
- return UnlockingWallet(
- walletNbr: int.parse(_repository.split(':')[0]),
- walletName: _repository.split(':')[1],
- derivation: int.parse(_repository.split(':')[2]));
- }));
- },
- )))
+ // subtitle: Text(_repository.split(':')[3],
+ // style: TextStyle(fontSize: 12.0, fontFamily: 'Monospace')),
+ title: Center(
+ child: Padding(
+ padding: EdgeInsets.symmetric(horizontal: 5),
+ child: Text(_repository.split(':')[1],
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 16.0,
+ color:
+ "${_repository.split(':')[0]}:${_repository.split(':')[2]}" ==
+ defaultWallet
+ ? Color(0xffF9F9F1)
+ : Colors.black)))),
+ // dense: true,
+ onTap: () {
+ Navigator.push(context,
+ MaterialPageRoute(builder: (context) {
+ return UnlockingWallet(
+ walletNbr: int.parse(_repository.split(':')[0]),
+ walletName: _repository.split(':')[1],
+ derivation:
+ int.parse(_repository.split(':')[2]));
+ }));
+ },
+ )
+ ])))
]);
}
@@ -200,7 +238,7 @@ class WalletsHome extends StatelessWidget {
onPressed: () async {
await _myWalletProvider
.generateNewDerivation(
- context, _newDerivationName.text, _walletNbr)
+ context, _newDerivationName.text)
.then((_) => _newDerivationName.text == '');
},
child: Text("Créer")),
diff --git a/lib/screens/myWallets/walletsHome_old.dart b/lib/screens/myWallets/walletsHome_old.dart
index 9f6dace..7a5f99e 100644
--- a/lib/screens/myWallets/walletsHome_old.dart
+++ b/lib/screens/myWallets/walletsHome_old.dart
@@ -142,7 +142,7 @@ class WalletsHome extends StatelessWidget {
onPressed: () async {
await _myWalletProvider
.generateNewDerivation(
- context, _newDerivationName.text, _walletNbr)
+ context, _newDerivationName.text)
.then((_) => _newDerivationName.text == '');
},
child: Text("Créer")),
diff --git a/lib/screens/onBoarding/12.dart b/lib/screens/onBoarding/12.dart
index 73f44ee..d9e8e61 100644
--- a/lib/screens/onBoarding/12.dart
+++ b/lib/screens/onBoarding/12.dart
@@ -116,9 +116,8 @@ class OnboardingStepFourteen extends StatelessWidget {
if (resultWallet) {
pinColor = Colors.green[500];
print(generatedWallet.pin);
- await _generateWalletProvider.storeWallet(
- generatedWallet, 'Mon portefeuille courant', context,
- isHD: true);
+ await _generateWalletProvider.storeHDWallet(
+ generatedWallet, 'Mon portefeuille courant', context);
_myWalletProvider.getAllWalletsNames();
_walletOptions.reloadBuild();
_myWalletProvider.rebuildWidget();
diff --git a/pubspec.yaml b/pubspec.yaml
index 7179ea6..8cdb9aa 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -5,7 +5,7 @@ description: Pay with G1.
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-version: 0.0.1+20
+version: 0.0.1+21
environment:
sdk: ">=2.7.0 <3.0.0"