Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Build

on:
push

jobs:
build:

runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Build with Gradle
run: gradle build
35 changes: 35 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

## TODO it should be bound to releases
on:
workflow_dispatch

jobs:
publish:

runs-on: ubuntu-20.04
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

- name: Build with Gradle
run: gradle build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: gradle publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'io.freefair.lombok' version '6.1.0' apply false
id 'maven-publish'
}

allprojects {
Expand All @@ -15,6 +16,7 @@ allprojects {
subprojects {
apply plugin: 'java'
apply plugin: 'io.freefair.lombok'
apply plugin: 'maven-publish'

targetCompatibility = '1.8'
sourceCompatibility = '1.8'
Expand All @@ -34,4 +36,23 @@ subprojects {
test {
useJUnitPlatform()
}

publishing {
publications {
gpr(MavenPublication) {
from(components.java)
}
}

repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/strategyobject/substrate-client-java"
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
}
}
}
}
9 changes: 5 additions & 4 deletions crypto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ task compileRust {
workingDir 'src/jni-crypto'
commandLine 'cargo', 'build', '--release', '--target=x86_64-unknown-linux-gnu', '--target-dir=../../build/jni-crypto'
}
exec {
workingDir 'src/jni-crypto'
commandLine 'cargo', 'build', '--release', '--target=x86_64-pc-windows-gnu', '--target-dir=../../build/jni-crypto'
}
// TODO the build of the native library will be moved out of the project
// exec {
// workingDir 'src/jni-crypto'
// commandLine 'cargo', 'build', '--release', '--target=x86_64-pc-windows-gnu', '--target-dir=../../build/jni-crypto'
// }
}
}

Expand Down
6 changes: 3 additions & 3 deletions rpc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
implementation project(':transport')
implementation project(':rpc:sections')
implementation project(':rpc:core')
implementation project(':rpc:codegen')
implementation project(':rpc:rpc-sections')
implementation project(':rpc:rpc-core')
implementation project(':rpc:rpc-codegen')
}
6 changes: 3 additions & 3 deletions rpc/codegen/build.gradle → rpc/rpc-codegen/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies {
implementation project(':common')
implementation project(':rpc:core')
implementation project(':rpc:rpc-core')
implementation project(':scale')
implementation project(':scale:scale-codegen')
implementation project(':transport')
Expand All @@ -12,7 +12,7 @@ dependencies {
testImplementation 'com.google.testing.compile:compile-testing:0.19'
testImplementation 'com.google.code.gson:gson:2.8.8'

testCompileOnly project(':rpc:codegen')
testAnnotationProcessor project(':rpc:codegen')
testCompileOnly project(':rpc:rpc-codegen')
testAnnotationProcessor project(':rpc:rpc-codegen')
testAnnotationProcessor project(':scale:scale-codegen')
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public class DecoderPair<T> {

public RpcDecoder<T> getDecoderOrThrow() {
if (decoder == null) {
throw new NullPointerException();
throw new NullPointerException("RpcDecoder is null.");
}

return decoder;
}

public ScaleReader<T> getScaleReaderOrThrow() {
if (scaleReader == null) {
throw new NullPointerException();
throw new NullPointerException("ScaleReader is null.");
}

return scaleReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public class EncoderPair<T> {

public RpcEncoder<T> getEncoderOrThrow() {
if (encoder == null) {
throw new NullPointerException();
throw new NullPointerException("RpcEncoder is null.");
}

return encoder;
}

public ScaleWriter<T> getScaleWriterOrThrow() {
if (scaleWriter == null) {
throw new NullPointerException();
throw new NullPointerException("ScaleWriter is null.");
}

return scaleWriter;
Expand Down
10 changes: 5 additions & 5 deletions rpc/sections/build.gradle → rpc/rpc-sections/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
dependencies {
compileOnly project(':rpc:codegen')
annotationProcessor project(':rpc:codegen')
compileOnly project(':rpc:core')
compileOnly project(':rpc:rpc-codegen')
annotationProcessor project(':rpc:rpc-codegen')
compileOnly project(':rpc:rpc-core')
compileOnly project(':transport')
implementation project(':types')
implementation project(':rpc:rpc-types')
implementation project(':scale')

testImplementation project(':rpc:codegen')
testImplementation project(':rpc:rpc-codegen')
testImplementation project(':tests')
testCompileOnly project(':rpc:core')
testCompileOnly project(':rpc:rpc-core')
testCompileOnly project(':common')
testCompileOnly project(':transport')
testImplementation project(':crypto')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ void accountNextIndex() throws ExecutionException, InterruptedException, Timeout
RpcEncoderRegistry encoderRegistry = mock(RpcEncoderRegistry.class);
when(encoderRegistry.resolve(AccountId.class))
.thenReturn((source, encoders) -> "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY");
mockStatic(RpcEncoderRegistry.class)
.when(RpcEncoderRegistry::getInstance)
.thenReturn(encoderRegistry);


val result = rpcSection.accountNextIndex(AccountId.fromBytes(
new byte[]{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
})).get(WAIT_TIMEOUT, TimeUnit.SECONDS);

assertEquals(0, result);
try (val utils = mockStatic(RpcEncoderRegistry.class)) {
utils.when(RpcEncoderRegistry::getInstance)
.thenReturn(encoderRegistry);
val result = rpcSection.accountNextIndex(AccountId.fromBytes(
new byte[]{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32
})).get(WAIT_TIMEOUT, TimeUnit.SECONDS);

assertEquals(0, result);
}
}
}
}
4 changes: 2 additions & 2 deletions rpc/rpc-types/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dependencies {
implementation project(':types')
implementation project(':scale')
implementation project(':rpc:core')
implementation project(':rpc:rpc-core')
implementation project(':common')
annotationProcessor project(':rpc:codegen')
annotationProcessor project(':rpc:rpc-codegen')
annotationProcessor project(':scale:scale-codegen')
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.strategyobject.substrateclient.rpc;

import com.strategyobject.substrateclient.rpc.sections.Author;
import com.strategyobject.substrateclient.rpc.sections.Chain;
import com.strategyobject.substrateclient.rpc.sections.State;

public interface Rpc {
Author getAuthor();

Chain getChain();

State getState();

System getSystem();
}
6 changes: 3 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ include 'api'
include 'common'
include 'crypto'
include 'rpc'
include 'rpc:codegen'
include 'rpc:core'
include 'rpc:rpc-codegen'
include 'rpc:rpc-core'
include 'rpc:rpc-types'
include 'rpc:sections'
include 'rpc:rpc-sections'
include 'types'
include 'scale'
include 'scale:scale-codegen'
Expand Down
2 changes: 1 addition & 1 deletion transport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ dependencies {
testImplementation 'org.testcontainers:junit-jupiter:1.16.0'
testImplementation "org.testcontainers:toxiproxy:1.16.0"
testImplementation 'org.awaitility:awaitility:4.1.0'
}
}