WIP: get received/sent certs
This commit is contained in:
parent
e7e4bca4e3
commit
1eb966046c
|
@ -210,6 +210,20 @@ class SubstrateSdk with ChangeNotifier {
|
|||
return result;
|
||||
}
|
||||
|
||||
Future<List<int>> getCerts(String address) async {
|
||||
final idtyIndex = await sdk.webView!
|
||||
.evalJavascript('api.query.identity.identityIndexOf("$address")');
|
||||
log.d(idtyIndex);
|
||||
|
||||
final _certsReceiver = await sdk.webView!
|
||||
.evalJavascript('api.query.cert.storageIdtyCertMeta($idtyIndex)') ??
|
||||
[];
|
||||
|
||||
log.d(_certsReceiver['receivedCount']);
|
||||
|
||||
return [_certsReceiver['receivedCount'], _certsReceiver['issuedCount']];
|
||||
}
|
||||
|
||||
Future<double> getBalance(String address, {bool isUd = false}) async {
|
||||
double balance = 0.0;
|
||||
if (nodeConnected) {
|
||||
|
|
|
@ -174,7 +174,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
return SizedBox(
|
||||
width: 230,
|
||||
child: Column(children: const <Widget>[
|
||||
Text(
|
||||
'Statut inconnu',
|
||||
|
@ -291,3 +290,44 @@ Widget balance(BuildContext context, String address, double size,
|
|||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
Map<String, String> certCache = {};
|
||||
Widget getCerts(BuildContext context, String address, double size,
|
||||
[Color _color = Colors.black]) {
|
||||
return Column(children: <Widget>[
|
||||
Consumer<SubstrateSdk>(builder: (context, _sdk, _) {
|
||||
return FutureBuilder(
|
||||
future: _sdk.getCerts(address),
|
||||
builder: (BuildContext context, AsyncSnapshot<List?>? _certs) {
|
||||
if (_certs!.connectionState != ConnectionState.done ||
|
||||
_certs.hasError) {
|
||||
if (certCache[address] != null) {
|
||||
return Text(certCache[address]!,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9, color: _color));
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 15,
|
||||
width: 15,
|
||||
child: CircularProgressIndicator(
|
||||
color: orangeC,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
certCache[address] = _certs.data![0] != 0
|
||||
? "Certifications reçus: ${_certs.data![0].toString()}\nCertifications envoyés: ${_certs.data![1].toString()}"
|
||||
: '';
|
||||
|
||||
return Text(
|
||||
certCache[address]!,
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: _color,
|
||||
),
|
||||
);
|
||||
});
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -91,23 +91,39 @@ class WalletOptions extends StatelessWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
const Spacer(flex: 1),
|
||||
const Spacer(flex: 5),
|
||||
avatar(walletProvider),
|
||||
const Spacer(flex: 1),
|
||||
// const Spacer(flex: 1),
|
||||
Column(children: <Widget>[
|
||||
walletName(walletProvider, _walletOptions),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
balance(context, walletProvider.address.text, 20),
|
||||
SizedBox(height: isTall ? 5 : 0),
|
||||
_walletOptions.idtyStatus(
|
||||
context, _walletOptions.address.text,
|
||||
SizedBox(
|
||||
width: 350,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// SizedBox(height: isTall ? 5 : 0),
|
||||
balance(
|
||||
context, walletProvider.address.text, 21),
|
||||
const SizedBox(width: 30),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
_walletOptions.idtyStatus(context,
|
||||
_walletOptions.address.text,
|
||||
isOwner: true),
|
||||
getCerts(context,
|
||||
walletProvider.address.text, 15),
|
||||
]),
|
||||
const Spacer(flex: 3),
|
||||
]),
|
||||
),
|
||||
SizedBox(height: 10 * ratio),
|
||||
]),
|
||||
const Spacer(flex: 1),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 10 * ratio),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(children: <Widget>[
|
||||
|
|
|
@ -609,12 +609,11 @@ class WalletViewScreen extends StatelessWidget {
|
|||
),
|
||||
]),
|
||||
const SizedBox(height: 25),
|
||||
Consumer<WalletOptionsProvider>(
|
||||
builder: (context, walletProvider, _) {
|
||||
return balance(context, pubkey!, 22);
|
||||
}),
|
||||
|
||||
balance(context, pubkey!, 22),
|
||||
const SizedBox(height: 10),
|
||||
_walletOptions.idtyStatus(context, pubkey!, isOwner: false),
|
||||
getCerts(context, pubkey!, 14),
|
||||
|
||||
// if (username == null &&
|
||||
// g1WalletsBox.get(pubkey)?.username == null)
|
||||
|
|
Loading…
Reference in New Issue