improve idty confirmation
This commit is contained in:
parent
9eacbef2a8
commit
36bc2f571f
|
@ -47,7 +47,7 @@ Color backgroundColor = const Color(0xFFF5F5F5);
|
||||||
|
|
||||||
// Substrate settings
|
// Substrate settings
|
||||||
const int ss58 = 42;
|
const int ss58 = 42;
|
||||||
String currencyName = 'Ğdev';
|
String currencyName = 'ĞD';
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
const debugPin = true;
|
const debugPin = true;
|
||||||
|
|
|
@ -106,6 +106,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
|
// currencyName = await getCurencyName();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_homeProvider.changeMessage(
|
_homeProvider.changeMessage(
|
||||||
'Vous êtes bien connecté aux noeud\n${getConnectedEndpoint()!.split('/')[2]}',
|
'Vous êtes bien connecté aux noeud\n${getConnectedEndpoint()!.split('/')[2]}',
|
||||||
|
@ -527,15 +528,34 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final result = await sdk.api.tx.signAndSend(
|
final hash = await sdk.api.tx.signAndSend(
|
||||||
txInfo,
|
txInfo,
|
||||||
[name],
|
[name],
|
||||||
password,
|
password,
|
||||||
|
onStatusChange: (status) {
|
||||||
|
log.d('Transaction status: ' + status);
|
||||||
|
transactionStatus = status;
|
||||||
|
notifyListeners();
|
||||||
|
},
|
||||||
|
).timeout(
|
||||||
|
const Duration(seconds: 12),
|
||||||
|
onTimeout: () => {},
|
||||||
);
|
);
|
||||||
log.d(result);
|
log.d(hash);
|
||||||
return 'confirmed';
|
if (hash.isEmpty) {
|
||||||
|
transactionStatus = 'timeout';
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
return 'timeout';
|
||||||
|
} else {
|
||||||
|
transactionStatus = hash.toString();
|
||||||
|
notifyListeners();
|
||||||
|
return hash.toString();
|
||||||
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
log.e(e);
|
log.e(e);
|
||||||
|
transactionStatus = e.toString();
|
||||||
|
notifyListeners();
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,18 +565,22 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> canCertify(String from, String to) async {
|
Future<bool> canCertify(String from, String to) async {
|
||||||
bool _result = false;
|
|
||||||
if (from != to && await isMember(from)) {
|
if (from != to && await isMember(from)) {
|
||||||
final _certData = await getCertData(from, to);
|
final _certData = await getCertData(from, to);
|
||||||
final _certMeta = await getCertMeta(from);
|
final _certMeta = await getCertMeta(from);
|
||||||
final int _removableOn = _certData['removableOn'] ?? 0;
|
final int _removableOn = _certData['removableOn'] ?? 0;
|
||||||
|
final int _renewableOn = _certData['renewableOn'] ?? 0;
|
||||||
final int _nextIssuableOn = _certMeta['nextIssuableOn'] ?? 0;
|
final int _nextIssuableOn = _certMeta['nextIssuableOn'] ?? 0;
|
||||||
log.d(_removableOn);
|
log.d(_renewableOn.toString() +
|
||||||
if (_removableOn == 0 && _nextIssuableOn == 0) {
|
'\n' +
|
||||||
_result = true;
|
_removableOn.toString() +
|
||||||
|
'\n' +
|
||||||
|
_nextIssuableOn.toString());
|
||||||
|
if (_renewableOn == 0 && _nextIssuableOn == 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map> getCertMeta(String address) async {
|
Future<Map> getCertMeta(String address) async {
|
||||||
|
@ -572,6 +596,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return _certMeta;
|
return _certMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future getCurencyName() async {}
|
||||||
|
|
||||||
Future<String> derive(
|
Future<String> derive(
|
||||||
BuildContext context, String address, int number, String password) async {
|
BuildContext context, String address, int number, String password) async {
|
||||||
final keypair = getKeypair(address);
|
final keypair = getKeypair(address);
|
||||||
|
|
|
@ -6,6 +6,8 @@ import 'package:gecko/providers/my_wallets.dart';
|
||||||
import 'package:gecko/models/wallet_data.dart';
|
import 'package:gecko/models/wallet_data.dart';
|
||||||
import 'package:gecko/providers/substrate_sdk.dart';
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/screens/common_elements.dart';
|
import 'package:gecko/screens/common_elements.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||||
|
import 'package:gecko/screens/transaction_in_progress.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
@ -217,12 +219,36 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (idtyName.text.length >= 2) {
|
if (idtyName.text.length >= 2) {
|
||||||
final _wallet = _myWalletProvider
|
WalletData? defaultWallet =
|
||||||
.getWalletDataByAddress(address.text);
|
_myWalletProvider.getDefaultWallet();
|
||||||
await _sub.setCurrentWallet(_wallet!);
|
|
||||||
_sub.confirmIdentity(_walletOptions.address.text,
|
String? _pin;
|
||||||
idtyName.text, _myWalletProvider.pinCode);
|
if (_myWalletProvider.pinCode == '') {
|
||||||
Navigator.pop(context);
|
_pin = await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (homeContext) {
|
||||||
|
return UnlockingWallet(wallet: defaultWallet);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_pin != null || _myWalletProvider.pinCode != '') {
|
||||||
|
final _wallet = _myWalletProvider
|
||||||
|
.getWalletDataByAddress(address.text);
|
||||||
|
await _sub.setCurrentWallet(_wallet!);
|
||||||
|
_sub.confirmIdentity(_walletOptions.address.text,
|
||||||
|
idtyName.text, _myWalletProvider.pinCode);
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const TransactionInProgress(
|
||||||
|
transType: 'comfirmIdty');
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -169,13 +169,13 @@ class WalletOptions extends StatelessWidget {
|
||||||
width: 110,
|
width: 110,
|
||||||
)
|
)
|
||||||
: Container(
|
: Container(
|
||||||
width: 180,
|
width: 150,
|
||||||
height: 180,
|
height: 150,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.cover,
|
||||||
image: FileImage(
|
image: FileImage(
|
||||||
File(wallet.imageCustomPath!),
|
File(wallet.imageCustomPath!),
|
||||||
),
|
),
|
||||||
|
|
|
@ -229,7 +229,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.fitHeight,
|
||||||
image: FileImage(
|
image: FileImage(
|
||||||
File(
|
File(
|
||||||
_repository.imageCustomPath!),
|
_repository.imageCustomPath!),
|
||||||
|
|
|
@ -46,6 +46,11 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
_actionName = 'Certification';
|
_actionName = 'Certification';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'comfirmIdty':
|
||||||
|
{
|
||||||
|
_actionName = "Confirmation d'identité";
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
_actionName = 'Transaction étrange';
|
_actionName = 'Transaction étrange';
|
||||||
|
@ -77,7 +82,14 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
_resultText = '$_actionName validé !';
|
_resultText = '$_actionName validé !';
|
||||||
} else {
|
} else {
|
||||||
_resultText = "Une erreur s'est produite:\n";
|
_resultText = "Une erreur s'est produite:\n";
|
||||||
final String _exception = _result.split('Exception: ')[1];
|
final List _exceptionSplit = _result.split('Exception: ');
|
||||||
|
String _exception;
|
||||||
|
if (_exceptionSplit.length > 1) {
|
||||||
|
_exception = _exceptionSplit[1];
|
||||||
|
} else {
|
||||||
|
_exception = _exceptionSplit[0];
|
||||||
|
}
|
||||||
|
|
||||||
switch (_exception) {
|
switch (_exception) {
|
||||||
case 'cert.NotRespectCertPeriod':
|
case 'cert.NotRespectCertPeriod':
|
||||||
case 'identity.CreatorNotAllowedToCreateIdty':
|
case 'identity.CreatorNotAllowedToCreateIdty':
|
||||||
|
@ -92,6 +104,12 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
"Vous ne pouvez pas vous certifier\nvous même ...";
|
"Vous ne pouvez pas vous certifier\nvous même ...";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'identity.IdtyNameAlreadyExist':
|
||||||
|
{
|
||||||
|
_resultText += "Ce nom est déjà pris";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
_resultText += "\n$_exception";
|
_resultText += "\n$_exception";
|
||||||
|
@ -208,6 +226,7 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
_sub.transactionStatus = '';
|
||||||
if (transType == 'pay') Navigator.pop(context);
|
if (transType == 'pay') Navigator.pop(context);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Pay with G1.
|
||||||
# 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.7+11
|
version: 0.0.7+12
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.12.0 <3.0.0'
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|
Loading…
Reference in New Issue