txListInternal method Null safety

Future<EtherScanTxInternalModel> txListInternal (
  1. {String? txhash,
  2. String? address,
  3. Object startblock = 0,
  4. String? endblock = 'latest',
  5. EtherSort sort = EtherSort.asc}
)

Get a list of internal transactions

txhash - Transaction hash. If specified then address will be ignored

address - Transaction address

startblock - start looking here

endblock - end looking there

sort - Sort asc/desc

Example

final txlist = eth.txListInternal('0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170');

Implementation

Future<EtherScanTxInternalModel> txListInternal({
  String? txhash,
  String? address,
  Object startblock = 0,
  String? endblock = 'latest',
  EtherSort sort = EtherSort.asc,
}) async {
  const module = 'account';
  const action = 'txlistinternal';

  Map<String, dynamic>? query = {
    'module': module,
    'action': action,
    'apiKey': apiKey,
  };

  query.addAll({
    'startblock': startblock,
    'endblock': endblock,
    'sort': sort.str,
  });

  if (txhash != null) {
    query.putIfAbsent('txhash', () => txhash);
  } else {
    query.putIfAbsent('address', () => address);
  }

  query['txhash'] = txhash;

  return (await get(query)).fold(
    (l) => EtherScanTxInternalModel.empty(),
    (r) => EtherScanTxInternalModel.fromJson(r),
  );
}