Skip to content

Commit da6549e

Browse files
feat(connector-corda): enable Flow Database Access CorDapp
Added new corda-all-in-one image for flow-database-access sample Modified Corda main-server image to allow calls to invoke without executing any transaction. Modified Corda InvokeContractV1Response to add the new flowId field to return the flow handle id instead of use the callOutput field, which now is used for the data returned by the flow. The transactionId is not required because we can call invoke without executing any transaction. Resolves hyperledger-cacti#1493 Signed-off-by: Elena Izaguirre <[email protected]>
1 parent 7deaa22 commit da6549e

33 files changed

+895
-55
lines changed

.cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"execa",
4141
"faio",
4242
"fidm",
43+
"flowdb",
4344
"fsouza",
4445
"GETHKEYCHAINPASSWORD",
4546
"ghcr",

.github/workflows/ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ jobs:
178178
- name: Print Disk Usage Reports
179179
run: df ; echo "" ; docker system df
180180

181+
- name: ghcr.io/hyperledger/cactus-corda-all-in-one-obligation
182+
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/corda-all-in-one/ -f ./tools/docker/corda-all-in-one/corda-v4_8/Dockerfile
183+
184+
- name: Print Disk Usage Reports
185+
run: df ; echo "" ; docker system df
186+
187+
- name: ghcr.io/hyperledger/cactus-corda-all-in-one-flowdb
188+
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/corda-all-in-one/corda-v4_8-flowdb/
189+
190+
- name: Print Disk Usage Reports
191+
run: df ; echo "" ; docker system df
192+
181193
# Skipping this one for now because it keeps making the CI fail most likely due to DockerHub rate limits.
182194
# TODO: Recommend the Fabric maintainers that they publish their images to ghcr.io as well or ask how can the
183195
# image registry be overridden in Fabric samples.

.taprc

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ files:
5858
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server-v4.8.test.ts
5959
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes.test.ts
6060
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8.test.ts
61+
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts
6162
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts
6263
- ./packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts
6364
- ./packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/plugin-keychain-google-sm.test.ts

jest.config.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
val corda_release_group = "net.corda"
44
val corda_core_release_group = "net.corda"
5-
val corda_release_version = "4.5"
6-
val corda_core_release_version = "4.5"
5+
val corda_release_version = "4.6"
6+
val corda_core_release_version = "4.6"
77
val corda_platform_version = 5
88

99
tasks.named<Test>("test") {

packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/impl/ApiPluginLedgerConnectorCordaServiceImpl.kt

+44-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,49 @@ class ApiPluginLedgerConnectorCordaServiceImpl(
7878
val returnValue = flowHandle.returnValue.get(timeoutMs, TimeUnit.MILLISECONDS)
7979
val id = flowHandle.id
8080

81+
// allow returnValue to be something different to SignedTransaction
82+
var callOutput: kotlin.Any = ""
83+
var transactionId: kotlin.String? = null
84+
85+
if (returnValue is SignedTransaction) {
86+
logger.trace("returnValue is SignedTransaction - using returnValue.id.toString() ...");
87+
transactionId = returnValue.id.toString();
88+
89+
callOutput = mapOf(
90+
"tx" to mapOf(
91+
"id" to returnValue.tx.id,
92+
"notary" to returnValue.tx.notary,
93+
"requiredSigningKeys" to returnValue.tx.requiredSigningKeys,
94+
"merkleTree" to returnValue.tx.merkleTree,
95+
"privacySalt" to returnValue.tx.privacySalt,
96+
"attachments" to returnValue.tx.attachments,
97+
"commands" to returnValue.tx.commands,
98+
// "digestService" to returnValue.tx.digestService,
99+
"inputs" to returnValue.tx.inputs,
100+
"networkParametersHash" to returnValue.tx.networkParametersHash,
101+
"references" to returnValue.tx.references,
102+
"timeWindow" to returnValue.tx.timeWindow
103+
),
104+
"id" to returnValue.id,
105+
"inputs" to returnValue.inputs,
106+
"networkParametersHash" to returnValue.networkParametersHash,
107+
"notary" to returnValue.notary,
108+
"references" to returnValue.references,
109+
"requiredSigningKeys" to returnValue.requiredSigningKeys,
110+
"sigs" to returnValue.sigs
111+
);
112+
113+
} else if (returnValue != null) {
114+
callOutput = try {
115+
val returnValueJson = writer.writeValueAsString(returnValue);
116+
logger.trace("returnValue JSON serialized OK, using returnValue ...");
117+
returnValueJson;
118+
} catch (ex: Exception) {
119+
logger.trace("returnValue JSON serialized failed, using returnValue.toString() ...");
120+
returnValue.toString();
121+
}
122+
}
123+
81124
logger.info("Progress(${progress.size})={}", progress)
82125
logger.info("ReturnValue={}", returnValue)
83126
logger.info("Id=$id")
@@ -96,7 +139,7 @@ class ApiPluginLedgerConnectorCordaServiceImpl(
96139
// org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Response["returnValue"]->
97140
// net.corda.client.jackson.internal.StxJson["wire"]->net.corda.client.jackson.internal.WireTransactionJson["outputs"])]
98141
// with root cause
99-
return InvokeContractV1Response(true, id.toString(), (returnValue as SignedTransaction).id.toString(), progress)
142+
return InvokeContractV1Response(true, callOutput, id.toString(), transactionId, progress)
100143
}
101144

102145
// FIXME - make it clear in the documentation that this deployment endpoint is not recommended for production

packages/cactus-plugin-ledger-connector-corda/src/main-server/kotlin/gen/kotlin-spring/src/main/kotlin/org/hyperledger/cactus/plugin/ledger/connector/corda/server/model/InvokeContractV1Response.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import javax.validation.Valid
1414
/**
1515
*
1616
* @param success
17-
* @param callOutput
17+
* @param callOutput Data returned from the JVM when no transaction is running
18+
* @param flowId The id for the flow handle
1819
* @param transactionId The net.corda.core.flows.StateMachineRunId value returned by the flow execution.
1920
* @param progress An array of strings representing the aggregated stream of progress updates provided by a *tracked* flow invocation. If the flow invocation was not tracked, this array is still returned, but as empty.
2021
*/
@@ -25,8 +26,10 @@ data class InvokeContractV1Response(
2526
@field:Valid
2627
@field:JsonProperty("callOutput", required = true) val callOutput: kotlin.Any,
2728

29+
@field:JsonProperty("flowId", required = true) val flowId: kotlin.String,
30+
2831
@get:Size(min=1,max=1024)
29-
@field:JsonProperty("transactionId", required = true) val transactionId: kotlin.String,
32+
@field:JsonProperty("transactionId") val transactionId: kotlin.String? = null,
3033

3134
@field:JsonProperty("progress") val progress: kotlin.collections.List<kotlin.String>? = null
3235
) {

packages/cactus-plugin-ledger-connector-corda/src/main/json/openapi.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,17 @@
455455
"type": "object",
456456
"required": [
457457
"success",
458-
"transactionId",
459-
"callOutput"
458+
"callOutput",
459+
"flowId"
460460
],
461461
"properties": {
462462
"success": {
463463
"type": "boolean",
464464
"nullable": false
465465
},
466466
"callOutput": {
467-
"type": "object"
467+
"type": "object",
468+
"description": "Data returned from the JVM when no transaction is running"
468469
},
469470
"transactionId": {
470471
"type": "string",
@@ -482,6 +483,10 @@
482483
"maxItems": 10e6
483484
},
484485
"default": []
486+
},
487+
"flowId": {
488+
"type": "string",
489+
"description": "The id for the flow handle"
485490
}
486491
}
487492
},

packages/cactus-plugin-ledger-connector-corda/src/main/typescript/generated/openapi/typescript-axios/api.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export interface InvokeContractV1Response {
368368
*/
369369
success: boolean;
370370
/**
371-
*
371+
* Data returned from the JVM when no transaction is running
372372
* @type {object}
373373
* @memberof InvokeContractV1Response
374374
*/
@@ -378,13 +378,19 @@ export interface InvokeContractV1Response {
378378
* @type {string}
379379
* @memberof InvokeContractV1Response
380380
*/
381-
transactionId: string;
381+
transactionId?: string;
382382
/**
383383
* An array of strings representing the aggregated stream of progress updates provided by a *tracked* flow invocation. If the flow invocation was not tracked, this array is still returned, but as empty.
384384
* @type {Array<string>}
385385
* @memberof InvokeContractV1Response
386386
*/
387387
progress?: Array<string>;
388+
/**
389+
* The id for the flow handle
390+
* @type {string}
391+
* @memberof InvokeContractV1Response
392+
*/
393+
flowId: string;
388394
}
389395
/**
390396
*

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.7.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
106106
const connector = new CordaConnectorContainer({
107107
logLevel,
108108
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
109-
imageVersion: "2021-11-11",
109+
imageVersion: "2021-11-23--feat-1493",
110110
envVars: [envVarSpringAppJson],
111111
});
112112
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8-express.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
111111
const connector = new CordaConnectorContainer({
112112
logLevel,
113113
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
114-
imageVersion: "2021-11-11",
114+
imageVersion: "2021-11-23--feat-1493",
115115
envVars: [envVarSpringAppJson],
116116
});
117117
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
107107
const connector = new CordaConnectorContainer({
108108
logLevel,
109109
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
110-
imageVersion: "2021-11-11",
110+
imageVersion: "2021-11-23--feat-1493",
111111
envVars: [envVarSpringAppJson],
112112
});
113113
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
106106
const connector = new CordaConnectorContainer({
107107
logLevel,
108108
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
109-
imageVersion: "2021-11-11",
110-
// imageName: "cccs",
111-
// imageVersion: "latest",
109+
imageVersion: "2021-11-23--feat-1493",
112110
envVars: [envVarSpringAppJson],
113111
});
114112
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");

0 commit comments

Comments
 (0)