getUncleByBlockNumberAndIndex method

Future<EthereumBlock?> getUncleByBlockNumberAndIndex(
  1. EthereumDefaultBlock? blockNumber,
  2. int? index
)

Get uncle by block number and index. Returns information about an uncle by block number and uncle index position. Note: An uncle doesn't contain individual transactions. A block number as in the default block parameter. Returns see getBlockByHash.

Implementation

Future<EthereumBlock?> getUncleByBlockNumberAndIndex(
    EthereumDefaultBlock? blockNumber, int? index) async {
  if (blockNumber == null) {
    throw ArgumentError.notNull(
        'Ethereum::getUncleByBlockNumberAndIndex - blockNumber');
  }
  if (index == null) {
    throw ArgumentError.notNull(
        'Ethereum::getUncleByBlockNumberAndIndex - index');
  }
  final blockNumberString = blockNumber.getSelection();
  final dynamic params = <dynamic>[
    blockNumberString,
    EthereumUtilities.intToHex(index)
  ];
  const method = EthereumRpcMethods.getUncleByBlockNumberAndIndex;
  final dynamic res = await _client.rpcClient.request(method, params);
  if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
    return EthereumBlock.fromMap(res[EthereumConstants.ethResultKey]);
  }
  _client.processError(method, res);
  return null;
}