mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
catch abi parsing errors
This commit is contained in:
parent
dad35470f8
commit
35ea94a209
1 changed files with 46 additions and 36 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue