Skip to content

Commit

Permalink
Explorer: Fix off by 1 error in pagination (MystenLabs#3100)
Browse files Browse the repository at this point in the history
  • Loading branch information
666lcz authored Jul 8, 2022
1 parent 715f0f4 commit 6933f28
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ function generateStartEndRange(
): { startGatewayTxSeqNumber: number; endGatewayTxSeqNumber: number } {
// Pagination pageNum from query params - default to 0; No negative values
const txPaged = pageNum && pageNum > 0 ? pageNum - 1 : 0;
const endGatewayTxSeqNumber: number = txCount - txNum * txPaged;
const tempStartGatewayTxSeqNumber: number = endGatewayTxSeqNumber - txNum;
// If startGatewayTxSeqNumber is less than 0, then set it 1 the first transaction sequence number
const startGatewayTxSeqNumber: number =
tempStartGatewayTxSeqNumber > 0 ? tempStartGatewayTxSeqNumber : 1;
const endGatewayTxSeqNumber = txCount - txNum * txPaged;
const startGatewayTxSeqNumber = Math.max(endGatewayTxSeqNumber - txNum, 0);
return {
startGatewayTxSeqNumber,
endGatewayTxSeqNumber,
Expand Down

0 comments on commit 6933f28

Please sign in to comment.