From 9a2f48451c9184f86a49cef45ed40986533e7c6a Mon Sep 17 00:00:00 2001 From: "iurii.vinogradov" Date: Fri, 24 May 2019 18:59:33 +0300 Subject: [PATCH] - Github #519 Query addresses of notaries from a contract --- .../bootstrap/controller/EthController.kt | 22 +++++++++++++++++++ .../bootstrap/dto/MasterContractModel.kt | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/controller/EthController.kt b/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/controller/EthController.kt index c5ebc1db6..8597d8eb1 100644 --- a/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/controller/EthController.kt +++ b/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/controller/EthController.kt @@ -25,6 +25,28 @@ import javax.validation.constraints.NotNull class EthController { private val log = KLogging().logger + @PostMapping("/deploy/D3/masterContract/data") + fun getMasterContractData(@NotNull @RequestBody request: GetMasterContractPeersRequest): ResponseEntity { + try { + val deployHelper = DeployHelperBuilder( + request.network.ethereumConfig, + request.network.ethPasswords + ).setFastTransactionManager() + .build() + if (request.masterContractAddress != null) { + val master = deployHelper.loadMasterContract(request.masterContractAddress) + + val tokens = master.tokens.send() + val peers = master.peers(address) + } + } catch (e: Exception) { + log.error("Error adding peer to smart contract", e) + return ResponseEntity.status(HttpStatus.CONFLICT).body( + UpdateMasterContractResponse(e.javaClass.simpleName, e.message) + ) + } + } + @PostMapping("/deploy/D3/masterContract/update") fun addPeerToMasterContract(@NotNull @RequestBody request: UpdateMasterContractRequest): ResponseEntity { try { diff --git a/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/dto/MasterContractModel.kt b/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/dto/MasterContractModel.kt index 7f2a7d33d..cf5af00c1 100644 --- a/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/dto/MasterContractModel.kt +++ b/bootstrap/src/main/kotlin/jp/co/soramitsu/bootstrap/dto/MasterContractModel.kt @@ -24,6 +24,11 @@ data class UpdateMasterContractResponse( } } +data class GetMasterContractPeersRequest( + @NotNull val network: EthereumNetworkProperties = EthereumNetworkProperties(), + @NotNull val masterContractAddress: String? = null +) + data class UpdateMasterContractRequest( @NotNull val network: EthereumNetworkProperties = EthereumNetworkProperties(), @NotNull val masterContract: MasterContractProperties = MasterContractProperties(),