gov2.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:polkawallet_sdk/service/index.dart';
  4. class ServiceGov2 {
  5. ServiceGov2(this.serviceRoot);
  6. final SubstrateService serviceRoot;
  7. Future<bool> checkGovExist(int version) async {
  8. final bool? res = await serviceRoot.webView!.evalJavascript(
  9. 'gov2.checkGovExist(api, $version)',
  10. wrapPromise: false);
  11. return res ?? false;
  12. }
  13. Future<Map> queryReferendums(String address) async {
  14. final Map res = await serviceRoot.webView!
  15. .evalJavascript('gov2.queryReferendums(api, "$address")');
  16. return res;
  17. }
  18. Future<List?> getDemocracyUnlocks(String address) async {
  19. final dynamic res = await serviceRoot.webView!
  20. .evalJavascript('gov.getDemocracyUnlocks(api, "$address")');
  21. return res;
  22. }
  23. Future<List?> getExternalLinks(Map params) async {
  24. final dynamic res = await serviceRoot.webView!
  25. .evalJavascript('settings.genLinks(api, ${jsonEncode(params)})');
  26. return res;
  27. }
  28. Future<List?> getReferendumVoteConvictions() async {
  29. final dynamic res = await serviceRoot.webView!
  30. .evalJavascript('gov2.getReferendumVoteConvictions(api)');
  31. return res;
  32. }
  33. }