-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: base processors package #8
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# grants-stack-indexer: processors package | ||
|
||
Description of your package goes here. | ||
|
||
## Setup | ||
|
||
1. Install dependencies running `pnpm install` | ||
|
||
## Available Scripts | ||
|
||
Available scripts that can be run using `pnpm`: | ||
|
||
| Script | Description | | ||
| ------------- | ------------------------------------------------------- | | ||
| `build` | Build library using tsc | | ||
| `check-types` | Check types issues using tsc | | ||
| `clean` | Remove `dist` folder | | ||
| `lint` | Run ESLint to check for coding standards | | ||
| `lint:fix` | Run linter and automatically fix code formatting issues | | ||
| `format` | Check code formatting and style using Prettier | | ||
| `format:fix` | Run formatter and automatically fix issues | | ||
| `test` | Run tests using vitest | | ||
| `test:cov` | Run tests with coverage report | | ||
|
||
## Usage | ||
|
||
Describe how to use your package here. | ||
|
||
## API | ||
|
||
Describe your package's API here. | ||
|
||
## References | ||
|
||
Add any relevant references here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@grants-stack-indexer/processors", | ||
"version": "0.0.1", | ||
"private": true, | ||
"description": "", | ||
"license": "MIT", | ||
"author": "Wonderland", | ||
"type": "module", | ||
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
"directories": { | ||
"src": "src" | ||
}, | ||
"files": [ | ||
"dist/*", | ||
"package.json", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"scripts": { | ||
"build": "tsc -p tsconfig.build.json", | ||
"check-types": "tsc --noEmit -p ./tsconfig.json", | ||
"clean": "rm -rf dist/", | ||
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"", | ||
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"", | ||
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"", | ||
"lint:fix": "pnpm lint --fix", | ||
"test": "vitest run --config vitest.config.ts --passWithNoTests", | ||
"test:cov": "vitest run --config vitest.config.ts --coverage" | ||
}, | ||
"dependencies": { | ||
"@grants-stack-indexer/metadata": "workspace:*", | ||
"@grants-stack-indexer/pricing": "workspace:*", | ||
"@grants-stack-indexer/repository": "workspace:*", | ||
"@grants-stack-indexer/shared": "workspace:*", | ||
"viem": "2.21.19" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Changeset } from "@grants-stack-indexer/repository"; | ||
import { AlloEvent, ProtocolEvent } from "@grants-stack-indexer/shared"; | ||
|
||
import type { IProcessor } from "../internal.js"; | ||
|
||
export class AlloProcessor implements IProcessor<"Allo", AlloEvent> { | ||
//TODO: Implement | ||
process(_event: ProtocolEvent<"Allo", AlloEvent>): Promise<Changeset> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./allo.processor.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Add your external exports here | ||
export { StrategyProcessor, AlloProcessor } from "./internal.js"; | ||
export type { IProcessor } from "./internal.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./external.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./processor.interface.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Changeset } from "@grants-stack-indexer/repository"; | ||
import { ContractName, ContractToEventName, ProtocolEvent } from "@grants-stack-indexer/shared"; | ||
|
||
export interface IProcessor<C extends ContractName, E extends ContractToEventName<C>> { | ||
/** | ||
* Processes an event from the Allo protocol. | ||
* @param event - The event to process. | ||
* @returns A promise that resolves to a changeset. | ||
*/ | ||
process(event: ProtocolEvent<C, E>): Promise<Changeset>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Add your internal exports here | ||
export * from "./interfaces/index.js"; | ||
export * from "./allo/index.js"; | ||
export * from "./strategy/index.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./strategy.processor.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Changeset } from "@grants-stack-indexer/repository"; | ||
import { ProtocolEvent, StrategyEvent } from "@grants-stack-indexer/shared"; | ||
|
||
import type { IProcessor } from "../internal.js"; | ||
|
||
export class StrategyProcessor implements IProcessor<"Strategy", StrategyEvent> { | ||
process(_event: ProtocolEvent<"Strategy", StrategyEvent>): Promise<Changeset> { | ||
//TODO: Implement | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { describe, it } from "vitest"; | ||
|
||
describe("dummy", () => { | ||
it.skip("dummy", () => {}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"declarationMap": true, | ||
"declaration": true, | ||
"outDir": "dist" | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist", "test"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from "path"; | ||
import { configDefaults, defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
environment: "node", | ||
include: ["test/**/*.spec.ts"], | ||
exclude: ["node_modules", "dist"], | ||
coverage: { | ||
provider: "v8", | ||
reporter: ["text", "json", "html"], | ||
exclude: ["node_modules", "dist", "src/index.ts", ...configDefaults.exclude], | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
"@": path.resolve(__dirname, "src"), | ||
}, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export * from "./db/connection.js"; | ||
export * from "./repositories/kysely/index.js"; | ||
export * from "./interfaces/index.js"; | ||
export * from "./external.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import { ChainId } from "@grants-stack-indexer/shared"; | ||
import { Address } from "@grants-stack-indexer/shared/dist/src/internal.js"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you mean to import this from the dist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch |
||
|
||
import { | ||
NewPendingProjectRole, | ||
NewProject, | ||
NewProjectRole, | ||
PartialProject, | ||
ProjectRole, | ||
} from "./project.types.js"; | ||
import { | ||
NewPendingRoundRole, | ||
NewRound, | ||
NewRoundRole, | ||
PartialRound, | ||
RoundRole, | ||
} from "./round.types.js"; | ||
|
||
export type Changeset = | ||
| { | ||
type: "InsertProject"; | ||
args: { | ||
project: NewProject; | ||
}; | ||
} | ||
| { | ||
type: "UpdateProject"; | ||
args: { | ||
chainId: ChainId; | ||
projectId: string; | ||
project: PartialProject; | ||
}; | ||
} | ||
| { | ||
type: "InsertPendingProjectRole"; | ||
args: { | ||
pendingProjectRole: NewPendingProjectRole; | ||
}; | ||
} | ||
| { | ||
type: "DeletePendingProjectRoles"; | ||
args: { | ||
ids: number[]; | ||
}; | ||
} | ||
| { | ||
type: "InsertProjectRole"; | ||
args: { | ||
projectRole: NewProjectRole; | ||
}; | ||
} | ||
| { | ||
type: "DeleteAllProjectRolesByRole"; | ||
args: { | ||
projectRole: Pick<ProjectRole, "chainId" | "projectId" | "role">; | ||
}; | ||
} | ||
| { | ||
type: "DeleteAllProjectRolesByRoleAndAddress"; | ||
args: { | ||
projectRole: Pick<ProjectRole, "chainId" | "projectId" | "role" | "address">; | ||
}; | ||
} | ||
| { | ||
type: "InsertRound"; | ||
args: { | ||
round: NewRound; | ||
}; | ||
} | ||
| { | ||
type: "UpdateRound"; | ||
args: { | ||
chainId: ChainId; | ||
roundId: string; | ||
round: PartialRound; | ||
}; | ||
} | ||
| { | ||
type: "UpdateRoundByStrategyAddress"; | ||
args: { | ||
chainId: ChainId; | ||
strategyAddress: Address; | ||
round: PartialRound; | ||
}; | ||
} | ||
| { | ||
type: "IncrementRoundFundedAmount"; | ||
args: { | ||
chainId: ChainId; | ||
roundId: string; | ||
fundedAmount: bigint; | ||
fundedAmountInUsd: number; | ||
}; | ||
} | ||
| { | ||
type: "IncrementRoundDonationStats"; | ||
args: { | ||
chainId: ChainId; | ||
roundId: Address; | ||
amountInUsd: number; | ||
}; | ||
} | ||
| { | ||
type: "IncrementRoundTotalDistributed"; | ||
args: { | ||
chainId: ChainId; | ||
roundId: string; | ||
amount: bigint; | ||
}; | ||
} | ||
| { | ||
type: "IncrementApplicationDonationStats"; | ||
args: { | ||
chainId: ChainId; | ||
roundId: Address; | ||
applicationId: string; | ||
amountInUsd: number; | ||
}; | ||
} | ||
| { | ||
type: "InsertPendingRoundRole"; | ||
args: { | ||
pendingRoundRole: NewPendingRoundRole; | ||
}; | ||
} | ||
| { | ||
type: "DeletePendingRoundRoles"; | ||
args: { | ||
ids: number[]; | ||
}; | ||
} | ||
| { | ||
type: "InsertRoundRole"; | ||
args: { | ||
roundRole: NewRoundRole; | ||
}; | ||
} | ||
| { | ||
type: "DeleteAllRoundRolesByRoleAndAddress"; | ||
args: { | ||
roundRole: Pick<RoundRole, "chainId" | "roundId" | "role" | "address">; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./project.types.js"; | ||
export * from "./round.types.js"; | ||
export * from "./changeset.types.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export type { AnyProtocolEvent, Address, Branded, ChainId } from "./internal.js"; | ||
export type * from "./types/index.js"; | ||
export type { Address } from "./internal.js"; | ||
export { NATIVE_TOKEN_ADDRESS, isNativeToken } from "./constants/index.js"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a better description here, giving more detail about the contracts and what should process function does. (Factory+process)
Or should be more abstracted as it is ? wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you think Contract should be explained here? I was thinking the latter, a more abstract description. (We can go deeper in readme)