Skip to content

Commit 28dcae6

Browse files
authored
feat: registry processor (#14)
# 🤖 Linear Closes GIT-86 GIT-87 GIT-88 GIT-89 ## Description - `RegistryProcessor` - `RoleGrantedHandler` - `ProfileCreatedHandler` ## Checklist before requesting a review - [x] I have conducted a self-review of my code. - [x] I have conducted a QA. - [x] If it is a core feature, I have included comprehensive tests.
2 parents 36e26eb + 38aff32 commit 28dcae6

27 files changed

+961
-66
lines changed

apps/indexer/config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ contracts:
1515
handler: src/handlers/Allo.ts
1616
events:
1717
- event: PoolCreated(uint256 indexed poolId, bytes32 indexed profileId, address strategy, address token, uint256 amount, (uint256,string) metadata)
18-
- event: RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember)
1918
- event: PoolMetadataUpdated(uint256 indexed poolId, (uint256,string) metadata)
2019
- event: PoolFunded(uint256 indexed poolId, uint256 amount, uint256 fee)
21-
- event: RoleRevoked(uint64 indexed roleId, address indexed account)
20+
- event: RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
21+
- event: RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
2222
- name: Registry
2323
handler: src/handlers/Registry.ts
2424
events:
2525
- event: ProfileCreated(bytes32 indexed profileId, uint256 nonce, string name, (uint256,string) metadata, address owner, address anchor)
2626
- event: ProfileMetadataUpdated(bytes32 indexed profileId, (uint256,string) metadata)
2727
- event: ProfileNameUpdated(bytes32 indexed profileId, string name, address anchor)
2828
- event: ProfileOwnerUpdated(bytes32 indexed profileId, address owner)
29+
- event: RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
30+
- event: RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
31+
2932
- name: Strategy
3033
handler: src/handlers/Strategy.ts
3134
events:

apps/indexer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"dependencies": {
1515
"chai": "4.3.10",
16-
"envio": "2.4.1",
16+
"envio": "2.5.2",
1717
"ethers": "6.8.0",
1818
"yaml": "2.5.1"
1919
},

apps/indexer/pnpm-lock.yaml

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/indexer/src/handlers/Registry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
22
import { Registry } from "../../generated";
33

4+
// Handler for RoleGranted event
5+
Registry.RoleGranted.handler(async ({}) => {});
6+
7+
// Handler for RoleRevoked event
8+
Registry.RoleRevoked.handler(async ({}) => {});
9+
410
// Handler for ProfileCreated event
511
Registry.ProfileCreated.handler(async ({}) => {});
612

packages/indexer-client/test/unit/envioIndexerClient.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ describe("EnvioIndexerClient", () => {
5252
srcAddress: "0x1234567890123456789012345678901234567890",
5353
logIndex: 0,
5454
params: { contractAddress: "0x1234" },
55-
transactionFields: { hash: "0x1234", transactionIndex: 0 },
55+
transactionFields: {
56+
hash: "0x123",
57+
transactionIndex: 1,
58+
},
5659
},
5760
];
5861

packages/indexer-client/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["src/**/*"]
3+
"include": ["src/**/*", "test/**/*"]
44
}

packages/processors/src/allo/handlers/poolCreated.handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { getToken } from "@grants-stack-indexer/shared/dist/src/internal.js";
77

88
import type { IEventHandler, ProcessorDependencies, StrategyTimings } from "../../internal.js";
99
import { getRoundRoles } from "../../helpers/roles.js";
10-
import { RoundMetadataSchema } from "../../helpers/schemas.js";
1110
import { extractStrategyFromId, getStrategyTimings } from "../../helpers/strategy.js";
1211
import { calculateAmountInUsd } from "../../helpers/tokenMath.js";
1312
import { TokenPriceNotFoundError } from "../../internal.js";
13+
import { RoundMetadataSchema } from "../../schemas/index.js";
1414

1515
type Dependencies = Pick<
1616
ProcessorDependencies,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {
2+
ChainId,
3+
ContractName,
4+
ContractToEventName,
5+
ProtocolEvent,
6+
} from "@grants-stack-indexer/shared";
7+
8+
import { ProcessorDependencies } from "../types/processor.types.js";
9+
import { IEventHandler } from "./index.js";
10+
11+
export interface IEventHandlerFactory<C extends ContractName, E extends ContractToEventName<C>> {
12+
createHandler(
13+
event: ProtocolEvent<C, E>,
14+
chainId: ChainId,
15+
dependencies: ProcessorDependencies,
16+
): IEventHandler<C, E>;
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./processor.interface.js";
2+
export * from "./factory.interface.js";
23
export * from "./eventHandler.interface.js";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./profileCreated.handler.js";
2+
export * from "./roleGranted.handler.js";

0 commit comments

Comments
 (0)