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

Commit

Permalink
fix(interactions): add multi write detection and parsing support for …
Browse files Browse the repository at this point in the history
…contract interactions
  • Loading branch information
atticusofsparta committed Nov 24, 2023
1 parent dd84862 commit 8a6d9b7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
import Arweave from 'arweave';
import { ArNSInteraction } from '../types.js';
import { GQLNodeInterface, TagsParser } from 'warp-contracts';

export const MAX_REQUEST_SIZE = 100;

Expand Down Expand Up @@ -106,6 +107,7 @@ export async function getWalletInteractionsForContract(
Omit<ArNSInteraction, 'valid' | 'errorMessage' | 'id'>
>;
}> {
const parser = new TagsParser();
const { address, contractTxId } = params;
let hasNextPage = false;
let cursor: string | undefined;
Expand Down Expand Up @@ -178,11 +180,13 @@ export async function getWalletInteractionsForContract(
};
pageInfo?: { hasNextPage: boolean };
}) => {
const interactionInput = e.node.tags.find(
(t: { name: string; value: string }) => t.name === 'Input',
const inputTag = parser.getInputTag(
e.node as GQLNodeInterface,
contractTxId,
);
const parsedInput = interactionInput
? JSON.parse(interactionInput.value)

const parsedInput = inputTag?.value
? JSON.parse(inputTag.value)
: undefined;
interactions.set(e.node.id, {
height: e.node.block.height,
Expand Down

0 comments on commit 8a6d9b7

Please sign in to comment.