From 0946dae13e4698ad174771468d13045edfefaa28 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Wed, 15 Sep 2021 11:19:34 +0430 Subject: [PATCH 1/2] Add ChainEndpointProxyFinderImpl --- .../core/spi/ChainEndpointProxyFinder.kt | 4 ++-- .../bcgateway/postgres/dao/ChainRepository.kt | 5 +++-- .../postgres/impl/ChainEndpointProxyFinderImpl.kt | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt diff --git a/BlockchainGateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/spi/ChainEndpointProxyFinder.kt b/BlockchainGateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/spi/ChainEndpointProxyFinder.kt index 7db1ba870..f4762765a 100644 --- a/BlockchainGateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/spi/ChainEndpointProxyFinder.kt +++ b/BlockchainGateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/spi/ChainEndpointProxyFinder.kt @@ -1,5 +1,5 @@ package co.nilin.opex.bcgateway.core.spi interface ChainEndpointProxyFinder { - suspend fun findChainEndpointProxy(chainName: String):ChainEndpointProxy -} \ No newline at end of file + suspend fun findChainEndpointProxy(chainName: String): ChainEndpointProxy +} diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt index 9395b112a..299ca7127 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/dao/ChainRepository.kt @@ -7,10 +7,11 @@ import kotlinx.coroutines.flow.Flow import org.springframework.data.r2dbc.repository.Query import org.springframework.data.repository.reactive.ReactiveCrudRepository import org.springframework.stereotype.Repository +import reactor.core.publisher.Mono @Repository interface ChainRepository : ReactiveCrudRepository { - fun findByName(name: String): Flow + fun findByName(name: String): Mono @Query( """ @@ -25,4 +26,4 @@ interface ChainRepository : ReactiveCrudRepository { @Query("select * from chain_endpoints where chain_name = :name") fun findEndpointsByName(name: String): Flow -} \ No newline at end of file +} diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt new file mode 100644 index 000000000..aaf2a09a0 --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt @@ -0,0 +1,15 @@ +package co.nilin.opex.port.bcgateway.postgres.impl + +import co.nilin.opex.bcgateway.core.spi.ChainEndpointProxy +import co.nilin.opex.bcgateway.core.spi.ChainEndpointProxyFinder +import co.nilin.opex.port.bcgateway.postgres.dao.ChainRepository +import kotlinx.coroutines.flow.toList +import org.springframework.stereotype.Component + +@Component +class ChainEndpointProxyFinderImpl(private val chainRepository: ChainRepository) : ChainEndpointProxyFinder { + override suspend fun findChainEndpointProxy(chainName: String): ChainEndpointProxy { +// val dao = chainRepository.findEndpointsByName(chainName).toList() +// return null + } +} From 175298f49c744df7c9bc09e51ca5e4ff21e80a6a Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Mon, 20 Sep 2021 18:19:40 +0430 Subject: [PATCH 2/2] Add chain proxy module --- .../bc-chain-proxy/.gitignore | 36 ++++++++ .../bc-gateway-ports/bc-chain-proxy/pom.xml | 90 +++++++++++++++++++ .../impl/ChainEndpointProxyImpl.kt | 12 +++ .../bc-persister-postgres/pom.xml | 8 +- .../impl/ChainEndpointProxyFinderImpl.kt | 7 +- BlockchainGateway/pom.xml | 1 + 6 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 BlockchainGateway/bc-gateway-ports/bc-chain-proxy/.gitignore create mode 100644 BlockchainGateway/bc-gateway-ports/bc-chain-proxy/pom.xml create mode 100644 BlockchainGateway/bc-gateway-ports/bc-chain-proxy/src/main/kotlin/co.nilin.opex.port.bcgateway.chainproxy/impl/ChainEndpointProxyImpl.kt diff --git a/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/.gitignore b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/.gitignore new file mode 100644 index 000000000..f4e066ca5 --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/.gitignore @@ -0,0 +1,36 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ +!/.mvn/ + +.DS_Store diff --git a/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/pom.xml b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/pom.xml new file mode 100644 index 000000000..ca4affcdc --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/pom.xml @@ -0,0 +1,90 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.4.4 + + + 4.0.0 + + co.nilin.opex.external + bc-chain-proxy + 1.0-SNAPSHOT + + + 1.8 + 1.4.31 + ${version} + + + + + org.springframework.boot + spring-boot-starter + + + + io.projectreactor.kotlin + reactor-kotlin-extensions + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + + + org.jetbrains.kotlinx + kotlinx-coroutines-core + + + co.nilin.opex.external + bc-gateway-core + ${bc-gateway.version} + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + diff --git a/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/src/main/kotlin/co.nilin.opex.port.bcgateway.chainproxy/impl/ChainEndpointProxyImpl.kt b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/src/main/kotlin/co.nilin.opex.port.bcgateway.chainproxy/impl/ChainEndpointProxyImpl.kt new file mode 100644 index 000000000..bf9e4e217 --- /dev/null +++ b/BlockchainGateway/bc-gateway-ports/bc-chain-proxy/src/main/kotlin/co.nilin.opex.port.bcgateway.chainproxy/impl/ChainEndpointProxyImpl.kt @@ -0,0 +1,12 @@ +package co.nilin.opex.port.bcgateway.chainproxy.impl + +import co.nilin.opex.bcgateway.core.model.ChainSyncRecord +import co.nilin.opex.bcgateway.core.model.Endpoint +import co.nilin.opex.bcgateway.core.spi.ChainEndpointProxy +import org.springframework.stereotype.Component + +class ChainEndpointProxyImpl(private val endpoints: List) : ChainEndpointProxy { + override suspend fun syncTransfers(filter: ChainEndpointProxy.DepositFilter): ChainSyncRecord { + TODO("Not yet implemented") + } +} diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/pom.xml b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/pom.xml index 321effaa2..f289f6e96 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/pom.xml +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/pom.xml @@ -67,7 +67,13 @@ reactor-test test - + + co.nilin.opex.external + bc-chain-proxy + 1.0-SNAPSHOT + compile + + ${project.basedir}/src/main/kotlin diff --git a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt index aaf2a09a0..b0873c9f9 100644 --- a/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt +++ b/BlockchainGateway/bc-gateway-ports/bc-persister-postgres/src/main/kotlin/co/nilin/opex/port/bcgateway/postgres/impl/ChainEndpointProxyFinderImpl.kt @@ -1,15 +1,18 @@ package co.nilin.opex.port.bcgateway.postgres.impl +import co.nilin.opex.bcgateway.core.model.Endpoint import co.nilin.opex.bcgateway.core.spi.ChainEndpointProxy import co.nilin.opex.bcgateway.core.spi.ChainEndpointProxyFinder +import co.nilin.opex.port.bcgateway.chainproxy.impl.ChainEndpointProxyImpl import co.nilin.opex.port.bcgateway.postgres.dao.ChainRepository +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.toList import org.springframework.stereotype.Component @Component class ChainEndpointProxyFinderImpl(private val chainRepository: ChainRepository) : ChainEndpointProxyFinder { override suspend fun findChainEndpointProxy(chainName: String): ChainEndpointProxy { -// val dao = chainRepository.findEndpointsByName(chainName).toList() -// return null + val endpoints = chainRepository.findEndpointsByName(chainName).map { Endpoint(it.url) }.toList() + return ChainEndpointProxyImpl(endpoints) } } diff --git a/BlockchainGateway/pom.xml b/BlockchainGateway/pom.xml index d2090befe..7c8b77ddf 100644 --- a/BlockchainGateway/pom.xml +++ b/BlockchainGateway/pom.xml @@ -13,5 +13,6 @@ bc-gateway-core bc-gateway-app bc-gateway-ports/bc-persister-postgres + bc-gateway-ports/bc-chain-proxy