(typ)
| 51 | return isinstance(typ, str) and (typ[:4] in ('uint', 'bool') or typ == 'byte') |
| 52 | |
| 53 | def is_constant_sized(typ): |
| 54 | if is_basic(typ): |
| 55 | return True |
| 56 | elif isinstance(typ, list) and len(typ) == 1: |
| 57 | return is_constant_sized(typ[0]) |
| 58 | elif isinstance(typ, list) and len(typ) == 2: |
| 59 | return False |
| 60 | elif isinstance(typ, str) and typ[:5] == 'bytes': |
| 61 | return len(typ) > 5 |
| 62 | elif hasattr(typ, 'fields'): |
| 63 | for subtype in typ.fields.values(): |
| 64 | if not is_constant_sized(subtype): |
| 65 | return False |
| 66 | return True |
| 67 | else: |
| 68 | raise Exception("Type not recognized") |
| 69 | |
| 70 | def coerce_to_bytes(x): |
| 71 | if isinstance(x, str): |
no test coverage detected