Skip to content

Commit

Permalink
fix: 🐛 Correct gql query to get transaction history for CA
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantasdeveloper committed Mar 4, 2024
1 parent 65157d2 commit 4bc66fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/api/entities/confidential/ConfidentialAccount/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,8 @@ export class ConfidentialAccount extends Entity<UniqueIdentifiers, string> {
);

const data: ConfidentialAssetHistoryEntry[] = nodes.map(
({ id, assetId, amount, eventId, createdBlock, eventIdx }) => {
({ assetId, amount, eventId, createdBlock, eventIdx }) => {
return {
id,
asset: new ConfidentialAsset({ id: assetId }, context),
amount,
eventId,
Expand Down
1 change: 0 additions & 1 deletion src/api/entities/confidential/ConfidentialAccount/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface ApplyIncomingBalanceParams {
}

export type ConfidentialAssetHistoryEntry = {
id: string;
asset: ConfidentialAsset;
eventId: EventIdEnum;
amount: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ describe('ConfidentialAccount class', () => {
const eventIdx = new BigNumber(1);
const fakeCreatedAt = { blockNumber, blockHash, blockDate, eventIndex: eventIdx };
const mockData = {
id: 1,
assetId: mockAsset.toHuman(),
amount: '100000000000000000',
eventId: EventIdEnum.AccountDeposit,
Expand Down Expand Up @@ -364,7 +363,6 @@ describe('ConfidentialAccount class', () => {
data: [historyEntry],
} = await account.getTransactionHistory({});

expect(historyEntry.id).toEqual(mockData.id);
expect(historyEntry.asset).toBeInstanceOf(ConfidentialAsset);
expect(historyEntry.amount).toEqual(mockData.amount);
expect(historyEntry.amount).toEqual(mockData.amount);
Expand Down Expand Up @@ -395,7 +393,6 @@ describe('ConfidentialAccount class', () => {
data: [historyEntry],
} = await account.getTransactionHistory({ size, start });

expect(historyEntry.id).toEqual(mockData.id);
expect(historyEntry.asset).toBeInstanceOf(ConfidentialAsset);
expect(historyEntry.amount).toEqual(mockData.amount);
expect(historyEntry.amount).toEqual(mockData.amount);
Expand Down
32 changes: 17 additions & 15 deletions src/middleware/queries/confidential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function confidentialAssetsByHolderQuery(
offset: $start
) {
nodes {
accountId,
accountId
assetId
}
totalCount
Expand All @@ -52,7 +52,7 @@ export function createTransactionHistoryByConfidentialAssetQueryFilters(): {
args: string;
filter: string;
} {
const args = ['$size: Int, $start: Int', '$assetId: [String!]'];
const args = ['$size: Int, $start: Int', '$assetId: String!'];
const filters = ['assetId: { equalTo: $assetId }'];

return {
Expand All @@ -73,7 +73,7 @@ export function transactionHistoryByConfidentialAssetQuery(
): QueryOptions<PaginatedQueryArgs<QueryArgs<ConfidentialAssetHistory, 'assetId'>>> {
const { args, filter } = createTransactionHistoryByConfidentialAssetQueryFilters();

const query = gql`
const query = `
query TransactionHistoryQuery
${args}
{
Expand All @@ -83,27 +83,29 @@ export function transactionHistoryByConfidentialAssetQuery(
offset: $start
){
nodes {
accountId,
fromId,
toId,
transactionId,
assetId,
fromId
toId
transactionId
assetId
createdBlock {
datetime,
hash,
blockId,
datetime
hash
blockId
}
amount,
eventId,
memo,
amount
eventId
memo
}
totalCount
}
}
`;

console.log(query);
return {
query,
query: gql`
${query}
`,
variables: { size: size?.toNumber(), start: start?.toNumber(), assetId },
};
}
Expand Down

0 comments on commit 4bc66fe

Please sign in to comment.