feat(config): document paired per-network SAC and NFT watch-list env vars (#162) - #174
Conversation
|
@kaylachi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…e shared var resolveNftContractIds used ?? , which only skips undefined. #174 adds NFT_CONTRACT_IDS_TESTNET= / _MAINNET= to .env.example as blank placeholders, so anyone copying that file and setting only the shared NFT_CONTRACT_IDS would have had it shadowed by the empty string and indexed no explicitly-watched NFT contracts at all. resolveSacContractIds already used || and was unaffected.
Miracle656
left a comment
There was a problem hiding this comment.
Approved and merging.
The code half of #162 landed in #171; this closes it out with the .env.example half, and the pairing is documented in the right place — beside the shared var, with a worked mainnet/testnet example rather than an abstract note.
One thing this PR exposed, now fixed on main in 3a43c43. Declaring the per-network vars as blank placeholders is the correct thing for an example file, but resolveNftContractIds read them with ??, which only skips undefined:
process.env.NFT_CONTRACT_IDS_TESTNET ?? process.env.NFT_CONTRACT_IDS // => ""So anyone who copied .env.example and filled in only the shared NFT_CONTRACT_IDS would have had it shadowed by the empty string and watched no NFT contracts at all — with no error, just an indexer that quietly finds nothing. resolveSacContractIds already used || and was unaffected, which is why the asymmetry survived review in the first place.
Fixed to || with a regression test asserting an empty per-network var falls back to the shared one. Not your bug — your PR is what made it reachable, which is a good reason to have written the docs.
Thanks!
Closes #162
Summary of Changes
Adds documentation and verification for paired per-network SAC and NFT watch-list environment variables (
SAC_CONTRACT_IDS_TESTNET,SAC_CONTRACT_IDS_MAINNET,NFT_CONTRACT_IDS_TESTNET,NFT_CONTRACT_IDS_MAINNET), enabling dual-network and single-network deployments to configure distinct watch-lists per chain with backwards-compatible single-variable and per-network default fallbacks.Key Changes
Configuration & Documentation (
.env.example):SAC_CONTRACT_IDS_TESTNETandSAC_CONTRACT_IDS_MAINNETwith native XLM SAC defaults for testnet and mainnet.NFT_CONTRACT_IDS_TESTNETandNFT_CONTRACT_IDS_MAINNETfor explicit CAP-46 NFT tracking per network.Resolution Logic & Fallback Order (
src/indexer.ts):resolveSacContractIds(network): ResolvesSAC_CONTRACT_IDS_${NETWORK}->SAC_CONTRACT_IDS-> legacyCONTRACT_IDS-> network default native XLM SAC (DEFAULT_XLM_SAC_MAINNET/DEFAULT_XLM_SAC_TESTNET).resolveNftContractIds(network): ResolvesNFT_CONTRACT_IDS_${NETWORK}->NFT_CONTRACT_IDS-> empty array.Test Suite (
src/__tests__/multiNetworkIndexer.test.ts):Verification Status
npm test: All 13 test suites and 124 unit tests passing cleanly.kaylachi.kaylachi <309505611+kaylachi@users.noreply.github.com>.