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