Skip to content

Commit

Permalink
Merge pull request #9 from provenance-io/multiparty_contract_execution
Browse files Browse the repository at this point in the history
Multiparty Contract Execution
  • Loading branch information
cworsnop-figure authored May 6, 2022
2 parents 8333b9d + 633ff73 commit d8f2f5f
Show file tree
Hide file tree
Showing 50 changed files with 680 additions and 273 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ jobs:
context: .
push: true
tags: ${{ steps.prep.outputs.tags }}

- name: Install gpg secret key
run: |
export GPG_TTY=$(tty)
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
echo -n "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 --decode > $GITHUB_WORKSPACE/release.gpg
- name: Publish to Maven Central
run: |
./gradlew publishToSonatype -Psemver.overrideVersion=${{ steps.ci-release-create-outputs.outputs.semVersion }} $(if [ "${{github.event.release.prerelease}}" = "true" ]; then echo 'closeSonatypeStagingRepository'; else echo 'closeAndReleaseSonatypeStagingRepository'; fi) \
-Psigning.keyId=B7D30ABE -Psigning.password="${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}" -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg \
--info
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ plugins {
kotlin("jvm") version Versions.Kotlin
id("java")
id("maven-publish")
id("java-library")
id("com.github.breadmoirai.github-release") version "2.2.12"
id("io.github.nefilim.gradle.semver-plugin") version "0.3.10"
id("io.github.gradle-nexus.publish-plugin") version Versions.NexusPublishing
signing
}

subprojects {
apply {
Plugins.Kotlin.addTo(this)
Plugins.Idea.addTo(this)
plugin("java")
plugin("signing")
}

java {
withJavadocJar()
withSourcesJar()
}

repositories {
Expand All @@ -42,6 +51,18 @@ subprojects {
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri(RepositoryLocations.Sonatype))
snapshotRepositoryUrl.set(uri(RepositoryLocations.SonatypeSnapshot))
username.set(findProject("ossrhUsername")?.toString() ?: System.getenv("OSSRH_USERNAME"))
password.set(findProject("ossrhPassword")?.toString() ?: System.getenv("OSSRH_PASSWORD"))
stagingProfileId.set("3180ca260b82a7") // prevents querying for the staging profile id, performance optimization
}
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
30 changes: 7 additions & 23 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ object Versions {
const val Kotlin = "1.5.31"
const val KotlinCoroutines = "1.5.2"
const val Protobuf = "3.18.1"
const val Kafka = "2.7.0"
const val SpringBoot = "2.5.6"
const val KotlinLogging = "2.0.11"
const val Reactor = "3.4.9"
const val Jackson = "2.12.5"
const val Redisson = "3.16.0"
const val Flyaway = "8.0.2"
const val Ktlint = "0.42.1"
const val Detekt = "1.18.1"
const val Hamkrest = "1.8.0.1"
Expand All @@ -32,15 +30,16 @@ object Versions {
const val SpringMockk = "3.0.1"
const val Swagger = "1.6.2"
const val AssetModel = "0.1.+"
const val P8eScope = "0.4.9"
const val P8eScope = "0.5.+"
const val ProvenanceHdWallet = "0.1.15"
const val ProvenanceClient = "1.1.1"
const val Unirest = "3.13.6"
const val KeyAccessLib = "0.2.+"
const val LoanPackage = "0.1.8"
const val KeyAccessLib = "0.2.15"
const val LoanPackage = "0.1.9"
const val Grpc = "1.45.0"
const val ProvenanceProto = "1.8.0"
const val Reflections = "0.9.10"
const val NexusPublishing = "1.1.0"
}

object Plugins { // please keep this sorted in sections
Expand All @@ -50,11 +49,11 @@ object Plugins { // please keep this sorted in sections

// 3rd Party
val Detekt = PluginSpec("io.gitlab.arturbosch.detekt", Versions.Detekt)
val Flyway = PluginSpec("org.flywaydb.flyway", Versions.Flyaway)
val Idea = PluginSpec("idea")
val Protobuf = PluginSpec("com.google.protobuf", "0.8.16")
val SpringBoot = PluginSpec("org.springframework.boot", Versions.SpringBoot)
val SpringDependencyManagement = PluginSpec("io.spring.dependency-management", "1.0.11.RELEASE")
val NexusPublishing = PluginSpec("io.github.gradle-nexus.publish-plugin", Versions.NexusPublishing)
}

object Dependencies {
Expand Down Expand Up @@ -87,6 +86,8 @@ object Dependencies {
val OsClient = DependencySpec("io.provenance.scope:os-client", Versions.P8eScope)
val Sdk = DependencySpec("io.provenance.scope:sdk", Versions.P8eScope)
val Util = DependencySpec("io.provenance.scope:util", Versions.P8eScope)
val ContractBase = DependencySpec("io.provenance.scope:contract-base", Versions.P8eScope)
val ContractProto = DependencySpec("io.provenance.scope:contract-proto", Versions.P8eScope)
}

// Spring Boot
Expand Down Expand Up @@ -126,11 +127,6 @@ object Dependencies {
val JavaUtil = DependencySpec("com.google.protobuf:protobuf-java-util", Versions.Protobuf)
}

// Apache Kafka
object Kafka {
val Clients = DependencySpec("org.apache.kafka:kafka-clients", Versions.Kafka)
}

object Kong {
val Unirest = DependencySpec("com.konghq:unirest-java", Versions.Unirest)
}
Expand All @@ -156,19 +152,7 @@ object Dependencies {

object Provenance {
val KeyAccessLib = DependencySpec("io.provenance.originator-key-access-lib:lib", Versions.KeyAccessLib)
val CoreKcache = DependencySpec("io.provenance:core-kcache", Versions.ProvenanceCore)
val CoreKcacheSpring = DependencySpec("io.provenance:core-kcache-spring", Versions.ProvenanceCore)
val CoreKafkaAggregator = DependencySpec("io.provenance:core-kafka-aggregator", Versions.ProvenanceCore)
val ProtoKotlin = DependencySpec("io.provenance:proto-kotlin", Versions.ProvenanceProto)
val CoreKafkaAggregatorSpring =
DependencySpec(
"io.provenance:core-kafka-aggregator-spring",
Versions.ProvenanceCore,
exclude = listOf(
"org.springframework.boot:spring-boot-starter-web",
"org.springframework.boot:spring-boot-starter-security"
)
)
val AssetModel = DependencySpec("io.provenance.model:metadata-asset-model", Versions.AssetModel)
val LoanPackage = DependencySpec("io.provenance.loan-package:contract", Versions.LoanPackage)

Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/Repositories.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object RepositoryLocations {
const val JitPack = "https://javadoc.jitpack.io"
const val Sonatype = "https://s01.oss.sonatype.org/service/local/"
const val SonatypeSnapshot = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
18 changes: 8 additions & 10 deletions dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ function up {
"stable payment cliff fault abuse clinic bus belt film then forward world goose bring picnic rich special brush basic lamp window coral worry change"

sh service/docker/vault/add-secret.sh 'http://127.0.0.1:8200' 'kv2_originations' deadbeef-face-2222-860c-facefaceface \
0A4104F43FD6CD0DA184A666D444A4359EB9D38E06DB1EDC97B221DF90ED8189CFB8476EE2BF633DE0B4560F0D2BA284696C02ED31ADB32F09DEBE8D8906AA3E2BE71A \
0A410469BE2EC4699803FB7B49077F1CE0C88E2D2D41D23661EB1F420A72AA2B8DDF4325B349208B7F348C108B7C145FAEF41BB68FF338A75810522A89323E54BE91A6 \
0A4104DB326CF64C7466C2D63A2CD2C0401D1D6F8583C5F837C7510205DFB5CFA89D2115D0A3E0930D5FA01ACC664F1A182E1C0B43099D689B579849DEDDA1C63D0CF7 \
0A2009ABB890B396449706BB5998EEC6F6B0C795297B391A4BC2CF227B263555FF15 \
0A200B221F389D9B8E4964A8EB66F4EC07F83FCDD2E9DCE79B356FDDBE97767CF11C \
0A2100F5FE00731E3BC71F22CF054712A7C1F9A610848FC04BA81E6822D82D82C3562E \
0A41042C52EB79307D248B6CFB2A4AF562E403D4826BB0F540F024BBC3937528F6EB0B7FFA7A6585B751DBA25C173E658F3FEAAB0F05980C76E985CE0D55294F3600D7 \
0A41042C52EB79307D248B6CFB2A4AF562E403D4826BB0F540F024BBC3937528F6EB0B7FFA7A6585B751DBA25C173E658F3FEAAB0F05980C76E985CE0D55294F3600D7 \
0A41042C52EB79307D248B6CFB2A4AF562E403D4826BB0F540F024BBC3937528F6EB0B7FFA7A6585B751DBA25C173E658F3FEAAB0F05980C76E985CE0D55294F3600D7 \
0A2100AF41AAD44E6D0A1DF587491D01C11DB4E0F1BBDDE33F19CB2C4ADDDBE7FC82C4 \
0A2100AF41AAD44E6D0A1DF587491D01C11DB4E0F1BBDDE33F19CB2C4ADDDBE7FC82C4 \
0A2100AF41AAD44E6D0A1DF587491D01C11DB4E0F1BBDDE33F19CB2C4ADDDBE7FC82C4 \
"jealous bright oyster fluid guide talent crystal minor modify broken stove spoon pen thank action smart enemy chunk ladder soon focus recall elite pulp"

docker ps -a
Expand All @@ -50,13 +50,11 @@ function publish() {
fi

source ./service/docker/bootstrap.env
export FULL_PATH=$(realpath $PATH_TO_CONTRACTS)
export FULL_PATH=$(realpath $PATH_TO_CONTRACTS)

echo $SIGNING_PRIVATE_KEY
echo $ENCRYPTION_PRIVATE_KEY
if [[ -d "$FULL_PATH" ]]; then
pushd $PATH_TO_CONTRACTS > /dev/null
./gradlew p8eClean p8eCheck p8eBootstrap --info && ./gradlew publishToMavenLocal -xsignMavenPublication --info
./gradlew p8eClean p8eCheck p8eBootstrap --info && ./gradlew publishToMavenLocal --info
popd > /dev/null
else
echo "Invalid path. Provide a valid path to the contracts directory you wish to publish."
Expand Down
98 changes: 98 additions & 0 deletions models/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
val ktlint: Configuration by configurations.creating

plugins {
Plugins.Detekt.addTo(this)
`java-library`
`maven-publish`
}

java.sourceCompatibility = JavaVersion.VERSION_11

dependencies {
ktlint(Dependencies.Ktlint.toDependencyNotation())

listOf(
Dependencies.Protobuf.JavaUtil,
Dependencies.P8eScope.ContractProto,
Dependencies.P8eScope.ContractBase,
Dependencies.Provenance.AssetModel,
Dependencies.Kotlin.CoroutinesReactor,
).forEach { dep ->
dep.implementation(this)
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "io.provenance.p8e-cee-api"
artifactId = project.name

from(components["java"])

pom {
name.set("Provenance p8e-cee-api data classes")
description.set("Provenance p8e-cee-api data classes")
url.set("https://provenance.io")

licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

developers {
developer {
id.set("cworsnop-figure")
name.set("Cody Worsnop")
email.set("[email protected]")
}
}

scm {
connection.set("[email protected]:provenance-io/p8e-cee-api.git")
developerConnection.set("[email protected]:provenance-io/p8e-cee-api.git")
url.set("https://github.com/provenance-io/p8e-cee-api")
}
}
}
}

signing {
sign(publishing.publications["maven"])
}

tasks.javadoc {
if(JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}
}

tasks.register<JavaExec>("ktlint") {
group = "verification"
description = "Check Kotlin code style."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args("src/**/*.kt")
}

tasks.named("check") {
dependsOn(tasks.named("ktlint"))
}

tasks.register<JavaExec>("ktlintFormat") {
group = "formatting"
description = "Fix Kotlin code style deviations."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args("-F", "src/**/*.kt")
}

detekt {
toolVersion = Versions.Detekt
buildUponDefaultConfig = true
config = files("${rootDir.path}/detekt.yml")
input = files("src/main/kotlin", "src/test/kotlin")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.provenance.onboarding.domain.usecase.common.model
package io.provenance.api.models.account

import io.provenance.scope.contract.proto.Specifications
import java.util.UUID
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.provenance.api.models.cee

import io.provenance.api.models.eos.ObjectStoreConfig
import io.provenance.api.models.account.AccountInfo
import io.provenance.api.models.p8e.ProvenanceConfig
import java.time.OffsetDateTime

data class ApproveContractRequest(
val account: AccountInfo,
val client: ObjectStoreConfig,
val provenanceConfig: ProvenanceConfig,
val envelope: ByteArray,
val expiration: OffsetDateTime = OffsetDateTime.now().plusHours(1),
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.provenance.onboarding.domain.usecase.cee.model
package io.provenance.api.models.cee

import java.util.UUID

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.provenance.api.models.cee

import io.provenance.api.models.p8e.TxResponse

data class ContractExecutionResponse(
val multiparty: Boolean,
val envelopeState: String? = null,
val metadata: TxResponse? = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.provenance.api.models.cee

import io.provenance.api.models.eos.ObjectStoreConfig
import io.provenance.api.models.account.AccountInfo
import io.provenance.api.models.p8e.ProvenanceConfig

data class ExecuteContractConfig(
val contract: ContractConfig,
val client: ObjectStoreConfig,
val account: AccountInfo,
val provenanceConfig: ProvenanceConfig,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.provenance.api.models.cee

import io.provenance.api.models.account.AccountInfo

data class ExecuteContractRequest(
val config: ExecuteContractConfig,
val records: Map<String, Any>,
val participants: List<AccountInfo> = emptyList()
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.provenance.api.models.cee

import io.provenance.api.models.eos.ObjectStoreConfig
import io.provenance.api.models.account.AccountInfo

data class RejectContractRequest(
val account: AccountInfo,
val client: ObjectStoreConfig,
val rejection: ByteArray,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.provenance.api.models.cee

import io.provenance.api.models.account.AccountInfo
import io.provenance.api.models.p8e.ProvenanceConfig

data class SubmitContractExecutionResultRequest(
val account: AccountInfo,
val provenance: ProvenanceConfig,
val envelope: ByteArray,
val state: ByteArray,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.provenance.api.models.eos

data class ObjectStoreConfig(
val objectStoreUrl: String,
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.provenance.onboarding.domain.usecase.common.model
package io.provenance.api.models.p8e

data class ProvenanceConfig(
val chainId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.provenance.onboarding.domain.usecase.common.model
package io.provenance.api.models.p8e

data class TxResponse(
val hash: String,
Expand Down
1 change: 1 addition & 0 deletions service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencyManagement {

dependencies {
ktlint(Dependencies.Ktlint.toDependencyNotation())
implementation(project(":models"))

listOf(
Dependencies.Kotlin.AllOpen,
Expand Down
Loading

0 comments on commit d8f2f5f

Please sign in to comment.