Merged
Conversation
598a7fc to
87becd1
Compare
87becd1 to
c328345
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors database YAML config parsing to be generic (mapping arbitrary YAML keys to ${key}Databases), updates config property names to match YAML keys (nfts/dexes/contracts), and wires the new names through route code.
Changes:
- Refactor
loadDbsConfigto generically map network-level YAML keys into typed${key}Databasesmaps and return an always-initialized config object. - Rename config accessors across routes (
dexDatabases→dexesDatabases,nftDatabases→nftsDatabases,contractDatabases→contractsDatabases). - Add
loadDbsConfigunit tests and extend the example YAML (including a Polymarket stanza).
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config/dbsConfig.ts | Implements generic YAML-to-{key}Databases parsing and updates parsed config typing. |
| src/config/dbsConfig.spec.ts | Adds unit tests for loadDbsConfig. |
| src/config.ts | Spreads parsed DB maps into runtime config and updates network derivation to renamed maps. |
| src/clickhouse/client.ts | Updates cluster lookup to use renamed maps and includes new maps. |
| src/supported-routes.ts | Updates DB category map to use renamed config properties. |
| src/supported-routes.spec.ts | Updates tests to use renamed config properties. |
| src/banner.ts | Updates logging to use renamed config properties. |
| src/routes/networks.ts | Updates dex DB reference to renamed config property. |
| src/routes/health.ts | Updates DB fallback selection to renamed config properties. |
| src/routes/transfers/svm.ts | Updates dex DB reference to renamed config property. |
| src/routes/swaps/{evm,svm,tvm}.ts | Updates dex DB reference to renamed config property. |
| src/routes/pools/{evm,svm,tvm}.ts | Updates dex DB reference to renamed config property. |
| src/routes/ohlcv/{evm,svm,tvm}.ts | Updates dex DB reference to renamed config property. |
| src/routes/dexes/{evm,svm,tvm}.ts | Updates dex DB reference to renamed config property. |
| src/routes/nft/*.ts | Updates NFT/contracts DB references to renamed config properties. |
| dbs-config.yaml.example | Updates documentation and adds a Polymarket example entry. |
Comments suppressed due to low confidence (1)
src/config.ts:364
config.networksis built solely fromevmNetworks,svmNetworks, andtvmNetworks, which in turn are derived only from balances/transfers/nfts/dexes/contracts maps and strict type checks (=== 'evm'|'svm'|'tvm'). Any network present only in newly added maps (e.g.polymarketDatabases/scraperDatabases) or with a nonstandardtypewill never appear inconfig.networks, which can break endpoints/schemas that rely onconfig.networksas the canonical network list. If the intent is to support these as real networks, consider including the new maps (and/or a new network-type bucket) in the network list derivation.
.transform((data) => ({
...data,
evmNetworks: Object.keys({
...data.balancesDatabases,
...data.transfersDatabases,
...data.nftsDatabases,
...data.dexesDatabases,
...data.contractsDatabases,
})
.filter((networkId) => {
return (
{
...data.balancesDatabases,
...data.transfersDatabases,
...data.nftsDatabases,
...data.dexesDatabases,
...data.contractsDatabases,
}[networkId]?.type === 'evm'
);
})
.sort(),
svmNetworks: Object.keys({
...data.balancesDatabases,
...data.transfersDatabases,
...data.nftsDatabases,
...data.dexesDatabases,
...data.contractsDatabases,
})
.filter((networkId) => {
return (
{
...data.balancesDatabases,
...data.transfersDatabases,
...data.nftsDatabases,
...data.dexesDatabases,
...data.contractsDatabases,
}[networkId]?.type === 'svm'
);
})
.sort(),
tvmNetworks: Object.keys({
...data.transfersDatabases,
...data.dexesDatabases,
})
.filter((networkId) => {
return (
{
...data.transfersDatabases,
...data.dexesDatabases,
}[networkId]?.type === 'tvm'
);
})
.sort(),
}))
.transform((data) => ({
...data,
networks: [...data.evmNetworks, ...data.svmNetworks, ...data.tvmNetworks],
}))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace hardcoded database field parsing in dbsConfig with a generic
loop that maps any YAML key to `${key}Databases`. This allows adding
new database types (e.g., Polymarket) without modifying the schema.
- NetworkConfigSchema uses `.catchall(z.string())` for database keys
- Rename `nftDatabases` → `nftsDatabases`, `dexDatabases` → `dexesDatabases`,
`contractDatabases` → `contractsDatabases` to match YAML key names
- Add Polymarket entry to dbs-config.yaml.example
- Add dbsConfig unit tests
Refs: #461
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c328345 to
2325c93
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dbsConfig.tswith a generic loop that maps any YAML key to${key}Databasesdbs-config.yamlwithout modifying the Zod schema — only theParsedDbsConfiginterface needs a new propertynftDatabases→nftsDatabases,dexDatabases→dexesDatabases,contractDatabases→contractsDatabasesto align with YAML key names (nfts,dexes,contracts)dbs-config.yaml.exampleloadDbsConfigRefs: #461
🤖 Generated with Claude Code