Skip to content

Commit

Permalink
apply these change to taurus files indexer also
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Dec 18, 2024
1 parent db51ce5 commit 944a298
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
11 changes: 11 additions & 0 deletions indexers/taurus/files/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ type FileCid @entity {
parentCid: String! @index
childCid: String! @index
}

type Error @entity {
id: ID!
blockHeight: BigInt! @index
blockHash: String! @index
extrinsicId: String! @index
extrinsicHash: String! @index
indexInBlock: Int! @index
error: String!
timestamp: Date! @index
}
24 changes: 24 additions & 0 deletions indexers/taurus/files/src/mappings/db.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Chunk,
Cid,
Error,
File,
FileCid,
Folder,
Expand Down Expand Up @@ -120,3 +121,26 @@ export async function createAndSaveFile(
}
return file;
}

export async function createAndSaveError(
blockHeight: bigint,
blockHash: string,
extrinsicId: string,
extrinsicHash: string,
indexInBlock: number,
error: string,
timestamp: Date
): Promise<Error> {
const _error = Error.create({
id: extrinsicId,
blockHeight,
blockHash,
extrinsicId,
extrinsicHash,
indexInBlock,
error,
timestamp,
});
await _error.save();
return _error;
}
12 changes: 11 additions & 1 deletion indexers/taurus/files/src/mappings/mappingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SubstrateExtrinsic } from "@subql/types";
import {
createAndSaveChunk,
createAndSaveCid,
createAndSaveError,
createAndSaveFile,
createAndSaveFolder,
createAndSaveMetadata,
Expand Down Expand Up @@ -120,8 +121,17 @@ export async function handleCall(_call: SubstrateExtrinsic): Promise<void> {
}
}
}
} catch (error) {
} catch (error: any) {
logger.error("Error decoding remark or seedHistory extrinsic");
logger.error(error);
await createAndSaveError(
BigInt(number.toString()),
blockHash.toString(),
`${number}-${idx}`,
hash.toString(),
idx,
stringify(error),
timestamp ? timestamp : new Date(0)
);
}
}

0 comments on commit 944a298

Please sign in to comment.