From 61220688b22c74b22cba536fe822ddd26ff254bf Mon Sep 17 00:00:00 2001 From: Tony Lawson Date: Tue, 18 Apr 2023 14:56:26 +0100 Subject: [PATCH] CORE-12153: Updates for Beta3 RC02 (#36) * CORE-12153: Updates for Beta3 RC02 * CORE-12153: Update to Beta3 RC02 --- build.gradle | 3 +- config/beta-ca-root.pem | 34 +++++++++++++++++++ gradle.properties | 9 +++-- .../workflows/CreateNewChatFlow.java | 19 ++--------- .../workflows/FinalizeChatResponderFlow.java | 2 +- .../workflows/FinalizeChatSubFlow.java | 2 +- .../utxoexample/workflows/UpdateChatFlow.java | 4 +-- 7 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 config/beta-ca-root.pem diff --git a/build.gradle b/build.gradle index ab9ec21..e0d0ce4 100644 --- a/build.gradle +++ b/build.gradle @@ -19,13 +19,14 @@ allprojects { csde { cordaClusterURL = "https://localhost:8888" networkConfigFile = "config/static-network-config.json" + r3RootCertFile = "config/beta-ca-root.pem" corDappCpiName = "MyCorDapp" notaryCpiName = "NotaryServer" cordaRpcUser = "admin" cordaRpcPasswd ="admin" csdeWorkspaceDir = "workspace" notaryVersion = cordaNotaryPluginsVersion - combinedWorkerVersion = "5.0.0.0-Gecko1.0" + combinedWorkerVersion = combinedWorkerJarVersion postgresJdbcVersion = "42.4.3" cordaDbContainerName = "CSDEpostgresql" cordaBinDir = "${System.getProperty("user.home")}/.corda/corda5" diff --git a/config/beta-ca-root.pem b/config/beta-ca-root.pem new file mode 100644 index 0000000..1f8de93 --- /dev/null +++ b/config/beta-ca-root.pem @@ -0,0 +1,34 @@ +-----BEGIN CERTIFICATE----- +MIIF0jCCA7qgAwIBAgIUFTJBhIamOXLuz9r5SkcimXAYgjIwDQYJKoZIhvcNAQEL +BQAwQzELMAkGA1UEBhMCR0IxDzANBgNVBAcMBkxvbmRvbjEPMA0GA1UECgwGUjMg +THRkMRIwEAYDVQQDDAlSMyBMdGQgQ0EwHhcNMjMwMzMxMTUwNDQ5WhcNMzMw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HRkIENBghQVMkGEhqY5cu7P2vlKRyKZcBiCMjALBgNVHQ8EBAMC +AQYwDQYJKoZIhvcNAQELBQADggIBACZ6osBe61Fi4kVkQ3PHvDkqoR/C2CyW5dCg +tzxxb6LbQ0eQ2dUkB0TezhYG8pzS1pR7NdyNZtulrCfT6woEScT/fqCklgTyRhff +OtovEQZIoScDHuVYNfF0YyLg0Wrx5BY65MgQl0r0eGZpwoKkqoTUJQNd8j33nHm9 +cdNQrJFyzMNsTHX3y1KgTZaFGhy2mV6ksjVMbIkrJ5bQADE1vL69XdjH796O0qyG +LxcxzgU7gcto4d1HKQANjHnGkq2+21Ym4jZdAWJyqdrGG0KnIv8wTRgHz2mc9EJQ +Aw9iDG2OXv3/Wu07yoJnzu1N9SP+j2dTdG20gkWus6/mAG1q3CmNdoeplmWBTRqp +4MD3OznUKQZowCyEPgHSCxUEiG5es7FU9PzftGj7io/dWh/ss2gKVU2bod0ZQ5mp +DeWVp76rz5yyx8ML5lh7sMUDW2Xx9kvPuU9tCtm3xh69twu4BPkJGYzAUVtAT3yT +EuJURe1SYX/flGYwSf15MqBw1wSHni5hGZjAkpkM3FB0ZB5qbTWYKjwCFPE9pW/u +fPwKPUf4lWofmdcYnxnYGi2OGFU/gRTHM0NTOt3GY9AAA9KmgQS/TOdpI09G7ab9 +QZArILPG4B+RbykFOOAkWY0aJLg3Cwn9tuhtES7p2Jum3jwU6GS0YLZXk3iK3Scv +0OXjjmtQ +-----END CERTIFICATE----- \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4ec3ac0..6a116be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,17 +2,20 @@ kotlin.code.style=official # Specify the version of the Corda-API to use. # This needs to match the version supported by the Corda Cluster the CorDapp will run on. -cordaApiVersion=5.0.0.665-Gecko1.0 +cordaApiVersion=5.0.0.753-Hawk1.0-RC02 # Specify the version of the notary plugins to use. # Currently packaged as part of corda-runtime-os, so should be set to a corda-runtime-os version. -cordaNotaryPluginsVersion=5.0.0.0-Gecko1.0 +cordaNotaryPluginsVersion=5.0.0.0-Hawk1.0-RC02 + +# Specify the version of the Combined Worker to use +combinedWorkerJarVersion=5.0.0.0-Hawk1.0-RC02 # Specify the version of the cordapp-cpb and cordapp-cpk plugins cordaPluginsVersion=7.0.1 # Specify the version of the CSDE gradle plugin to use -csdePluginVersion=1.0.+ +csdePluginVersion=1.0.0-alpha-+ # For the time being this just needs to be set to a dummy value. platformVersion = 999 diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlow.java index 9a8e11c..f3c7286 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/CreateNewChatFlow.java @@ -9,7 +9,6 @@ import net.corda.v5.base.annotations.Suspendable; import net.corda.v5.base.exceptions.CordaRuntimeException; import net.corda.v5.base.types.MemberX500Name; import net.corda.v5.ledger.common.NotaryLookup; -import net.corda.v5.ledger.common.Party; import net.corda.v5.ledger.utxo.UtxoLedgerService; import net.corda.v5.ledger.utxo.transaction.UtxoSignedTransaction; import net.corda.v5.ledger.utxo.transaction.UtxoTransactionBuilder; @@ -78,24 +77,10 @@ public class CreateNewChatFlow implements ClientStartableFlow { // Obtain the Notary name and public key. NotaryInfo notary = notaryLookup.getNotaryServices().iterator().next(); - PublicKey notaryKey = null; - for(MemberInfo memberInfo: memberLookup.lookup()){ - if(Objects.equals( - memberInfo.getMemberProvidedContext().get("corda.notary.service.name"), - notary.getName().toString())) { - notaryKey = memberInfo.getLedgerKeys().get(0); - break; - } - } - // Note, in Java CorDapps only unchecked RuntimeExceptions can be thrown not - // declared checked exceptions as this changes the method signature and breaks override. - if(notaryKey == null) { - throw new CordaRuntimeException("No notary PublicKey found"); - } // Use UTXOTransactionBuilder to build up the draft transaction. - UtxoTransactionBuilder txBuilder = ledgerService.getTransactionBuilder() - .setNotary(new Party(notary.getName(), notaryKey)) + UtxoTransactionBuilder txBuilder = ledgerService.createTransactionBuilder() + .setNotary(notary.getName()) .setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis())) .addOutputState(chatState) .addCommand(new ChatContract.Create()) diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatResponderFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatResponderFlow.java index 01f4b31..0cb2f3d 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatResponderFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatResponderFlow.java @@ -50,7 +50,7 @@ public class FinalizeChatResponderFlow implements ResponderFlow { // Calls receiveFinality() function which provides the responder to the finalise() function // in the Initiating Flow. Accepts a lambda validator containing the business logic to decide whether // responder should sign the Transaction. - UtxoSignedTransaction finalizedSignedTransaction = utxoLedgerService.receiveFinality(session, txValidator); + UtxoSignedTransaction finalizedSignedTransaction = utxoLedgerService.receiveFinality(session, txValidator).getTransaction(); log.info("Finished responder flow - " + finalizedSignedTransaction.getId()); } // Soft fails the flow and log the exception. diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java index 12f8e98..b6b17f9 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/FinalizeChatSubFlow.java @@ -54,7 +54,7 @@ public class FinalizeChatSubFlow implements SubFlow { UtxoSignedTransaction finalizedSignedTransaction = ledgerService.finalize( signedTransaction, sessionsList - ); + ).getTransaction(); result = finalizedSignedTransaction.getId().toString(); log.info("Success! Response: " + result); diff --git a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java index 79d9609..49e84a1 100644 --- a/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java +++ b/workflows/src/main/java/com/r3/developers/csdetemplate/utxoexample/workflows/UpdateChatFlow.java @@ -79,8 +79,8 @@ public class UpdateChatFlow implements ClientStartableFlow { ChatState newChatState = state.updateMessage(myInfo.getName(), flowArgs.getMessage()); // Use UTXOTransactionBuilder to build up the draft transaction. - UtxoTransactionBuilder txBuilder = ledgerService.getTransactionBuilder() - .setNotary(chatStateAndRef.getState().getNotary()) + UtxoTransactionBuilder txBuilder = ledgerService.createTransactionBuilder() + .setNotary(chatStateAndRef.getState().getNotaryName()) .setTimeWindowBetween(Instant.now(), Instant.now().plusMillis(Duration.ofDays(1).toMillis())) .addOutputState(newChatState) .addInputState(chatStateAndRef.getRef())