fix: bugs about idtyStatus and few stuff
This commit is contained in:
parent
7514eb7299
commit
b436341808
|
@ -214,18 +214,23 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
(await _getStorage('system.account.multi($stringifyAddresses)') as List)
|
(await _getStorage('system.account.multi($stringifyAddresses)') as List)
|
||||||
.map((dynamic e) => e as Map<String, dynamic>)
|
.map((dynamic e) => e as Map<String, dynamic>)
|
||||||
.toList();
|
.toList();
|
||||||
log.d('debug multi: $balanceGlobalMulti');
|
|
||||||
|
|
||||||
final List<int?> idtyIndexList = (await _getStorage(
|
final List<int?> idtyIndexList = (await _getStorage(
|
||||||
'identity.identityIndexOf.multi($stringifyAddresses)') as List)
|
'identity.identityIndexOf.multi($stringifyAddresses)') as List)
|
||||||
.map((dynamic e) => e as int?)
|
.map((dynamic e) => e as int?)
|
||||||
.toList();
|
.toList();
|
||||||
final List<Map?> idtyDataList = (idtyIndexList.isEmpty
|
|
||||||
|
//FIXME: With local dev duniter node only, need to switch null values by unused init as index to have good idtyDataList...
|
||||||
|
final List<int> idtyIndexListNoNull =
|
||||||
|
idtyIndexList.map((item) => item ?? 99999999).toList();
|
||||||
|
|
||||||
|
final List<Map?> idtyDataList = (idtyIndexListNoNull.isEmpty
|
||||||
? []
|
? []
|
||||||
: (await _getStorage('identity.identities.multi($idtyIndexList)'))
|
: (await _getStorage(
|
||||||
as List)
|
'identity.identities.multi($idtyIndexListNoNull)')) as List)
|
||||||
.map((dynamic e) => e as Map<String, dynamic>?)
|
.map((dynamic e) => e as Map<String, dynamic>?)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final List pastReevals =
|
final List pastReevals =
|
||||||
await _getStorage('universalDividend.pastReevals()');
|
await _getStorage('universalDividend.pastReevals()');
|
||||||
|
|
||||||
|
@ -311,19 +316,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isSmithGet(String address) async {
|
|
||||||
var idtyIndex = await _getIdentityIndexOf(address);
|
|
||||||
|
|
||||||
final Map smithExpireOn =
|
|
||||||
(await _getStorage('smithsMembership.membership($idtyIndex)')) ?? {};
|
|
||||||
|
|
||||||
if (smithExpireOn.isEmpty) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, int>> certState(String from, String to) async {
|
Future<Map<String, int>> certState(String from, String to) async {
|
||||||
Map<String, int> result = {};
|
Map<String, int> result = {};
|
||||||
final toStatus = await idtyStatus(to);
|
final toStatus = await idtyStatus(to);
|
||||||
|
@ -423,10 +415,9 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
Future<bool> isSmith(String address) async {
|
Future<bool> isSmith(String address) async {
|
||||||
var idtyIndex = await _getIdentityIndexOf(address);
|
var idtyIndex = await _getIdentityIndexOf(address);
|
||||||
if (idtyIndex == 0) return false;
|
if (idtyIndex == -1) return false;
|
||||||
|
|
||||||
final isSmith =
|
final isSmith = await _getStorage('smithMembership.membership($idtyIndex)');
|
||||||
await _getStorage('smithsMembership.membership($idtyIndex)');
|
|
||||||
return isSmith == null ? false : true;
|
return isSmith == null ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -746,7 +737,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
seedText = seed.seed!.split('//')[0];
|
seedText = seed.seed!.split('//')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d(seedText);
|
|
||||||
return seedText;
|
return seedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +875,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
? {'transferableBalance': 0}
|
? {'transferableBalance': 0}
|
||||||
: await getBalance(fromAddress);
|
: await getBalance(fromAddress);
|
||||||
final fromIdtyStatus =
|
final fromIdtyStatus =
|
||||||
fromAddress == '' ? 'noid' : await idtyStatus(fromAddress);
|
fromAddress == '' ? IdtyStatus.none : await idtyStatus(fromAddress);
|
||||||
final fromHasConsumer =
|
final fromHasConsumer =
|
||||||
fromAddress == '' ? false : await hasAccountConsumers(fromAddress);
|
fromAddress == '' ? false : await hasAccountConsumers(fromAddress);
|
||||||
final toIdtyStatus = await idtyStatus(toAddress);
|
final toIdtyStatus = await idtyStatus(toAddress);
|
||||||
|
@ -982,8 +972,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
final toCerts = await getCertsCounter(destAddress);
|
final toCerts = await getCertsCounter(destAddress);
|
||||||
|
|
||||||
// log.d('debug: ${currencyParameters['minCertForMembership']}');
|
|
||||||
|
|
||||||
log.d(
|
log.d(
|
||||||
"debug toCert: ${toCerts?[0]} --- ${currencyParameters['minCertForMembership']!} --- $toIdtyStatus");
|
"debug toCert: ${toCerts?[0]} --- ${currencyParameters['minCertForMembership']!} --- $toIdtyStatus");
|
||||||
|
|
||||||
|
@ -1136,7 +1124,7 @@ newKeySig: $newKeySig""");
|
||||||
Future migrateCsToV2(String salt, String password, String destAddress,
|
Future migrateCsToV2(String salt, String password, String destAddress,
|
||||||
{required destPassword,
|
{required destPassword,
|
||||||
required Map balance,
|
required Map balance,
|
||||||
String idtyStatus = 'noid'}) async {
|
IdtyStatus idtyStatus = IdtyStatus.none}) async {
|
||||||
final scrypt = pc.KeyDerivator('scrypt');
|
final scrypt = pc.KeyDerivator('scrypt');
|
||||||
|
|
||||||
scrypt.init(
|
scrypt.init(
|
||||||
|
@ -1167,7 +1155,7 @@ newKeySig: $newKeySig""");
|
||||||
);
|
);
|
||||||
|
|
||||||
log.d('g1migration idtyStatus: $idtyStatus');
|
log.d('g1migration idtyStatus: $idtyStatus');
|
||||||
if (idtyStatus != 'noid') {
|
if (idtyStatus != IdtyStatus.none) {
|
||||||
await migrateIdentity(
|
await migrateIdentity(
|
||||||
fromAddress: keypair.address!,
|
fromAddress: keypair.address!,
|
||||||
destAddress: destAddress,
|
destAddress: destAddress,
|
||||||
|
|
|
@ -27,11 +27,13 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||||
|
|
||||||
Timer? debounce;
|
Timer? debounce;
|
||||||
const int debouneTime = 300;
|
const int debouneTime = 600;
|
||||||
WalletData selectedWallet = myWalletProvider.getDefaultWallet();
|
WalletData selectedWallet = myWalletProvider.getDefaultWallet();
|
||||||
bool canValidate = false;
|
bool canValidate = false;
|
||||||
String validationStatus = '';
|
String validationStatus = '';
|
||||||
|
|
||||||
|
log.d(myWalletProvider.listWallets);
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
resetScreen(context);
|
resetScreen(context);
|
||||||
|
@ -58,8 +60,6 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
future: sub.getBalanceAndIdtyStatus(
|
future: sub.getBalanceAndIdtyStatus(
|
||||||
sub.g1V1NewAddress, selectedWallet.address),
|
sub.g1V1NewAddress, selectedWallet.address),
|
||||||
builder: (BuildContext context, AsyncSnapshot<List> status) {
|
builder: (BuildContext context, AsyncSnapshot<List> status) {
|
||||||
// log.d(_certs.data);
|
|
||||||
|
|
||||||
if (status.data == null) {
|
if (status.data == null) {
|
||||||
return const Column(children: [
|
return const Column(children: [
|
||||||
SizedBox(height: 80),
|
SizedBox(height: 80),
|
||||||
|
@ -79,13 +79,11 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map balance = status.data?[0] ?? {};
|
final Map balance = status.data?[0] ?? {};
|
||||||
final String idtyStatus = status.data?[1];
|
final IdtyStatus idtyStatus = status.data?[1];
|
||||||
final String myIdtyStatus = status.data?[2];
|
final IdtyStatus myIdtyStatus = status.data?[2];
|
||||||
final bool hasConsumer = status.data?[3] ?? false;
|
final bool hasConsumer = status.data?[3] ?? false;
|
||||||
final bool isSmith = status.data?[4] ?? false;
|
final bool isSmith = status.data?[4] ?? false;
|
||||||
|
|
||||||
// log.d('hasconsumer: $hasConsumer');
|
|
||||||
|
|
||||||
if (balance['transferableBalance'] != 0 && !hasConsumer) {
|
if (balance['transferableBalance'] != 0 && !hasConsumer) {
|
||||||
canValidate = true;
|
canValidate = true;
|
||||||
validationStatus = '';
|
validationStatus = '';
|
||||||
|
@ -96,7 +94,8 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
: 'thisAccountIsEmpty'.tr();
|
: 'thisAccountIsEmpty'.tr();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
|
if (idtyStatus != IdtyStatus.none &&
|
||||||
|
myIdtyStatus != IdtyStatus.none) {
|
||||||
canValidate = false;
|
canValidate = false;
|
||||||
validationStatus =
|
validationStatus =
|
||||||
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ManageMembership extends StatelessWidget {
|
||||||
migrateIdentity(context),
|
migrateIdentity(context),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: sub.isSmithGet(address),
|
future: sub.isSmith(address),
|
||||||
builder: (BuildContext context, AsyncSnapshot<bool> isSmith) {
|
builder: (BuildContext context, AsyncSnapshot<bool> isSmith) {
|
||||||
if (isSmith.data ?? false) {
|
if (isSmith.data ?? false) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
|
|
@ -96,8 +96,8 @@ class MigrateIdentityScreen extends StatelessWidget {
|
||||||
// log.d('statusData: ${status.data}');
|
// log.d('statusData: ${status.data}');
|
||||||
|
|
||||||
final Map balance = status.data?[0] ?? {};
|
final Map balance = status.data?[0] ?? {};
|
||||||
final String idtyStatus = status.data?[1];
|
final IdtyStatus idtyStatus = status.data?[1];
|
||||||
final String myIdtyStatus = status.data?[2];
|
final IdtyStatus myIdtyStatus = status.data?[2];
|
||||||
final bool hasConsumer = status.data?[3] ?? false;
|
final bool hasConsumer = status.data?[3] ?? false;
|
||||||
final bool isSmith = status.data?[4] ?? false;
|
final bool isSmith = status.data?[4] ?? false;
|
||||||
|
|
||||||
|
@ -110,7 +110,8 @@ class MigrateIdentityScreen extends StatelessWidget {
|
||||||
!hasConsumer) {
|
!hasConsumer) {
|
||||||
canValidate = true;
|
canValidate = true;
|
||||||
validationStatus = '';
|
validationStatus = '';
|
||||||
} else if (idtyStatus != 'noid' && myIdtyStatus != 'noid') {
|
} else if (idtyStatus != IdtyStatus.none &&
|
||||||
|
myIdtyStatus != IdtyStatus.none) {
|
||||||
canValidate = false;
|
canValidate = false;
|
||||||
validationStatus =
|
validationStatus =
|
||||||
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
'youCannotMigrateIdentityToExistingIdentity'.tr();
|
||||||
|
|
|
@ -193,9 +193,10 @@ class WalletOptions extends StatelessWidget {
|
||||||
address:
|
address:
|
||||||
walletProvider.address.text,
|
walletProvider.address.text,
|
||||||
username: duniterIndexer
|
username: duniterIndexer
|
||||||
.walletNameIndexer[
|
.walletNameIndexer[
|
||||||
walletProvider
|
walletProvider
|
||||||
.address.text]!);
|
.address.text] ??
|
||||||
|
'');
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,9 @@ class _WalletsHomeState extends State<WalletsHome> {
|
||||||
(w) => w.hasIdentity(),
|
(w) => w.hasIdentity(),
|
||||||
orElse: () => WalletData(address: ''),
|
orElse: () => WalletData(address: ''),
|
||||||
);
|
);
|
||||||
listWallets.removeWhere((w) => w.address == idtyWallet.address);
|
|
||||||
|
List<WalletData> listWalletsWithoutIdty = listWallets.toList();
|
||||||
|
listWalletsWithoutIdty.removeWhere((w) => w.address == idtyWallet.address);
|
||||||
|
|
||||||
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
|
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
@ -318,7 +320,7 @@ class _WalletsHomeState extends State<WalletsHome> {
|
||||||
crossAxisSpacing: 0,
|
crossAxisSpacing: 0,
|
||||||
mainAxisSpacing: 0,
|
mainAxisSpacing: 0,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
for (WalletData repository in listWallets)
|
for (WalletData repository in listWalletsWithoutIdty)
|
||||||
LongPressDraggable<String>(
|
LongPressDraggable<String>(
|
||||||
delay: const Duration(milliseconds: 200),
|
delay: const Duration(milliseconds: 200),
|
||||||
data: repository.address,
|
data: repository.address,
|
||||||
|
|
Loading…
Reference in New Issue