Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package co.nilin.opex.bcgateway.core.spi

interface ChainEndpointProxyFinder {
suspend fun findChainEndpointProxy(chainName: String):ChainEndpointProxy
}
suspend fun findChainEndpointProxy(chainName: String): ChainEndpointProxy
}
36 changes: 36 additions & 0 deletions BlockchainGateway/bc-gateway-ports/bc-chain-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -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
90 changes: 90 additions & 0 deletions BlockchainGateway/bc-gateway-ports/bc-chain-proxy/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>

<groupId>co.nilin.opex.external</groupId>
<artifactId>bc-chain-proxy</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<java.version>1.8</java.version>
<kotlin.version>1.4.31</kotlin.version>
<bc-gateway.version>${version}</bc-gateway.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>io.projectreactor.kotlin</groupId>
<artifactId>reactor-kotlin-extensions</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-reactor</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
</dependency>
<dependency>
<groupId>co.nilin.opex.external</groupId>
<artifactId>bc-gateway-core</artifactId>
<version>${bc-gateway.version}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

</project>
Original file line number Diff line number Diff line change
@@ -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<Endpoint>) : ChainEndpointProxy {
override suspend fun syncTransfers(filter: ChainEndpointProxy.DepositFilter): ChainSyncRecord {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>co.nilin.opex.external</groupId>
<artifactId>bc-chain-proxy</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChainModel, String> {
fun findByName(name: String): Flow<ChainModel>
fun findByName(name: String): Mono<ChainModel>

@Query(
"""
Expand All @@ -25,4 +26,4 @@ interface ChainRepository : ReactiveCrudRepository<ChainModel, String> {

@Query("select * from chain_endpoints where chain_name = :name")
fun findEndpointsByName(name: String): Flow<ChainEndpointModel>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +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 endpoints = chainRepository.findEndpointsByName(chainName).map { Endpoint(it.url) }.toList()
return ChainEndpointProxyImpl(endpoints)
}
}
1 change: 1 addition & 0 deletions BlockchainGateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
<module>bc-gateway-core</module>
<module>bc-gateway-app</module>
<module>bc-gateway-ports/bc-persister-postgres</module>
<module>bc-gateway-ports/bc-chain-proxy</module>
</modules>
</project>