Skip to content

Commit

Permalink
Merge pull request #3 from kryptokrauts/dev
Browse files Browse the repository at this point in the history
publish release v1.0.1
  • Loading branch information
mitch-lbw authored Feb 13, 2019
2 parents 213440e + 0a0b2f5 commit 5a2a329
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 76 deletions.
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,10 @@ A community developed Java SDK to interact with the Æternity blockchain.
- get latest release [libsodium](https://download.libsodium.org/libsodium/releases/)
- download the latest pre-built binary (e.g. `libsodium-1.0.16-msvc.zip`)
- extract `libsodium.dll` to `C:\Windows\System32`
- bouncycastle version 161b20 (beta and currently not available in a public maven repository)
- copy `bcprov-jdk15on-161b20.jar` into your projects `lib` folder
- Maven
```xml
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>161b20</version>
<scope>system</scope>
<systemPath>${basedir}/lib/bcprov-jdk15on-161b20.jar</systemPath>
</dependency>
```
- Gradle
```xml
compile fileTree(include: ["*.jar"], dir: "lib")
```

## Latest stable release

- [v1.0.0](https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v1.0.0)
- [v1.0.1](https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v1.0.1)

### Download

Expand All @@ -56,7 +40,7 @@ A community developed Java SDK to interact with the Æternity blockchain.
<dependency>
<groupId>com.kryptokrauts</groupId>
<artifactId>aepp-sdk-java</artifactId>
<version>X.X.X</version>
<version>1.0.1</version>
</dependency>
...
```
Expand All @@ -68,7 +52,7 @@ repositories {
jcenter()
}
compile "com.kryptokrauts:aepp-sdk-java:X.X.X"
compile "com.kryptokrauts:aepp-sdk-java:1.0.1"
```

### Snapshots
Expand All @@ -94,7 +78,7 @@ Here's the [list of snapshot versions](https://oss.jfrog.org/webapp/#/artifacts/
<dependency>
<groupId>com.kryptokrauts</groupId>
<artifactId>aepp-sdk-java</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
...
Expand All @@ -106,7 +90,7 @@ repositories {
maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
}
compile "com.kryptokrauts:aepp-sdk-java:1.0.1-SNAPSHOT"
compile "com.kryptokrauts:aepp-sdk-java:1.0.2-SNAPSHOT"
```

## Documentation
Expand All @@ -121,6 +105,7 @@ new TransactionServiceFactory().getService( TransactionServiceConfiguration.conf

## Release notes

- [v1.0.1](docs/release-notes/RELEASE-NOTES-1.0.1.md)
- [v1.0.0](docs/release-notes/RELEASE-NOTES-1.0.0.md)

## License
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ext {

lombokVersion = "1.18.4"

bouncycastleVersion = ""
bouncycastleVersion = "1.61"
bitcoinjCoreVersion = "0.14.7"
cavaVersion = "0.6.0"

Expand Down Expand Up @@ -87,8 +87,6 @@ configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
sharedCompile
// exclude transitive bcprov dep because we need the current one (see lib folder)
compile.exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
}

sourceSets {
Expand Down Expand Up @@ -146,7 +144,7 @@ dependencies {

// cryptography
compile "org.bitcoinj:bitcoinj-core:${bitcoinjCoreVersion}"
compile fileTree(include: ["*.jar"], dir: "lib")
compile "org.bouncycastle:bcprov-jdk15on:${bouncycastleVersion}"
compile "net.consensys.cava:cava-crypto:${cavaVersion}"
compile "net.consensys.cava:cava-rlp:${cavaVersion}"
compile "de.mkammerer:argon2-jvm:2.5"
Expand Down
23 changes: 23 additions & 0 deletions docs/release-notes/RELEASE-NOTES-1.0.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Release notes ([v1.0.1](https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v1.0.1))

## Changes

- return Single instead of Observable for responses that return only one object
- switch from bouncycastle 1.61-beta to the release version (no more need to manually add it)

## Contributors

Everybody is welcome to contribute to this project. Following people contributed to this release:

- [Marco Walz](https://github.com/marc0olo)
- [Michel Meier](https://github.com/mitch-lbw)

## Support us

If you like this project we would appreciate your support.

- [ak_5z1fmzTKR1GA1P7qiLDCC1s3V7AK2RRpNbXqUhfHQbUeg7mmV](https://explorer.aepps.com/#/account/ak_5z1fmzTKR1GA1P7qiLDCC1s3V7AK2RRpNbXqUhfHQbUeg7mmV)

![ak_5z1fmzTKR1GA1P7qiLDCC1s3V7AK2RRpNbXqUhfHQbUeg7mmV](../../donations.png)

(QR-code generated with https://cwaqrgen.com/aeternity)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
organization=kryptokrauts
group=com.kryptokrauts
name=aepp-sdk-java
version=1.0.0-SNAPSHOT
version=1.0.1-SNAPSHOT
Binary file removed lib/bcprov-jdk15on-161b20.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
package com.kryptokrauts.aeternity.generated.api;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;

import com.kryptokrauts.aeternity.generated.model.KeyBlock;
import com.kryptokrauts.aeternity.sdk.service.chain.ChainServiceFactory;

import io.reactivex.Observable;
import io.reactivex.Single;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;

public class ChainApiTest extends BaseTest {

@Test
public void getCurrentKeyBlockTest( TestContext context ) {
Async async = context.async();
Observable<KeyBlock> keyBlockObservable = chainService.getCurrentKeyBlock();
Single<KeyBlock> keyBlockObservable = chainService.getCurrentKeyBlock();
keyBlockObservable.subscribe( keyBlock -> {
System.out.println( keyBlock.toString() );
Assertions.assertTrue( keyBlock.getHeight().longValue() > 0 );
async.complete();
}, failure -> {
failure.printStackTrace();
}, throwable -> {
throwable.printStackTrace();
context.fail();
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.kryptokrauts.aeternity.generated.model.UnsignedTx;
import com.kryptokrauts.aeternity.sdk.constants.BaseConstants;
import com.kryptokrauts.aeternity.sdk.domain.secret.impl.BaseKeyPair;
import io.reactivex.Observable;
import io.reactivex.Single;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import org.bouncycastle.crypto.CryptoException;
Expand All @@ -32,11 +32,11 @@ public void buildNativeTransactionTest( TestContext context ) throws ExecutionEx

UnsignedTx unsignedTxNative = transactionServiceNative.createSpendTx( sender, recipient, amount, payload, fee, ttl, nonce ).toFuture().get();

Observable<UnsignedTx> unsignedTxObservable = transactionServiceDebug.createSpendTx( sender, recipient, amount, payload, fee, ttl, nonce );
unsignedTxObservable.subscribe( it -> {
Single<UnsignedTx> unsignedTx = transactionServiceDebug.createSpendTx( sender, recipient, amount, payload, fee, ttl, nonce );
unsignedTx.subscribe( it -> {
Assertions.assertEquals( it, unsignedTxNative );
async.complete();
}, failure -> {
}, throwable -> {
context.fail();
} );
}
Expand All @@ -49,7 +49,7 @@ public void postSpendTxTest( TestContext context ) throws ExecutionException, In

// get the currents accounts nonce in case a transaction is already
// created and increase it by one
Observable<Account> acc = accountService.getAccount( keyPair.getPublicKey() );
Single<Account> acc = accountService.getAccount( keyPair.getPublicKey() );
acc.subscribe( account -> {
BaseKeyPair kp = keyPairService.generateBaseKeyPair();
String recipient = kp.getPublicKey();
Expand All @@ -60,13 +60,15 @@ public void postSpendTxTest( TestContext context ) throws ExecutionException, In
BigInteger nonce = account.getNonce().add( BigInteger.ONE );
UnsignedTx unsignedTxNative = transactionServiceNative.createSpendTx( keyPair.getPublicKey(), recipient, amount, payload, fee, ttl, nonce ).toFuture().get();
Tx signedTx = transactionServiceNative.signTransaction( unsignedTxNative, keyPair.getPrivateKey() );
Observable<PostTxResponse> txResponseObservable = transactionServiceNative.postTransaction( signedTx );
txResponseObservable.subscribe( it -> {
Single<PostTxResponse> txResponse = transactionServiceNative.postTransaction( signedTx );
txResponse.subscribe( it -> {
Assertions.assertEquals( it.getTxHash(), transactionServiceNative.computeTxHash( signedTx.getTx() ) );
async.complete();
}, failure -> {
}, throwable -> {
context.fail();
} );
} );
}, throwable -> {
context.fail();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import com.kryptokrauts.aeternity.generated.model.Account;
import com.kryptokrauts.aeternity.sdk.util.EncodingType;
import com.kryptokrauts.aeternity.sdk.util.EncodingUtils;

import io.reactivex.Observable;
import io.reactivex.Single;

public interface AccountService {

Expand All @@ -13,8 +12,8 @@ public interface AccountService {
* {@link EncodingUtils}
*
* @param publicKey
* @return the account wrapped in an observable
* @return the account wrapped in a single
*/
Observable<Account> getAccount( String publicKey );
Single<Account> getAccount(String publicKey );

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.kryptokrauts.aeternity.sdk.service.account.impl;

import javax.annotation.Nonnull;

import com.kryptokrauts.aeternity.generated.api.AccountApiImpl;
import com.kryptokrauts.aeternity.generated.api.rxjava.AccountApi;
import com.kryptokrauts.aeternity.generated.model.Account;
import com.kryptokrauts.aeternity.sdk.service.ServiceConfiguration;
import com.kryptokrauts.aeternity.sdk.service.account.AccountService;

import io.reactivex.Observable;
import io.reactivex.Single;
import lombok.RequiredArgsConstructor;

import javax.annotation.Nonnull;

@RequiredArgsConstructor
public final class AccountServiceImpl implements AccountService {

Expand All @@ -27,8 +26,8 @@ private AccountApi getAccountApi() {
}

@Override
public Observable<Account> getAccount( final String base58PublicKey ) {
return getAccountApi().rxGetAccountByPubkey( base58PublicKey ).toObservable();
public Single<Account> getAccount(final String base58PublicKey ) {
return getAccountApi().rxGetAccountByPubkey( base58PublicKey );
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.kryptokrauts.aeternity.sdk.service.chain;

import com.kryptokrauts.aeternity.generated.model.KeyBlock;

import io.reactivex.Observable;
import io.reactivex.Single;

public interface ChainService {

public Observable<KeyBlock> getCurrentKeyBlock();
Single<KeyBlock> getCurrentKeyBlock();

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.kryptokrauts.aeternity.sdk.service.chain.impl;

import javax.annotation.Nonnull;

import com.kryptokrauts.aeternity.generated.api.ChainApiImpl;
import com.kryptokrauts.aeternity.generated.api.rxjava.ChainApi;
import com.kryptokrauts.aeternity.generated.model.KeyBlock;
import com.kryptokrauts.aeternity.sdk.service.ServiceConfiguration;
import com.kryptokrauts.aeternity.sdk.service.chain.ChainService;

import io.reactivex.Observable;
import io.reactivex.Single;
import lombok.RequiredArgsConstructor;

import javax.annotation.Nonnull;

@RequiredArgsConstructor
public class ChainServiceImpl implements ChainService {
@Nonnull
Expand All @@ -26,7 +25,7 @@ private ChainApi getChainApi() {
}

@Override
public Observable<KeyBlock> getCurrentKeyBlock() {
return getChainApi().rxGetCurrentKeyBlock().toObservable();
public Single<KeyBlock> getCurrentKeyBlock() {
return getChainApi().rxGetCurrentKeyBlock();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import com.kryptokrauts.aeternity.generated.model.PostTxResponse;
import com.kryptokrauts.aeternity.generated.model.Tx;
import com.kryptokrauts.aeternity.generated.model.UnsignedTx;
import io.reactivex.Observable;
import io.reactivex.Single;
import org.bouncycastle.crypto.CryptoException;

import java.math.BigInteger;

public interface TransactionService {

Observable<UnsignedTx> createSpendTx( String sender, String recipient, BigInteger amount, String payload, BigInteger fee, BigInteger ttl, BigInteger nonce );
Single<UnsignedTx> createSpendTx(String sender, String recipient, BigInteger amount, String payload, BigInteger fee, BigInteger ttl, BigInteger nonce );

Observable<PostTxResponse> postTransaction( Tx tx );
Single<PostTxResponse> postTransaction( Tx tx );

Observable<GenericSignedTx> getTransactionByHash( String txHash );
Single<GenericSignedTx> getTransactionByHash( String txHash );

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.kryptokrauts.aeternity.sdk.util.ByteUtils;
import com.kryptokrauts.aeternity.sdk.util.EncodingUtils;
import com.kryptokrauts.aeternity.sdk.util.SigningUtil;
import io.reactivex.Observable;
import io.reactivex.Single;
import lombok.RequiredArgsConstructor;
import net.consensys.cava.bytes.Bytes;
import net.consensys.cava.rlp.RLP;
Expand All @@ -36,7 +36,7 @@ private TransactionApi getTransactionApi() {
}

@Override
public Observable<UnsignedTx> createSpendTx( String sender, String recipient, BigInteger amount, String payload, BigInteger fee, BigInteger ttl, BigInteger nonce ) {
public Single<UnsignedTx> createSpendTx( String sender, String recipient, BigInteger amount, String payload, BigInteger fee, BigInteger ttl, BigInteger nonce ) {
SpendTx spendTx = new SpendTx();
spendTx.setSenderId( sender );
spendTx.setRecipientId( recipient );
Expand All @@ -45,17 +45,17 @@ public Observable<UnsignedTx> createSpendTx( String sender, String recipient, Bi
spendTx.setFee( fee );
spendTx.setTtl( ttl );
spendTx.setNonce( nonce );
return config.isNativeMode() ? Observable.just( spendTxNative( spendTx ) ) : spendTxInternal( spendTx );
return config.isNativeMode() ? Single.just( spendTxNative( spendTx ) ) : spendTxInternal( spendTx );
}

@Override
public Observable<PostTxResponse> postTransaction( Tx tx ) {
return getTransactionApi().rxPostTransaction( tx ).toObservable();
public Single<PostTxResponse> postTransaction(Tx tx ) {
return getTransactionApi().rxPostTransaction( tx );
}

@Override
public Observable<GenericSignedTx> getTransactionByHash( String txHash ) {
return getTransactionApi().rxGetTransactionByHash( txHash ).toObservable();
public Single<GenericSignedTx> getTransactionByHash( String txHash ) {
return getTransactionApi().rxGetTransactionByHash( txHash );
}

@Override
Expand All @@ -79,8 +79,8 @@ public Tx signTransaction( final UnsignedTx unsignedTx, final String privateKey
/**
* for validate native tx generation
*/
private Observable<UnsignedTx> spendTxInternal( SpendTx spendTx ) {
return getTransactionApi().rxPostSpend( spendTx ).toObservable();
private Single<UnsignedTx> spendTxInternal( SpendTx spendTx ) {
return getTransactionApi().rxPostSpend( spendTx );
}

private UnsignedTx spendTxNative( SpendTx spendTx ) {
Expand Down

0 comments on commit 5a2a329

Please sign in to comment.