private TransactionReceipt performTransfer( Web3j web3j, String destinationAddress, Credentials credentials, BigDecimal amountInWei) { console.printf("Commencing transfer (this may take a few minutes) "); try { Future<TransactionReceipt> future = Transfer.sendFunds( web3j, credentials, destinationAddress, amountInWei, Convert.Unit.WEI) .sendAsync(); while (!future.isDone()) { console.printf("."); Thread.sleep(500); } console.printf("$%n%n"); return future.get(); } catch (InterruptedException | ExecutionException | TransactionException | IOException e) { exitError("Problem encountered transferring funds: \n" + e.getMessage()); } throw new RuntimeException("Application exit failure"); }
@Test public void testTransactionPolling() throws Exception { List<Future<TransactionReceipt>> transactionReceipts = new LinkedList<>(); FastRawTransactionManager transactionManager = new FastRawTransactionManager( web3j, ALICE, new PollingTransactionReceiptProcessor( web3j, POLLING_FREQUENCY, DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH)); Transfer transfer = new Transfer(web3j, transactionManager); BigInteger gasPrice = transfer.requestCurrentGasPrice(); for (int i = 0; i < COUNT; i++) { Future<TransactionReceipt> transactionReceiptFuture = createTransaction(transfer, gasPrice).sendAsync(); transactionReceipts.add(transactionReceiptFuture); } for (int i = 0; i < DEFAULT_POLLING_ATTEMPTS_PER_TX_HASH && !transactionReceipts.isEmpty(); i++) { for (Iterator<Future<TransactionReceipt>> iterator = transactionReceipts.iterator(); iterator.hasNext(); ) { Future<TransactionReceipt> transactionReceiptFuture = iterator.next(); if (transactionReceiptFuture.isDone()) { TransactionReceipt transactionReceipt = transactionReceiptFuture.get(); assertFalse(transactionReceipt.getBlockHash().isEmpty()); iterator.remove(); } } Thread.sleep(POLLING_FREQUENCY); } assertTrue(transactionReceipts.isEmpty()); }
public CompletableFuture<Double> longitude() { return instance.longitude().sendAsync().thenApply(Converter::toLongitude); }
public CompletableFuture<String> authorize(final String identifier, final String authorizedEthereumAddress, final String authorizedIndentity) { return ((Authorization) contract).authorize(identifier, authorizedEthereumAddress, authorizedIndentity) .sendAsync() // replace the complete receipt with the transaction hash only. .thenApply(TransactionReceipt::getTransactionHash); }
public CompletableFuture<Integer> getPointsAmountByRing(Integer ringIndex) { return instance.getPointsAmountByRing(BigInteger.valueOf(ringIndex)).sendAsync().thenApply(BigInteger::intValue); }
public CompletableFuture<TransactionReceipt> deleteOracledAddress(String oracled) { return instance.deleteOracledAddress(oracled).sendAsync(); }
public CompletableFuture<TransactionReceipt> makeImmutable() { return instance.makeImmutable().sendAsync(); }
public CompletableFuture<Boolean> isImmutable() { return instance.isImmutable().sendAsync(); }
public CompletableFuture<Integer> radius() { return instance.radius().sendAsync().thenApply(BigInteger::intValue); }
public static CompletableFuture<PolygonContract> deployLight(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, Polygon polygon) { List<BigInteger> data = validateAndConvert(polygon); return LightPolygon.deploy(web3j, transactionManager, gasPrice, gasLimit, data).sendAsync().thenApply(PolygonContract::new); }
public CompletableFuture<String> saveState(final String identifier, final String state) { LocalDateTime start = LocalDateTime.now(); byte[] compressed = CompressionUtils.compress(state.getBytes()); LOGGER.debug("Compressing fingerprint lasted {}", Duration.between(LocalDateTime.now(), start).toString()); return ((Provenance) contract).addResourceVersion(identifier, compressed) .sendAsync() // replace the complete receipt with the transaction hash only. .thenApply(TransactionReceipt::getTransactionHash); }
public static CompletableFuture<CircleContract> deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, io.platin.geo.models.Circle circle) { List<BigInteger> data = validateAndConvert(circle); return Circle.deploy(web3j, transactionManager, gasPrice, gasLimit, data).sendAsync().thenApply(CircleContract::new); }
public CompletableFuture<TransactionReceipt> addPoints(List<Point> points, Integer ringIndex, Integer pointNum) { List<BigInteger> pointsData = Converter.toNumbers(points); return instance.addPoints(pointsData, BigInteger.valueOf(ringIndex), BigInteger.valueOf(pointNum)).sendAsync(); }
public static CompletableFuture<PolygonContract> deployHeavy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, Polygon polygon) { List<BigInteger> data = validateAndConvert(polygon); return HeavyPolygon.deploy(web3j, credentials, gasPrice, gasLimit, data).sendAsync().thenApply(PolygonContract::new); }
public static CompletableFuture<PolygonContract> deployHeavy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit, Polygon polygon) { List<BigInteger> data = validateAndConvert(polygon); return HeavyPolygon.deploy(web3j, transactionManager, gasPrice, gasLimit, data).sendAsync().thenApply(PolygonContract::new); }
public static CompletableFuture<CircleContract> deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, io.platin.geo.models.Circle circle) { List<BigInteger> data = validateAndConvert(circle); return Circle.deploy(web3j, credentials, gasPrice, gasLimit, data).sendAsync().thenApply(CircleContract::new); }
public static CompletableFuture<PolygonContract> deployLight(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit, Polygon polygon) { List<BigInteger> data = validateAndConvert(polygon); return LightPolygon.deploy(web3j, credentials, gasPrice, gasLimit, data).sendAsync().thenApply(PolygonContract::new); }
public CompletableFuture<TransactionReceipt> addPoints(List<Point> points, Integer ringIndex) { List<BigInteger> pointsData = Converter.toNumbers(points); return instance.addPoints(pointsData, BigInteger.valueOf(ringIndex)).sendAsync(); }
public CompletableFuture<TransactionReceipt> addRing(List<Point> points, Integer index) { List<BigInteger> pointsData = Converter.toNumbers(points); return instance.addRing(pointsData, BigInteger.valueOf(index)).sendAsync(); }
public CompletableFuture<TransactionReceipt> addRing(List<Point> points) { List<BigInteger> pointsData = Converter.toNumbers(points); return instance.addRing(pointsData).sendAsync(); }