MCPcopy
hub / github.com/ethereum/research / is_constant_sized

Function is_constant_sized

spec_pythonizer/minimal_ssz.py:53–68  ·  view source on GitHub ↗
(typ)

Source from the content-addressed store, hash-verified

51 return isinstance(typ, str) and (typ[:4] in ('uint', 'bool') or typ == 'byte')
52
53def 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
70def coerce_to_bytes(x):
71 if isinstance(x, str):

Callers 1

serialize_valueFunction · 0.70

Calls 1

is_basicFunction · 0.70

Tested by

no test coverage detected