Skip to content

Commit

Permalink
return 200 when mint info not found (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanmomo committed May 23, 2024
1 parent f16ac8a commit 7ab23ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.dl.officialsite.nft.config.ContractConfigService;
import com.dl.officialsite.nft.constant.ContractNameEnum;
import com.dl.officialsite.nft.contract.WarCraftContract;
import com.dl.officialsite.nft.util.RankExtractorUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -59,27 +58,22 @@ public BaseResponse rank(String address, ContractNameEnum contractName, String c
BigInteger tokenId = contract.claimedTokenIdBy(address).sendAsync().get(TIMEOUT, TimeUnit.SECONDS);
if (tokenId == null || tokenId.intValue() == 0) {
log.error("No claim(tokenId) info found for address:[{}].", address);
return BaseResponse.failWithReason("1206", "No claim info found.");
return BaseResponse.failWithReason("200", "No claim info found.");
}

String rank = contract.tokenURI(tokenId).sendAsync().get(TIMEOUT, TimeUnit.SECONDS);
String rank = contract.tokenURIs(tokenId).sendAsync().get(TIMEOUT, TimeUnit.SECONDS);
if (StringUtils.isBlank(rank)) {
log.error("No rank info found for address:[{}] and tokenId:[{}].", address, tokenId.intValue());
return BaseResponse.failWithReason("1206", "No rank info found.");
}
int rankValue = RankExtractorUtil.extractParameterValueFromUrl(rank, "rank");
if (rankValue < 0) {
log.error("Invalid rank value:[{}] found in url:[{}].", rankValue, rank);
return BaseResponse.failWithReason("1206", "No rank info found.");
return BaseResponse.failWithReason("200", "No rank info found.");
}

MemberNFTMintRecord memberNFTMintRecord = new MemberNFTMintRecord();
memberNFTMintRecord.setAddress(address);
memberNFTMintRecord.setContractName(contractName);
memberNFTMintRecord.setChainId(chainId);
memberNFTMintRecord.setRankValue(rankValue);
memberNFTMintRecord.setRankValue(Integer.parseInt(rank));
this.memberNFTMintRecordRepository.save(memberNFTMintRecord);
return BaseResponse.successWithData(rankValue);
return BaseResponse.successWithData(rank);
} catch (Exception e) {
log.error("Call contract method:[claimedTokenIdBy] remote error.", e);
return BaseResponse.failWithReason("1205", "Fetch rank failed, please try again later.");
Expand Down
32 changes: 0 additions & 32 deletions src/main/java/com/dl/officialsite/nft/util/RankExtractorUtil.java

This file was deleted.

0 comments on commit 7ab23ef

Please sign in to comment.