parseQrCode method
parse data of QR code. @return: signer pubKey String
Implementation
Future<String> parseQrCode(List keyPairs, String data) async {
final res = await serviceRoot.webView!
.evalJavascript('keyring.parseQrCode("$data")');
if (res['error'] != null) {
throw Exception(res['error']);
}
final pubKeyAddressMap = await (serviceRoot.account
.decodeAddress([res['signer']]) as FutureOr<Map<dynamic, dynamic>>);
final pubKey = pubKeyAddressMap.keys.toList()[0];
final accIndex = keyPairs.indexWhere((e) => e['pubKey'] == pubKey);
if (accIndex < 0) {
throw Exception('signer: ${res['signer']} not found.');
}
return pubKey;
}