fix: check if node is connected before chest creation/import; Do not allow wallet generation if node is disconnected; live check
This commit is contained in:
parent
7c11146278
commit
7cbf328123
|
@ -374,6 +374,10 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
scanedWalletNumber = 0;
|
scanedWalletNumber = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
|
if (!_sub.nodeConnected) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final hasRoot = await scanRootBalance(_sub, currentChestNumber);
|
final hasRoot = await scanRootBalance(_sub, currentChestNumber);
|
||||||
if (hasRoot) {
|
if (hasRoot) {
|
||||||
scanedWalletNumber = 1;
|
scanedWalletNumber = 1;
|
||||||
|
|
|
@ -113,7 +113,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
} else {
|
} else {
|
||||||
nodeConnected = true;
|
nodeConnected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,6 @@ class HomeScreen extends StatelessWidget {
|
||||||
.onConnectivityChanged
|
.onConnectivityChanged
|
||||||
.listen((ConnectivityResult result) async {
|
.listen((ConnectivityResult result) async {
|
||||||
log.d('Network changed: $result');
|
log.d('Network changed: $result');
|
||||||
|
|
||||||
await _sub.connectNode(ctx);
|
await _sub.connectNode(ctx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/chest_provider.dart';
|
import 'package:gecko/providers/chest_provider.dart';
|
||||||
import 'package:gecko/providers/home.dart';
|
import 'package:gecko/providers/home.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/myWallets/change_pin.dart';
|
import 'package:gecko/screens/myWallets/change_pin.dart';
|
||||||
import 'package:gecko/screens/myWallets/custom_derivations.dart';
|
import 'package:gecko/screens/myWallets/custom_derivations.dart';
|
||||||
import 'package:gecko/screens/myWallets/show_seed.dart';
|
import 'package:gecko/screens/myWallets/show_seed.dart';
|
||||||
|
@ -47,7 +49,8 @@ class ChestOptions extends StatelessWidget {
|
||||||
child: Text(currentChest.name!),
|
child: Text(currentChest.name!),
|
||||||
)),
|
)),
|
||||||
bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
||||||
body: Builder(
|
body: Stack(children: [
|
||||||
|
Builder(
|
||||||
builder: (ctx) => SafeArea(
|
builder: (ctx) => SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
SizedBox(height: 30 * ratio),
|
SizedBox(height: 30 * ratio),
|
||||||
|
@ -101,9 +104,11 @@ class ChestOptions extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 10 * ratio),
|
SizedBox(height: 10 * ratio),
|
||||||
InkWell(
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
return InkWell(
|
||||||
key: const Key('changePin'),
|
key: const Key('changePin'),
|
||||||
onTap: () async {
|
onTap: _sub.nodeConnected
|
||||||
|
? () async {
|
||||||
// await _chestProvider.changePin(context, cesiumWallet);
|
// await _chestProvider.changePin(context, cesiumWallet);
|
||||||
String? pinResult = await Navigator.push(
|
String? pinResult = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@ -120,7 +125,8 @@ class ChestOptions extends StatelessWidget {
|
||||||
if (pinResult != null) {
|
if (pinResult != null) {
|
||||||
walletProvider.pinCode = pinResult;
|
walletProvider.pinCode = pinResult;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Row(children: <Widget>[
|
child: Row(children: <Widget>[
|
||||||
|
@ -130,16 +136,23 @@ class ChestOptions extends StatelessWidget {
|
||||||
height: 25,
|
height: 25,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 18),
|
const SizedBox(width: 18),
|
||||||
const Text(
|
Text(
|
||||||
'Changer mon code secret',
|
'Changer mon code secret',
|
||||||
style: TextStyle(fontSize: 20, color: Colors.black),
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: _sub.nodeConnected
|
||||||
|
? Colors.black
|
||||||
|
: Colors.grey[500]),
|
||||||
),
|
),
|
||||||
])),
|
])),
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
SizedBox(height: 10 * ratio),
|
SizedBox(height: 10 * ratio),
|
||||||
InkWell(
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
return InkWell(
|
||||||
key: const Key('createRootDerivation'),
|
key: const Key('createRootDerivation'),
|
||||||
onTap: () async {
|
onTap: _sub.nodeConnected
|
||||||
|
? () async {
|
||||||
await Navigator.push(
|
await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
|
@ -148,23 +161,29 @@ class ChestOptions extends StatelessWidget {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Row(children: const <Widget>[
|
child: Row(children: <Widget>[
|
||||||
SizedBox(width: 35),
|
const SizedBox(width: 35),
|
||||||
Icon(
|
const Icon(
|
||||||
Icons.manage_accounts,
|
Icons.manage_accounts,
|
||||||
size: 33,
|
size: 33,
|
||||||
),
|
),
|
||||||
SizedBox(width: 25),
|
const SizedBox(width: 25),
|
||||||
Text(
|
Text(
|
||||||
'Créer une autre dérivation',
|
'Créer une autre dérivation',
|
||||||
style: TextStyle(fontSize: 20, color: Colors.black),
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: _sub.nodeConnected
|
||||||
|
? Colors.black
|
||||||
|
: Colors.grey[500]),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}),
|
||||||
SizedBox(height: 10 * ratio),
|
SizedBox(height: 10 * ratio),
|
||||||
InkWell(
|
InkWell(
|
||||||
key: const Key('deleteChest'),
|
key: const Key('deleteChest'),
|
||||||
|
@ -193,6 +212,8 @@ class ChestOptions extends StatelessWidget {
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
CommonElements().offlineInfo(context),
|
||||||
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ class UnlockingWallet extends StatelessWidget {
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
if (canUnlock)
|
// if (canUnlock)
|
||||||
InkWell(
|
InkWell(
|
||||||
key: const Key('chooseChest'),
|
key: const Key('chooseChest'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:gecko/providers/home.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallet_options.dart';
|
import 'package:gecko/providers/wallet_options.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
import 'package:gecko/screens/myWallets/chest_options.dart';
|
import 'package:gecko/screens/myWallets/chest_options.dart';
|
||||||
|
@ -298,7 +299,11 @@ class WalletsHome extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
addNewDerivation(context),
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
return _sub.nodeConnected
|
||||||
|
? addNewDerivation(context)
|
||||||
|
: const Text('');
|
||||||
|
}),
|
||||||
// SizedBox(height: 1),
|
// SizedBox(height: 1),
|
||||||
// Padding(
|
// Padding(
|
||||||
// padding: EdgeInsets.symmetric(horizontal: 35),
|
// padding: EdgeInsets.symmetric(horizontal: 35),
|
||||||
|
|
|
@ -73,8 +73,26 @@ class OnboardingStepTen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
pinForm(context, _walletOptions, _pinLenght, 1, 2),
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
InkWell(
|
return _sub.nodeConnected
|
||||||
|
? pinForm(context, _walletOptions, _pinLenght, 1, 2)
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Text(
|
||||||
|
'Vous devez vous connecter à internet\npour valider votre coffre',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: Colors.redAccent,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
return _sub.nodeConnected
|
||||||
|
? InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_walletOptions.changePinCacheChoice();
|
_walletOptions.changePinCacheChoice();
|
||||||
},
|
},
|
||||||
|
@ -90,11 +108,13 @@ class OnboardingStepTen extends StatelessWidget {
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
'Garder ce code en mémoire 15 minutes',
|
'Garder ce code en mémoire 15 minutes',
|
||||||
style: TextStyle(fontSize: 16, color: Colors.grey[700]),
|
style:
|
||||||
|
TextStyle(fontSize: 16, color: Colors.grey[700]),
|
||||||
),
|
),
|
||||||
const Spacer()
|
const Spacer()
|
||||||
]),
|
]))
|
||||||
),
|
: const Text('');
|
||||||
|
}),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
]),
|
]),
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue