diff --git a/src/main/java/com/nynja/walletservice/controller/TransactionController.java b/src/main/java/com/nynja/walletservice/controller/TransactionController.java index 89f5cd7babc02aef8947d22e65a69cb092c7ea24..babf2562114b75a2eb770865c987658d4d413944 100644 --- a/src/main/java/com/nynja/walletservice/controller/TransactionController.java +++ b/src/main/java/com/nynja/walletservice/controller/TransactionController.java @@ -57,7 +57,7 @@ public class TransactionController { @ApiResponse(code = 200, message = RETRIEVED) @PostMapping(API_VERSION + "/signed-transaction-send") public CompletableFuture>> sendSignedTransaction(@Valid @RequestBody SignedTransactionDto dto) { - return web3JService.sendSignedTransaction(dto.getBase64Transaction()).thenApplyAsync(ResponseEntity::ok); + return web3JService.sendSignedTransaction(dto.getSignedTransaction()).thenApplyAsync(ResponseEntity::ok); } @ApiOperation(value = "Endpoint for getting transaction info by hash", httpMethod = "GET") diff --git a/src/main/java/com/nynja/walletservice/dto/SignedTransactionDto.java b/src/main/java/com/nynja/walletservice/dto/SignedTransactionDto.java index 7fd85b08655b1e4a76f8dfef5987a0ccd9d34061..01537d75ab5242fea5737e81dc6aaf236f51ae66 100644 --- a/src/main/java/com/nynja/walletservice/dto/SignedTransactionDto.java +++ b/src/main/java/com/nynja/walletservice/dto/SignedTransactionDto.java @@ -15,5 +15,5 @@ import org.hibernate.validator.constraints.NotBlank; public class SignedTransactionDto { @NotBlank - private String base64Transaction; + private String signedTransaction; } diff --git a/src/main/java/com/nynja/walletservice/service/Web3JService.java b/src/main/java/com/nynja/walletservice/service/Web3JService.java index 0c304985a5b1d93631819234278eccb6ee9f20d3..9294b5ea4672fa261a008004faf98067d5e88d5e 100644 --- a/src/main/java/com/nynja/walletservice/service/Web3JService.java +++ b/src/main/java/com/nynja/walletservice/service/Web3JService.java @@ -78,12 +78,16 @@ public class Web3JService { return web3j().ethGetBalance(address, DefaultBlockParameterName.LATEST).sendAsync(); } - public CompletableFuture> sendSignedTransaction(String base64Transaction) { - return web3j().ethSendRawTransaction(base64Transaction) + public CompletableFuture> sendSignedTransaction(String transaction) { + return web3j().ethSendRawTransaction(transaction) .sendAsync() .thenApplyAsync(ethSendTransaction -> { - log.info(SIGNED_TRANSACTION_SENT, ethSendTransaction.getTransactionHash()); - return new TransactionResponseDto<>(ethSendTransaction.getTransactionHash(), ""); + if (ethSendTransaction.getError() != null) { + throw new RuntimeException(ethSendTransaction.getError().getMessage()); + } else { + log.info(SIGNED_TRANSACTION_SENT, ethSendTransaction.getTransactionHash()); + return new TransactionResponseDto<>(ethSendTransaction.getTransactionHash(), ""); + } }).exceptionally(ex -> { log.error(SIGNED_TRANSACTION_FAIL, ex.getMessage()); return new TransactionResponseDto<>(TRANSACTION_FAILED, ex.getMessage()); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a6192b77c05e45fe04beec091359017309948980..c9bd4973dc67eb6c4561896ab1c065292afe4911 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -25,7 +25,7 @@ ethereum: private-key: "960d1cad3ad7c42251f79c31e15636915f953cbfff1770cc4483efa44bf4ffc9" contract: # First deploy a contract and then place/replace it's address into this property - nynja-coin-address: "0x812e97c042632982b7cbd1c2818577602e646b1e" + nynja-coin-address: "0x5c015d5b7490cc329b96aebfb9d8e5ebd78e2bf6" gas-price: 2000000000000 gas-limit: 4700000 etherscan: