Skip to content

Commit

Permalink
feat: remove deprecated nft info queries (#673)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Akhterov <[email protected]>

Co-authored-by: Sean Tedrow <[email protected]>
  • Loading branch information
janaakhterov and Sean-Tedrow-LB authored Aug 27, 2021
1 parent 6c321bf commit 18b63fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 61 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `AccountInfo.maxAutomaticTokenAssociations`
* `TokenRelationship.automaticAssociation`
* New status codes

### Deprecated

* `TokenNftInfoQuery.[set|get]AccountId()` with no replacement
* `TokenNftInfoQuery.[set|get]TokenId()` with no replacement
* `TokenNftInfoQuery.[set|get]Start()` with no replacement
* `TokenNftInfoQuery.[set|get]End()` with no replacement

### Fixed

* TLS connector failing when the networks address book did not have cert hashes

### v2.0.12

## v2.0.12

### Added

Expand All @@ -40,7 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Deprecated `Client.setMax[TransactionFee|QueryPayment]()`, added `Client.setDefaultMax[TransactionFee|QueryPayment]()` and `Client.getDefaultMax[TransactionFee|QueryPayment]()`

### v2.0.11
## v2.0.11

### Added

Expand Down
79 changes: 20 additions & 59 deletions sdk/src/main/java/com/hedera/hashgraph/sdk/TokenNftInfoQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,27 @@ public NftId getNftId() {
}

/**
* @deprecated with no replacement
* Sets the Token ID and the index range for which information is requested.
*
* @param tokenId The ID of the token for which information is requested
* @return {@code this}
*/
@Deprecated
public TokenNftInfoQuery byTokenId(TokenId tokenId) {
Objects.requireNonNull(tokenId);
this.tokenId = tokenId;
return this;
}

@Nullable
@Deprecated
public TokenId getTokenId() {
return tokenId;
}

/**
* @deprecated with no replacement
* Sets the Account ID for which information is requested.
*
* @param accountId The Account ID for which information is requested
Expand All @@ -86,35 +90,42 @@ public TokenNftInfoQuery byAccountId(AccountId accountId) {
}

@Nullable
@Deprecated
public AccountId getAccountId() {
return accountId;
}

@Deprecated
public long getStart() {
return start;
}

/**
* @deprecated with no replacement
* Sets the start of the index range for which information is requested.
*
* @param start The start index (inclusive) of the range of NFTs to query for. Value must be in the range [0; ownedNFTs-1]
* @return {@code this}
*/
@Deprecated
public TokenNftInfoQuery setStart(@Nonnegative long start) {
this.start = start;
return this;
}

@Deprecated
public long getEnd() {
return end;
}

/**
* @deprecated with no replacement
* Sets the end of the index range for which information is requested.
*
* @param end The end index (exclusive) of the range of NFTs to query for. Value must be in the range (start; ownedNFTs]
* @return {@code this}
*/
@Deprecated
public TokenNftInfoQuery setEnd(@Nonnegative long end) {
this.end = end;
return this;
Expand All @@ -125,14 +136,6 @@ void validateChecksums(Client client) throws BadEntityIdException {
if (nftId != null) {
nftId.tokenId.validateChecksum(client);
}

if (tokenId != null) {
tokenId.validateChecksum(client);
}

if (accountId != null) {
accountId.validateChecksum(client);
}
}

@Override
Expand All @@ -148,73 +151,31 @@ CompletableFuture<Void> onExecuteAsync(Client client) {

@Override
void onMakeRequest(com.hedera.hashgraph.sdk.proto.Query.Builder queryBuilder, QueryHeader header) {
if (nftId != null) {
queryBuilder.setTokenGetNftInfo(
TokenGetNftInfoQuery.newBuilder()
.setNftID(nftId.toProtobuf())
.setHeader(header)
);
} else if (tokenId != null) {
queryBuilder.setTokenGetNftInfos(
TokenGetNftInfosQuery.newBuilder()
.setTokenID(tokenId.toProtobuf())
.setStart(start)
.setEnd(end)
.setHeader(header)
);
} else /* is by account */ {
queryBuilder.setTokenGetAccountNftInfos(
TokenGetAccountNftInfosQuery.newBuilder()
.setAccountID(accountId.toProtobuf())
.setStart(start)
.setEnd(end)
.setHeader(header)
);
}
queryBuilder.setTokenGetNftInfo(
TokenGetNftInfoQuery.newBuilder()
.setNftID(nftId.toProtobuf())
.setHeader(header)
);
}

@Override
ResponseHeader mapResponseHeader(Response response) {
if (nftId != null) {
return response.getTokenGetNftInfo().getHeader();
} else if (tokenId != null) {
return response.getTokenGetNftInfos().getHeader();
} else /* is by account */ {
return response.getTokenGetAccountNftInfos().getHeader();
}
return response.getTokenGetNftInfo().getHeader();
}

@Override
QueryHeader mapRequestHeader(com.hedera.hashgraph.sdk.proto.Query request) {
if (nftId != null) {
return request.getTokenGetInfo().getHeader();
} else if (tokenId != null) {
return request.getTokenGetNftInfos().getHeader();
} else /* is by account */ {
return request.getTokenGetAccountNftInfos().getHeader();
}
return request.getTokenGetInfo().getHeader();
}

@Override
List<TokenNftInfo> mapResponse(Response response, AccountId nodeId, com.hedera.hashgraph.sdk.proto.Query request) {
if (nftId != null) {
return Collections.singletonList(TokenNftInfo.fromProtobuf(response.getTokenGetNftInfo().getNft()));
} else if (tokenId != null) {
return infosFromProtos(response.getTokenGetNftInfos().getNftsList());
} else /* is by account */ {
return infosFromProtos(response.getTokenGetAccountNftInfos().getNftsList());
}
return Collections.singletonList(TokenNftInfo.fromProtobuf(response.getTokenGetNftInfo().getNft()));
}

@Override
MethodDescriptor<Query, Response> getMethodDescriptor() {
if (nftId != null) {
return TokenServiceGrpc.getGetTokenNftInfoMethod();
} else if (tokenId != null) {
return TokenServiceGrpc.getGetTokenNftInfosMethod();
} else /* is by account */ {
return TokenServiceGrpc.getGetAccountNftInfosMethod();
}
return TokenServiceGrpc.getGetTokenNftInfoMethod();
}

@Override
Expand Down

0 comments on commit 18b63fb

Please sign in to comment.