schemaFromName function
BcsType
schemaFromName(
- String name
)
Implementation
BcsType schemaFromName(String name) {
switch (name) {
case 'u8': return SuiBcs.U8;
case 'u16': return SuiBcs.U16;
case 'u32': return SuiBcs.U32;
case 'u64': return SuiBcs.U64;
case 'u128': return SuiBcs.U128;
case 'u256': return SuiBcs.U256;
case 'bool': return SuiBcs.BOOL;
case 'string': return SuiBcs.STRING;
case 'id':
case 'address': return SuiBcs.Address;
}
final generic = RegExp(r'^(vector|option)<(.+)>$').firstMatch(name);
if (generic != null) {
final kind = generic.group(1);
final inner = generic.group(2)!;
if (kind == 'vector') {
return Bcs.vector(schemaFromName(inner));
} else {
return Bcs.option(schemaFromName(inner));
}
}
throw ArgumentError('Invalid Pure type name: $name');
}