Пример #1
0
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     a = cast(Union[NatType, BLS12_381_FrType], stack.pop1())
     a.assert_type_in(NatType, BLS12_381_FrType)
     res = IntType.from_value(int(a))
     stack.push(res)
     stdout.append(f'{cls.prim} / {repr(a)} => {repr(res)}')
     return cls(stack_items_added=1)
Пример #2
0
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     a, b = stack.pop2()
     a.assert_type_equal(type(b))
     res = IntType.from_value(compare(a, b))
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [a, b], [res]))  # type: ignore
     return cls(stack_items_added=1)
Пример #3
0
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     a = cast(
         Union[IntType, NatType, BLS12_381_FrType, BLS12_381_G1Type,
               BLS12_381_G2Type], stack.pop1())
     res_type, = dispatch_types(type(a),
                                mapping={
                                    (IntType, ): (IntType, ),
                                    (NatType, ): (IntType, ),
                                    (BLS12_381_FrType, ):
                                    (BLS12_381_FrType, ),
                                    (BLS12_381_G1Type, ):
                                    (BLS12_381_G1Type, ),
                                    (BLS12_381_G2Type, ):
                                    (BLS12_381_G2Type, )
                                })
     if issubclass(res_type, IntType):
         res = IntType.from_value(-int(a))
     else:
         res = res_type.from_point(bls12_381.neg(a.to_point()))
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [a], [res]))
     return cls()