Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #73 from ar-io/tag-check
Browse files Browse the repository at this point in the history
fix(gql): validate tags for gql interactions
  • Loading branch information
dtfiedler authored Nov 27, 2023
2 parents 8ae0a23 + 90df3d9 commit d60e11b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
import Arweave from 'arweave';
import { ArNSInteraction } from '../types.js';
import { GQLEdgeInterface, TagsParser } from 'warp-contracts';
import { TagsParser } from 'warp-contracts';
import logger from '../logger';

export const MAX_REQUEST_SIZE = 100;

Expand Down Expand Up @@ -170,9 +171,19 @@ export async function getWalletInteractionsForContract(
if (!response.data.data?.transactions?.edges?.length) {
continue;
}
response.data.data.transactions.edges.forEach((e: GQLEdgeInterface) => {
for (const e of response.data.data.transactions.edges) {
// basic validation for smartweave tags
const inputTag = parser.getInputTag(e.node, contractTxId);

const contractTag = parser.getContractTag(e.node);
if (!inputTag || !contractTag) {
logger.debug('Invalid tags for interaction via GQL, ignoring...', {
contractTxId,
interactionId: e.node.id,
inputTag,
contractTag,
});
continue;
}
const parsedInput = inputTag?.value
? JSON.parse(inputTag.value)
: undefined;
Expand All @@ -182,7 +193,7 @@ export async function getWalletInteractionsForContract(
input: parsedInput,
owner: e.node.owner.address,
});
});
}
cursor =
response.data.data.transactions.edges[MAX_REQUEST_SIZE - 1]?.cursor ??
undefined;
Expand Down

0 comments on commit d60e11b

Please sign in to comment.