apiRecovery.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:polkawallet_sdk/api/api.dart';
  2. import 'package:polkawallet_sdk/api/types/recoveryInfo.dart';
  3. import 'package:polkawallet_sdk/service/recovery.dart';
  4. class ApiRecovery {
  5. ApiRecovery(this.apiRoot, this.service);
  6. final PolkawalletApi apiRoot;
  7. final ServiceRecovery service;
  8. Future<RecoveryInfo?> queryRecoverable(String address) async {
  9. // address = "J4sW13h2HNerfxTzPGpLT66B3HVvuU32S6upxwSeFJQnAzg";
  10. final res = await service.queryRecoverable(address);
  11. if (res != null) {
  12. return RecoveryInfo.fromJson(
  13. Map<String, dynamic>.of(res as Map<String, dynamic>));
  14. }
  15. return null;
  16. }
  17. Future<List<RecoveryInfo>> queryRecoverableList(
  18. List<String> addresses) async {
  19. final List res = await service.queryRecoverableList(addresses);
  20. return res
  21. .map((e) => RecoveryInfo.fromJson(Map<String, dynamic>.of(e ?? {})))
  22. .toList();
  23. }
  24. Future<List?> queryActiveRecoveryAttempts(
  25. String address, List<String> addressNew) async {
  26. final res = await service.queryActiveRecoveryAttempts(address, addressNew);
  27. return res;
  28. }
  29. Future<List?> queryActiveRecoveries(
  30. List<String> addresses, String addressNew) async {
  31. final res = await service.queryActiveRecoveries(addresses, addressNew);
  32. return res;
  33. }
  34. Future<List?> queryRecoveryProxies(List<String> addresses) async {
  35. final res = await service.queryRecoveryProxies(addresses);
  36. return res;
  37. }
  38. }