connect method

  1. @override
Future<List<String>> connect()

Requests access to the Wallet for the dApp, may be rejected or approved. Every access to the extension begins with a connect request, which if approved by the user, allows the dApp to follow-up with other requests.

Returns the list of accounts from MyAlgo.

Implementation

@override
Future<List<String>> connect() async {
  var c = Completer<List<String>>();
  promiseToFuture(myAlgo.connect()).then((value) {
    if (value is! List) {
      return c.complete([]);
    }

    final addresses = value.map((address) {
      return getProperty(address, 'address') as String;
    }).toList();

    return c.complete(addresses);
  }).onError((error, stackTrace) => c.completeError(_handleError(error)));

  return c.future;
}