-
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.
feat(ponder-ens): introduce plugin architecture (#3)
This change allows defining simple ponder plugins per supported subnames. Only one plugin can be active during indexing, and to select it, please set the `ACTIVE_PLUGIN` env var to the name of one of the available plugins (see `src/plugins` directory). For example: ``` ACTIVE_PLUGIN=eth ACTIVE_PLUGIN=base.eth ``` Also, please [make sure to know](https://ponder.sh/docs/getting-started/database#database-schema) how to use the `DATABASE_SCHEMA` env var. ### Examples Running indexer with the requested subname plugin for ponder: ``` ACTIVE_PLUGIN=base.eth DATABASE_SCHEMA=my_base_eth pnpm start ```
- Loading branch information
Showing
40 changed files
with
4,544 additions
and
602 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# RPC configuration | ||
# Follow the format: RPC_URL_{chainId}={rpcUrl} | ||
|
||
RPC_URL_1=https://ethereum-rpc.publicnode.com | ||
RPC_URL_8453=https://base-rpc.publicnode.com | ||
RPC_URL_59144=https://linea-rpc.publicnode.com | ||
|
||
# Identify which indexer plugin to activate (see `src/plugins` for available plugins) | ||
|
||
ACTIVE_PLUGIN=base.eth | ||
|
||
# Database configuration | ||
|
||
# This is where the indexer will create the tables defined in ponder.schema.ts | ||
# No two indexer instances can use the same database schema at the same time. This prevents data corruption. | ||
# @link https://ponder.sh/docs/api-reference/database#database-schema-rules | ||
DATABASE_SCHEMA=subname_index_base.eth | ||
# The indexer will use Postgres with that as the connection string. If not defined, the indexer will use PSlite. | ||
DATABASE_URL=postgresql://dbuser:abcd1234@localhost:5432/my_database |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Static Analysis | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
biome-ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run Biome CI | ||
run: pnpm biome ci |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,98 +1,29 @@ | ||
import { createConfig, factory, mergeAbis } from "ponder"; | ||
import { http, getAbiItem } from "viem"; | ||
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 { BaseRegistrar } from "./abis/BaseRegistrar"; | ||
import { EthRegistrarController } from "./abis/EthRegistrarController"; | ||
import { EthRegistrarControllerOld } from "./abis/EthRegistrarControllerOld"; | ||
import { LegacyPublicResolver } from "./abis/LegacyPublicResolver"; | ||
import { NameWrapper } from "./abis/NameWrapper"; | ||
import { Registry } from "./abis/Registry"; | ||
import { Resolver } from "./abis/Resolver"; | ||
type AllConfigs = typeof ethConfig & typeof ethBaseConfig; | ||
|
||
// just for testing... | ||
const END_BLOCK = 12_000_000; | ||
|
||
const RESOLVER_ABI = mergeAbis([LegacyPublicResolver, Resolver]); | ||
|
||
const REGISTRY_OLD_ADDRESS = "0x314159265dd8dbb310642f98f50c066173c1259b"; | ||
const REGISTRY_ADDRESS = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; | ||
|
||
const BASE_REGISTRAR_ADDRESS = "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85"; | ||
const ETH_REGISTRAR_CONTROLLER_OLD_ADDRESS = "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5"; | ||
const ETH_REGISTRAR_CONTROLLER_ADDRESS = "0x253553366Da8546fC250F225fe3d25d0C782303b"; | ||
const NAME_WRAPPER_ADDRESS = "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401"; | ||
|
||
export default createConfig({ | ||
networks: { | ||
mainnet: { | ||
chainId: 1, | ||
transport: http(process.env.PONDER_RPC_URL_1), | ||
}, | ||
}, | ||
contracts: { | ||
RegistryOld: { | ||
network: "mainnet", | ||
abi: Registry, | ||
address: REGISTRY_OLD_ADDRESS, | ||
startBlock: 3327417, | ||
endBlock: END_BLOCK, | ||
}, | ||
Registry: { | ||
network: "mainnet", | ||
abi: Registry, | ||
address: REGISTRY_ADDRESS, | ||
startBlock: 9380380, | ||
endBlock: END_BLOCK, | ||
}, | ||
OldRegistryResolvers: { | ||
network: "mainnet", | ||
abi: RESOLVER_ABI, | ||
address: factory({ | ||
address: REGISTRY_OLD_ADDRESS, | ||
event: getAbiItem({ abi: Registry, name: "NewResolver" }), | ||
parameter: "resolver", | ||
}), | ||
startBlock: 9380380, | ||
endBlock: END_BLOCK, | ||
}, | ||
Resolver: { | ||
network: "mainnet", | ||
abi: RESOLVER_ABI, | ||
address: factory({ | ||
address: REGISTRY_ADDRESS, | ||
event: getAbiItem({ abi: Registry, name: "NewResolver" }), | ||
parameter: "resolver", | ||
}), | ||
startBlock: 9380380, | ||
endBlock: END_BLOCK, | ||
}, | ||
BaseRegistrar: { | ||
network: "mainnet", | ||
abi: BaseRegistrar, | ||
address: BASE_REGISTRAR_ADDRESS, | ||
startBlock: 9380410, | ||
endBlock: END_BLOCK, | ||
}, | ||
EthRegistrarControllerOld: { | ||
network: "mainnet", | ||
abi: EthRegistrarControllerOld, | ||
address: ETH_REGISTRAR_CONTROLLER_OLD_ADDRESS, | ||
startBlock: 9380471, | ||
endBlock: END_BLOCK, | ||
}, | ||
EthRegistrarController: { | ||
network: "mainnet", | ||
abi: EthRegistrarController, | ||
address: ETH_REGISTRAR_CONTROLLER_ADDRESS, | ||
startBlock: Math.min(16925618, END_BLOCK), | ||
endBlock: END_BLOCK, | ||
}, | ||
NameWrapper: { | ||
network: "mainnet", | ||
abi: NameWrapper, | ||
address: NAME_WRAPPER_ADDRESS, | ||
startBlock: Math.min(16925608, END_BLOCK), | ||
endBlock: END_BLOCK, | ||
}, | ||
}, | ||
}); | ||
// 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 | ||
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}`); | ||
} | ||
})(); |
Oops, something went wrong.