-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces the `linea.eth` plugin for Ponder indexer. The `linea.eth` plugin is very similar to the `eth` plugin. We can say it extends it (with minor naming alterations in some interfaces).
- Loading branch information
Showing
19 changed files
with
2,814 additions
and
179 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,29 +1,29 @@ | ||
import { ACTIVE_PLUGIN } from "./src/lib/plugin-helpers"; | ||
import { | ||
activate as activateEthBase, | ||
config as ethBaseConfig, | ||
ownedName as ethBaseOwnedName, | ||
} from "./src/plugins/base.eth/ponder.config"; | ||
import { | ||
activate as activateEth, | ||
config as ethConfig, | ||
ownedName as ethOwnedName, | ||
} from "./src/plugins/eth/ponder.config"; | ||
import * as baseEthPlugin from "./src/plugins/base.eth/ponder.config"; | ||
import * as ethPlugin from "./src/plugins/eth/ponder.config"; | ||
import * as lineaEthPlugin from "./src/plugins/linea.eth/ponder.config"; | ||
|
||
type AllConfigs = typeof ethConfig & typeof ethBaseConfig; | ||
const plugins = [baseEthPlugin, ethPlugin, lineaEthPlugin] as const; | ||
|
||
// here we export only a single 'plugin's config, by type it as every config | ||
// this makes all of the mapping types happy at typecheck-time, but only the relevant | ||
// config is run at runtime | ||
// this makes all of the mapping types happy at typecheck-time, but only the | ||
// relevant config is run at runtime | ||
export default ((): AllConfigs => { | ||
switch (ACTIVE_PLUGIN) { | ||
case ethOwnedName: | ||
activateEth(); | ||
return ethConfig as AllConfigs; | ||
case ethBaseOwnedName: | ||
activateEthBase(); | ||
return ethBaseConfig as AllConfigs; | ||
default: | ||
throw new Error(`Unsupported ACTIVE_PLUGIN: ${ACTIVE_PLUGIN}`); | ||
const pluginToActivate = plugins.find((p) => p.ownedName === ACTIVE_PLUGIN); | ||
|
||
if (!pluginToActivate) { | ||
throw new Error(`Unsupported ACTIVE_PLUGIN: ${ACTIVE_PLUGIN}`); | ||
} | ||
|
||
pluginToActivate.activate(); | ||
|
||
return pluginToActivate.config as AllConfigs; | ||
})(); | ||
|
||
// Helper type to get the intersection of all config types | ||
type IntersectionOf<T> = (T extends any ? (x: T) => void : never) extends (x: infer R) => void | ||
? R | ||
: never; | ||
// The type of the exported default is the intersection of all plugin configs to | ||
// each plugin can be correctly typechecked | ||
type AllConfigs = IntersectionOf<(typeof plugins)[number]["config"]>; |
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.