refacto: add methods to WalletData
This commit is contained in:
parent
1b1c5ab7f0
commit
b916c44db4
|
@ -61,6 +61,24 @@ class WalletData extends HiveObject {
|
||||||
return "$chest:$number:$name:$derivation:$imageDefaultPath";
|
return "$chest:$number:$name:$derivation:$imageDefaultPath";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasIdentity() {
|
||||||
|
return identityStatus == IdtyStatus.created ||
|
||||||
|
identityStatus == IdtyStatus.confirmed ||
|
||||||
|
identityStatus == IdtyStatus.validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMembre() {
|
||||||
|
return identityStatus == IdtyStatus.validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool exist() {
|
||||||
|
return balance != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasCustomImage() {
|
||||||
|
return imageCustomPath != null;
|
||||||
|
}
|
||||||
|
|
||||||
// returns only the id part of the ':'-separated string
|
// returns only the id part of the ':'-separated string
|
||||||
List<int?> id() {
|
List<int?> id() {
|
||||||
return [chest, number];
|
return [chest, number];
|
||||||
|
|
|
@ -311,15 +311,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return totalAmount;
|
return totalAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isMember(String address) async {
|
|
||||||
final isMember = await idtyStatus(address) == IdtyStatus.validated;
|
|
||||||
final walletData = walletBox.get(address) ?? WalletData(address: address);
|
|
||||||
walletData.identityStatus = IdtyStatus.validated;
|
|
||||||
walletBox.put(address, walletData);
|
|
||||||
// notifyListeners();
|
|
||||||
return isMember;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> isSmithGet(String address) async {
|
Future<bool> isSmithGet(String address) async {
|
||||||
var idtyIndex = await _getIdentityIndexOf(address);
|
var idtyIndex = await _getIdentityIndexOf(address);
|
||||||
|
|
||||||
|
@ -337,7 +328,9 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
Map<String, int> result = {};
|
Map<String, int> result = {};
|
||||||
final toStatus = await idtyStatus(to);
|
final toStatus = await idtyStatus(to);
|
||||||
|
|
||||||
if (from != to && await isMember(from)) {
|
final myWallets = MyWalletsProvider();
|
||||||
|
|
||||||
|
if (from != to && myWallets.getWalletDataByAddress(from)!.isMembre()) {
|
||||||
final removableOn = await getCertValidityPeriod(from, to);
|
final removableOn = await getCertValidityPeriod(from, to);
|
||||||
final certMeta = await getCertMeta(from);
|
final certMeta = await getCertMeta(from);
|
||||||
final int nextIssuableOn = certMeta['nextIssuableOn'] ?? 0;
|
final int nextIssuableOn = certMeta['nextIssuableOn'] ?? 0;
|
||||||
|
|
|
@ -262,28 +262,16 @@ class WalletOptions extends StatelessWidget {
|
||||||
walletOptions,
|
walletOptions,
|
||||||
currentChest),
|
currentChest),
|
||||||
SizedBox(height: 17 * ratio),
|
SizedBox(height: 17 * ratio),
|
||||||
// walletProvider.isMember(context, _walletOptions.address.text)
|
Column(children: [
|
||||||
FutureBuilder(
|
if (!walletProvider.isDefaultWallet &&
|
||||||
future:
|
!wallet.isMembre())
|
||||||
sub.isMember(walletOptions.address.text),
|
deleteWallet(
|
||||||
builder: (BuildContext context,
|
context, walletProvider, currentChest)
|
||||||
AsyncSnapshot<bool> isMember) {
|
else
|
||||||
if (isMember.connectionState !=
|
const SizedBox(),
|
||||||
ConnectionState.done ||
|
if (wallet.isMembre())
|
||||||
isMember.hasError) {
|
const ManageMembershipButton()
|
||||||
return const Text('');
|
])
|
||||||
}
|
|
||||||
return Column(children: [
|
|
||||||
if (!walletProvider.isDefaultWallet &&
|
|
||||||
!isMember.data!)
|
|
||||||
deleteWallet(context, walletProvider,
|
|
||||||
currentChest)
|
|
||||||
else
|
|
||||||
const SizedBox(),
|
|
||||||
if (isMember.data!)
|
|
||||||
const ManageMembershipButton()
|
|
||||||
]);
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
|
Loading…
Reference in New Issue