Skip to content

Commit

Permalink
fix: 🐛 fix instruction from middleware with SQ v19+
Browse files Browse the repository at this point in the history
  • Loading branch information
polymath-eric committed Dec 10, 2024
1 parent 8260aac commit 5917116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/api/entities/Instruction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class Instruction extends Entity<UniqueIdentifiers, string> {
},
},
} = await context.queryMiddleware<Ensured<Query, 'instructions'>>(
instructionsQuery(false, {
instructionsQuery(context.isSqIdPadded, {
id: id.toString(),
})
);
Expand Down
13 changes: 9 additions & 4 deletions src/middleware/queries/settlements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';
import gql from 'graphql-tag';

import { Context } from '~/internal';
import { createArgsAndFilters, getSizeAndOffset } from '~/middleware/queries/common';
import { createArgsAndFilters, getSizeAndOffset, padSqId } from '~/middleware/queries/common';
import {
Instruction,
InstructionAffirmation,
Expand Down Expand Up @@ -174,9 +174,14 @@ export function instructionsQuery(
status: 'InstructionStatusEnum',
});

const orderBy = paddedIds
? `[${InstructionEventsOrderBy.IdDesc}]`
: `[${InstructionsOrderBy.CreatedAtDesc}, ${InstructionsOrderBy.IdDesc}]`;
let orderBy = `[${InstructionsOrderBy.CreatedAtDesc}, ${InstructionsOrderBy.IdDesc}]`;

if (paddedIds) {
orderBy = `[${InstructionEventsOrderBy.IdDesc}]`;
if (filters.id) {
filters.id = padSqId(filters.id);
}
}

const query = gql`
query InstructionsQuery
Expand Down

0 comments on commit 5917116

Please sign in to comment.