Feat/amm registry - #335
Open
0x-r4bbit wants to merge 5 commits into
Open
Conversation
Split the AMM UI's known-tokens/known-pools loading into two concerns: - reading raw JSON bytes from a source (`readConfigFileBytes`, currently a local file at TOKENS_CONFIG / AMM_POOLS_CONFIG), and - parsing those bytes into the UI list (`parseTokensJson` / `parsePoolsJson`). The parsers are now source-agnostic, so a remote payload can feed the exact same validation and shaping. No behavior change: the local-file env-var path is preserved, including the fail-soft / skip-malformed-entry semantics.
Introduce apps/amm/src/RegistryLoader, a QObject that owns the known-tokens / known-pools snapshot and serves it to the backend's QtRO slots. The JSON parsers move here; AmmUiBackend now reads tokenList/poolList/resolveTokens from the loader's snapshot instead of re-parsing the config files inline. Add the refresh plumbing the UI will drive: - PROP(int registryRevision READONLY) — bumped on every snapshot refresh so QML replicas re-fetch the lists. - SLOT(void refreshRegistry()) — manual re-load. No behavior change: the source is still the local TOKENS_CONFIG / AMM_POOLS_CONFIG files. This is Phase 2a of docs/amm-registry-plan.md; Phase 2b reshapes RegistryLoader::refresh() into the async remote (AMM_REGISTRY_URL) fetch — manifest + deployment guard + disk cache — with the same snapshot contract.
When no local TOKENS_CONFIG / AMM_POOLS_CONFIG is set, RegistryLoader now loads the known-tokens / known-pools from a remote GitHub registry named by AMM_REGISTRY_URL: an async QNetworkAccessManager fetch of a registry.json manifest, then the tokens.json / pools.json it points at (resolved relative to the manifest URL). - Stale-while-revalidate: the on-disk cache is served immediately and revalidated against the network (the manifest `timestamp` is the freshness key); a failed/offline fetch keeps the last cache. - Deployment guard: a manifest whose programIds don't match the app's deployment (from configAccount) is rejected; a manifest that omits programIds is trusted. - Precedence unchanged: local files replace the remote source when set; user custom tokens still merge on top. - registryRevision bumps on each snapshot update; SwapPage/PoolsPage/ LiquidityPage re-fetch on it. CMake links Qt6::Network. Add apps/amm/registry-sample/ — a manifest plus empty tokens.json / pools.json and a README — to exercise the remote path end to end (start with the empty case). Compile-verified via `nix build .#amm-ui`; not yet run end to end.
Replace the per-network manifest + separate tokens.json/pools.json with a single
Uniswap-token-list-style document: { networks:[{id,name,programIds}],
tokens:[{network,...}], pools:[{network,...}] }. RegistryLoader now fetches one
file, selects the active network, and filters entries to it.
- Active network = AMM_NETWORK (override) -> else the network whose programIds
match the connected deployment (configAccount) -> else the lone network. The
programIds match doubles as the deployment guard.
- Registry lives in-repo at artifacts/amm-registry.json (no separate repo yet);
remove apps/amm/registry-sample/.
- Rename setExpectedProgramIds -> setConnectedProgramIds (drives selection + guard);
add activeNetwork(). Local dev source (bare arrays) is unchanged.
setup-amm-testnet.sh now also writes tests/testnet/amm-registry.json — the seeded tokens/pools in the single-file multi-network registry shape (one "local" network with empty programIds so the lone-network rule auto-selects it; holding-agnostic tokens; a fresh timestamp each run). This lets the AMM_REGISTRY_URL path be exercised against the local sequencer without hosting anything — point AMM_REGISTRY_URL at the file with a file:// URL.
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.
No description provided.