decodeTransactionEvents function

Future<List<DecodedEvent>> decodeTransactionEvents({
  1. required Transaction transaction,
  2. required String contractAbi,
})

Decode events of transaction and return list of DecodedEvent or throws error

Implementation

Future<List<DecodedEvent>> decodeTransactionEvents({
  required Transaction transaction,
  required String contractAbi,
}) async {
  final res = await createLib().decodeTransactionEvents(
    transaction: jsonEncode(transaction),
    contractAbi: contractAbi,
  );
  final decoded = jsonDecode(res);
  final json = decoded as List<dynamic>;
  final list = json.cast<Map<String, dynamic>>();
  return list.map((e) => DecodedEvent.fromJson(e)).toList();
}