Skip to content

fix(typescript): build Router event markets as MarketList - #2111

Open
VaggelisGian wants to merge 1 commit into
pmxt-dev:mainfrom
VaggelisGian:fix/router-event-markets-marketlist
Open

fix(typescript): build Router event markets as MarketList#2111
VaggelisGian wants to merge 1 commit into
pmxt-dev:mainfrom
VaggelisGian:fix/router-event-markets-marketlist

Conversation

@VaggelisGian

Copy link
Copy Markdown

Fixes #2074

What was broken

Router's local convertEvent() in sdks/typescript/pmxt/router.ts built markets as a plain array, while UnifiedEvent.markets is declared as MarketList (an Array subclass with a .match(query) helper). Any caller doing result.event.markets.match(...) or result.markets.match(...) on data from Router.fetchEventMatches or Router.fetchMatchedEventClusters got TypeError: ...match is not a function, despite the type system promising MarketList. Python has no equivalent bug because router.py reuses the single _convert_event from client.py.

What changed

router.ts now builds the markets array with MarketList.from((raw.markets || []).map(convertMarket)) as MarketList, exactly matching the canonical converter in client.ts. This covers both call sites that use the local converter (fetchEventMatches and fetchMatchedEventClusters). No other behavior changes; the per-venue converters in client.ts are untouched.

Tests

Added sdks/typescript/tests/router-event-markets.test.ts following the existing router-sql-orderbook.test.ts fetch-spy pattern:

  • fetchEventMatches returns results whose .markets and .event.markets are both MarketList instances and on which .match() resolves the expected market.
  • fetchMatchedEventClusters returns clustered events whose markets are also MarketList.

Both tests fail without the fix (TypeError / not instanceof MarketList) and pass with it.

Verification

  • Full TypeScript SDK suite: 18 suites, 95 tests, all passing.
  • bash scripts/verify-all.sh on this branch: core jest 48/52 suites pass, python SDK 265 passed. The only failures are three pre-existing Windows-environment sandbox defects that fail identically on a clean checkout of main before any change of mine (core test/server/pmxt-ensure-server.test.ts plus two HOME-based sdks/python/tests/test_server_manager.py cases; they set env HOME but Node and Path.home() read USERPROFILE on win32). Upstream CI runs ubuntu-latest where these pass.

Router's local convertEvent() returned markets as a plain array, but
UnifiedEvent.markets is typed MarketList and callers rely on its
.match() helper, so results from fetchEventMatches and
fetchMatchedEventClusters threw TypeError on .match(). Build the array
with MarketList.from(...) exactly like the canonical converter in
client.ts does.

Fixes pmxt-dev#2074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant