Skip to content

Commit

Permalink
Update to Iroha 1.1.0 (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Chernyshov <[email protected]>
  • Loading branch information
Alexey-N-Chernyshov authored and Warchant committed Jul 29, 2019
1 parent 4d65459 commit 4b4be14
Show file tree
Hide file tree
Showing 17 changed files with 512 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
1. Fork this repo
2. Select iroha version for dev:
```bash
export IROHA_VERSION=v1.0.0_rc2
export IROHA_VERSION=v1.1.0
git checkout ${IROHA_VERSION}
```
2. Create feature branch:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import lombok.NonNull;
import lombok.val;


/**
* Stateless validator for transaction and query fields.
*/
Expand Down Expand Up @@ -108,7 +107,6 @@ public void checkQuorum(int quorum) {
}
}


public void checkAssetId(@NonNull String assetId) {
val t = assetId.split(assetIdDelimiter);
if (t.length != 2) {
Expand All @@ -131,7 +129,6 @@ public void checkAssetId(@NonNull String assetId) {
}
}


public void checkAccountDetailsKey(@NonNull String key) {
val m = accountDetailsKeyPattern.matcher(key);
if (!m.matches()) {
Expand All @@ -144,7 +141,6 @@ public void checkAccountDetailsKey(@NonNull String key) {
}
}


public void checkAccountDetailsValue(@NonNull String value) {
if (!(value.length() <= accountDetailsMaxLength)) {
throw new ValidationException(DETAILS_VALUE,
Expand Down
116 changes: 114 additions & 2 deletions client/src/main/java/jp/co/soramitsu/iroha/java/QueryAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import iroha.protocol.QryResponses.AssetResponse;
import iroha.protocol.QryResponses.BlockResponse;
import iroha.protocol.QryResponses.ErrorResponse;
import iroha.protocol.QryResponses.PeersResponse;
import iroha.protocol.QryResponses.QueryResponse;
import iroha.protocol.QryResponses.SignatoriesResponse;
import iroha.protocol.QryResponses.TransactionsPageResponse;
Expand Down Expand Up @@ -49,6 +50,24 @@ private void checkErrorResponse(QueryResponse response) {
}
}

public PeersResponse getPeers() {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getPeers()
.buildSigned(keyPair);

val res = api.query(q);

checkErrorResponse(res);

return res.getPeersResponse();
}

/**
* Pagination metadata can be missing in the request for compatibility reasons, but this behaviour
* is deprecated and should be avoided. This function is deprecated in Iroha 1.1.0 and will be
* deleted in Iroha 2.0.0
*/
@Deprecated
public String getAccountDetails(
String accountId,
String writer,
Expand All @@ -67,6 +86,43 @@ public String getAccountDetails(
return adr.getDetail();
}

public String getAccountDetails(
String accountId,
String writer,
String key,
Integer pageSize,
String accountDetailRecordIdWriter,
String accountDetailRecordIdKey
) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getAccountDetail(
accountId,
writer,
key,
pageSize,
accountDetailRecordIdWriter,
accountDetailRecordIdKey
)
.buildSigned(keyPair);

val res = api.query(q);

checkErrorResponse(res);

val adr = res.getAccountDetailResponse();

return adr.getDetail();
}

public String getAccountDetails(
String accountId,
String writer,
String key,
Integer pageSize
) {
return getAccountDetails(accountId, writer, key, pageSize, null, null);
}

public AccountResponse getAccount(String accountId) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getAccount(accountId)
Expand Down Expand Up @@ -158,6 +214,12 @@ public AssetResponse getAssetInfo(String assetId) {
return res.getAssetResponse();
}

/**
* Pagination metadata can be missing in the request for compatibility reasons, but this behaviour
* is deprecated and should be avoided. This function is deprecated in Iroha 1.1.0 and will be
* deleted in Iroha 2.0.0
*/
@Deprecated
public AccountAssetResponse getAccountAssets(String accountId) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getAccountAssets(accountId)
Expand All @@ -170,10 +232,33 @@ public AccountAssetResponse getAccountAssets(String accountId) {
return res.getAccountAssetsResponse();
}

public AccountAssetResponse getAccountAssets(
String accountId,
Integer pageSize,
String firstAssetId
) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getAccountAssets(accountId, pageSize, firstAssetId)
.buildSigned(keyPair);

val res = api.query(q);

checkErrorResponse(res);

return res.getAccountAssetsResponse();
}

public AccountAssetResponse getAccountAssets(
String accountId,
Integer pageSize
) {
return getAccountAssets(accountId, pageSize, null);
}

public SignatoriesResponse getSignatories(String accountId) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getSignatories(accountId)
.buildSigned(keyPair);
.getSignatories(accountId)
.buildSigned(keyPair);

val res = api.query(q);

Expand All @@ -182,6 +267,12 @@ public SignatoriesResponse getSignatories(String accountId) {
return res.getSignatoriesResponse();
}

/**
* Pagination metadata can be missing in the request for compatibility reasons, but this behaviour
* is deprecated and should be avoided. This function is deprecated in Iroha 1.1.0 and will be
* deleted in Iroha 2.0.0
*/
@Deprecated
public TransactionsResponse getPendingTransactions() {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getPendingTransactions()
Expand All @@ -193,4 +284,25 @@ public TransactionsResponse getPendingTransactions() {

return res.getTransactionsResponse();
}

public TransactionsResponse getPendingTransactions(
Integer pageSize,
String firstHashHex
) {
val q = Query.builder(this.accountId, counter.getAndIncrement())
.getPendingTransactions(pageSize, firstHashHex)
.buildSigned(keyPair);

val res = api.query(q);

checkErrorResponse(res);

return res.getTransactionsResponse();
}

public TransactionsResponse getPendingTransactions(
Integer pageSize
) {
return getPendingTransactions(pageSize, null);
}
}
Loading

0 comments on commit 4b4be14

Please sign in to comment.