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;
|
||||
notifyListeners();
|
||||
|
||||
if (!_sub.nodeConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final hasRoot = await scanRootBalance(_sub, currentChestNumber);
|
||||
if (hasRoot) {
|
||||
scanedWalletNumber = 1;
|
||||
|
|
|
@ -113,7 +113,6 @@ class SubstrateSdk with ChangeNotifier {
|
|||
} else {
|
||||
nodeConnected = true;
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
});
|
||||
|
||||
|
|
|
@ -134,7 +134,6 @@ class HomeScreen extends StatelessWidget {
|
|||
.onConnectivityChanged
|
||||
.listen((ConnectivityResult result) async {
|
||||
log.d('Network changed: $result');
|
||||
|
||||
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/home.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/custom_derivations.dart';
|
||||
import 'package:gecko/screens/myWallets/show_seed.dart';
|
||||
|
@ -47,7 +49,8 @@ class ChestOptions extends StatelessWidget {
|
|||
child: Text(currentChest.name!),
|
||||
)),
|
||||
bottomNavigationBar: _homeProvider.bottomAppBar(context),
|
||||
body: Builder(
|
||||
body: Stack(children: [
|
||||
Builder(
|
||||
builder: (ctx) => SafeArea(
|
||||
child: Column(children: <Widget>[
|
||||
SizedBox(height: 30 * ratio),
|
||||
|
@ -101,9 +104,11 @@ class ChestOptions extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
SizedBox(height: 10 * ratio),
|
||||
InkWell(
|
||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||
return InkWell(
|
||||
key: const Key('changePin'),
|
||||
onTap: () async {
|
||||
onTap: _sub.nodeConnected
|
||||
? () async {
|
||||
// await _chestProvider.changePin(context, cesiumWallet);
|
||||
String? pinResult = await Navigator.push(
|
||||
context,
|
||||
|
@ -120,7 +125,8 @@ class ChestOptions extends StatelessWidget {
|
|||
if (pinResult != null) {
|
||||
walletProvider.pinCode = pinResult;
|
||||
}
|
||||
},
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: <Widget>[
|
||||
|
@ -130,16 +136,23 @@ class ChestOptions extends StatelessWidget {
|
|||
height: 25,
|
||||
),
|
||||
const SizedBox(width: 18),
|
||||
const Text(
|
||||
Text(
|
||||
'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),
|
||||
InkWell(
|
||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||
return InkWell(
|
||||
key: const Key('createRootDerivation'),
|
||||
onTap: () async {
|
||||
onTap: _sub.nodeConnected
|
||||
? () async {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
|
@ -148,23 +161,29 @@ class ChestOptions extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(children: const <Widget>[
|
||||
SizedBox(width: 35),
|
||||
Icon(
|
||||
child: Row(children: <Widget>[
|
||||
const SizedBox(width: 35),
|
||||
const Icon(
|
||||
Icons.manage_accounts,
|
||||
size: 33,
|
||||
),
|
||||
SizedBox(width: 25),
|
||||
const SizedBox(width: 25),
|
||||
Text(
|
||||
'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),
|
||||
InkWell(
|
||||
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),
|
||||
if (canUnlock)
|
||||
// if (canUnlock)
|
||||
InkWell(
|
||||
key: const Key('chooseChest'),
|
||||
onTap: () {
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:gecko/providers/home.dart';
|
|||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
import 'package:gecko/screens/common_elements.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),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 35),
|
||||
|
|
|
@ -73,8 +73,26 @@ class OnboardingStepTen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
pinForm(context, _walletOptions, _pinLenght, 1, 2),
|
||||
InkWell(
|
||||
Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||
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: () {
|
||||
_walletOptions.changePinCacheChoice();
|
||||
},
|
||||
|
@ -90,11 +108,13 @@ class OnboardingStepTen extends StatelessWidget {
|
|||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'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 Text('');
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
]),
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue