Exemple #1
0
 def match(type_expr) -> Type['ParameterSection']:
     try:
         cls = Micheline.match(type_expr)
         if not issubclass(cls, ParameterSection):
             cls = ParameterSection.create_type(args=[cls])
     except Exception as e:
         raise MichelsonRuntimeError('parameter', *e.args) from e
     return cls
Exemple #2
0
 def match(type_expr) -> Type['StorageSection']:
     try:
         cls = Micheline.match(type_expr)
         if not issubclass(cls, StorageSection):
             cls = StorageSection.create_type(args=[cls])
         assert cls.args[
             0].field_name is None, f'argument type cannot be annotated: %{cls.args[0].field_name}'  # type: ignore
     except Exception as e:
         raise MichelsonRuntimeError('storage', *e.args) from e
     return cls  # type: ignore
Exemple #3
0
 def match(output_expr) -> Type['NowSection']:
     cls = Micheline.match(output_expr)
     if not issubclass(cls, NowSection):
         cls = NowSection.create_type(args=[cls])
     return cls  # type: ignore
Exemple #4
0
 def match(expr) -> Type['MichelsonType']:
     return cast(Type['MichelsonType'], Micheline.match(expr))
Exemple #5
0
 def from_micheline_value(cls, val_expr) -> 'LambdaType':
     assert isinstance(
         val_expr, list), f'expected list, got {type(val_expr).__name__}'
     return cls(Micheline.match(val_expr))
Exemple #6
0
 def dummy(cls, context: AbstractContext) -> 'LambdaType':
     return cls(Micheline.match(context.get_dummy_lambda()))
Exemple #7
0
 def match(code_expr) -> Type['CodeSection']:
     cls = Micheline.match(code_expr)
     if not issubclass(cls, CodeSection):
         cls = CodeSection.create_type(args=[cls])
     return cls  # type: ignore
Exemple #8
0
 def match(expr) -> Type['MichelsonInstruction']:
     return cast(Type['MichelsonInstruction'], Micheline.match(expr))