Skip to content

fix(wallet-toolbox): WERR_NETWORK_CHAIN is defined and deserialized but never thrown #541

Description

@E-Jacko

Area

Wallet

Affected package or service and version

@bsv/wallet-toolboxsrc/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.ts does 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions