Skip to content

fix(typescript): replace any with proper types for Exchange router methods#1419

Open
AbhilashG12 wants to merge 3 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/typescript-router-params
Open

fix(typescript): replace any with proper types for Exchange router methods#1419
AbhilashG12 wants to merge 3 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/typescript-router-params

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

What this PR does

Adds proper TypeScript types to Exchange router methods.

The Problem

Five Exchange methods used params?: any instead of typed params:

  • fetchMarketMatches
  • fetchEventMatches
  • compareMarketPrices
  • fetchMatchedPrices
  • fetchArbitrage

The Fix

  • Added typed param interfaces in router.ts
  • Updated all five methods to use proper types
  • Added proper return types

Why it matters

TypeScript users now get proper type checking when calling these methods.

Fixes #1403

…thods

- fetchMarketMatches: any → typed params + MatchResult[]
- fetchEventMatches: any → typed params + EventMatchResult[]
- compareMarketPrices: any → typed params + PriceComparison[]
- fetchMatchedPrices: any → typed params + PriceComparison[]
- fetchArbitrage: any → typed params + ArbitrageOpportunity[]

Fixes pmxt-dev#1403
- Sync with BaseExchange.ts
- Remove fetchEventsPaginated (not in BaseExchange)

Fixes pmxt-dev#1403
@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: FAIL

What This Does

This PR is intended to tighten TypeScript SDK typings for router/matching methods. In the final head commit, however, the regenerated client.ts reverts those router methods back to any and removes hosted-mode dispatch branches for several trading/account methods, which would matter directly to hosted SDK consumers.

Blast Radius

TypeScript SDK only (sdks/typescript/pmxt/client.ts), affecting router/matching method type surfaces and hosted trading/account reads/writes (cancelOrder, fetchOrder, fetchOpenOrders, fetchMyTrades, fetchPositions, fetchBalance).

Consumer Verification

Before (base branch):
Static inspection of the base TypeScript SDK shows hosted-mode dispatch exists for these methods; for example cancelOrder calls _hostedCancelOrder(orderId) before falling back to the local sidecar route, and fetchPositions uses HOSTED_METHOD_ROUTES + _tradingRequest to call hosted /api/p2p/my-style routes.

After (PR branch):
On PR head d33d23d8, sdks/typescript/pmxt/client.ts:1168 cancelOrder, :1194 fetchOrder, :1220 fetchOpenOrders, :1246 fetchMyTrades, :1324 fetchPositions, and :1350 fetchBalance no longer check this.isHosted and instead post to ${baseUrl}/api/${exchangeName}/<method> with sidecar-style { args, credentials }. A hosted SDK consumer with PMXT_API_KEY/hosted base URL would hit the wrong endpoint shape for these methods instead of the hosted route helpers.

Test Results

  • Build: NOT VERIFIED — npm run build --workspace=pmxtjs is blocked in this review checkout by missing generated SDK artifacts: pmxt/client.ts(15,8): error TS2307: Cannot find module '../generated/src/index.js' and pmxt/server-manager.ts(7,43): error TS2307.
  • Unit tests: NOT RUN because the TypeScript SDK build is blocked by missing generated artifacts.
  • Server starts: NOT RUN; this is an SDK-only change and build artifacts were missing.
  • E2E smoke: FAIL by static consumer-path trace for hosted SDK methods: the PR removes hosted dispatch and routes hosted consumers to sidecar-style endpoints.

Findings

  1. sdks/typescript/pmxt/client.ts:1168, 1194, 1220, 1246, 1324, 1350 — Blocking regression: the final regenerated client removes the hosted-mode branches for order/account methods. Those methods now always use /api/${exchangeName}/... sidecar calls with { args, credentials }, bypassing HOSTED_METHOD_ROUTES, _tradingRequest, resolveWalletAddress, and the hosted mappers. This breaks hosted TypeScript consumers for cancelOrder, fetchOrder, fetchOpenOrders, fetchMyTrades, fetchPositions, and fetchBalance.
  2. sdks/typescript/pmxt/client.ts:1450, 1477, 1525, 1603, 1650 — The stated fix is not present in the final head. fetchMarketMatches, fetchEventMatches, compareMarketPrices, fetchMatchedPrices, and fetchArbitrage are still declared as params?: any / Promise<any[]> (or params: any), so the PR does not resolve the any typing issue it claims to fix.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A
  • OpenAPI sync: N/A
  • Financial precision: N/A
  • Type safety: ISSUE — target router methods remain any in the final head.
  • Auth safety: ISSUE — hosted authenticated trading/account methods no longer use the hosted auth/route path.

Semver Impact

patch if fixed -- intended SDK type-only bug fix, but current head contains a breaking hosted SDK regression.

Risk

I could not run the full TypeScript build because generated SDK artifacts are absent in the review checkout, but the blocking issues above are visible in the checked-in source and do not depend on build output.

@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: FAIL

What This Does

This PR is intended to replace any with concrete TypeScript types for Exchange router/matching methods in the TypeScript SDK. At the current head, the generated client still exposes those methods as any, so the consumer-facing type-safety fix is not present.

Blast Radius

TypeScript SDK client method declarations in sdks/typescript/pmxt/client.ts, specifically exchange methods around router/matching APIs (fetchMarketMatches, fetchEventMatches, compareMarketPrices, fetchMatchedMarkets, fetchMatchedPrices, fetchArbitrage). Runtime HTTP dispatch is largely unchanged for those methods; the blast radius is the published TypeScript declaration/API surface.

Consumer Verification

Before (base branch):
The SDK client exposes the router/matching methods as broad any types, e.g.:

async fetchMarketMatches(params?: any): Promise<any[]>
async compareMarketPrices(params: any): Promise<any[]>

This is the issue the PR title/body says it fixes.

After (PR branch):
On current PR head dcf955103e384547fa66331e4eb10b4d07197070, the consumer-visible methods are still typed as any:

// sdks/typescript/pmxt/client.ts:1552
async fetchMarketMatches(params?: any): Promise<any[]>

// sdks/typescript/pmxt/client.ts:1602
async fetchEventMatches(params?: any): Promise<any[]>

// sdks/typescript/pmxt/client.ts:1627
async compareMarketPrices(params: any): Promise<any[]>

// sdks/typescript/pmxt/client.ts:1677
async fetchMatchedMarkets(params?: any): Promise<any[]>

So a TypeScript SDK consumer still receives no typed params/results for these Exchange methods.

Test Results

  • Build: PASS for npm run build --workspace=pmxt-core
  • Unit tests: PASS for core Jest suite (46 passed, 1 skipped; 809 passed, 3 skipped)
  • Server starts: PASS during root verification script
  • E2E smoke: NOT VERIFIED — root npm test then failed on environment setup (/usr/bin/python3: No module named pytest), and this PR is a type-surface change rather than a sidecar behavior change.

Findings

  1. sdks/typescript/pmxt/client.ts:1552, 1602, 1627, 1677 — The current PR head still publishes any params/results for the Exchange router/matching methods. This leaves the claimed fix unresolved for SDK consumers. The earlier typed method signatures shown in commit 1 were overwritten by the later regeneration commit, so the durable generated/source-of-truth output still contains any.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A — no response field/schema change.
  • OpenAPI sync: N/A for runtime schema; issue is generated TS client typing durability.
  • Financial precision: N/A.
  • Type safety: ISSUE — the target Exchange methods still expose any in the PR head.
  • Auth safety: N/A.

Semver Impact

patch -- intended type-only SDK fix, but the current head does not deliver the advertised type improvement.

Risk

Because client.ts is generated/regenerated, hand-editing it is not durable unless the generator/source-of-truth emits the typed signatures. The current regenerated output demonstrates the typed signatures were lost, so the published package would still have the original any problem.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript SDK Exchange client: router passthrough methods use params?: any instead of typed params

2 participants