Esempio n. 1
0
 def to_literal(self) -> Type[Micheline]:
     if self.ptr is not None:
         return MichelineLiteral.create(self.ptr)
     else:
         return MichelineSequence.create_type(args=[
             EltLiteral.create_type(
                 args=[k.to_literal(), v.to_literal()])
             for k, v in self.items
         ])
Esempio n. 2
0
    def execute(cls, stack: MichelsonStack, stdout: List[str], context: AbstractContext):
        left, lambda_ = cast(Tuple[MichelsonType, LambdaType], stack.pop2())
        lambda_.assert_type_in(LambdaType)
        lambda_.args[0].assert_type_in(PairType)
        left_type, right_type = lambda_.args[0].args
        left.assert_type_equal(left_type)

        new_value = MichelineSequence.create_type(args=[
            PushInstruction.create_type(args=[left_type, left.to_literal()]),
            PairInstruction,
            lambda_.value
        ])
        res = LambdaType.create_type(args=[right_type, lambda_.args[1]])(new_value)  # type: ignore
        stack.push(res)
        stdout.append(format_stdout(cls.prim, [left, lambda_], [res]))  # type: ignore
        return cls(stack_items_added=1)
Esempio n. 3
0
 def to_literal(self) -> Type[Micheline]:
     return MichelineSequence.create_type(args=[
         EltLiteral.create_type(
             args=[k.to_literal(), v.to_literal()]) for k, v in self.items
     ])
Esempio n. 4
0
 def to_literal(self) -> Type[Micheline]:
     if self.ptr is not None:
         return MichelineLiteral.create(self.ptr)
     else:
         return MichelineSequence.create_type(args=[])
Esempio n. 5
0
 def to_literal(self) -> Type[Micheline]:
     return MichelineSequence.create_type(
         args=[item.to_literal() for item in self.items])