-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: control networks with ENABLED_NETWORKS env
Now you can use ENABLED_NETWORKS to decide what networks should be added.
- Loading branch information
Showing
4 changed files
with
44 additions
and
8 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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
/** | ||
* Array of enabled networks. Can be defined using ENABLED_NETWORKS environment variable | ||
* with comma-separated list of network names. | ||
*/ | ||
export const ENABLED_NETWORKS = process.env.ENABLED_NETWORKS | ||
? process.env.ENABLED_NETWORKS.split(',') | ||
: null; | ||
|
||
/** Infura API key used by default for network nodes. */ | ||
export const DEFAULT_INFURA_API_KEY = | ||
process.env.INFURA_API_KEY || '46a5dd9727bf48d4a132672d3f376146'; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Checkpoint, { | ||
BaseIndexer, | ||
CheckpointConfig | ||
} from '@snapshot-labs/checkpoint'; | ||
import { ENABLED_NETWORKS } from './config'; | ||
|
||
export function registerIndexer( | ||
instance: Checkpoint, | ||
indexerName: string, | ||
config: CheckpointConfig, | ||
indexer: BaseIndexer | ||
) { | ||
if (ENABLED_NETWORKS && !ENABLED_NETWORKS.includes(indexerName)) return; | ||
|
||
instance.addIndexer(indexerName, config, indexer); | ||
} |
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