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";
|
||||
}
|
||||
|
||||
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
|
||||
List<int?> id() {
|
||||
return [chest, number];
|
||||
|
|
|
@ -311,15 +311,6 @@ class SubstrateSdk with ChangeNotifier {
|
|||
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 {
|
||||
var idtyIndex = await _getIdentityIndexOf(address);
|
||||
|
||||
|
@ -337,7 +328,9 @@ class SubstrateSdk with ChangeNotifier {
|
|||
Map<String, int> result = {};
|
||||
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 certMeta = await getCertMeta(from);
|
||||
final int nextIssuableOn = certMeta['nextIssuableOn'] ?? 0;
|
||||
|
|
|
@ -262,28 +262,16 @@ class WalletOptions extends StatelessWidget {
|
|||
walletOptions,
|
||||
currentChest),
|
||||
SizedBox(height: 17 * ratio),
|
||||
// walletProvider.isMember(context, _walletOptions.address.text)
|
||||
FutureBuilder(
|
||||
future:
|
||||
sub.isMember(walletOptions.address.text),
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<bool> isMember) {
|
||||
if (isMember.connectionState !=
|
||||
ConnectionState.done ||
|
||||
isMember.hasError) {
|
||||
return const Text('');
|
||||
}
|
||||
return Column(children: [
|
||||
if (!walletProvider.isDefaultWallet &&
|
||||
!isMember.data!)
|
||||
deleteWallet(context, walletProvider,
|
||||
currentChest)
|
||||
else
|
||||
const SizedBox(),
|
||||
if (isMember.data!)
|
||||
const ManageMembershipButton()
|
||||
]);
|
||||
}),
|
||||
Column(children: [
|
||||
if (!walletProvider.isDefaultWallet &&
|
||||
!wallet.isMembre())
|
||||
deleteWallet(
|
||||
context, walletProvider, currentChest)
|
||||
else
|
||||
const SizedBox(),
|
||||
if (wallet.isMembre())
|
||||
const ManageMembershipButton()
|
||||
])
|
||||
]);
|
||||
}),
|
||||
]),
|
||||
|
|
Loading…
Reference in New Issue