CSPR-Kotlin-SDK
Kotlin SDK library for interacting with a CSPR node.
What is CSPR-Kotlin-SDK?
SDK to streamline the 3rd party Kotlin client integration processes. Such 3rd parties include exchanges & app developers.
System requirement
The SDK is built with Kotlin version 1.5 JVM version 1.8
Build and test
The package can be built and tested from IntelliJ IDEA and from command line
Build and test in IntelliJ IDEA
Download the latest IntelliJ IDEA from https://www.jetbrains.com/idea/
The SDK is developed with IntelliJ IDEA 2021.3.3 (Community Edition). Then a Community Edition is good enough to test the SDK.
Download or clone the code from github, then open it with IntelliJ IDEA.
Set up environment for ItelliJ IDEA
The first thing to do is to set up the SDK for the Project.
In IntelliJ IDEA hit "File-> Project Structure..."
You will see this screen shown up
Click on tab "SDKs" in the left panel to see the list of SDK being installed in your ItelliJ IDEA. You need to install the SDK from 11 or above, the suggested SDK is "openjdk-18".
By default, the SDKs list is just "Kotlin SDK". To install more SDK, hit the "+" button and choose "Download JDK ..."
Select your JDK version. You can choose any option in the list box, but the suggested version is 18, then hit the "Download" button
After the downloading is completed, you'll see the "openjdk-18" item (if you install JDK version 18) together with the Kotlin SDK.
Add more JDK version with the same step if you wish to test on more version of the JDK.
Next in the tab Project, choose the SDK for the project. In this case the choosen SDK is "openjdk-18"
Just do this for the SDK configuration, left the other configurations with default values. Make sure that the "Language level" is "SDK default" as in the image below.
Click "Apply" and then "OK" to save the configruation. Now you are ready to build and test the project in IntelliJ IDEA.
Build the sdk:
To build the project, in IntelliJ IDEA, hit "Build->Build Project" as in the image below
Test the sdk:
To run the test, in the Project panel that show the files and folders, under the folder "test", right click on the "kotlin" folder (folder marked with green in the below image), hit "Run 'All Tests'".
The test list is in the right panel, the result is in the left panel, as shown in the image:
Build and test in command line
In order to build and test the sdk, you need to install Java JDK and Maven.
Install Java JDK
This step include the work of installing JDK and setting up the path in local system environment variable.
The detail process of this stepp can be done with the manual in this address https://www.geeksforgeeks.org/setting-environment-java/
Here is a brief instruction: (For Windows)
- Download the JDK at this address: https://www.oracle.com/java/technologies/downloads/, depends on which operating system you are using, choose the corresponding download (Windows, Mac, Linux)
- Run the already downloaded JDK .exe file (for example "jdk-18_windows-x64_bin.exe" to setup the JDK.
- Open the "Environment Variables" setting
- Double click on the "Path" line or Click on "Path" line and then hit the "Edit" button
- Click New and enter the path for the jdk bin folder, in this example "C:\Program Files\Java\jdk-18\bin" (in general the default location will be this value, but if your folder is different, please enter the bin folder address for the sdk)
Click OK several times to close the "Environment Variables" setting window, then open the "Command prompt" progame in Windows, type in this command:
javac -version
You will see that java is running on your machine, somehow the result will be "javac 18" if you install JDK 18
Install Maven
Follow these step in this address to install Maven (for Windows & Linux)
https://maven.apache.org/install.html
For MacOS, run this command in Terminal
brew install maven
Once you have maven install successfully in your machine, type this in the command prompt to check for it
mvn -v
To build the SDK with Maven
Enter the Casper Kotlin SDK root folder, then run the following command
mvn clean package
Then
mvn -B package --file pom.xml
Build and test using Github script
You can build and test the package with Github script in the "Action" section. Hit the "Action" section of this SDK and choose the latest Work Flow, for example with the below image, hit the green line "Update CONTRIBUTING.md"
Then hit the "Build" button in the next screen
In the next screen, hit the line "Build with Maven" and scroll down to see the full list of the test
Documentation for classes and methods
Coding standard
The code in the SDK follow the coding convention at this address
https://kotlinlang.org/docs/coding-conventions.html#immutability