polkawallet-io / sdk

polkawallet SDK for integrating substrate-based blockchain as a plugin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

signAndSend doesn't wait for Finalized event

poka-IT opened this issue · comments

commented

Your signAndSend method is commented with:

/// Send tx, [params] will be ignored if we have [rawParam].
/// [onStatusChange] is a callback when tx status change.
/// @return txHash [string] if tx finalized success.

But that's wrong, the method return hash when transaction is validate by Babe, but still not Finalized by Granpa.

By reading your code in tx.dart, I realy don't understand why :

  Future<Map?> signAndSend(Map txInfo, String params, password,
      Function(String) onStatusChange) async {
    final msgId =
        "onStatusChange${serviceRoot.webView!.getEvalJavascriptUID()}";
    serviceRoot.webView!.addMsgHandler(msgId, onStatusChange);
    final code =
        'keyring.sendTx(api, ${jsonEncode(txInfo)}, $params, "$password", "$msgId")';
    // print(code);
    final dynamic res = await serviceRoot.webView!.evalJavascript(code);
    serviceRoot.webView!.removeMsgHandler(msgId);

    return res;
  }

Do you have an idea ?

You're right, the comment is wrong, it doesn't wait for finalized event.