generated from defi-wonderland/ts-turborepo-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,104 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { AnyEvent, ContractName, ProcessorEvent } from "@grants-stack-indexer/shared"; | ||
import { AnyEvent, ContractName, ProcessorEvent, stringify } from "@grants-stack-indexer/shared"; | ||
|
||
export class InvalidEvent extends Error { | ||
constructor(event: ProcessorEvent<ContractName, AnyEvent>) { | ||
super(`Event couldn't be processed: ${event}`); | ||
super(`Event couldn't be processed: ${stringify(event)}`); | ||
|
||
this.name = "InvalidEvent"; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/data-flow/src/interfaces/eventsRegistry.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import { AnyEvent, ContractName, ProcessorEvent } from "@grants-stack-indexer/shared"; | ||
|
||
/** | ||
* The events registry saves as a checkpoint to the last processed event by the system. | ||
* This is used to resume the indexing from the last processed event in case of an error or temporary interruption. | ||
*/ | ||
export interface IEventsRegistry { | ||
/** | ||
* Get the last processed event by the system | ||
* @returns The last processed event or undefined if no event has been processed yet. | ||
*/ | ||
getLastProcessedEvent(): Promise<ProcessorEvent<ContractName, AnyEvent> | undefined>; | ||
/** | ||
* Save the last processed event by the system | ||
* @param event - The event to save. | ||
*/ | ||
saveLastProcessedEvent(event: ProcessorEvent<ContractName, AnyEvent>): Promise<void>; | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/data-flow/src/interfaces/strategyRegistry.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
import { Address, Hex } from "viem"; | ||
|
||
/** | ||
* The strategy registry saves the mapping between the strategy address and the strategy id. Serves as a Cache | ||
* to avoid having to read from the chain to get the strategy id every time. | ||
*/ | ||
//TODO: implement a mechanism to record Strategy that we still don't have a corresponding handler | ||
// we need to store and mark that this strategy is not handled yet, so when it's supported we can process all of the pending events for it | ||
export interface IStrategyRegistry { | ||
/** | ||
* Get the strategy id by the strategy address | ||
* @param strategyAddress - The strategy address | ||
* @returns The strategy id or undefined if the strategy address is not registered | ||
*/ | ||
getStrategyId(strategyAddress: Address): Promise<Hex | undefined>; | ||
/** | ||
* Save the strategy id by the strategy address | ||
* @param strategyAddress - The strategy address | ||
* @param strategyId - The strategy id | ||
*/ | ||
saveStrategyId(strategyAddress: Address, strategyId: Hex): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.