getLogs method

Future<MoacFilter> getLogs ({MoacDefaultBlock fromBlock, MoacDefaultBlock toBlock, dynamic address, List<BigInt> topics })

Get logs The filter definition, see newFilter parameters. Returns see getFilterChanges

Implementation

Future<MoacFilter> getLogs(
    {MoacDefaultBlock fromBlock,
    MoacDefaultBlock toBlock,
    dynamic address,
    List<BigInt> topics}) async {
  final String fromBlockString = fromBlock.getSelection();
  final String toBlockString = toBlock.getSelection();
  final Map params = {"toBlock": toBlockString, "fromBlock": fromBlockString};
  if (address != null) {
    if (address is List) {
      final List<String> addresses =
          MoacUtilities.bigIntegerToHexList(address);
      params["address"] = addresses;
    } else {
      params["address"] = (MoacUtilities.bigIntegerToHex(address));
    }
  }
  if (topics != null) {
    params["topics"] = MoacUtilities.bigIntegerToHexList(topics);
  }
  final List paramBlock = [params];
  final String method = MoacRpcMethods.getLogs;
  final res = await rpcClient.request(method, paramBlock);
  if (res != null && res.containsKey(moacResultKey)) {
    return MoacFilter.fromMap(res[moacResultKey]);
  }
  _processError(method, res);
  return null;
}