diff --git a/.gitignore b/.gitignore
index e8e4b444..f6bde748 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,10 @@ hs_err_pid*
# maven build files
target
+#gradle build files
+build
+.gradle
+
# vim specific files
*.swp
.vim-project
@@ -33,3 +37,7 @@ target
.classpath
.settings
.project
+
+#IntellijIDEA specific files
+
+.idea
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..a0ccf77b
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Environment-dependent path to Maven home directory
+/mavenHomeManager.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 00000000..5ba30e0b
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 00000000..5857d777
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..b4339cc3
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..9dc782bb
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..c0612e5e
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,74 @@
+plugins {
+ id 'java-platform'
+}
+
+group = "com.github.singnet.snet-sdk-java"
+version = "master-SNAPSHOT"
+
+javaPlatform {
+ allowDependencies()
+}
+
+ext {
+ protobufVersion = "3.5.1"
+ grpcVersion = "1.28.0"
+ web3jVersion = "4.2.0-android"
+ platformContractsVersion = "1.0.1"
+ snetDaemonVersion = "3.0.0"
+}
+
+repositories {
+ mavenCentral()
+ maven { url "https://jitpack.io" }
+}
+
+dependencies {
+ constraints {
+ // compile scope equivalents
+ api "com.github.singnet.snet-sdk-java:snet-sdk-java:${version}"
+ api "com.github.singnet.snet-sdk-java:snet-sdk-plugin-core:${version}"
+
+ // protobuf + grpc
+ api "com.google.protobuf:protobuf-java:4.31.1"
+ api(enforcedPlatform("io.grpc:grpc-bom:1.73.0"))
+ api "jakarta.annotation:jakarta.annotation-api:2.1.1"
+
+ // web3j
+ api "org.web3j:core:5.0.0"
+ api "org.web3j:codegen:5.0.0"
+
+ // IPFS
+ api "com.github.ipfs:java-ipfs-http-client:v1.4.4"
+ api "com.github.multiformats:java-multihash:1.2.1"
+
+ // apache commons
+ api "org.apache.commons:commons-compress:1.27.1"
+ api "commons-io:commons-io:2.19.0"
+
+ // lombok
+ api "org.projectlombok:lombok:1.18.30"
+
+ // slf4j
+ api "org.slf4j:slf4j-api:2.0.16"
+
+ // gson
+ api "com.google.code.gson:gson:2.10.1"
+
+ // json
+ api "jakarta.json:jakarta.json-api:2.1.3"
+ api "org.glassfish:jakarta.json:2.0.1"
+
+ // test scope
+ api "junit:junit:4.13.2"
+ api 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ api 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ api "org.mockito:mockito-core:5.18.0"
+ api "org.slf4j:slf4j-simple:2.0.16"
+ }
+}
+
+tasks.named('build') {
+ dependsOn subprojects.findAll { it.tasks.findByName('build') != null }
+ .collect { it.tasks.named('build') }
+}
+
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 00000000..377538c9
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,5 @@
+# This file was generated by the Gradle 'init' task.
+# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
+
+org.gradle.configuration-cache=true
+
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 00000000..38c3f373
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,64 @@
+# This file was generated by the Gradle 'init' task.
+# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
+
+[versions]
+com-github-ipfs-java-ipfs-api = "1.4.4"
+com-github-multiformats-java-multihash = "1.2.1"
+com-google-code-gson-gson = "2.10.1"
+com-google-guava-guava = "33.4.0-jre"
+com-google-protobuf-protobuf-java = "3.21.12"
+commons-io-commons-io = "2.19.0"
+io-grpc-grpc-netty-shaded = "1.71.0"
+io-grpc-grpc-protobuf = "1.71.0"
+io-grpc-grpc-stub = "1.71.0"
+jakarta-annotation-jakarta-annotation-api = "2.1.1"
+javax-annotation-javax-annotation-api = "1.3.2"
+javax-json-javax-json-api = "1.1.4"
+junit-junit = "4.13.2"
+org-apache-commons-commons-compress = "1.27.1"
+org-apache-maven-maven-artifact = "3.3.9"
+org-apache-maven-maven-compat = "3.3.9"
+org-apache-maven-maven-core = "3.3.9"
+org-apache-maven-maven-plugin-api = "3.9.9"
+org-apache-maven-plugin-testing-maven-plugin-testing-harness = "3.3.0"
+org-apache-maven-plugin-tools-maven-plugin-annotations = "3.15.1"
+org-codehaus-groovy-groovy = "3.0.21"
+org-glassfish-javax-json = "1.1.4"
+org-gradle-gradle-core = "3.4"
+org-mockito-mockito-core = "5.18.0"
+org-projectlombok-lombok = "1.18.30"
+org-slf4j-slf4j-api = "2.0.16"
+org-slf4j-slf4j-simple = "2.0.16"
+org-web3j-codegen = "5.0.0"
+org-web3j-core = "5.0.0"
+
+[libraries]
+com-github-ipfs-java-ipfs-api = { module = "com.github.ipfs:java-ipfs-api", version.ref = "com-github-ipfs-java-ipfs-api" }
+com-github-multiformats-java-multihash = { module = "com.github.multiformats:java-multihash", version.ref = "com-github-multiformats-java-multihash" }
+com-google-code-gson-gson = { module = "com.google.code.gson:gson", version.ref = "com-google-code-gson-gson" }
+com-google-guava-guava = { module = "com.google.guava:guava", version.ref = "com-google-guava-guava" }
+com-google-protobuf-protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "com-google-protobuf-protobuf-java" }
+commons-io-commons-io = { module = "commons-io:commons-io", version.ref = "commons-io-commons-io" }
+io-grpc-grpc-netty-shaded = { module = "io.grpc:grpc-netty-shaded", version.ref = "io-grpc-grpc-netty-shaded" }
+io-grpc-grpc-protobuf = { module = "io.grpc:grpc-protobuf", version.ref = "io-grpc-grpc-protobuf" }
+io-grpc-grpc-stub = { module = "io.grpc:grpc-stub", version.ref = "io-grpc-grpc-stub" }
+jakarta-annotation-jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakarta-annotation-jakarta-annotation-api" }
+javax-annotation-javax-annotation-api = { module = "javax.annotation:javax.annotation-api", version.ref = "javax-annotation-javax-annotation-api" }
+javax-json-javax-json-api = { module = "javax.json:javax.json-api", version.ref = "javax-json-javax-json-api" }
+junit-junit = { module = "junit:junit", version.ref = "junit-junit" }
+org-apache-commons-commons-compress = { module = "org.apache.commons:commons-compress", version.ref = "org-apache-commons-commons-compress" }
+org-apache-maven-maven-artifact = { module = "org.apache.maven:maven-artifact", version.ref = "org-apache-maven-maven-artifact" }
+org-apache-maven-maven-compat = { module = "org.apache.maven:maven-compat", version.ref = "org-apache-maven-maven-compat" }
+org-apache-maven-maven-core = { module = "org.apache.maven:maven-core", version.ref = "org-apache-maven-maven-core" }
+org-apache-maven-maven-plugin-api = { module = "org.apache.maven:maven-plugin-api", version.ref = "org-apache-maven-maven-plugin-api" }
+org-apache-maven-plugin-testing-maven-plugin-testing-harness = { module = "org.apache.maven.plugin-testing:maven-plugin-testing-harness", version.ref = "org-apache-maven-plugin-testing-maven-plugin-testing-harness" }
+org-apache-maven-plugin-tools-maven-plugin-annotations = { module = "org.apache.maven.plugin-tools:maven-plugin-annotations", version.ref = "org-apache-maven-plugin-tools-maven-plugin-annotations" }
+org-codehaus-groovy-groovy = { module = "org.codehaus.groovy:groovy", version.ref = "org-codehaus-groovy-groovy" }
+org-glassfish-javax-json = { module = "org.glassfish:javax.json", version.ref = "org-glassfish-javax-json" }
+org-gradle-gradle-core = { module = "org.gradle:gradle-core", version.ref = "org-gradle-gradle-core" }
+org-mockito-mockito-core = { module = "org.mockito:mockito-core", version.ref = "org-mockito-mockito-core" }
+org-projectlombok-lombok = { module = "org.projectlombok:lombok", version.ref = "org-projectlombok-lombok" }
+org-slf4j-slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "org-slf4j-slf4j-api" }
+org-slf4j-slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "org-slf4j-slf4j-simple" }
+org-web3j-codegen = { module = "org.web3j:codegen", version.ref = "org-web3j-codegen" }
+org-web3j-core = { module = "org.web3j:core", version.ref = "org-web3j-core" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..2a84e188
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 00000000..ef07e016
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,251 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH="\\\"\\\""
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 00000000..5eed7ee8
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/plugin/core/build.gradle b/plugin/core/build.gradle
new file mode 100644
index 00000000..144b4920
--- /dev/null
+++ b/plugin/core/build.gradle
@@ -0,0 +1,67 @@
+plugins {
+ id 'java'
+ id 'jacoco'
+}
+
+group = 'com.github.singnet.snet-sdk-java'
+version = 'master-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+ maven { url "https://jitpack.io" }
+}
+
+dependencies {
+ // compile scope
+ implementation(project(":snet-sdk-java")) {
+ exclude group: "com.google.guava", module: "guava"
+ }
+ implementation "com.google.guava:guava:33.4.0-jre"
+ implementation "org.apache.commons:commons-compress:1.27.1"
+ implementation "org.slf4j:slf4j-api:2.0.16"
+
+ // test scope
+// testImplementation "junit:junit:4.13.2"
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ testImplementation "org.mockito:mockito-core:5.18.0"
+ testImplementation "org.slf4j:slf4j-simple:2.0.16"
+ implementation 'org.web3j:abi:5.0.0'
+ implementation 'org.web3j:contracts:5.0.0'
+ implementation 'org.web3j:crypto:5.0.0'
+ implementation 'org.web3j:rlp:5.0.0'
+ implementation 'org.web3j:tuples:5.0.0'
+ implementation 'com.github.ipfs:java-ipfs-api:v1.4.4'
+}
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+jacoco {
+ toolVersion = "0.8.12"
+}
+
+tasks.test {
+ useJUnitPlatform()
+ finalizedBy jacocoTestReport
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ showStandardStreams = true
+ }
+}
+
+tasks.javadoc {
+ options.encoding = 'UTF-8'
+}
+
+tasks.named('compileJava') {
+ dependsOn(
+ project(':snet-sdk-java').tasks.named('getDependencies'),
+ project(':snet-sdk-java').tasks.named('getContracts'),
+ project(':snet-sdk-java').tasks.named('generateContractStubsMain'),
+ project(':snet-sdk-java').tasks.named('generateContractStubsMulti'),
+ project(':snet-sdk-java').tasks.named('getDaemonProto'),
+ project(':snet-sdk-java').tasks.named('generateProto')
+ )
+}
\ No newline at end of file
diff --git a/plugin/core/pom.xml b/plugin/core/pom.xml
index e1219b56..528f285b 100644
--- a/plugin/core/pom.xml
+++ b/plugin/core/pom.xml
@@ -21,6 +21,7 @@
+
com.github.singnet.snet-sdk-java
snet-sdk-java
@@ -39,36 +40,44 @@
guava
+
+
com.google.guava
guava
-
- 29.0-jre
+ 33.4.0-jre
org.apache.commons
commons-compress
+
org.slf4j
slf4j-api
+ 2.0.16
junit
junit
+ 4.13.2
test
+
org.mockito
mockito-core
+ 5.18.0
test
+
org.slf4j
slf4j-simple
+ 2.0.16
test
diff --git a/plugin/core/src/main/java/io/singularitynet/sdk/plugin/ServiceApiGetter.java b/plugin/core/src/main/java/io/singularitynet/sdk/plugin/ServiceApiGetter.java
index 1afcac71..314e4654 100644
--- a/plugin/core/src/main/java/io/singularitynet/sdk/plugin/ServiceApiGetter.java
+++ b/plugin/core/src/main/java/io/singularitynet/sdk/plugin/ServiceApiGetter.java
@@ -5,10 +5,11 @@
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.MalformedURLException;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.nio.file.Files;
+
+import io.singularitynet.sdk.contracts.Registry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
@@ -23,14 +24,12 @@
import org.slf4j.LoggerFactory;
import io.singularitynet.sdk.common.Utils;
-import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.ethereum.Address;
import io.singularitynet.sdk.ethereum.ContractUtils;
import io.singularitynet.sdk.registry.IpfsMetadataStorage;
import io.singularitynet.sdk.registry.RegistryMetadataProvider;
import io.singularitynet.sdk.registry.ServiceMetadata;
import io.singularitynet.sdk.registry.RegistryContract;
-import io.singularitynet.sdk.client.Configuration;
public class ServiceApiGetter {
diff --git a/plugin/core/src/test/java/io/singularitynet/sdk/plugin/ServiceApiGetterTest.java b/plugin/core/src/test/java/io/singularitynet/sdk/plugin/ServiceApiGetterTest.java
index 864ec63d..5d30f5e2 100644
--- a/plugin/core/src/test/java/io/singularitynet/sdk/plugin/ServiceApiGetterTest.java
+++ b/plugin/core/src/test/java/io/singularitynet/sdk/plugin/ServiceApiGetterTest.java
@@ -1,12 +1,15 @@
package io.singularitynet.sdk.plugin;
-import org.junit.*;
-import static org.junit.Assert.*;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.io.TempDir;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
+
+import io.singularitynet.sdk.contracts.Registry;
+import io.singularitynet.sdk.common.Utils;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -14,15 +17,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.Collections;
-import java.util.List;
+
import io.ipfs.api.IPFS;
import io.ipfs.multihash.Multihash;
-import org.web3j.protocol.core.RemoteCall;
+import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.tuples.generated.Tuple3;
-import io.singularitynet.sdk.common.Utils;
-import io.singularitynet.sdk.contracts.Registry;
public class ServiceApiGetterTest {
@@ -34,27 +34,30 @@ public class ServiceApiGetterTest {
private Registry registry;
private IPFS ipfs;
- @Rule
- public TemporaryFolder testFolder = new TemporaryFolder();
-
- @Before
+ @BeforeEach
public void setUp() throws IOException {
+ RemoteFunctionCall> remoteCall = mock(RemoteFunctionCall.class);
+ try {
+ when(remoteCall.send()).thenReturn(new Tuple3<>(
+ true,
+ Utils.strToBytes32(SERVICE_ID),
+ Utils.strToBytes("ipfs://" + METADATA_HASH))
+ );
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
registry = mock(Registry.class);
when(registry.getServiceRegistrationById(
- eq(Utils.strToBytes32(ORG_ID)),
- eq(Utils.strToBytes32(SERVICE_ID))))
- .thenReturn(new RemoteCall<>(
- () -> {
- return new Tuple3<>(true,
- Utils.strToBytes32(SERVICE_ID),
- Utils.strToBytes("ipfs://" + METADATA_HASH));
- }));
+ eq(Utils.strToBytes32(ORG_ID)),
+ eq(Utils.strToBytes32(SERVICE_ID))))
+ .thenReturn(remoteCall);
ipfs = mock(IPFS.class);
when(ipfs.cat(eq(Multihash.fromBase58(METADATA_HASH))))
- .thenReturn(readResource("/example-service-metadata.json"));
+ .thenReturn(readResource("/example-service-metadata.json"));
when(ipfs.cat(eq(Multihash.fromBase58(MODEL_IPFS_HASH))))
- .thenReturn(readResource("/example-service-model.tar"));
+ .thenReturn(readResource("/example-service-model.tar"));
}
private static byte[] readResource(String name) {
@@ -78,37 +81,57 @@ private static Path getResourcePath(String name) {
}
@Test
- public void getServiceApi() throws IOException, PluginException {
- File outputDir = testFolder.newFolder("output");
+ public void getServiceApi(@TempDir File outputDir) throws IOException, PluginException {
ServiceApiGetter.Parameters params = new ServiceApiGetter.DefaultParameters() {
- public String getOrgId() { return ORG_ID; }
- public String getServiceId() { return SERVICE_ID; }
- public File getOutputDir() { return outputDir; }
- public String getJavaPackage() { return "org.example.exampleservice"; }
- public URL getEthereumJsonRpcEndpoint() { return Utils.wrapExceptions(() -> new URL("http://localhost:8545")); }
+ public String getOrgId() {
+ return ORG_ID;
+ }
+
+ public String getServiceId() {
+ return SERVICE_ID;
+ }
+
+ public File getOutputDir() {
+ return outputDir;
+ }
+
+ public String getJavaPackage() {
+ return "org.example.exampleservice";
+ }
+
+ public URL getEthereumJsonRpcEndpoint() {
+ return Utils.wrapExceptions(() -> new URL("http://localhost:8545"));
+ }
};
ServiceApiGetter getter = new ServiceApiGetter(registry, ipfs, params);
getter.run();
- assertEquals("API Protobuf file",
- readFileAsString(getResourcePath("/example_service.proto")),
- readFileAsString(outputDir.toPath().resolve("example_service.proto")));
+ assertEquals(readFileAsString(getResourcePath("/example_service.proto")),
+ readFileAsString(outputDir.toPath().resolve("example_service.proto")),
+ "API Protobuf file");
}
- @Rule
- public ExpectedException exceptionRule = ExpectedException.none();
-
@Test
public void throwExceptionOnWeb3jClientConnectionError() throws PluginException {
- exceptionRule.expect(PluginException.class);
- exceptionRule.expectMessage("Could not perform operation on Ethereum RPC endpoint provided: http://localhost:1");
ServiceApiGetter.Parameters params = new ServiceApiGetter.DefaultParameters() {
- public String getOrgId() { return ORG_ID; }
- public String getServiceId() { return SERVICE_ID; }
- public File getOutputDir() { return null; }
- public String getJavaPackage() { return "org.example.exampleservice"; }
- public URL getEthereumJsonRpcEndpoint() {
+ public String getOrgId() {
+ return ORG_ID;
+ }
+
+ public String getServiceId() {
+ return SERVICE_ID;
+ }
+
+ public File getOutputDir() {
+ return null;
+ }
+
+ public String getJavaPackage() {
+ return "org.example.exampleservice";
+ }
+
+ public URL getEthereumJsonRpcEndpoint() {
try {
return new URL("http://localhost:1");
} catch (MalformedURLException e) {
@@ -118,6 +141,14 @@ public URL getEthereumJsonRpcEndpoint() {
};
ServiceApiGetter getter = new ServiceApiGetter(null, null, params);
- getter.run();
+ PluginException ex = assertThrows(
+ PluginException.class,
+ getter::run
+ );
+
+ assertTrue(ex.getMessage().contains(
+ "Could not perform operation on Ethereum RPC endpoint provided: http://localhost:1"
+ ));
+
}
}
diff --git a/plugin/gradle/build.gradle b/plugin/gradle/build.gradle
new file mode 100644
index 00000000..aa9bc5f5
--- /dev/null
+++ b/plugin/gradle/build.gradle
@@ -0,0 +1,59 @@
+plugins {
+ id 'java'
+ id 'groovy'
+ id 'jacoco'
+
+}
+
+group = 'com.github.singnet.snet-sdk-java'
+version = 'master-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+ mavenCentral()
+ maven { url "https://jitpack.io" }
+}
+
+
+
+dependencies {
+ implementation project(":snet-sdk-plugin-core")
+ implementation project(":snet-sdk-java")
+ compileOnly "org.projectlombok:lombok:1.18.30"
+ annotationProcessor "org.projectlombok:lombok:1.18.30"
+
+
+
+ // gradle plugin internals
+ implementation "org.codehaus.groovy:groovy:3.0.21"
+ compileOnly gradleApi()
+
+
+// testImplementation "junit:junit:4.13.2"
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ testImplementation "org.mockito:mockito-core:5.18.0"
+ testImplementation "org.slf4j:slf4j-simple:2.0.16"
+}
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+jacoco {
+ toolVersion = "0.8.12"
+}
+
+tasks.test {
+ useJUnitPlatform()
+ finalizedBy jacocoTestReport
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ showStandardStreams = true
+ }
+}
+
+tasks.javadoc {
+ options.encoding = 'UTF-8'
+}
+
diff --git a/plugin/gradle/pom.xml b/plugin/gradle/pom.xml
index 81c34eeb..6dba63bd 100644
--- a/plugin/gradle/pom.xml
+++ b/plugin/gradle/pom.xml
@@ -39,22 +39,26 @@
com.github.singnet.snet-sdk-java
snet-sdk-plugin-core
+
org.projectlombok
lombok
+ 1.18.30
provided
+
+
org.codehaus.groovy
groovy
- 2.5.14
- provided
+ 3.0.21
+
org.gradle
gradle-core
- ${gradle.version}
+ 3.4
provided
diff --git a/plugin/gradle/src/main/java/io/singularitynet/sdk/gradle/GetSingularityNetServiceApi.java b/plugin/gradle/src/main/java/io/singularitynet/sdk/gradle/GetSingularityNetServiceApi.java
index 28a3eed3..2f9ba7a7 100644
--- a/plugin/gradle/src/main/java/io/singularitynet/sdk/gradle/GetSingularityNetServiceApi.java
+++ b/plugin/gradle/src/main/java/io/singularitynet/sdk/gradle/GetSingularityNetServiceApi.java
@@ -5,7 +5,6 @@
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.TaskAction;
-
import java.io.File;
import java.net.URL;
import lombok.Setter;
diff --git a/plugin/maven/build.gradle b/plugin/maven/build.gradle
new file mode 100644
index 00000000..057a2947
--- /dev/null
+++ b/plugin/maven/build.gradle
@@ -0,0 +1,107 @@
+plugins {
+ id 'java'
+ id 'groovy'
+ id 'maven-publish'
+ id 'jacoco'
+ id 'base'
+ id 'com.bmuschko.docker-remote-api' version '9.4.0'
+}
+
+group = 'com.github.singnet.snet-sdk-java'
+version = 'master-SNAPSHOT'
+
+apply plugin: 'com.bmuschko.docker-remote-api'
+
+
+repositories {
+ mavenCentral()
+ maven {
+ url "https://repo.gradle.org/gradle/libs-releases-local"
+ }
+ maven { url "https://jitpack.io" }
+ gradlePluginPortal()
+}
+
+dependencies {
+ implementation project(':snet-sdk-plugin-core')
+
+ compileOnly "org.projectlombok:lombok:1.18.30"
+ annotationProcessor "org.projectlombok:lombok:1.18.30"
+
+ compileOnly "org.apache.maven:maven-plugin-api:3.9.9"
+ compileOnly "org.apache.maven:maven-core:3.3.9"
+ compileOnly "org.apache.maven:maven-artifact:3.3.9"
+ compileOnly "org.apache.maven.plugin-tools:maven-plugin-annotations:3.15.1"
+
+// testImplementation "junit:junit:4.13.2"
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ testImplementation "org.slf4j:slf4j-simple:2.0.16"
+ implementation "commons-io:commons-io:2.19.0"
+
+ testImplementation "org.apache.maven.plugin-testing:maven-plugin-testing-harness:3.3.0"
+ testImplementation "org.apache.maven:maven-compat:3.3.9"
+ implementation 'com.github.docker-java:docker-java:3.5.3'
+ implementation 'com.github.docker-java:docker-java-transport-httpclient5:3.5.3'
+
+}
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+jacoco {
+ toolVersion = "0.8.12"
+}
+
+tasks.test {
+ useJUnitPlatform()
+ finalizedBy jacocoTestReport
+ testLogging {
+ events "passed", "skipped", "failed", "standardOut", "standardError"
+ showStandardStreams = true
+ }
+}
+
+tasks.javadoc {
+ options.encoding = 'UTF-8'
+}
+
+
+// import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
+// import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
+//
+// task createIpfs(type: DockerCreateContainer) {
+// containerName = 'Ipfs'
+// targetImageId 'ipfs/go-ipfs:master-latest'
+// portSpecs = ['5002:5002']
+// }
+//
+// task startIpfs(type: DockerStartContainer) {
+// dependsOn createIpfs
+// doLast{
+// targetContainerId { createIpfs.getContainerId() }
+// }
+// }
+//
+// task createEthereum(type: DockerCreateContainer) {
+// containerName = 'Ethereum'
+// targetImageId 'trufflesuite/ganache-cli:latest'
+// portSpecs = ['8545:8545']
+// }
+//
+// task startEthereum(type: DockerStartContainer) {
+// dependsOn createEthereum
+// doLast{
+// targetContainerId { createEthereum.getContainerId() }
+// }
+// }
+//
+// tasks.test {
+// dependsOn startIpfs, startEthereum
+// doLast {
+// println 'Останавливаем и удаляем контейнеры...'
+// removeIpfs.execute()
+// removeEthereum.execute()
+// }
+// }
\ No newline at end of file
diff --git a/plugin/maven/pom.xml b/plugin/maven/pom.xml
index ae848446..f7f0141c 100644
--- a/plugin/maven/pom.xml
+++ b/plugin/maven/pom.xml
@@ -30,16 +30,19 @@
com.github.singnet.snet-sdk-java
snet-sdk-plugin-core
+
+
org.projectlombok
lombok
+ 1.18.30
provided
org.apache.maven
maven-plugin-api
- ${maven.version}
+ 3.9.9
provided
@@ -57,7 +60,7 @@
org.apache.maven.plugin-tools
maven-plugin-annotations
- 3.6.0
+ 3.15.1
provided
@@ -66,17 +69,21 @@
junit
junit
+ 4.13.2
test
+
org.slf4j
slf4j-simple
+ 2.0.16
test
+
commons-io
commons-io
- test
+ 2.19.0
@@ -166,7 +173,7 @@
maven-plugin-plugin
- 3.6.0
+ 3.15.1
maven-invoker-plugin
diff --git a/plugin/maven/src/main/java/io/singularitynet/sdk/maven/SnetServiceApiMojo.java b/plugin/maven/src/main/java/io/singularitynet/sdk/maven/SnetServiceApiMojo.java
index 444529f0..d2f0917f 100644
--- a/plugin/maven/src/main/java/io/singularitynet/sdk/maven/SnetServiceApiMojo.java
+++ b/plugin/maven/src/main/java/io/singularitynet/sdk/maven/SnetServiceApiMojo.java
@@ -10,6 +10,7 @@
import java.io.File;
import java.net.URL;
import lombok.Getter;
+//import lombok.Setter;
import io.singularitynet.sdk.plugin.ServiceApiGetter;
import io.singularitynet.sdk.plugin.PluginException;
@@ -25,6 +26,8 @@ public class SnetServiceApiMojo extends AbstractMojo implements ServiceApiGetter
@Parameter(property = "serviceId", required = true)
private String serviceId;
+// here was added setter for io.singularitynet.sdk.maven.SnetServiceApiMojoTestIT
+// @Setter
@Getter
@Parameter(defaultValue = "${project.build.directory}/proto", property = "outputDir", required = true)
private File outputDir;
diff --git a/plugin/maven/src/test/java/io/singularitynet/sdk/maven/SnetServiceApiMojoTestIT.java b/plugin/maven/src/test/java/io/singularitynet/sdk/maven/SnetServiceApiMojoTestIT.java
index c4bb8c1e..11670b01 100644
--- a/plugin/maven/src/test/java/io/singularitynet/sdk/maven/SnetServiceApiMojoTestIT.java
+++ b/plugin/maven/src/test/java/io/singularitynet/sdk/maven/SnetServiceApiMojoTestIT.java
@@ -1,54 +1,80 @@
package io.singularitynet.sdk.maven;
-import org.apache.maven.plugin.testing.MojoRule;
-import org.apache.maven.plugin.testing.WithoutMojo;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import org.junit.Rule;
-import static org.junit.Assert.*;
-import org.junit.Test;
-import java.io.File;
import java.io.BufferedInputStream;
+import java.io.File;
import java.io.FileInputStream;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.Socket;
+import java.net.URL;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class SnetServiceApiMojoTestIT {
-public class SnetServiceApiMojoTestIT
-{
private static final File testProjectDir = new File("target/test-classes/project-to-test/");
+ private SnetServiceApiMojo mojo;
- @Rule
- public MojoRule rule = new MojoRule() {
- @Override
- protected void before() throws Throwable {
- FileUtils.deleteDirectory(new File(testProjectDir, "target"));
- }
+ @BeforeEach
+ void setUp() throws Exception {
+ FileUtils.deleteDirectory(new File(testProjectDir, "target"));
- @Override
- protected void after() {
- }
- };
+ mojo = new SnetServiceApiMojo();
+
+ Field field = mojo.getClass().getDeclaredField("orgId");
+ field.setAccessible(true);
+ field.set(mojo, "example-org");
+
+ field = mojo.getClass().getDeclaredField("serviceId");
+ field.setAccessible(true);
+ field.set(mojo, "example-service");
+
+ field = mojo.getClass().getDeclaredField("outputDir");
+ field.setAccessible(true);
+ field.set(mojo, new File("build"));
+
+ field = mojo.getClass().getDeclaredField("javaPackage");
+ field.setAccessible(true);
+ field.set(mojo, "io.singularitynet.service");
+
+ field = mojo.getClass().getDeclaredField("ipfsRpcEndpoint");
+ field.setAccessible(true);
+ field.set(mojo, new URL("http://localhost:5002"));
+
+ field = mojo.getClass().getDeclaredField("ethereumJsonRpcEndpoint");
+ field.setAccessible(true);
+ field.set(mojo, new URL("http://localhost:8545"));
+
+ field = mojo.getClass().getDeclaredField("registryAddress");
+ field.setAccessible(true);
+ field.set(mojo, "0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2");
+
+// mojo.setOutputDir(outputDir);
+
+
+ }
@Test
- public void getApiUsingRegistryAndIpfs() throws Exception {
- SnetServiceApiMojo mojo = (SnetServiceApiMojo) rule.lookupConfiguredMojo(testProjectDir, "get");
- assertNotNull(mojo);
+ void getApiUsingRegistryAndIpfs() throws Exception {
+ assertNotNull(mojo, "Mojo должен быть создан");
mojo.execute();
+ File outputDir = new File(testProjectDir, "target/generated-sources");
- File outputDir = (File) rule.getVariableValueFromObject(mojo, "outputDir");
assertNotNull(outputDir);
- assertTrue("Output dir doesn't exist", outputDir.exists());
+ assertTrue(outputDir.exists(), "Output dir doesn't exist");
File protoFile = new File(outputDir, "example_service.proto");
- assertTrue("API is not downloaded", protoFile.exists());
+ assertTrue(protoFile.exists(), "API не был загружен");
- BufferedInputStream is = new BufferedInputStream(new FileInputStream(protoFile));
- try {
+ try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(protoFile))) {
String protobuf = IOUtils.toString(is);
- assertTrue("Java package is not added", protobuf.endsWith("option java_package = \"io.singularitynet.service\";\n"));
- } finally {
- is.close();
+ assertTrue(protobuf.endsWith("option java_package = \"io.singularitynet.service\";\n"),
+ "Java package не добавлен");
}
}
-
}
-
diff --git a/pom.xml b/pom.xml
index cfaa39b0..bf3dac57 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,8 +10,8 @@
true
UTF-8
- 1.8
- 1.8
+ 21
+ 21
1.0.1
3.0.0
3.5.1
@@ -53,43 +53,52 @@
snet-sdk-plugin-core
${project.version}
+
+
com.google.protobuf
protobuf-java
- ${protobuf.version}
+ 4.31.1
+
io.grpc
grpc-bom
- ${grpc.version}
+ 1.73.0
pom
import
+
- javax.annotation
- javax.annotation-api
- 1.3.2
+ jakarta.annotation
+ jakarta.annotation-api
+ 2.1.1
+
+
org.web3j
core
- ${web3j.version}
+ 5.0.0
+
org.web3j
codegen
- ${web3j.version}
+ 5.0.0
provided
+
+
com.github.ipfs
java-ipfs-http-client
- 1.2.3
+ v1.4.4
com.github.multiformats
@@ -97,51 +106,66 @@
1.2.1
+
+
org.apache.commons
commons-compress
- 1.21
+ 1.27.1
+
+
commons-io
commons-io
- 2.7
+ 2.19.0
+
+
org.projectlombok
lombok
- 1.18.10
+ 1.18.30
provided
+
+
org.slf4j
slf4j-api
- 1.7.29
+ 2.0.16
+
org.slf4j
slf4j-simple
- 1.7.29
+ 2.0.16
+ test
+
+
com.google.code.gson
gson
- 2.8.5
+ 2.10.1
+
+
- javax.json
- javax.json-api
- 1.1.4
+ jakarta.json
+ jakarta.json-api
+ 2.1.3
+
org.glassfish
- javax.json
- 1.1.4
+ jakarta.json
+ 2.0.1
@@ -149,13 +173,14 @@
junit
junit
- 4.13.1
+ 4.13.2
test
+
org.mockito
mockito-core
- 3.1.0
+ 5.18.0
test
@@ -191,7 +216,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.2
+ 0.8.12
org.apache.maven.plugins
@@ -214,7 +239,7 @@
org.apache.maven.plugins
maven-antrun-plugin
- 1.6
+ 3.1.0
io.fabric8
@@ -262,11 +287,15 @@
maven-compiler-plugin
- 3.8.0
+ 3.13.0
+
+ 17
+ 17
+
maven-surefire-plugin
- 2.22.1
+ 3.2.5
false
@@ -291,12 +320,12 @@
-
-
-
- maven-project-info-reports-plugin
-
-
-
+
+
+
+
+
+
+
diff --git a/script.deb.sh b/script.deb.sh
new file mode 100644
index 00000000..3ae5b514
--- /dev/null
+++ b/script.deb.sh
@@ -0,0 +1,233 @@
+#!/bin/bash
+
+unknown_os ()
+{
+ echo "Unfortunately, your operating system distribution and version are not supported by this script."
+ echo
+ echo "You can override the OS detection by setting os= and dist= prior to running this script."
+ echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version"
+ echo
+ echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
+ echo
+ echo "Please contact the owner of this repository/package for further support."
+ exit 1
+}
+
+gpg_check ()
+{
+ echo "Checking for gpg..."
+ if command -v gpg > /dev/null; then
+ echo "Detected gpg..."
+ else
+ echo "Installing gnupg for GPG verification..."
+ apt-get install -y gnupg
+ if [ "$?" -ne "0" ]; then
+ echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
+ echo "Repository installation aborted."
+ exit 1
+ fi
+ fi
+}
+
+curl_check ()
+{
+ echo "Checking for curl..."
+ if command -v curl > /dev/null; then
+ echo "Detected curl..."
+ else
+ echo "Installing curl..."
+ apt-get install -q -y curl
+ if [ "$?" -ne "0" ]; then
+ echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
+ echo "Repository installation aborted."
+ exit 1
+ fi
+ fi
+}
+
+install_debian_keyring ()
+{
+ if [ "${os,,}" = "debian" ]; then
+ echo "Installing debian-archive-keyring which is needed for installing "
+ echo "apt-transport-https on many Debian systems."
+ apt-get install -y debian-archive-keyring &> /dev/null
+ fi
+}
+
+
+detect_os ()
+{
+ if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
+ # some systems dont have lsb-release yet have the lsb_release binary and
+ # vice-versa
+ if [ -e /etc/lsb-release ]; then
+ . /etc/lsb-release
+
+ if [ "${ID}" = "raspbian" ]; then
+ os=${ID}
+ dist=`cut --delimiter='.' -f1 /etc/debian_version`
+ else
+ os=${DISTRIB_ID}
+ dist=${DISTRIB_CODENAME}
+
+ if [ -z "$dist" ]; then
+ dist=${DISTRIB_RELEASE}
+ fi
+ fi
+
+ elif [ `which lsb_release 2>/dev/null` ]; then
+ dist=`lsb_release -c | cut -f2`
+ os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
+
+ elif [ -e /etc/debian_version ]; then
+ # some Debians have jessie/sid in their /etc/debian_version
+ # while others have '6.0.7'
+ os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
+ if grep -q '/' /etc/debian_version; then
+ dist=`cut --delimiter='/' -f1 /etc/debian_version`
+ else
+ dist=`cut --delimiter='.' -f1 /etc/debian_version`
+ fi
+
+ else
+ unknown_os
+ fi
+ fi
+
+ if [ -z "$dist" ]; then
+ unknown_os
+ fi
+
+ # remove whitespace from OS and dist name
+ os="${os// /}"
+ dist="${dist// /}"
+
+ echo "Detected operating system as $os/$dist."
+}
+
+detect_apt_version ()
+{
+ apt_version_full=`apt-get -v | head -1 | awk '{ print $2 }'`
+ apt_version_major=`echo $apt_version_full | cut -d. -f1`
+ apt_version_minor=`echo $apt_version_full | cut -d. -f2`
+ apt_version_modified="${apt_version_major}${apt_version_minor}0"
+
+ echo "Detected apt version as ${apt_version_full}"
+}
+
+main ()
+{
+ detect_os
+ curl_check
+ gpg_check
+ detect_apt_version
+
+ # Need to first run apt-get update so that apt-transport-https can be
+ # installed
+ echo -n "Running apt-get update... "
+ apt-get update &> /dev/null
+ echo "done."
+
+ # Install the debian-archive-keyring package on debian systems so that
+ # apt-transport-https can be installed next
+ install_debian_keyring
+
+ echo -n "Installing apt-transport-https... "
+ apt-get install -y apt-transport-https &> /dev/null
+ echo "done."
+
+
+ gpg_key_url="https://packagecloud.io/ookla/speedtest-cli/gpgkey"
+ apt_config_url="https://packagecloud.io/install/repositories/ookla/speedtest-cli/config_file.list?os=${os}&dist=${dist}&source=script"
+
+ apt_source_path="/etc/apt/sources.list.d/ookla_speedtest-cli.list"
+ apt_keyrings_dir="/etc/apt/keyrings"
+ if [ ! -d "$apt_keyrings_dir" ]; then
+ install -d -m 0755 "$apt_keyrings_dir"
+ fi
+ gpg_keyring_path="$apt_keyrings_dir/ookla_speedtest-cli-archive-keyring.gpg"
+ gpg_key_path_old="/etc/apt/trusted.gpg.d/ookla_speedtest-cli.gpg"
+
+ echo -n "Installing $apt_source_path..."
+
+ # create an apt config file for this repository
+ curl -sSf "${apt_config_url}" > $apt_source_path
+ curl_exit_code=$?
+
+ if [ "$curl_exit_code" = "22" ]; then
+ echo
+ echo
+ echo -n "Unable to download repo config from: "
+ echo "${apt_config_url}"
+ echo
+ echo "This usually happens if your operating system is not supported by "
+ echo "packagecloud.io, or this script's OS detection failed."
+ echo
+ echo "You can override the OS detection by setting os= and dist= prior to running this script."
+ echo "You can find a list of supported OSes and distributions on our website: https://packagecloud.io/docs#os_distro_version"
+ echo
+ echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
+ echo
+ echo "If you are running a supported OS, contact the owner of this repository/package for further support."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
+ echo "curl is unable to connect to packagecloud.io over TLS when running: "
+ echo " curl ${apt_config_url}"
+ echo "This is usually due to one of two things:"
+ echo
+ echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
+ echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
+ echo
+ echo "Please contact the owner of this repository/package with information about your system for help."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ elif [ "$curl_exit_code" -gt "0" ]; then
+ echo
+ echo "Unable to run: "
+ echo " curl ${apt_config_url}"
+ echo
+ echo "Double check your curl installation and try again."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ else
+ echo "done."
+ fi
+
+
+ echo -n "Importing packagecloud gpg key... "
+ # import the gpg key
+ curl -fsSL "${gpg_key_url}" | gpg --dearmor > ${gpg_keyring_path}
+ # grant 644 permisions to gpg keyring path
+ chmod 0644 "${gpg_keyring_path}"
+
+ # move gpg key to old path if apt version is older than 1.1
+ if [ "${apt_version_modified}" -lt 110 ]; then
+ # move to trusted.gpg.d
+
+ mv ${gpg_keyring_path} ${gpg_key_path_old}
+ # grant 644 permisions to gpg key path
+ chmod 0644 "${gpg_key_path_old}"
+
+ # deletes the keyrings directory if it is empty
+ if ! ls -1qA $apt_keyrings_dir | grep -q .;then
+ rm -r $apt_keyrings_dir
+ fi
+ echo "Packagecloud gpg key imported to ${gpg_key_path_old}"
+ else
+ echo "Packagecloud gpg key imported to ${gpg_keyring_path}"
+ fi
+ echo "done."
+
+ echo -n "Running apt-get update... "
+ # update apt on this system
+ apt-get update &> /dev/null
+ echo "done."
+
+ echo
+ echo "The repository is setup! You can now install packages."
+}
+
+main
+
+
diff --git a/sdk/build.gradle b/sdk/build.gradle
new file mode 100644
index 00000000..2cc53b51
--- /dev/null
+++ b/sdk/build.gradle
@@ -0,0 +1,182 @@
+plugins {
+ id 'java'
+ id 'com.google.protobuf' version '0.9.4'
+ id 'jacoco'
+}
+
+group = 'com.github.singnet'
+version = 'master-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+ maven { url 'https://jitpack.io' }
+}
+
+dependencies {
+ implementation 'com.google.protobuf:protobuf-java:3.21.12'
+ implementation 'io.grpc:grpc-netty-shaded:1.71.0'
+ implementation 'io.grpc:grpc-protobuf:1.71.0'
+ implementation 'io.grpc:grpc-stub:1.71.0'
+ implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
+ implementation 'javax.annotation:javax.annotation-api:1.3.2'
+ implementation 'org.projectlombok:lombok:1.18.30'
+ implementation 'org.web3j:core:5.0.0'
+ implementation 'org.web3j:codegen:5.0.0'
+ implementation 'com.github.ipfs:java-ipfs-api:1.4.4'
+ implementation 'com.github.multiformats:java-multihash:1.2.1'
+ implementation 'com.google.code.gson:gson:2.10.1'
+ implementation 'org.slf4j:slf4j-api:2.0.16'
+
+// testImplementation 'junit:junit:4.13.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.13.4'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.13.4'
+ testImplementation 'org.mockito:mockito-core:5.18.0'
+ testImplementation 'org.slf4j:slf4j-simple:2.0.16'
+ testImplementation 'org.glassfish:javax.json:1.1.4'
+ implementation 'javax.json:javax.json-api:1.1.4'
+}
+
+protobuf {
+ protoc {
+ artifact = "com.google.protobuf:protoc:3.21.12"
+ }
+ plugins {
+ grpc {
+ artifact = "io.grpc:protoc-gen-grpc-java:1.71.0"
+ }
+ }
+ generateProtoTasks {
+ all().each { task ->
+ task.plugins {
+ grpc {}
+ }
+ }
+ }
+}
+
+
+
+jacoco {
+ toolVersion = "0.8.12"
+}
+
+tasks.named('compileJava') {
+ dependsOn 'getDependencies','generateContractStubs', 'getContracts' ,'generateContractStubsMain', 'generateContractStubsMulti', 'getDaemonProto', 'generateProto'
+}
+
+tasks.named('generateProto') {
+ dependsOn 'getDaemonProto'
+}
+
+tasks.named("processResources") {
+ dependsOn(tasks.named("processTestResources"))
+}
+
+tasks.register('getDependencies') {
+ dependsOn 'generateContractStubs', 'getDaemonProto'
+}
+
+tasks.register('generateContractStubs') {
+ dependsOn 'getContracts', 'generateContractStubsMain', 'generateContractStubsMulti'
+
+}
+
+tasks.register('getContracts') {
+ def platformContractsVersion = rootProject.ext.platformContractsVersion
+ def buildDirPath = buildDir
+
+ doLast {
+ ant.get( src: "https://registry.npmjs.org/singularitynet-platform-contracts/-/singularitynet-platform-contracts-${platformContractsVersion}.tgz",
+ dest: "${buildDirPath}/singularitynet-platform-contracts.tgz")
+
+ ant.untar( src: "${buildDirPath}/singularitynet-platform-contracts.tgz",
+ dest: "${buildDirPath}",
+ compression: 'gzip')
+
+ ant.mkdir( dir: "${buildDirPath}/singularitynet-platform-contracts")
+ ant.mkdir( dir: "${buildDirPath}/singularitynet-platform-contracts/package")
+
+ ant.move( file: "${buildDirPath}/package",
+ tofile: "${buildDirPath}/singularitynet-platform-contracts")
+
+ ant.mkdir( dir: "${buildDirPath}/resources")
+
+ ant.move( file: "${buildDirPath}/singularitynet-platform-contracts/networks",
+ todir: "${buildDirPath}/resources")
+
+ ant.mkdir( dir: "${buildDirPath}/generated/sol")
+ ant.mkdir( dir: "${buildDirPath}/generated/sol/java")
+ }
+}
+
+tasks.register('generateContractStubsMain', JavaExec) {
+ dependsOn 'getContracts'
+ outputs.dir "$buildDir/generated/sol/java"
+ def buildDirPath = buildDir
+
+ classpath = configurations.runtimeClasspath
+ mainClass.set("org.web3j.codegen.SolidityFunctionWrapperGenerator")
+
+ args = [
+ "-a", "build/singularitynet-platform-contracts/abi/Registry.json",
+ "-o", "build/generated/sol/java",
+ "-p", "io.singularitynet.sdk.contracts"]
+}
+
+tasks.register('generateContractStubsMulti', JavaExec) {
+ dependsOn 'getContracts'
+ outputs.dir "$buildDir/generated/sol/java"
+ def buildDirPath = buildDir
+
+ classpath = configurations.runtimeClasspath
+ mainClass.set("org.web3j.codegen.SolidityFunctionWrapperGenerator")
+
+ args = [
+ "-a", "build/singularitynet-platform-contracts/abi/MultiPartyEscrow.json",
+ "-o", "build/generated/sol/java",
+ "-p", "io.singularitynet.sdk.contracts"]
+}
+
+tasks.register('getDaemonProto') {
+ def snetDaemonVersion = rootProject.ext.snetDaemonVersion
+ def buildDirPath = buildDir
+ doLast {
+ ant.get(src: "https://github.com/singnet/snet-daemon/releases/download/v${snetDaemonVersion}/snet-daemon-v${snetDaemonVersion}-linux-amd64.tar.gz",
+ dest: "$buildDirPath/snet-daemon.tar.gz")
+ ant.untar(src: "$buildDirPath/snet-daemon.tar.gz",
+ dest: "$buildDirPath", compression: 'gzip')
+ ant.move(file: "$buildDirPath/snet-daemon-v${snetDaemonVersion}-linux-amd64",
+ tofile: "$buildDirPath/snet-daemon")
+ ant.mkdir(dir: "$buildDirPath/proto")
+ ant.move(file: "$buildDirPath/snet-daemon/proto/state_service.proto", todir: "$buildDirPath/proto")
+ ant.move(file: "$buildDirPath/snet-daemon/proto/control_service.proto", todir: "$buildDirPath/proto")
+ }
+}
+
+sourceSets {
+ main {
+ java {
+ srcDir "$buildDir/generated/sol/java/io/singularitynet/sdk/contracts"
+ srcDir "$buildDir/generated/source/proto/main/java"
+ srcDir "$buildDir/generated/source/proto/main/grpc"
+ }
+ proto {
+ srcDir "$buildDir/proto"
+ }
+ resources {
+ srcDir "$buildDir/resources"
+ }
+ }
+ test {
+ java {
+ srcDir "$buildDir/generated/source/proto/test/java"
+ srcDir "$buildDir/generated/source/proto/test/grpc"
+ }
+ proto {
+ srcDir "$buildDir/proto"
+ }
+ resources {
+ srcDir "$buildDir/resources/test"
+ }
+ }
+}
\ No newline at end of file
diff --git a/sdk/get-dependencies.xml b/sdk/get-dependencies.xml
index 107504d4..a0ec2f2f 100644
--- a/sdk/get-dependencies.xml
+++ b/sdk/get-dependencies.xml
@@ -34,6 +34,8 @@
+
+
@@ -44,6 +46,8 @@
+
+
diff --git a/sdk/pom.xml b/sdk/pom.xml
index d74624d5..016cb606 100644
--- a/sdk/pom.xml
+++ b/sdk/pom.xml
@@ -20,86 +20,146 @@
+
+
+
+
+
+
+
com.google.protobuf
protobuf-java
+ 3.21.12
+
io.grpc
grpc-netty-shaded
+ 1.71.0
+
io.grpc
grpc-protobuf
+ 1.71.0
+
io.grpc
grpc-stub
+ 1.71.0
+
+
+ jakarta.annotation
+ jakarta.annotation-api
+ 2.1.1
+
+
javax.annotation
javax.annotation-api
+ 1.3.2
+
org.projectlombok
lombok
+ 1.18.30
provided
+
org.web3j
core
+ 5.0.0
+
org.web3j
codegen
+ 5.0.0
+ provided
+
+
+
com.github.ipfs
- java-ipfs-http-client
+ java-ipfs-api
+ 1.4.4
+
com.github.multiformats
java-multihash
+ 1.2.1
+
+
com.google.code.gson
gson
+ 2.10.1
+
org.slf4j
slf4j-api
+ 2.0.16
junit
junit
+ 4.13.2
test
+
org.mockito
mockito-core
+ 5.18.0
test
+
org.slf4j
slf4j-simple
+ 2.0.16
test
-
- javax.json
- javax.json-api
- test
-
+
+
+
+
+
+
+
+
+
+
+
+
+
org.glassfish
javax.json
+ 1.1.4
test
+
+
+ javax.json
+ javax.json-api
+ 1.1.4
+
@@ -127,7 +187,9 @@
+
+
run
@@ -199,6 +261,7 @@
org.jacoco
jacoco-maven-plugin
+ 0.8.12
diff --git a/sdk/src/main/java/io/singularitynet/sdk/client/ConfigurationDependencyFactory.java b/sdk/src/main/java/io/singularitynet/sdk/client/ConfigurationDependencyFactory.java
index 35e9ca09..be459707 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/client/ConfigurationDependencyFactory.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/client/ConfigurationDependencyFactory.java
@@ -6,7 +6,6 @@
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.exceptions.ClientConnectionException;
import org.web3j.tx.gas.StaticGasProvider;
-import org.web3j.tx.gas.DefaultGasProvider;
import org.web3j.tx.RawTransactionManager;
import org.web3j.tx.TransactionManager;
import org.slf4j.Logger;
@@ -15,15 +14,13 @@
import io.singularitynet.sdk.common.Preconditions;
import io.singularitynet.sdk.common.Utils;
-import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.contracts.MultiPartyEscrow;
+import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.ethereum.Address;
import io.singularitynet.sdk.ethereum.ContractUtils;
import io.singularitynet.sdk.ethereum.Identity;
import io.singularitynet.sdk.ethereum.MnemonicIdentity;
import io.singularitynet.sdk.ethereum.PrivateKeyIdentity;
-import io.singularitynet.sdk.contracts.Registry;
-import io.singularitynet.sdk.contracts.MultiPartyEscrow;
/**
* Bootstraps SDK dependencies from configuration.
diff --git a/sdk/src/main/java/io/singularitynet/sdk/client/DependencyFactory.java b/sdk/src/main/java/io/singularitynet/sdk/client/DependencyFactory.java
index 2de1d435..e5deb65f 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/client/DependencyFactory.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/client/DependencyFactory.java
@@ -1,10 +1,10 @@
package io.singularitynet.sdk.client;
+import io.singularitynet.sdk.contracts.Registry;
import org.web3j.protocol.Web3j;
import io.ipfs.api.IPFS;
import io.singularitynet.sdk.ethereum.Identity;
-import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.contracts.MultiPartyEscrow;
/**
diff --git a/sdk/src/main/java/io/singularitynet/sdk/client/Sdk.java b/sdk/src/main/java/io/singularitynet/sdk/client/Sdk.java
index 5c59d783..0b57744d 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/client/Sdk.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/client/Sdk.java
@@ -2,11 +2,12 @@
import io.ipfs.api.IPFS;
import java.math.BigInteger;
+
+import io.singularitynet.sdk.contracts.Registry;
import org.web3j.protocol.Web3j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.contracts.MultiPartyEscrow;
import io.singularitynet.sdk.registry.RegistryContract;
import io.singularitynet.sdk.registry.MetadataStorage;
@@ -24,11 +25,7 @@
import io.singularitynet.sdk.mpe.MpePaymentChannelManager;
import io.singularitynet.sdk.mpe.MultiPartyEscrowContract;
import io.singularitynet.sdk.mpe.PaymentChannelStateProvider;
-import io.singularitynet.sdk.mpe.PaymentChannelStateService;
import io.singularitynet.sdk.freecall.FreeCallStateService;
-import io.singularitynet.sdk.client.PaymentStrategy;
-import io.singularitynet.sdk.client.ServiceClient;
-import io.singularitynet.sdk.client.BaseServiceClient;
import io.singularitynet.sdk.ethereum.Identity;
import io.singularitynet.sdk.ethereum.Ethereum;
import io.singularitynet.sdk.ethereum.Address;
diff --git a/sdk/src/main/java/io/singularitynet/sdk/mpe/MultiPartyEscrowContract.java b/sdk/src/main/java/io/singularitynet/sdk/mpe/MultiPartyEscrowContract.java
index 32c90e07..724d66ed 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/mpe/MultiPartyEscrowContract.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/mpe/MultiPartyEscrowContract.java
@@ -1,12 +1,9 @@
package io.singularitynet.sdk.mpe;
-import io.reactivex.Flowable;
import java.math.BigInteger;
import java.util.Optional;
-import java.util.Spliterators;
-import java.util.Spliterator;
import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.web3j.abi.EventEncoder;
diff --git a/sdk/src/main/java/io/singularitynet/sdk/registry/EndpointGroup.java b/sdk/src/main/java/io/singularitynet/sdk/registry/EndpointGroup.java
index b04c0c4b..bf70bb40 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/registry/EndpointGroup.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/registry/EndpointGroup.java
@@ -1,13 +1,13 @@
package io.singularitynet.sdk.registry;
+import com.google.gson.annotations.SerializedName;
+import io.singularitynet.sdk.ethereum.Address;
import lombok.EqualsAndHashCode;
import lombok.ToString;
+
import java.net.URL;
-import java.util.List;
import java.util.ArrayList;
-import com.google.gson.annotations.SerializedName;
-
-import io.singularitynet.sdk.ethereum.Address;
+import java.util.List;
@EqualsAndHashCode
@ToString
diff --git a/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryContract.java b/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryContract.java
index f72278f7..248608e5 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryContract.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryContract.java
@@ -1,10 +1,13 @@
package io.singularitynet.sdk.registry;
import java.util.Optional;
+
+import io.singularitynet.sdk.contracts.Registry;
import org.web3j.tuples.generated.*;
import java.net.URI;
import java.util.List;
-import io.singularitynet.sdk.contracts.Registry;
+
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryMetadataProvider.java b/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryMetadataProvider.java
index 176d896c..35091e04 100644
--- a/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryMetadataProvider.java
+++ b/sdk/src/main/java/io/singularitynet/sdk/registry/RegistryMetadataProvider.java
@@ -1,14 +1,14 @@
package io.singularitynet.sdk.registry;
import com.google.gson.*;
+import io.singularitynet.sdk.common.Utils;
+import io.singularitynet.sdk.ethereum.Address;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import java.lang.reflect.Type;
-import java.util.List;
import java.net.URL;
-
-import io.singularitynet.sdk.common.Utils;
-import io.singularitynet.sdk.ethereum.Address;
+import java.util.List;
/**
* Metadata provider implementation which synchronously forwards calls to the
@@ -31,7 +31,7 @@ public class RegistryMetadataProvider implements MetadataProvider {
* @param metadataStorage metadata storage implementation.
*/
public RegistryMetadataProvider(String orgId, String serviceId,
- RegistryContract registryContract, MetadataStorage metadataStorage) {
+ RegistryContract registryContract, MetadataStorage metadataStorage) {
this.orgId = orgId;
this.serviceId = serviceId;
this.registryContract = registryContract;
diff --git a/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationDependencyFactoryTest.java b/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationDependencyFactoryTest.java
index 52ad2687..02b5138b 100644
--- a/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationDependencyFactoryTest.java
+++ b/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationDependencyFactoryTest.java
@@ -1,8 +1,8 @@
package io.singularitynet.sdk.client;
-import org.junit.*;
-import static org.junit.Assert.*;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.*;
+import org.junit.jupiter.api.Assertions;
+//import org.junit.rules.ExpectedException;
import java.net.URL;
import java.net.MalformedURLException;
diff --git a/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationUtilsTest.java b/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationUtilsTest.java
index 5816d005..4f66980f 100644
--- a/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationUtilsTest.java
+++ b/sdk/src/test/java/io/singularitynet/sdk/client/ConfigurationUtilsTest.java
@@ -1,7 +1,7 @@
package io.singularitynet.sdk.client;
-import org.junit.*;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.math.BigInteger;
import java.net.URL;
@@ -24,6 +24,7 @@ public class ConfigurationUtilsTest {
private final static String gasPrice = "1000000";
private final static String gasLimit = "2000000";
+
@Test
public void fromJsonLoadAllProperties() throws MalformedURLException {
String json = "{" +
@@ -43,7 +44,15 @@ public void fromJsonLoadAllProperties() throws MalformedURLException {
assertEquals("IPFS endpoint", new URL(ipfsEndpoint), config.getIpfsEndpoint());
assertEquals("Identity type", Enum.valueOf(Configuration.IdentityType.class, identityType), config.getIdentityType());
assertArrayEquals("Identity private key", Utils.hexToBytes(privateKey), config.getIdentityPrivateKey().get());
- assertEquals("Registry address", new Address(registryAddress), config.getRegistryAddress().get());
+ Address address = new Address(registryAddress);
+ System.out.println("address" + address.toString());
+ Address addressOpt = config.getRegistryAddress().get();
+ System.out.println("address" + addressOpt.toString());
+
+ assertEquals("Registry address", address, addressOpt);
+
+// assertEquals("Registry address", new Address(registryAddress), config.getRegistryAddress().get());
+
assertEquals("MultiPartyEscrow address", new Address(mpeAddress), config.getMultiPartyEscrowAddress().get());
assertEquals("Gas price", new BigInteger(gasPrice), config.getGasPrice());
assertEquals("Gas limit", new BigInteger(gasLimit), config.getGasLimit());
diff --git a/sdk/src/test/java/io/singularitynet/sdk/integration/Web3jTestIT.java b/sdk/src/test/java/io/singularitynet/sdk/integration/Web3jTestIT.java
index 12dd6a19..22c177df 100644
--- a/sdk/src/test/java/io/singularitynet/sdk/integration/Web3jTestIT.java
+++ b/sdk/src/test/java/io/singularitynet/sdk/integration/Web3jTestIT.java
@@ -3,19 +3,17 @@
import org.junit.*;
import static org.junit.Assert.*;
-import io.reactivex.Flowable;
import java.math.BigInteger;
import java.util.List;
import java.util.stream.Collectors;
import org.web3j.tx.ReadonlyTransactionManager;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
-import org.web3j.tx.gas.ContractGasProvider;
import org.web3j.tx.gas.DefaultGasProvider;
import org.web3j.tuples.generated.*;
-import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.contracts.MultiPartyEscrow;
+import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.common.Utils;
import io.singularitynet.sdk.mpe.MultiPartyEscrowContract;
import io.singularitynet.sdk.mpe.PaymentChannel;
diff --git a/sdk/src/test/java/io/singularitynet/sdk/mpe/MultiPartyEscrowMock.java b/sdk/src/test/java/io/singularitynet/sdk/mpe/MultiPartyEscrowMock.java
index 3abca956..307198b9 100644
--- a/sdk/src/test/java/io/singularitynet/sdk/mpe/MultiPartyEscrowMock.java
+++ b/sdk/src/test/java/io/singularitynet/sdk/mpe/MultiPartyEscrowMock.java
@@ -1,12 +1,13 @@
package io.singularitynet.sdk.mpe;
import java.math.BigInteger;
+
import org.web3j.protocol.core.*;
import org.web3j.tuples.generated.*;
import io.singularitynet.sdk.contracts.MultiPartyEscrow;
+
import static org.mockito.Mockito.*;
-import static io.singularitynet.sdk.common.Utils.*;
import io.singularitynet.sdk.ethereum.Address;
public class MultiPartyEscrowMock {
@@ -18,16 +19,36 @@ public MultiPartyEscrow get() {
}
public void addPaymentChannel(PaymentChannel paymentChannel) {
+ RemoteFunctionCall> remoteCall =
+ mock(RemoteFunctionCall.class);
+ try {
+ when(remoteCall.send()).thenReturn(new Tuple7<>(paymentChannel.getNonce(),
+ paymentChannel.getSender().toString(),
+ paymentChannel.getSigner().toString(),
+ paymentChannel.getRecipient().toString(),
+ paymentChannel.getPaymentGroupId().getBytes(),
+ paymentChannel.getValue(),
+ paymentChannel.getExpiration()));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
when(mpe.channels(eq(paymentChannel.getChannelId()))).
- thenReturn(new RemoteCall<>(() -> {
- return new Tuple7<>(paymentChannel.getNonce(),
- paymentChannel.getSender().toString(),
- paymentChannel.getSigner().toString(),
- paymentChannel.getRecipient().toString(),
- paymentChannel.getPaymentGroupId().getBytes(),
- paymentChannel.getValue(),
- paymentChannel.getExpiration());
- }));
+ thenReturn(remoteCall);
+
+// try {
+// when(remoteCall.send()).thenReturn(new Tuple6<>(
+// true,
+// Utils.strToBytes32(registration.getOrgId()),
+// Utils.strToBytes(registration.getMetadataUri().toString()),
+// "0xfA8a01E837c30a3DA3Ea862e6dB5C6232C9b800A",
+// Collections.EMPTY_LIST,
+// registration.getServiceIds().stream().map(Utils::strToBytes32).collect(toList())
+// ));
+// } catch (Exception e) {
+// throw new RuntimeException(e);
+// }
+// when(registry.getOrganizationById(eq(Utils.strToBytes32(orgId))))
+// .thenReturn(remoteCall);
}
public void setContractAddress(Address address) {
diff --git a/sdk/src/test/java/io/singularitynet/sdk/registry/RegistryMock.java b/sdk/src/test/java/io/singularitynet/sdk/registry/RegistryMock.java
index 3c304e83..6295a90d 100644
--- a/sdk/src/test/java/io/singularitynet/sdk/registry/RegistryMock.java
+++ b/sdk/src/test/java/io/singularitynet/sdk/registry/RegistryMock.java
@@ -2,10 +2,12 @@
import org.web3j.protocol.core.*;
import org.web3j.tuples.generated.*;
-import io.singularitynet.sdk.contracts.Registry;
+
import static org.mockito.Mockito.*;
import static java.util.stream.Collectors.toList;
import java.util.Collections;
+import java.util.List;
+import io.singularitynet.sdk.contracts.Registry;
import io.singularitynet.sdk.common.Utils;
@@ -19,32 +21,41 @@ public Registry get() {
public void addServiceRegistration(String orgId, String serviceId,
ServiceRegistration registration) {
+ RemoteFunctionCall> remoteCall = mock(RemoteFunctionCall.class);
+ try {
+ when(remoteCall.send()).thenReturn(new Tuple3<>(
+ true,
+ Utils.strToBytes32(registration.getServiceId()),
+ Utils.strToBytes(registration.getMetadataUri().toString())
+ ));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
when(registry.getServiceRegistrationById(eq(Utils.strToBytes32(orgId)),
- eq(Utils.strToBytes32(serviceId))))
- .thenReturn(new RemoteCall<>(
- () -> {
- return new Tuple3<>(true,
- Utils.strToBytes32(registration.getServiceId()),
- Utils.strToBytes(registration.getMetadataUri().toString())
- );
- })
- );
+ eq(Utils.strToBytes32(serviceId))))
+ .thenReturn(remoteCall);
+
}
public void addOrganizationRegistration(String orgId,
OrganizationRegistration registration) {
+ RemoteFunctionCall, List>> remoteCall =
+ mock(RemoteFunctionCall.class);
+ try {
+ when(remoteCall.send()).thenReturn(new Tuple6<>(
+ true,
+ Utils.strToBytes32(registration.getOrgId()),
+ Utils.strToBytes(registration.getMetadataUri().toString()),
+ "0xfA8a01E837c30a3DA3Ea862e6dB5C6232C9b800A",
+ Collections.EMPTY_LIST,
+ registration.getServiceIds().stream().map(Utils::strToBytes32).collect(toList())
+ ));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
when(registry.getOrganizationById(eq(Utils.strToBytes32(orgId))))
- .thenReturn(new RemoteCall<>(
- () -> {
- return new Tuple6<>(true,
- Utils.strToBytes32(registration.getOrgId()),
- Utils.strToBytes(registration.getMetadataUri().toString()),
- "0xfA8a01E837c30a3DA3Ea862e6dB5C6232C9b800A",
- Collections.EMPTY_LIST,
- registration.getServiceIds().stream().map(Utils::strToBytes32).collect(toList())
- );
- })
- );
+ .thenReturn(remoteCall);
}
}
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 00000000..2a5ee94f
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,17 @@
+rootProject.name = 'snet-sdk-java-pom'
+
+include(
+ "snet-sdk-maven-plugin",
+ "snet-sdk-plugin-core",
+ "snet-sdk-gradle-plugin",
+ "snet-sdk-java",
+ "snet-sdk-plugin-pom"
+)
+
+project(":snet-sdk-maven-plugin").projectDir = file("plugin/maven")
+project(":snet-sdk-plugin-core").projectDir = file("plugin/core")
+project(":snet-sdk-gradle-plugin").projectDir = file("plugin/gradle")
+project(":snet-sdk-java").projectDir = file("sdk")
+project(":snet-sdk-plugin-pom").projectDir = file("plugin")
+
+