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

The following examples show how to use org.fisco.bcos.web3j.protocol.core.methods.response.BcosTransactionReceipt#getTransactionReceipt() . 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: AccountCrawlerHandler.java    From WeBASE-Collect-Bee with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public BlockAccountsInfoBO crawl(Block block) throws IOException {
    List<AccountInfoBO> accountInfoList = new ArrayList<>();
    Map<String, String> map = new HashMap<>();
    List<TransactionResult> transactionResults = block.getTransactions();
    for (TransactionResult result : transactionResults) {
        BcosTransactionReceipt bcosTransactionReceipt = ethClient.getTransactionReceipt(result);
        Optional<TransactionReceipt> opt = bcosTransactionReceipt.getTransactionReceipt();
        if (opt.isPresent()) {
            TransactionReceipt tr = opt.get();
            handle(tr, block.getTimestamp()).ifPresent(e -> {
                accountInfoList.add(e);
                map.putIfAbsent(e.getTxHash(), e.getContractAddress());
            });

        }
    }
    return new BlockAccountsInfoBO(accountInfoList, map);
}
 
Example 2
Source File: EventCrawlerHandler.java    From WeBASE-Collect-Bee with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public List<EventBO> crawl(Block block, Map<String, String> txHashContractNameMapping) throws IOException {
    List<EventBO> boList = new ArrayList<>();
    List<TransactionResult> transactionResults = block.getTransactions();
    for (TransactionResult result : transactionResults) {
        BcosTransactionReceipt bcosTransactionReceipt = ethClient.getTransactionReceipt(result);
        Optional<TransactionReceipt> opt = bcosTransactionReceipt.getTransactionReceipt();
        if (opt.isPresent()) {
            TransactionReceipt tr = opt.get();
            String contractName = txHashContractNameMapping.get(tr.getTransactionHash());
            Optional<Transaction> optt = ethClient.getTransactionByHash(tr);
            if (optt.isPresent()) {
                Transaction transaction = optt.get();
                if (transaction.getTo() != null && !transaction.getTo().equals(ContractConstants.EMPTY_ADDRESS)) {
                    tr.setContractAddress(transaction.getTo());
                }
            }
            if (ContractConstants.EXPORT_INNER_CALL_EVENT == false && StringUtils.isEmpty(contractName)) {
                log.error("TxHash {} is Empty, and the blockNumber is {}! Please check it. ",
                        tr.getTransactionHash(), block.getNumber());
                continue;
            }
            bcosEventCrawlerMap.forEach((k, v) -> {
                if (ContractConstants.EXPORT_INNER_CALL_EVENT == false
                        && !StringUtils.startsWithIgnoreCase(k, contractName)) {
                    return;
                }
                boList.addAll(v.handleReceipt(tr, block.getTimestamp()));
            });
        }
    }
    return boList;
}
 
Example 3
Source File: FunctionTest.java    From WeBASE-Collect-Bee with Apache License 2.0 5 votes vote down vote up
@Test
public void testInput() throws IOException, BaseException {
    BigInteger bigBlockHeight = new BigInteger(Integer.toString(8));
    Block block = ethClient.getBlock(bigBlockHeight);
    List<TransactionResult> transactionResults = block.getTransactions();
    log.info("transactionResults.size:{}", transactionResults.size());
    for (TransactionResult result : transactionResults) {
        BcosTransactionReceipt ethGetTransactionReceipt = web3j.getTransactionReceipt((String) result.get()).send();
        Optional<TransactionReceipt> opt = ethGetTransactionReceipt.getTransactionReceipt();
        if (opt.isPresent()) {
            log.info("TransactionReceipt hash: {}", opt.get().getTransactionHash());
            Optional<Transaction> optt =
                    web3j.getTransactionByHash(opt.get().getTransactionHash()).send().getTransaction();
            if (optt.isPresent()) {
                String rawInput = optt.get().getInput();

                log.info("input : {}", optt.get().getInput());
                List<TypeReference<Type>> referencesTypeList = new ArrayList<>(1);
                TypeReference exScore = TypeReferenceUtils.getTypeRef("uint128");
                referencesTypeList.add(exScore);
                TypeReference operationType = TypeReferenceUtils.getTypeRef("uint8");
                referencesTypeList.add(operationType);

                List<Type> listT = FunctionReturnDecoder.decode(rawInput.substring(10), referencesTypeList);
                for (Type type : listT) {
                    log.info("type value : {}", type.getValue());
                }
                log.info("type info : {}", JacksonUtils.toJson(listT));
            }
        }
    }
}
 
Example 4
Source File: FunctionTest.java    From WeBASE-Collect-Bee with Apache License 2.0 5 votes vote down vote up
public void testActivity() throws IOException, BaseException {
    BigInteger bigBlockHeight = new BigInteger(Integer.toString(200));
    Block block = ethClient.getBlock(bigBlockHeight);
    List<TransactionResult> transactionResults = block.getTransactions();
    log.info("transactionResults.size:{}", transactionResults.size());
    for (TransactionResult result : transactionResults) {
        BcosTransactionReceipt ethGetTransactionReceipt = web3j.getTransactionReceipt((String) result.get()).send();
        Optional<TransactionReceipt> opt = ethGetTransactionReceipt.getTransactionReceipt();
        if (opt.isPresent()) {
            log.info("TransactionReceipt hash: {}", opt.get().getTransactionHash());
            Optional<Transaction> optt =
                    web3j.getTransactionByHash(opt.get().getTransactionHash()).send().getTransaction();
            if (optt.isPresent()) {
                String rawInput = optt.get().getInput();
                log.info("input : {}", optt.get().getInput());
                List<TypeReference<Type>> referencesTypeList = new ArrayList<>(1);
                TypeReference exScore = TypeReferenceUtils.getTypeRef("uint64");
                referencesTypeList.add(exScore);

                List<Type> listT = FunctionReturnDecoder.decode(rawInput.substring(10), referencesTypeList);
                for (Type type : listT) {
                    log.info("type value : {}", type.getValue());
                }
                log.info("type info : {}", JacksonUtils.toJson(listT));
            }
        }
    }
}
 
Example 5
Source File: BlockInfoServiceTest.java    From WeBASE-Collect-Bee with Apache License 2.0 5 votes vote down vote up
@Test
public void testInput() throws IOException {
    Block block = ethClient.getBlock(BigInteger.valueOf(8677));
    List<TransactionResult> transactionResults = block.getTransactions();
    log.info("transactionResults.size:{}", transactionResults.size());
    for (TransactionResult result : transactionResults) {
        BcosTransactionReceipt ethGetTransactionReceipt = web3j.getTransactionReceipt((String) result.get()).send();
        Optional<TransactionReceipt> opt = ethGetTransactionReceipt.getTransactionReceipt();
        if (opt.isPresent()) {
            log.info("TransactionReceipt hash: {}", opt.get().getTransactionHash());
            Optional<Transaction> optt =
                    web3j.getTransactionByHash(opt.get().getTransactionHash()).send().getTransaction();
            if (optt.isPresent()) {
                log.info("transaction hash : {}", optt.get().getHash());
                log.info("transaction info : {}", optt.get().getValue());
                List<Type> lt = new ArrayList<>();
                lt.add(Uint64.DEFAULT);
                List<TypeReference<?>> references = new ArrayList<>();
                TypeReference<Uint64> typeReference = new TypeReference<Uint64>() {
                };
                references.add(typeReference);
                List<TypeReference<Type>> ll = Utils.convert(references);
                List<Type> inputList = FunctionReturnDecoder.decode(optt.get().getInput(), ll);
                log.info("input : {}", inputList.size());
                log.info("input : {}", JacksonUtils.toJson(inputList));
            }

        }
    }

}