catch abi parsing errors

This commit is contained in:
julian 2023-05-01 11:18:38 -06:00
parent dad35470f8
commit 35ea94a209

View file

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:stackwallet/utilities/logger.dart';
import 'package:web3dart/web3dart.dart';
extension ContractAbiExtensions on ContractAbi {
@ -7,10 +8,12 @@ extension ContractAbiExtensions on ContractAbi {
required String name,
required String jsonList,
}) {
try {
final List<ContractFunction> functions = [];
final List<ContractEvent> events = [];
final list = List<Map<String, dynamic>>.from(jsonDecode(jsonList) as List);
final list =
List<Map<String, dynamic>>.from(jsonDecode(jsonList) as List);
for (final json in list) {
final type = json["type"] as String;
@ -53,6 +56,13 @@ extension ContractAbiExtensions on ContractAbi {
}
return ContractAbi(name, functions, events);
} catch (e, s) {
Logging.instance.log(
"Failed to parse ABI for $name: $e\n$s",
level: LogLevel.Error,
);
rethrow;
}
}
static const Map<String, ContractFunctionType> _functionTypeNames = {