Repository navigation
Fix Unknown network for Simplex, LibertyX and Changelly - #244
Merged
Merged
Conversation
Pure extraction so the update decision can be unit tested without loading the query engine, which binds its Couch connection on import.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a15866e. Configure here.
A partner read that cannot resolve a chain (a catalog outage, an unmapped code) returns undefined chain fields. checkUpdateTx counted defined -> undefined as a change and the update wrote the fresh tx, so orders in the lookback window lost their stored chains and moved to "Unknown network". planTxUpdate now carries over any chain field the fresh read leaves undefined before deciding whether the order changed. A defined value, including a null tokenId, still replaces the stored one. This sits on the shared update path, so it covers every partner.
The Changelly catalog sends some blockchain codes in upper case ("BASE"),
so the case-sensitive lookup left those orders without a chain. Lowercase
the code before the lookup and map hyperevm, which Edge supports.
j0ntz
force-pushed
the
jon/reports-unknown-network
branch
from
November 10, 2026 06:54
a15866e to
c07ef0f
Compare
A single failed getCurrenciesFull call stored a whole run of orders without chain ids. Retry once, treating an empty catalog as a failure, before degrading to the empty map.
LibertyX only sells bitcoin, but its orders carried no payout chain, so dashboard v2 counted them under "Unknown network".
Simplex orders carried no payout chain, so dashboard v2 counted all of them under "Unknown network". Simplex crypto_currency codes are unique per chain, so a reversed copy of the app's SIMPLEX_ID_MAP resolves each one to a chain pluginId, EVM chain id and Edge tokenId. BNB resolves to BNB Smart Chain. Codes missing from the table (delisted assets) log a warning and keep the order without a payout chain.
Stored Simplex, LibertyX and Changelly orders written before the processor fixes have no chain ids, so the v2 dashboard keeps their volume under "Unknown network". backfillChainIds reprocesses each doc's rawTx with the current partner processor and fills only the chain fields the doc is missing (missingChainFields). A leg whose stored chain differs from the reprocessed one is left alone, and docs with nothing to fill are never written. Dry run is the default and prints, per partition, the docs scanned, the docs that would change with their dashboard USD, the currencies still without a payout chain, and how to rebuild the cache back to the oldest changed order. --apply writes the changed docs.
j0ntz
force-pushed
the
jon/reports-unknown-network
branch
from
November 10, 2026 07:45
c07ef0f to
e7a283c
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.

CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Description
Asana: task 1220274889691904
Simplex, LibertyX and Changelly volume showed as "Unknown network" in the v2 dashboard because their stored orders had no payout chain id. The processors now set it, and stored chain ids survive a degraded read. A backfill script fills the ids on orders already in Couch.
Changes
planTxUpdateinsrc/util/updateTx.tscarries a stored chain field over when a fresh read leaves itundefined(catalog outage, unmapped code). A defined value, including anullnative tokenId, still replaces it. The carry-over is per leg: a read that names a different chain for a leg takes that leg as read, which keeps an old token id off a new chain.queryEngineuses it, so that a degraded run can no longer move volume back to "Unknown network".hyperevmis mapped, and the currency catalog fetch retries once before giving up.bitcoinwith anulltokenId.src/partners/simplexCodes.tsholds a copy of the app'sSIMPLEX_ID_MAP(edge-react-guisrc/plugins/gui/providers/simplexProvider.ts, source named in the file comment; no runtime link to the GUI repo). Reversed, it maps eachcrypto_currencycode to payout chainPluginId, evmChainId and tokenId. BNB resolves tobinancesmartchain. Tokens with no Edge builtin get the chain and leave tokenId unknown. Codes missing from the table (delisted assets) log the usual unmapped warning.Backfill script
--applyis passed.<appId>_<partnerId>partition whose plugin is simplex, libertyx or changelly (or the one partition named). It selects docs missingdepositChainPluginIdorpayoutChainPluginIdand reprocesses each doc'srawTxwith the current processor.depositChainPluginIdstays absent and those docs match the selector on every run. Nothing is written for them; they only add scan time.Cache rebuild after
--applyThe v2 dashboard reads the reports_hour/day/month cache. The script prints the oldest changed doc's date and how many months back it is:
cacheLookbackMonths(default 24): the cache engine's next pass picks the change up."cacheLookbackMonths": <N>in config.json for onestart.cachepass and restore it, or delete the<partition>:00000000_initializeddoc from reports_month for each changed partition. The next pass then recomputes that partition from the start.Testing
npm testhas no failures. New tests cover the guard, Changelly case matching and retry, LibertyX, the Simplex reverse map, andmissingChainFields.tscclean.backfilltest_simplex: scanned 5, would change 2 ($350), with one delisted code (XYZOLD 1) reported unmapped;backfilltest_libertyx: scanned 1, would change 1 ($1,251); the Changelly partition skipped for missing keys; the oldest doc (68 months back) printed both rebuild options.--applywrote 3 docs (USDT-TRC20 to tron with tokenId, USDT-TON to ton, LibertyX to bitcoin with a null tokenId) and left a wrong-chain doc and a complete doc untouched. A re-run found 0 changes.The production dry run,
--apply, cache rebuild and deploy are Jon's steps.Test evidence
e7a283cAdd a chain id backfill script
2026-11-10
1. before unknown network
2. after backfill networks
4. c2 backfill exits after summary
C2 retest: Changelly retry and skip, summary, exit 0 in 1-2 s, no leftover node process, Changelly docs unchanged
Note
Medium Risk
Changes global transaction update merging in the query engine and adds a CouchDB write script; mis-use of --apply could alter stored orders, though guards limit overwrites to missing chain fields only.
Overview
Simplex, LibertyX, and Changelly orders previously lacked payout chain metadata, so v2 dashboard volume landed under "Unknown network". This PR teaches those processors to set
payoutChainPluginId/ EVM / token fields, prevents degraded partner reads from wiping chains already in Couch, and adds anpm run backfillChainIdspath to repair historical docs.Ingestion guard (all partners). New
planTxUpdate/keepKnownChainFieldsinsrc/util/updateTx.tspreserves stored chain fields when a fresh read leaves themundefined;queryEnginenow uses this instead of blind overwrites.Partner fixes. Simplex resolves
crypto_currencyvia newsimplexCodes.ts(GUI map copy). LibertyX always records native bitcoin payout. Changelly normalizes blockchain case, maps hyperevm, and retries the currency catalog once on failure.Backfill.
backfillChainIdsreprocessesrawTxfor affected partitions, fills only missing chain fields viamissingChainFields, dry-runs by default, and prints cache rebuild guidance after--apply.Reviewed by Cursor Bugbot for commit e7a283c. Bugbot is set up for automated code reviews on this repo. Configure here.