Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blockHeight, absoluteSlot and blockTime should actually be withi… #377

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import org.apache.commons.collections4.ListUtils;
import rest.koios.client.backend.api.base.common.Asset;
import rest.koios.client.backend.api.transactions.TransactionsService;
import rest.koios.client.backend.api.transactions.model.*;
import rest.koios.client.backend.api.transactions.model.TxCertificate;
import rest.koios.client.backend.api.transactions.model.TxIO;
import rest.koios.client.backend.api.transactions.model.TxInfo;
import rest.koios.client.backend.api.transactions.model.TxPlutusContract;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -91,9 +94,15 @@ private TransactionContent convertToTransactionContent(TxInfo txInfo) {
TransactionContent transactionContent = new TransactionContent();
transactionContent.setHash(txInfo.getTxHash());
transactionContent.setBlock(txInfo.getBlockHash());
transactionContent.setBlockHeight(txInfo.getBlockHeight());
transactionContent.setBlockTime(txInfo.getTxTimestamp());
transactionContent.setSlot(txInfo.getAbsoluteSlot());
if (txInfo.getBlockHeight() != null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make assumption that any of these value will never be null? I find my own defensive programming here a bit clunky.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matiwinnetou Thanks for the PR.

These should not be null unless there is a defect on the provider's side. But I think we can keep this null check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, feel free to merge when you think this is fine and right time for it.

transactionContent.setBlockHeight(txInfo.getBlockHeight().longValue());
}
if (txInfo.getTxTimestamp() != null) {
transactionContent.setBlockTime(txInfo.getTxTimestamp().longValue());
}
if (txInfo.getAbsoluteSlot() != null) {
transactionContent.setSlot(txInfo.getAbsoluteSlot().longValue());
}
transactionContent.setIndex(txInfo.getTxBlockIndex());
List<TxOutputAmount> txOutputAmountList = new ArrayList<>();
txOutputAmountList.add(new TxOutputAmount(LOVELACE, txInfo.getTotalOutput()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class TransactionContent {

private String hash;
private String block;
private Integer blockHeight;
private Integer blockTime;
private Integer slot;
private Long blockHeight;
private Long blockTime;
private Long slot;
private Integer index;

@Builder.Default
Expand All @@ -43,4 +43,5 @@ public class TransactionContent {
private Integer assetMintOrBurnCount;
private Integer redeemerCount;
private Boolean validContract;

}
Loading