ABICoder<T>.fromType constructor
ABICoder<T>.fromType (
- String type
Factory method to create an ABICoder instance based on the provided type string.
Implementation
factory ABICoder.fromType(String type) {
String? correctType;
// Check for array, bytes, and numeric types
if (type.endsWith(']')) {
correctType = "array";
} else if (type.startsWith('bytes')) {
correctType = "bytes";
} else if (type.startsWith('uint') || type.startsWith('int')) {
correctType = "number";
}
// Use the corrected type or the original type if not modified
correctType ??= type;
if (!_types.containsKey(correctType)) {
throw MessageException("Unsuported ABI type", details: {"type": type});
}
// Return the corresponding ABICoder instance
return _types[correctType]! as ABICoder<T>;
}