Skip to content

Commit

Permalink
chore: add support for multi-indexer checkpoint (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekhmet authored Jun 14, 2024
1 parent d0302d2 commit 53d4276
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 88 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"prettier": "@snapshot-labs/prettier-config",
"dependencies": {
"@snapshot-labs/checkpoint": "^0.1.0-beta.35",
"@snapshot-labs/checkpoint": "^0.1.0-beta.36",
"@types/node": "^18.11.6",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import express from 'express';
import cors from 'cors';
import path from 'path';
import fs from 'fs';
import Checkpoint, { LogLevel } from '@snapshot-labs/checkpoint';
import Checkpoint, { starknet, LogLevel } from '@snapshot-labs/checkpoint';
import config from './config.json';
import * as writers from './writers';
import checkpointBlocks from './checkpoints.json';
Expand All @@ -13,7 +13,8 @@ const dir = __dirname.endsWith('dist/src') ? '../' : '';
const schemaFile = path.join(__dirname, `${dir}../src/schema.gql`);
const schema = fs.readFileSync(schemaFile, 'utf8');

const checkpoint = new Checkpoint(config, writers, schema, {
const indexer = new starknet.StarknetIndexer(writers);
const checkpoint = new Checkpoint(config, indexer, schema, {
logLevel: LogLevel.Info,
prettifyLogs: true,
fetchInterval: 15000,
Expand Down
4 changes: 2 additions & 2 deletions src/writers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { validateAndParseAddress } from 'starknet';
import { CheckpointWriter } from '@snapshot-labs/checkpoint';
import { starknet } from '@snapshot-labs/checkpoint';
import { Post } from '../.checkpoint/models';
import { longStringToText } from './utils';

export const handleNewPost: CheckpointWriter = async ({ block, tx, rawEvent, event }) => {
export const handleNewPost: starknet.Writer = async ({ block, tx, rawEvent, event }) => {
if (!block || !event || !rawEvent) return;

const author = validateAndParseAddress(rawEvent.from_address);
Expand Down
Loading

0 comments on commit 53d4276

Please sign in to comment.