Skip to content

Commit

Permalink
Fix: Fetch all blocks in a Slot (#1443)
Browse files Browse the repository at this point in the history
* remove cursor from slot blocks request

* fix: add cursor from response

* fix: slot blocks query

* fix: add copy button to commit id

* fix: update block stats query

---------

Co-authored-by: Mario <[email protected]>
Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 6aecb37 commit e4be147
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 26 deletions.
5 changes: 0 additions & 5 deletions api/src/models/api/nova/chronicle/ISlotBlocksRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ export interface ISlotBlocksRequest {
* The slot index to get the details for.
*/
slotIndex: string;

/**
* The cursor state for the request.
*/
cursor?: string;
}
8 changes: 2 additions & 6 deletions api/src/services/nova/chronicleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class ChronicleService {

do {
try {
const params = {
cursor: request.cursor,
};
const params = { cursor };
const response = await FetchHelper.json<never, ISlotBlocksResponse>(
this.chronicleEndpoint,
`${CHRONICLE_ENDPOINTS.slotBlocks}${params ? `${FetchHelper.urlParams(params)}` : ""}`.replace(
Expand All @@ -69,9 +67,7 @@ export class ChronicleService {
),
"get",
);
// Hardcoded to null for now because chronicle always returns the same cursor: https://github.com/iotaledger/inx-chronicle/issues/1362
cursor = null;
// cursor = response.cursor;
cursor = response.cursor;

if (response.blocks) {
slotBlocks.push(...response.blocks);
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/nova/influx/influxQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const BLOCK_STATS_QUERY = `
sum("candidacy_announcement_count") AS "candidacy",
sum("validation_count") AS "noPayload"
FROM "iota_block_activity"
WHERE time >= $from and time <= $to
WHERE time >= $from and time < $to
`;

export const TOKENS_HELD_BY_OUTPUTS_DAILY_QUERY = {
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/routes/nova/SlotPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function SlotPage({
<div className="section--data">
<div className="label">Commitment Id</div>
<div className="value code">
<TruncatedId id={slotCommitmentId ?? FALLBACK_STRING} />
<TruncatedId id={slotCommitmentId ?? FALLBACK_STRING} showCopyButton />
</div>
</div>
<div className="card-info-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/routes/nova/TransactionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const TransactionPage: React.FC<RouteComponentProps<TransactionPageProps>> = ({
<div className="section--data">
<div className="label">Slot Commitment</div>
<div className="value code">
<TruncatedId id={block.header.slotCommitmentId} />
<TruncatedId id={block.header.slotCommitmentId} showCopyButton />
</div>
</div>
{issuerAddress && (
Expand Down
5 changes: 0 additions & 5 deletions client/src/models/api/nova/ISlotBlocksRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ export interface ISlotBlocksRequest {
* The slot index to get the details for.
*/
slotIndex: string;

/**
* The cursor state for the request.
*/
cursor?: string;
}
8 changes: 1 addition & 7 deletions client/src/services/nova/novaApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,7 @@ export class NovaApiClient extends ApiClient {
* @returns The response from the request.
*/
public async getSlotBlocks(request: ISlotBlocksRequest): Promise<ISlotBlocksResponse> {
const params = {
cursor: request.cursor,
};
return this.callApi<unknown, ISlotBlocksResponse>(
`nova/slot/blocks/chronicle/${request.network}/${request.slotIndex}${FetchHelper.urlParams(params)}`,
"get",
);
return this.callApi<unknown, ISlotBlocksResponse>(`nova/slot/blocks/chronicle/${request.network}/${request.slotIndex}`, "get");
}

/**
Expand Down

0 comments on commit e4be147

Please sign in to comment.