Indexer: catalog and API for community tax tokens by code_id #594
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#594
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Depends on #592 (launcher events, code_id,
GetConfig). Sibling: dApp create/manage.Problem statement
The indexer discovers CW20s only as pair legs (
assetsupsert from factory pairs / swaps). It does not watch a token launcher, does not storecode_id/ manager / tax bps / SKUs, and cannot list “tokens created with this template.” The dApp and integrators need a read API: catalog by code_id, detail (taxes, features, admin attestation), and events (create, SKU enable, tax updates, mint, skim).Current codebase
indexer/migrations/20260310000001_initial_schema.sqlassets— address, denom, name, symbol, decimals, logos — nocode_id, no manager, no tax fields.indexer/src/indexer/pair_discovery.rs+ asset resolver. Tokens without a factory pair never appear.GET /api/v1/tokens,GET /api/v1/tokens/{addr},GET /api/v1/tokens/{addr}/pairs—indexer/src/api/tokens.rs. Pagination caps (limit≤ 500,offset≤ 10_000) perdocs/indexer-invariants.md.ContractInfoused for F6 freeze on pairs (asset_code_id_freeze.rs), not as a token catalog dimension.GET /api/v1/hooks— swap hook events, not token SKU events.internal_errsanitization, rate limits, no SQL in sort strings. CSV formula injection rules if any CSV is added (#432).Why needed
Launcher-created tokens must be reportable before or without a DEX pair (leaders will share a link). Swap/Trade need
code_id+ tax preview metadata. Ops need to see rogue instantiations (admin ≠ CMM) vs launcher-attested. Without indexer support the dApp would LCD-poll every token (slow, easy to DoS the LCD).Constraints / guardrails
code_id = COMMUNITY_TAX_CODE_IDand (recommended)wasm_admin = CMMandlauncher_txpresent. Query flags:?include_unattested=1for ops (not retail dApp).code_id/adminare source of truth; DB columns are a cache. Re-probe on a slow loop (similar to F6 60s) so migrate-off-template flipsattested/ freeze-adjacent flags.sort→ 400.DATABASE_URLor LCD bodies at INFO (#433).COMMUNITY_TAX_CODE_ID,COMMUNITY_TOKEN_LAUNCHER,CMM_GOVERNANCE_ADDR— unset → endpoints 404 or empty list withconfigured: false(pick one; document; prefer empty list +configured: falseon list, 404 on detail of non-catalog addr).make test-indexer-integrationwith Postgres.Relevant files
indexer/src/api/tokens.rs,indexer/src/api/mod.rs(router)indexer/migrations/,indexer/src/db/queries/assets.rsindexer/src/indexer/parser.rs(or newcommunity_token.rs),poller.rsindexer/src/lcd/mod.rs(get_contract_code_idalready exists)indexer/tests/api_*.rs, newapi_community_tokens.rsdocs/indexer-invariants.md,docs/integrators.md(optional)Recommended direction
community_tokens(or columns onassetsplus a side table — prefer side table to avoid bloating every LUNC/CW20 row):contract_addressPKcode_id,wasm_admin,manager,launcher_addressbuy_bps,sell_bps,transfer_bpsfeaturesJSONB / bitflagstreasury,attested_cmmboolcreated_at_block,instantiate_txupdated_atcreate_token/enable_feature/ tokenupdate_tax/mint/revoke_mintwasm events (stableaction=attrs — coordinate with contracts issue).GET /api/v1/community-tokens?manager=&limit=&offset=GET /api/v1/community-tokens/{addr}— config snapshot +attested_cmm+code_id+ pairs (reuse pair join)GET /api/v1/community-tokens/{addr}/eventsGET /api/v1/tokens/{addr}with optionalcommunity_tax: null | { ... }so Swap can branch without a second round-trip (keep payload small).{ configured, code_id, items: [...] }.Acceptance criteria
admin ≠ CMM(orattested_cmm=false); ops flag includes them.docs/indexer-invariants.mdrow;make verify-issue-NNN.--test-threads=1.Test plan (all paths)
[]/ configured true.include_unattested.manager=filter case-insensitive bech32 (document canonical lower/normalize).limit=-1/0clamp to 1; huge offset → 400./pairs; token without pair still in community list.attested_cmmfalse on next loop (mock LCD).GET /tokens/{addr}includescommunity_taxonly for matching code_id.Attack / abuse / hack test plan
manager,addr,sort.ContractInfoper list row on the request path (cache/probe loop only).launcher_txattested.ContractInfo.code_id, not event field alone.wasm_adminmust match env CMM exactly (full bech32).Verification criteria
make setup-indexer-postgresthenmake test-indexer-integration(or targetedcargo test --test api_community_tokens -- --test-threads=1).make verify-issue-NNN./tokens/{addr}/pairsnon-empty.Labels / owner / priority
backendenhancement· Owner: indexer · Priority: P2 · Blocked by: launcher event schema from contracts issuemarked as related to #592
marked as related to #593
mentioned in issue #592
When ingesting community-token events, index settings-fee txs (50 UST1 × N) separately from SKU unlocks so the dApp can show a paid-settings history. Coordinate action attrs with #592.
mentioned in issue #597
marked as related to #597
mentioned in merge request !1119
mentioned in issue #601
Columbus-5 pins (from #601, 2026-08-23)
Ingest 11611 only as the community-tax template. Launcher address is unset until code 11612 is instantiated (0 contracts on that id today). Prefer empty list +
configured: falseuntilCOMMUNITY_TOKEN_LAUNCHERis set.COMMUNITY_TAX_CODE_ID9D33BF2539A9A5B2F13FD4B321CDBD0B0FD86D936D5D6BD6681955FA30210EC2. Trust LCDContractInfo.code_id, not event fieldsCOMMUNITY_TOKEN_LAUNCHERlauncher_txonly from this contract once it existsCMM_GOVERNANCE_ADDR(attested wasm admin)terra16j5u6ey7a84g40sr3gd94nzg5w5fm45046k9s2347qhfpwm5fr6sem3lr2--adminfromcmm_governance. Default catalog:code_id=11611andwasm_admin=CMMand launcher tx presentterra1ejpgvv7g3hj0u6fpcnxhflqp84g0w3cnaskqkg5733ygwlmf963sfchsea[6036, 8266, 10184, 11611]as of height 30071160terra1f0eqgy9w7e5e7up97vjudqwx38tesf8ylx75x2lv3nwm0clry0pqmgfy72Do not scrape every CW20. Do not treat 11612/11613 instantiates as catalog tokens. ALPHA 8654 stays off.
Launcher address (columbus-5)
COMMUNITY_TOKEN_LAUNCHER=terra1af9xm63mev4hnf4z0nmmcsnd9f4lpac2vs205rmaeg3kdqlqudhq894lyzCOMMUNITY_TAX_CODE_IDCOMMUNITY_TOKEN_LAUNCHERterra1af9xm63mev4hnf4z0nmmcsnd9f4lpac2vs205rmaeg3kdqlqudhq894lyzCMM_GOVERNANCE_ADDRterra16j5u6ey7a84g40sr3gd94nzg5w5fm45046k9s2347qhfpwm5fr6sem3lr2Attest
launcher_txonly from this contract. InstantiateF7FCF13FB59148832AFA717FE3889830C19ACA33B18BFFB0122FB237BBDC2317height 30071219. List can flipconfigured: trueonce Coolify/indexer env is set.mentioned in commit
4ed227a4b1mentioned in commit
6916d274b8mentioned in merge request !1120
mentioned in commit
5acbe574f5mentioned in commit
e2b098ab72mentioned in issue #593
!1120 merge note (conflicts + AC)
!1120 is merged. Conflicts vs
main(#601) were docs/Makefile/launcher only; indexer catalog files auto-merged. Did not wait for CI.Automated AC re-run after the merge commit (
5acbe574):make verify-issue-594— PASS (3/3): I594 docs, no request-path LCD incommunity_tokens.rs,api_community_tokens9/9 sqlxStill open (not merge blockers — do not reopen this issue):
{ configured: false, items: [] }(I594-1). NeedCOMMUNITY_TAX_CODE_ID=11611,COMMUNITY_TOKEN_LAUNCHER=terra1af9xm63mev4hnf4z0nmmcsnd9f4lpac2vs205rmaeg3kdqlqudhq894lyz,CMM_GOVERNANCE_ADDR=terra16j5u6ey7a84g40sr3gd94nzg5w5fm45046k9s2347qhfpwm5fr6sem3lr2.attested_cmm) was not run against columbus-5 or a redeployed LocalTerra in this merge.Tracking: follow-up issue after this comment.
mentioned in issue #602
marked as related to #602
Post-merge leftovers tracked in #602 (do not reopen this issue).
Post-merge leftovers tracked in #602 (do not reopen this issue).
mentioned in issue #609
mentioned in merge request !1124
mentioned in issue #611
mentioned in issue #615
marked as related to #615
marked as related to #620
mentioned in issue #624
mentioned in issue #626
marked as related to #626