This github project represents the RxIrohaAndroid development stream. The earlier project page (hyperledger repository) represents the earlier iroha-android development stream. This versions have benefitted from strong involvement from individual for @kobaken0029.
iroha-android is currently in active development, primarily internally at hyperledger project, with regular pushes to the open-source community.
いろは(iroha) is this.
いろはAndroid(RxIrohaAndroid) is client library for using いろは(iroha) for Android.
- Android Studio >=2.2.1
- Android API Level >=v19 (v4.4, KitKat)
- Android Build Tools >=v25
In your app/build.gradle
compile 'click.kobaken:rx-iroha-android:0.3.3'
Or if you use Maven, like this
<dependency>
<groupId>click.kobaken</groupId>
<artifactId>rx-iroha-android</artifactId>
<version>0.3.3</version>
<type>pom</type>
</dependency>
String hashedMessage = MessageDigest.digest("message", MessageDigest.SHA3_256);
// ===> hashed message by SHA3_256
In your app on 'onCreate' your class inheriting Application
import click.kobaken.rxirohaandroid.Iroha;
new Iroha.Builder()
.baseUrl("https://[input your domain(base url)]")
.client(IrohaHttpClient.getInstance().get())
.build();
import io.soramitsu.irohaandroid.Iroha;
import io.soramitsu.irohaandroid.model.KeyPair;
KeyPair keypair = Iroha.createKeyPair();
keypair.publicKey; // Ed25519 public key encoded by base64
keypair.privateKey; // Ed25519 private key encoded by base64
import io.soramitsu.irohaandroid.Iroha;
import io.soramitsu.irohaandroid.model.KeyPair;
String signature = Iroha.sign(keyPair, "message")
//===> signature // String
import io.soramitsu.irohaandroid.Iroha;
import io.soramitsu.irohaandroid.model.KeyPair;
boolean verify = Iroha.verify(keyPair.publicKey, signature, "message")
//===> true if the correct message
Iroha.getInstance().registerAccount("publicKey", "alias");
// ===> return Observable<Account> for register account
Iroha.getInstance().findAccount("uuid");
// ===> return Observable<Account> for find account
Iroha.getInstance().registerDomain("name", "owner", "signature");
// ===> return Observable<Doamin> for register domain
Iroha.getInstance().findDomains(/* limit */30, /* offset */0);
// ===> return Observable<List<Domain>> for find domains
Iroha.getInstance().createAsset("name", "owner", "creator", "signature");
// ===> return Observable<Asset> for create asset
Iroha.getInstance().findAssets("domain", /* limit */30, /* offset */0);
// ===> return Observable<List<Asset>> for find assets
Iroha.getInstance().operationAsset(
"asset-uuid",
"command",
"amount",
"sender",
"receiver",
"signature",
/* timestamp */100000
);
// ===> return Observable<BaseModel> for operation
// Single asset
Iroha.getInstance().findTransactionHistory("uuid", /* limit */30, /* offset */0);
// ===> return Observable<TraqnsactionHistory> for find transaction history
// Multi assets
Iroha.getInstance().findTransactionHistory("domain", "asset-uuid", "uuid", /* limit */30, /* offset */0);
// ===> return Observable<TransactionHistory> for find transaction history
You can use like RxJava2.
ex.) registerAccount
Iroha.getInstance().registerAccount(keyPair.publicKey, alias)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribeWith(new DisposableObserver<Account>() {
@Override
public void onNext(Account result) {
// successful!
}
@Override
public void onError(Throwable e) {
// error!
}
@Override
public void onComplete() {
// complete!
}
});
);
ex.) findAccount and findTransactionHistory
Observable.zip(iroha.findAccount(uuid), iroha.findTransactionHistory(uuid, 30, 0),
new BiFunction<Account, TransactionHistory, Tx>() {
@Override
public Tx apply(Account account,TransactionHistory transactionHistory) throws Exception {
Tx history = new Tx();
if (account != null && account.assets != null && !account.assets.isEmpty()) {
history.value = account.assets.get(0).value;
}
history.histories = transactionHistory.history;
return history;
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribeWith(new DisposableObserver<Tx>() {
@Override
public void onNext(Tx result) {
// successful!
}
@Override
public void onError(Throwable e) {
// error!
}
@Override
public void onComplete() {
// complete!
}
});
Copyright(c) 2016 kobaken0029
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
http://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.