Skip to content

Commit

Permalink
fix(plugins): lazy-loaded config (#46)
Browse files Browse the repository at this point in the history
* fix(plugins): lazy-loaded config

Defer exectuing the networks config object for each plugin, so that the env vars validation could become optional and only done for the activated plugins

Resolves #37

* chore(code-style): apply auto-fixes
  • Loading branch information
tk-o authored Jan 21, 2025
1 parent 5413bc0 commit 699310f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/plugins/base.eth/ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ const END_BLOCK: ContractConfig["endBlock"] = undefined;

export const config = createConfig({
networks: {
base: {
chainId: base.id,
transport: http(rpcEndpointUrl(base.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(base.id),
get base() {
return {
chainId: base.id,
transport: http(rpcEndpointUrl(base.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(base.id),
};
},
},
contracts: {
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/eth/ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ const REGISTRY_ADDRESS = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";

export const config = createConfig({
networks: {
mainnet: {
chainId: mainnet.id,
transport: http(rpcEndpointUrl(mainnet.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(mainnet.id),
get mainnet() {
return {
chainId: mainnet.id,
transport: http(rpcEndpointUrl(mainnet.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(mainnet.id),
};
},
},
contracts: {
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/linea.eth/ponder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ const END_BLOCK: ContractConfig["endBlock"] = undefined;

export const config = createConfig({
networks: {
linea: {
chainId: linea.id,
transport: http(rpcEndpointUrl(linea.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(linea.id),
get linea() {
return {
chainId: linea.id,
transport: http(rpcEndpointUrl(linea.id)),
maxRequestsPerSecond: rpcMaxRequestsPerSecond(linea.id),
};
},
},
contracts: {
Expand Down

0 comments on commit 699310f

Please sign in to comment.