コード例 #1
0
ファイル: tezos.py プロジェクト: kengkiat/pytezos
 def execute(cls, stack: 'MichelsonStack', stdout: List[str],
             context: AbstractContext):
     address = cast(KeyHashType, stack.pop1())
     address.assert_type_equal(KeyHashType)
     res = NatType.from_value(context.get_voting_power(str(address)))
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [address], [res]))
     return cls()
コード例 #2
0
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     a = cast(IntType, stack.pop1())
     a.assert_type_equal(IntType)
     res = NatType.from_value(abs(int(a)))
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [a], [res]))  # type: ignore
     return cls(stack_items_added=1)
コード例 #3
0
ファイル: generic.py プロジェクト: kengkiat/pytezos
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     src = cast(Union[StringType, BytesType, ListType, SetType, MapType],
                stack.pop1())
     src.assert_type_in(StringType, BytesType, ListType, SetType, MapType)
     res = NatType.from_value(len(src))
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [src], [res]))
     return cls()
コード例 #4
0
def execute_shift(prim: str, stack: MichelsonStack, stdout: List[str],
                  shift: Callable[[Tuple[int, int]], int]):
    a, b = cast(Tuple[NatType, NatType], stack.pop2())
    a.assert_type_equal(NatType)
    b.assert_type_equal(NatType)
    assert int(b) < 257, f'shift overflow {int(b)}, should not exceed 256'
    c = shift((int(a), int(b)))
    res = NatType.from_value(c)
    stack.push(res)
    stdout.append(format_stdout(prim, [a, b], [res]))
コード例 #5
0
ファイル: arithmetic.py プロジェクト: kengkiat/pytezos
 def execute(cls, stack: MichelsonStack, stdout: List[str],
             context: AbstractContext):
     a = cast(IntType, stack.pop1())
     a.assert_type_equal(IntType)
     if int(a) >= 0:
         res = OptionType.from_some(NatType.from_value(int(a)))
     else:
         res = OptionType.none(NatType)
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [a], [res]))
     return cls()
コード例 #6
0
 def execute(cls, stack: 'MichelsonStack', stdout: List[str],
             context: AbstractContext):
     res = NatType.from_value(context.get_level())
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [], [res]))  # type: ignore
     return cls(stack_items_added=1)
コード例 #7
0
ファイル: tezos.py プロジェクト: kengkiat/pytezos
 def execute(cls, stack: 'MichelsonStack', stdout: List[str],
             context: AbstractContext):
     res = NatType.from_value(context.get_total_voting_power())
     stack.push(res)
     stdout.append(format_stdout(cls.prim, [], [res]))
     return cls()