valueOf static method
Deserialize ABI type scheme from string @param str string representation of ABI type schemes @return ABI type scheme object @throws ArgumentError if ABI type serialization strings are corrupted
Implementation
static AbiType valueOf(String scheme) {
if (scheme.endsWith('[]')) {
return TypeArrayDynamic.valueOf(scheme);
} else if (scheme.endsWith(']')) {
return TypeArrayStatic.valueOf(scheme);
} else if (scheme.startsWith('uint')) {
return TypeUint.valueOf(scheme);
} else if (scheme.startsWith('byte')) {
return TypeByte();
} else if (scheme.startsWith('ufixed')) {
return TypeUfixed.valueOf(scheme);
} else if (scheme.startsWith('bool')) {
return TypeBool();
} else if (scheme.startsWith('address')) {
return TypeAddress();
} else if (scheme.startsWith('string')) {
return TypeString();
} else if (scheme.length >= 2 && scheme[0] == '(' && scheme.endsWith(')')) {
return TypeTuple.valueOf(scheme);
} else {
throw ArgumentError('Cannot infer type from string: $scheme');
}
}