def execute(cls, stack: MichelsonStack, stdout: List[str], context: AbstractContext): source = context.get_source() res = AddressType.from_value(source) stack.push(res) stdout.append(format_stdout(cls.prim, [], [res])) # type: ignore return cls(stack_items_added=1)
def execute(cls, stack: MichelsonStack, stdout: List[str], context: AbstractContext): sender = context.get_sender() res = AddressType.from_value(sender) stack.push(res) stdout.append(format_stdout(cls.prim, [], [res])) return cls()
def execute(cls, stack: MichelsonStack, stdout: List[str], context: AbstractContext): sequence = cast(MichelineSequence, cls.args[0]) assert len(sequence.args ) == 3, f'expected 3 sections, got {len(sequence.args)}' assert {arg.prim for arg in sequence.args} == {'parameter', 'storage', 'code'}, f'unexpected sections' storage_type = cast( Type[MichelsonType], next(arg.args[0] for arg in sequence.args if arg.prim == 'storage')) delegate, amount, initial_storage = cast( Tuple[OptionType, MutezType, MichelsonType], stack.pop3()) delegate.assert_type_equal(OptionType.create_type(args=[KeyHashType])) amount.assert_type_equal(MutezType) initial_storage.assert_type_equal(storage_type) originated_address = AddressType.from_value( context.get_originated_address()) context.spend_balance(int(amount)) origination = OperationType.origination( source=context.get_self_address(), script=cls.args[0], # type: ignore storage=initial_storage, balance=int(amount), delegate=None if delegate.is_none() else str(delegate.get_some())) stack.push(originated_address) stack.push(origination) stdout.append( format_stdout(cls.prim, [delegate, amount, initial_storage], [origination, originated_address])) # type: ignore return cls(stack_items_added=2)
def execute(cls, stack: MichelsonStack, stdout: List[str], context: AbstractContext): contract = cast(ContractType, stack.pop1()) contract.assert_type_in(ContractType) res = AddressType.from_value(contract.get_address()) stack.push(res) stdout.append(format_stdout(cls.prim, [contract], [res])) return cls()