Corda CSDE

djmil 2023-08-14 21:39:18 +02:00
parent fb49e5019e
commit 7e41cd8c0f

115
CordApp.md Normal file

@ -0,0 +1,115 @@
# CSDE
The CorDapp Standard Development Environment (CSDE) makes the process of prototyping CorDapps more straight-forward. The CSDE is obtained by cloning our `CSDE-cordapp-template-kotlin` or `CSDE-cordapp-template-java` repository to your local machine. The CSDE provides:
- a prepared CorDapp project that you can use as a starting point to develop your own prototypes.
- a base Gradle configuration that 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; these are effectively wrappers over the [Corda CLI](https://docs.r3.com/en/platform/corda/5.0/developing-applications/tooling/installing-corda-cli.html).
- debug configuration for debugging a local Corda cluster.
- the `MyFirstFlow` code which forms the basis of the Getting Started documentation.
- the `utxoexample` Chat CorDapp, which provides a basic, working [UTXO](https://docs.r3.com/en/platform/corda/5.0/introduction/glossary.html#utxo) Ledger CorDapp.
- the ability to configure the members of the local Corda network.
## Installation
### Prerequisites
Be sure to [install](https://docs.r3.com/en/platform/corda/5.0/developing-applications/getting-started/prerequisites.html) required SW and CLI tools prior starting development with CSDE.
## Template project
Template Java or Kotlin projects are availvable as a git repo.
```sh
git clone https://github.com/corda/CSDE-cordapp-template-java.git <local-folder>
..
git checkout release/corda-5-0
git init
git remote add origin <remote-url>
```
In order for the `CSDE-cordapp-template` app to work on MacOS with VsCode, these steps must be made:
### Add `$rootDir` prefix in `build.gradle`
For some reason, to run gradle tasks from VsCode, the default `build.gradle` must be updated with absolute paths. Unpatched file works just fine for commands from CLI.
*`build.gradle`*
```diff
// Configure the CSDE
csde {
cordaClusterURL = "https://localhost:8888"
- networkConfigFile = "config/static-network-config.json"
+ networkConfigFile = "$rootDir/config/static-network-config.json"
r3RootCertFile = "config/r3-ca-key.pem"
corDappCpiName = "MyCorDapp"
notaryCpiName = "NotaryServer"
cordaRpcUser = "admin"
cordaRpcPasswd ="admin"
workflowsModuleName = workflowsModule
- csdeWorkspaceDir = "workspace"
+ csdeWorkspaceDir = "$rootDir/workspace"
notaryVersion = cordaNotaryPluginsVersion
combinedWorkerVersion = combinedWorkerJarVersion
postgresJdbcVersion = "42.4.3"
cordaDbContainerName = "CSDEpostgresql"
cordaBinDir = "${System.getProperty("user.home")}/.corda/corda5"
cordaCliBinDir = "${System.getProperty("user.home")}/.corda/cli"
}
```
Note, that there must be no prefix for `r3RootCertFile` property.
### JDK
[Install](https://docs.azul.com/core/zulu-openjdk/install/macos) recommend JDK (Azul Zulu 11) and tell gradle to use it.
_`gradle.properties`_
```diff
+ # Use JDK Zulu 11
+ org.gradle.java.home=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
```
Otherwise, funny errors might happen:
```bash
oxbee@MacBook HelloCorda % ./gradlew 5-vNodesSetup
Starting a Gradle Daemon, 1 busy and 3 incompatible and 2 stopped Daemons could not be reused, use --status for details
> Task :1-createGroupPolicy FAILED
Group policy up to date.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':1-createGroupPolicy'.
> net.corda.plugins.csde.CsdeException: Unable to find the Corda CLI, has it been installed?
```
Even if CordaCLI is actually installed!
#### List all the Java versions installed on Mac
```shell
/usr/libexec/java_home -V
```
## Execution
Gradle commands shall be accessible to you at this moment. Although, it is possible to run gradle tasks in VsCode, it is **suggested to execute them as a generic bash commands**, since most of the configuration files are tested and finetuned only for JetBrains IDEA.
Type `./gradlew tasks` to get list of availvable tasks. The most basic of which are:
### Start local Corda application network
```sh
./gradlew startCord
```
> [!note] Be sure to have your Docker demon up and running
### Run virtual nodes
```sh
./gradlew 5-vNodesSetup
```