Giter Club home page Giter Club logo

csde-cordapp-template-kotlin's Introduction

CSDE-cordapp-template-kotlin

To help make the process of prototyping CorDapps on Corda 5 release more straight forward we have developed the Cordapp Standard Development Environment (CSDE).

The CSDE is obtained by cloning this CSDE-Cordapp-Template-Kotlin repository to your local machine. The CSDE provides:

  • A pre-setup Cordapp Project which you can use as a starting point to develop your own prototypes.

  • A base Gradle configuration which brings in the dependencies you need to write and test a Corda 5 Cordapp.

  • A set of Gradle helper tasks which speed up and simplify the development and deployment process.

  • Debug configuration for debugging a local Corda cluster.

  • The MyFirstFlow code which forms the basis of this getting started documentation, this is located in package com.r3.developers.csdetemplate.flowexample

  • A UTXO example in package com.r3.developers.csdetemplate.utxoexample packages

  • Ability to configure the Members of the Local Corda Network.

To find out how to use the CSDE, please refer to the Getting Started Using the CSDE subsection within the Developing Applications section in the latest Corda 5 documentation at https://docs.r3.com/

Chat app

We have built a simple one to one chat app to demo some functionalities of the next gen Corda platform.

In this app you can:

  1. Create a new chat with a counterparty. CreateNewChatFlow
  2. List out the chat entries you had. ListChatsFlow
  3. Individually query out the history of one chat entry. GetChatFlowArgs
  4. Continue chatting within the chat entry with the counterparty. UpdateChatFlow

Setting up

  1. We will begin our test deployment with clicking the startCorda. This task will load up the combined Corda workers in docker. A successful deployment will allow you to open the REST APIs at: https://localhost:8888/api/v1/swagger#. You can test out some of the functions to check connectivity. (GET /cpi function call should return an empty list as for now.)
  2. We will now deploy the cordapp with a click of 5-vNodeSetup task. Upon successful deployment of the CPI, the GET /cpi function call should now return the meta data of the cpi you just upload

Running the chat app

In Corda 5, flows will be triggered via POST /flow/{holdingidentityshorthash} and flow result will need to be view at GET /flow/{holdingidentityshorthash}/{clientrequestid}

  • holdingidentityshorthash: the id of the network participants, ie Bob, Alice, Charlie. You can view all the short hashes of the network member with another gradle task called ListVNodes
  • clientrequestid: the id you specify in the flow requestBody when you trigger a flow.

Step 1: Create Chat Entry

Pick a VNode identity to initiate the chat, and get its short hash. (Let's pick Alice. Dont pick Bob because Bob is the person who we will have the chat with).

Go to POST /flow/{holdingidentityshorthash}, enter the identity short hash(Alice's hash) and request body:

{
    "clientRequestId": "create-1",
    "flowClassName": "com.r3.developers.csdetemplate.utxoexample.workflows.CreateNewChatFlow",
    "requestBody": {
        "chatName":"Chat with Bob",
        "otherMember":"CN=Bob, OU=Test Dept, O=R3, L=London, C=GB",
        "message": "Hello Bob"
        }
}

After trigger the create-chat flow, hop to GET /flow/{holdingidentityshorthash}/{clientrequestid} and enter the short hash(Alice's hash) and clientrequestid to view the flow result

Step 2: List the chat

In order to continue the chat, we would need the chat ID. This step will bring out all the chat entries this entity (Alice) has. Go to POST /flow/{holdingidentityshorthash}, enter the identity short hash(Alice's hash) and request body:

{
    "clientRequestId": "list-1",
    "flowClassName": "com.r3.developers.csdetemplate.utxoexample.workflows.ListChatsFlow",
    "requestBody": {}
}

After trigger the list-chats flow, again, we need to hop to GET /flow/{holdingidentityshorthash}/{clientrequestid} and check the result. As the screenshot shows, in the response body, we will see a list of chat entries, but it currently only has one entry. And we can see the id of the chat entry. Let's record that id.

Step 3: Continue the chat with UpdateChatFlow

In this step, we will continue the chat between Alice and Bob. Goto POST /flow/{holdingidentityshorthash}, enter the identity short hash and request body. Note that here we can have either Alice or Bob's short hash. If you enter Alice's hash, this message will be recorded as a message from Alice, vice versa. And the id field is the chat entry id we got from the previous step.

{
    "clientRequestId": "update-1",
    "flowClassName": "com.r3.developers.csdetemplate.utxoexample.workflows.UpdateChatFlow",
    "requestBody": {
        "id":" ** fill in id **",
        "message": "How are you today?"
        }
}

And as for the result of this flow, go to GET /flow/{holdingidentityshorthash}/{clientrequestid} and enter the required fields.

Step 4: See the whole chat history of one chat entry

After a few back and forth of the messaging, you can view entire chat history by calling GetChatFlow.

{
    "clientRequestId": "get-1",
    "flowClassName": "com.r3.developers.csdetemplate.utxoexample.workflows.GetChatFlow",
    "requestBody": {
        "id":" ** fill in id **",
        "numberOfRecords":"4"
    }
}

And as for the result, you need to go to the Get API again and enter the short hash and client request ID.

Thus, we have concluded a full run through of the chat app.

csde-cordapp-template-kotlin's People

Contributors

anton-subbotin avatar ceebee-dev avatar chrisr3 avatar christian-napoles-r3 avatar egabrovski-r3 avatar khutsijabari avatar knguyen-r3 avatar marvincudjoe avatar mattbradburyr3 avatar mcgovc avatar nargas-ritu avatar peterli-r3 avatar ronanbrowne avatar seanbrereton avatar tlawson3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csde-cordapp-template-kotlin's Issues

No initiator is configured for protocol

Using CSDE-cordapp-template-kotlin for 5.0.0 i get the following when checking the status of a flow run:

{
  "holdingIdentityShortHash": "FFF34CD757BA",
  "clientRequestId": "create-3",
  "flowId": "ef0214c0-447b-49ea-8396-0d48b36c65a0",
  "flowStatus": "COMPLETED",
  "flowResult": "Flow failed, message: No initiator is configured for protocol com.r3.corda.notary.plugin.nonvalidating at versions [1]",
  "flowError": null,
  "timestamp": "2023-08-16T14:05:21.296Z"
}

What do i need to do for configuring the norary properly?

Corda 5.1 with Java 17?

Is a usable branch/tag for Corda 5.1 and Java 17 available? Maybe I'm missing something, but it's unclear how to go about it. Tried the development branch but doesn't build for me, guess it requires access to private R3 repos:

could not resolve plugin artifact 'net.corda.cordapp.cordapp-configuration:net.corda.cordapp.cordapp-configuration.gradle.plugin:5.1.0.12-HC03'

The default port chosen by Corda 5 worker crashes the default port that is used by AirPlay on macOS

I have discovered that when I execute the startCorda gradle task on macOS, the Corda log always complains that port 7000 is already in used by some other process.

After some googling, I found that 7000 port is used by AirPlay on macOS by default. In order to run the startCorda task, I have to switch off AirPlay in my system setting to make it works.

I suggest making the listening port number configurable such that we can choose other port number other than port 7000 to avoid the problem.

	at io.javalin.Javalin.start(Javalin.java:184) ~[?:?]
	at io.javalin.Javalin.start(Javalin.java:148) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl$startServer$1$1.invoke(WorkerMonitorImpl.kt:114) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl$startServer$1$1.invoke(WorkerMonitorImpl.kt:113) ~[?:?]
	at net.corda.utilities.LogUtilsKt.executeWithStdErrSuppressed(LogUtils.kt:46) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl$startServer$1.invoke(WorkerMonitorImpl.kt:113) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl$startServer$1.invoke(WorkerMonitorImpl.kt:109) ~[?:?]
	at net.corda.utilities.classload.ClassLoadingUtilsKt.executeWithThreadContextClassLoader(ClassLoadingUtils.kt:11) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl.startServer(WorkerMonitorImpl.kt:109) ~[?:?]
	at net.corda.applications.workers.workercommon.internal.WorkerMonitorImpl.listen(WorkerMonitorImpl.kt:65) ~[?:?]
	at net.corda.applications.workers.workercommon.WorkerHelpers$Companion.setupMonitor(WorkerHelpers.kt:108) ~[?:?]
	at net.corda.applications.workers.combined.CombinedWorker.startup(CombinedWorker.kt:118) ~[?:?]
	at net.corda.osgi.framework.OSGiFrameworkWrap.startApplication(OSGiFrameworkWrap.java:588) ~[corda-combined-worker-5.0.0.0-Fox1.0.jar:?]
	at net.corda.osgi.framework.OSGiFrameworkMain.main(OSGiFrameworkMain.java:168) ~[corda-combined-worker-5.0.0.0-Fox1.0.jar:?]
Caused by: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:7000
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349) ~[?:?]
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310) ~[?:?]
	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) ~[?:?]
	at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
	at org.eclipse.jetty.server.Server.doStart(Server.java:401) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
	at io.javalin.jetty.JettyServer.start(JettyServer.kt:65) ~[?:?]
	at io.javalin.Javalin.start(Javalin.java:174) ~[?:?]
	... 13 more
Caused by: java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
	at sun.nio.ch.Net.bind(Net.java:552) ~[?:?]
	at sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:336) ~[?:?]
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[?:?]
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:88) ~[?:?]
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344) ~[?:?]
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310) ~[?:?]
	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80) ~[?:?]
	at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
	at org.eclipse.jetty.server.Server.doStart(Server.java:401) ~[?:?]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ~[?:?]
	at io.javalin.jetty.JettyServer.start(JettyServer.kt:65) ~[?:?]
	at io.javalin.Javalin.start(Javalin.java:174) ~[?:?]```

Execution Failed For Task getCombinedWorkerJar

I am currently working on a project using Corda 5 and while using CSDE-cordapp-template-kotlin release/corda-5-0, I encountered an error where the corda-runtime-os release 5.0.0.0 corda-combined-worker that it is trying to pull cannot be found on github. I looked at the Github releases and it is not available. It seems that the corda-runtime-os 5.0.0.0 release has been removed only recently since this was working previously.

MicrosoftTeams-image (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.