You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(wallet-toolbox): WERR_NETWORK_CHAIN is defined and deserialized but never thrown #541
@bsv/wallet-toolbox — src/sdk/WERR_errors.ts, src/sdk/WalletErrorFromJson.ts. Current on main at 82ab4d3c.
Defect
WERR_NETWORK_CHAIN is defined and faithfully deserialized, but nothing ever throws it. Occurrences across src/:
file
occurrences
sdk/WERR_errors.ts
2 (the class definition)
sdk/WalletErrorFromJson.ts
3 (the deserializer arm)
sdk/__test/WalletError.test.ts
5 (a round-trip test)
throw new WERR_NETWORK_CHAIN appears 0 times in src/.
Its message — "Configured network chain is invalid or does not match across services" — describes a real hazard, but absent a caller-side preflight a live sync between stores on different chains simply proceeds and merges. I found no chain comparison anywhere in WalletStorageManager's sync path or in EntitySyncState.
Minimal reproduction
Static: grep -rn "throw new WERR_NETWORK_CHAIN" src/ returns nothing, while the class and its deserializer arm both exist.
Expected behavior
Either the sync handshake compares chains and throws this error before any chunk moves (makeAvailable() settings already carry the chain), or the unused error class is removed so it does not read as an implemented guard.
Actual behavior and evidence
Defined, deserializable, never thrown. A reader encountering the class reasonably concludes cross-chain sync is guarded; it is not.
For anyone auditing this: src/storage/portable/index.tsdoes check for a chain mismatch, but only in the separate offline importBRC38 portable-import path, and it throws a bare Error, not WERR_NETWORK_CHAIN. That check does not cover the live syncToWriter/syncFromReader/processSyncChunk path this report is about and should not be mistaken for one that does.
Environment
Static analysis of main at 82ab4d3c; no runtime claim made.
Maintainer review: the live-sync chain guard remains valid work. Changes are requested on #551 because deleting exported WERR_NETWORK_CHAIN does not address cross-chain syncing and breaks existing imports/instance checks. Preserve its identity and JSON round trip; add chain preflight before the first live chunk/write, with tests for mismatched stores and zero destination mutation. Keep this issue open until the guard is implemented and its provider compatibility contract is explicit.
Activity
ty-everett commentedon Sep 23, 2026
Maintainer review: the live-sync chain guard remains valid work. Changes are requested on #551 because deleting exported
WERR_NETWORK_CHAINdoes not address cross-chain syncing and breaks existing imports/instance checks. Preserve its identity and JSON round trip; add chain preflight before the first live chunk/write, with tests for mismatched stores and zero destination mutation. Keep this issue open until the guard is implemented and its provider compatibility contract is explicit.fix(wallet-toolbox): remove unused WERR_NETWORK_CHAIN and ProcessSync…
fix(wallet-toolbox): wire live-sync chain preflight and ProcessSyncCh…
fix(wallet-toolbox): wire live-sync chain preflight and ProcessSyncCh…