Java Code Examples for org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt#setMessage()

The following examples show how to use org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt#setMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Service.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public void onReceiveTransactionMessage(String seq, TransactionReceipt receipt) {
    TransactionSucCallback callback = (TransactionSucCallback) seq2TransactionCallback.get(seq);

    if (callback != null) {
        if (callback.getTimeout() != null) {
            // stop timer,avoid response more once
            callback.getTimeout().cancel();
        }

        try {
            Tuple2<Boolean, String> revertMessage =
                    RevertResolver.tryResolveRevertMessage(receipt);
            if (revertMessage.getValue1()) {
                logger.debug(" revert message: {}", revertMessage.getValue2());
                receipt.setMessage(revertMessage.getValue2());
            }
            callback.onResponse(receipt);
        } catch (Exception e) {
            logger.error("Error process transactionMessage: ", e);
        }

        seq2TransactionCallback.remove(seq);
    } else {
        logger.trace(" transaction call back null, seq: {}", seq);
    }
}
 
Example 2
Source File: CallContract.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public TransactionReceipt sendTransaction(
        String contractAddress, String funcName, Type... args) {
    final Function function =
            new Function(
                    funcName,
                    Arrays.<Type>asList(args),
                    Collections.<TypeReference<?>>emptyList());

    TransactionReceipt transactionReceipt = new TransactionReceipt();
    try {
        ExecuteTransaction executeTransaction =
                new ExecuteTransaction(contractAddress, web3j, credentials, gasPrice, gasLimit);

        transactionReceipt = executeTransaction.send(function);
        String status = transactionReceipt.getStatus();
        transactionReceipt.setMessage(StatusCode.getStatusMessage(status));

    } catch (Exception e) {
        transactionReceipt.setStatus(StatusCode.ExceptionCatched);
        transactionReceipt.setMessage(e.getMessage());
        transactionReceipt.setOutput("0x");
    }
    return transactionReceipt;
}
 
Example 3
Source File: TransactionSucCallback.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public void onTimeout() {
    logger.error("transactionSuc timeout");

    TransactionReceipt receipt = new TransactionReceipt();
    receipt.setStatus("Transaction receipt timeout.");
    // For console can get error message when timeout
    receipt.setMessage("Transaction receipt timeout.");
    onResponse(receipt);
}
 
Example 4
Source File: CallContract.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public TransactionReceipt sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String contractAddress,
        String funcName,
        Type... args) {
    final Function function =
            new Function(
                    funcName,
                    Arrays.<Type>asList(args),
                    Collections.<TypeReference<?>>emptyList());
    TransactionReceipt transactionReceipt = new TransactionReceipt();
    try {
        ExecuteTransaction executeTransaction =
                new ExecuteTransaction(contractAddress, web3j, credentials, gasPrice, gasLimit);
        transactionReceipt = executeTransaction.send(function);

        String status = transactionReceipt.getStatus();
        transactionReceipt.setMessage(StatusCode.getStatusMessage(status));

    } catch (Exception e) {
        transactionReceipt.setStatus(StatusCode.ExceptionCatched);
        transactionReceipt.setMessage(e.getMessage());
        transactionReceipt.setOutput("0x");
    }
    return transactionReceipt;
}