Example #1
0
def post_transfer(from_address: Union[UInt160,
                                      None], to_address: Union[UInt160, None],
                  amount: int, data: Any, call_onPayment: bool):
    """
    Checks if the one receiving NEP17 tokens is a smart contract and if it's one the onPayment method will be called.

    :param from_address: the address of the sender
    :type from_address: UInt160
    :param to_address: the address of the receiver
    :type to_address: UInt160
    :param amount: the amount of cryptocurrency that is being sent
    :type amount: int
    :param data: any pertinent data that might validate the transaction
    :type data: Any
    :param call_onPayment: whether onPayment should be called or not
    :type call_onPayment: bool
    """
    if call_onPayment:
        if not isinstance(
                to_address, None
        ):  # TODO: change to 'is not None' when `is` semantic is implemented
            contract = get_contract(to_address)
            if not isinstance(
                    contract, None
            ):  # TODO: change to 'is not None' when `is` semantic is implemented
                call_contract(to_address, 'onNEP17Payment',
                              [from_address, amount, data])
Example #2
0
def post_transfer(token_owner: Union[UInt160, None], to: Union[UInt160, None],
                  tokenId: bytes, data: Any):
    """
    Checks if the one receiving NEP11 tokens is a smart contract and if it's one the onPayment method will be called - internal

    :param token_owner: the address of the sender
    :type token_owner: UInt160
    :param to: the address of the receiver
    :type to: UInt160
    :param tokenId: the token hash as bytes
    :type tokenId: bytes
    :param data: any pertinent data that might validate the transaction
    :type data: Any
    """
    on_transfer(token_owner, to, 1, tokenId)
    if not isinstance(
            to, None
    ):  # TODO: change to 'is not None' when `is` semantic is implemented
        contract = get_contract(to)
        if not isinstance(
                contract, None
        ):  # TODO: change to 'is not None' when `is` semantic is implemented
            call_contract(to, 'onNEP11Payment',
                          [token_owner, 1, tokenId, data])
            pass
Example #3
0
def post_transfer(from_address: Union[UInt160, None], to_address: Union[UInt160, None], amount: int, data: Any):
    """
    Checks if the one receiving DSTONE tokens is a smart contract and if it's one the onPayment method will be called

    :param from_address: the address of the sender
    :param to_address: the address of the receiver
    :param amount: the amount of cryptocurrency that is being sent
    :param data: any pertinent data that might validate the transaction
    """
    if not isinstance(to_address, None):
        contract = get_contract(to_address)
        if not isinstance(contract, None):
            call_contract(to_address, 'onNEP17Payment', [from_address, amount, data])
def is_get_contract_a_contract() -> bool:
    contract = get_contract(executing_script_hash)
    return is_contract(contract)
Example #5
0
def main(hash_: UInt160) -> Contract:
    return blockchain.get_contract(hash_)
Example #6
0
def main(hash: UInt160) -> Contract:
    return get_contract(hash)