org.fisco.bcos.web3j.protocol.core.methods.response.BcosTransactionReceipt Java Examples
The following examples show how to use
org.fisco.bcos.web3j.protocol.core.methods.response.BcosTransactionReceipt.
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 |
@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 |
@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 |
@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 |
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 |
@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)); } } } }
Example #6
Source File: JsonRpc2_0Web3j.java From web3sdk with Apache License 2.0 | 5 votes |
@Override public Request<?, BcosTransactionReceipt> getTransactionReceipt(String transactionHash) { return new Request<>( "getTransactionReceipt", Arrays.asList(groupId, transactionHash), web3jService, BcosTransactionReceipt.class); }
Example #7
Source File: ManagedTransactionTester.java From web3sdk with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") void prepareTransactionReceipt(TransactionReceipt transactionReceipt) throws IOException { BcosTransactionReceipt ethGetTransactionReceipt = new BcosTransactionReceipt(); ethGetTransactionReceipt.setResult(transactionReceipt); Request<?, BcosTransactionReceipt> getTransactionReceiptRequest = mock(Request.class); when(getTransactionReceiptRequest.send()).thenReturn(ethGetTransactionReceipt); when(web3j.getTransactionReceipt(TRANSACTION_HASH)) .thenReturn((Request) getTransactionReceiptRequest); }
Example #8
Source File: EthClient.java From WeBASE-Collect-Bee with Apache License 2.0 | 4 votes |
public BcosTransactionReceipt getTransactionReceipt(TransactionResult result) throws IOException { return getTransactionReceipt((String) result.get()); }
Example #9
Source File: EthClient.java From WeBASE-Collect-Bee with Apache License 2.0 | 4 votes |
@Cacheable(cacheNames = { "transactionReceipt" }) public BcosTransactionReceipt getTransactionReceipt(String hash) throws IOException { return web3j.getTransactionReceipt(hash).send(); }
Example #10
Source File: Web3jApITest.java From web3sdk with Apache License 2.0 | 4 votes |
@Test public void getTransactionReceipt() throws IOException { BcosTransactionReceipt bcosTransactionReceipt = web3j.getTransactionReceipt(txHash).send(); TransactionReceipt transactionReceipt = bcosTransactionReceipt.getTransactionReceipt().get(); assertNotNull(transactionReceipt); }
Example #11
Source File: Ethereum.java From web3sdk with Apache License 2.0 | votes |
Request<?, BcosTransactionReceipt> getTransactionReceipt(String transactionHash);