From ab9182a27ba55da32ca22cd0c9c168280ba63642 Mon Sep 17 00:00:00 2001 From: AbhilashG12 Date: Tue, 30 Jun 2026 19:32:19 +0530 Subject: [PATCH 1/4] fix(typescript): replace any with proper types for Exchange router methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 #1403 --- sdks/typescript/pmxt/client.ts | 53 ++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index 0c19edc9..c403b26e 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -45,6 +45,11 @@ import { UnifiedMarket, UnifiedSeries, UserTrade, + MatchResult, + EventMatchResult, + PriceComparison, + ArbitrageOpportunity, + MatchRelation, FirehoseEvent, FetchMatchedMarketClustersParams, } from "./models.js"; @@ -1517,7 +1522,18 @@ export abstract class Exchange { } } - async fetchMarketMatches(params?: any): Promise { + async fetchMarketMatches(params?: { + market?: UnifiedMarket; + marketId?: string; + slug?: string; + url?: string; + query?: string; + category?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1567,7 +1583,17 @@ export abstract class Exchange { } } - async fetchEventMatches(params?: any): Promise { + async fetchEventMatches(params?: { + event?: UnifiedEvent; + eventId?: string; + slug?: string; + query?: string; + category?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1592,7 +1618,12 @@ export abstract class Exchange { } } - async compareMarketPrices(params: any): Promise { + async compareMarketPrices(params: { + marketId: string; + targetMarketIds?: string[]; + minDifference?: number; + limit?: number; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1667,7 +1698,14 @@ export abstract class Exchange { } } - async fetchMatchedPrices(params?: any): Promise { + async fetchMatchedPrices(params?: { + marketId?: string; + slug?: string; + category?: string; + limit?: number; + minDifference?: number; + sort?: string; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1717,7 +1755,12 @@ export abstract class Exchange { } } - async fetchArbitrage(params?: any): Promise { + async fetchArbitrage(params?: { + minSpread?: number; + category?: string; + limit?: number; + relations?: MatchRelation | MatchRelation[]; +}): Promise { await this.initPromise; try { const args: any[] = []; From d33d23d8ab2d18a2046c710ef6e129b3cc39f166 Mon Sep 17 00:00:00 2001 From: AbhilashG12 Date: Tue, 30 Jun 2026 20:30:51 +0530 Subject: [PATCH 2/4] fix(typescript): regenerate client.ts from BaseExchange.ts - Sync with BaseExchange.ts - Remove fetchEventsPaginated (not in BaseExchange) Fixes #1403 --- sdks/typescript/pmxt/client.ts | 125 ++------------------------------- 1 file changed, 6 insertions(+), 119 deletions(-) diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index c403b26e..0ae199d5 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -968,36 +968,6 @@ export abstract class Exchange { } } - async fetchEventsPaginated(params?: any): Promise { - await this.initPromise; - try { - const args: any[] = []; - if (params !== undefined) args.push(params); - const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventsPaginated`, { - method: 'POST', - headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() }, - body: JSON.stringify({ args, credentials: this.getCredentials() }), - }); - if (!response.ok) { - const body = await response.json().catch(() => ({})); - if (body.error && typeof body.error === "object") { - throw fromServerError(body.error); - } - throw new PmxtError(body.error?.message || response.statusText); - } - const json = await response.json(); - const data = this.handleResponse(json); - return { - data: (data.data || []).map(convertEvent), - total: data.total, - nextCursor: data.nextCursor, - }; - } catch (error) { - if (error instanceof PmxtError) throw error; - throw new PmxtError(`Failed to fetchEventsPaginated: ${error}`); - } - } - async fetchEvents(params?: EventFetchParams): Promise { await this.initPromise; try { @@ -1197,9 +1167,6 @@ export abstract class Exchange { async cancelOrder(orderId: string): Promise { await this.initPromise; - if (this.isHosted) { - return this._hostedCancelOrder(orderId); - } try { const args: any[] = []; args.push(orderId); @@ -1226,12 +1193,6 @@ export abstract class Exchange { async fetchOrder(orderId: string): Promise { await this.initPromise; - if (this.isHosted) { - const route = HOSTED_METHOD_ROUTES.get("fetchOrder")!; - const path = formatRoutePath(route, { order_id: orderId }); - const data = await _tradingRequest(this, { method: route.method, path }); - return orderFromV0(data as Record); - } try { const args: any[] = []; args.push(orderId); @@ -1258,18 +1219,6 @@ export abstract class Exchange { async fetchOpenOrders(marketId?: string): Promise { await this.initPromise; - if (this.isHosted) { - const resolvedAddress = resolveWalletAddress(this, undefined); - const route = HOSTED_METHOD_ROUTES.get("fetchOpenOrders")!; - const path = formatRoutePath(route, {}); - const params: Record = { address: resolvedAddress }; - if (marketId !== undefined) params.market_id = marketId; - const data = await _tradingRequest(this, { method: route.method, path, params }); - const list = Array.isArray(data) - ? data - : (data && Array.isArray((data as any).orders) ? (data as any).orders : []); - return list.map((o: unknown) => orderFromV0(o as Record)); - } try { const args: any[] = []; if (marketId !== undefined) args.push(marketId); @@ -1296,14 +1245,6 @@ export abstract class Exchange { async fetchMyTrades(params?: MyTradesParams): Promise { await this.initPromise; - if (this.isHosted) { - const resolvedAddress = resolveWalletAddress(this, undefined); - const route = HOSTED_METHOD_ROUTES.get("fetchMyTrades")!; - const path = formatRoutePath(route, { address: resolvedAddress }); - const data = await _tradingRequest(this, { method: route.method, path }); - const list = Array.isArray(data) ? data : (data && Array.isArray((data as any).trades) ? (data as any).trades : []); - return list.map((t: unknown) => userTradeFromV0(t as Record)); - } try { const args: any[] = []; if (params !== undefined) args.push(params); @@ -1382,14 +1323,6 @@ export abstract class Exchange { async fetchPositions(address?: string): Promise { await this.initPromise; - if (this.isHosted) { - const resolvedAddress = resolveWalletAddress(this, address); - const route = HOSTED_METHOD_ROUTES.get("fetchPositions")!; - const path = formatRoutePath(route, { address: resolvedAddress }); - const data = await _tradingRequest(this, { method: route.method, path }); - const list = Array.isArray(data) ? data : []; - return list.map((p) => positionFromV0(p as Record)); - } try { const args: any[] = []; if (address !== undefined) args.push(address); @@ -1416,14 +1349,6 @@ export abstract class Exchange { async fetchBalance(address?: string): Promise { await this.initPromise; - if (this.isHosted) { - const resolvedAddress = resolveWalletAddress(this, address); - const route = HOSTED_METHOD_ROUTES.get("fetchBalance")!; - const path = formatRoutePath(route, { address: resolvedAddress }); - const data = await _tradingRequest(this, { method: route.method, path }); - const list = Array.isArray(data) ? data : []; - return list.map((b) => balanceFromV0(b as Record)); - } try { const args: any[] = []; if (address !== undefined) args.push(address); @@ -1522,18 +1447,7 @@ export abstract class Exchange { } } - async fetchMarketMatches(params?: { - market?: UnifiedMarket; - marketId?: string; - slug?: string; - url?: string; - query?: string; - category?: string; - relation?: MatchRelation; - minConfidence?: number; - limit?: number; - includePrices?: boolean; -}): Promise { + async fetchMarketMatches(params?: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1583,17 +1497,7 @@ export abstract class Exchange { } } - async fetchEventMatches(params?: { - event?: UnifiedEvent; - eventId?: string; - slug?: string; - query?: string; - category?: string; - relation?: MatchRelation; - minConfidence?: number; - limit?: number; - includePrices?: boolean; -}): Promise { + async fetchEventMatches(params?: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1618,12 +1522,7 @@ export abstract class Exchange { } } - async compareMarketPrices(params: { - marketId: string; - targetMarketIds?: string[]; - minDifference?: number; - limit?: number; -}): Promise { + async compareMarketPrices(params: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1673,7 +1572,7 @@ export abstract class Exchange { } } - async fetchMatchedMarkets(params?: FetchMatchedMarketClustersParams): Promise { + async fetchMatchedMarkets(params?: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1698,14 +1597,7 @@ export abstract class Exchange { } } - async fetchMatchedPrices(params?: { - marketId?: string; - slug?: string; - category?: string; - limit?: number; - minDifference?: number; - sort?: string; -}): Promise { + async fetchMatchedPrices(params?: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1755,12 +1647,7 @@ export abstract class Exchange { } } - async fetchArbitrage(params?: { - minSpread?: number; - category?: string; - limit?: number; - relations?: MatchRelation | MatchRelation[]; -}): Promise { + async fetchArbitrage(params?: any): Promise { await this.initPromise; try { const args: any[] = []; From 6e6bb4a86acc6ccb649a61da91f3c892cfbfd3a9 Mon Sep 17 00:00:00 2001 From: AbhilashG12 Date: Sat, 4 Jul 2026 21:57:57 +0530 Subject: [PATCH 3/4] Merge and resolve conflicts --- sdks/typescript/pmxt/client.ts | 61 +++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index 52089467..3729e207 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -1264,10 +1264,7 @@ export abstract class Exchange { const route = HOSTED_METHOD_ROUTES.get("fetchOrder")!; const path = formatRoutePath(route, { order_id: orderId }); const data = await _tradingRequest(this, { method: route.method, path }); - const payload = data && typeof data === "object" && "order" in data - ? (data as { order: unknown }).order - : data; - return orderFromV0(payload as Record); + return orderFromV0(data as Record); } try { const args: any[] = []; @@ -1410,9 +1407,7 @@ export abstract class Exchange { const route = HOSTED_METHOD_ROUTES.get("fetchPositions")!; const path = formatRoutePath(route, { address: resolvedAddress }); const data = await _tradingRequest(this, { method: route.method, path }); - const list: unknown[] = Array.isArray(data) - ? data - : (data && Array.isArray((data as any).positions) ? (data as any).positions : []); + const list = Array.isArray(data) ? data : []; return list.map((p) => positionFromV0(p as Record)); } try { @@ -1446,9 +1441,7 @@ export abstract class Exchange { const route = HOSTED_METHOD_ROUTES.get("fetchBalance")!; const path = formatRoutePath(route, { address: resolvedAddress }); const data = await _tradingRequest(this, { method: route.method, path }); - const list: unknown[] = Array.isArray(data) - ? data - : (data && Array.isArray((data as any).balances) ? (data as any).balances : []); + const list = Array.isArray(data) ? data : []; return list.map((b) => balanceFromV0(b as Record)); } try { @@ -1549,7 +1542,18 @@ export abstract class Exchange { } } - async fetchMarketMatches(params?: any): Promise { + async fetchMarketMatches(params?: { + market?: UnifiedMarket; + marketId?: string; + slug?: string; + url?: string; + query?: string; + category?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1599,7 +1603,17 @@ export abstract class Exchange { } } - async fetchEventMatches(params?: any): Promise { + async fetchEventMatches(params?: { + event?: UnifiedEvent; + eventId?: string; + slug?: string; + query?: string; + category?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1624,7 +1638,12 @@ export abstract class Exchange { } } - async compareMarketPrices(params: any): Promise { + async compareMarketPrices(params: { + marketId: string; + targetMarketIds?: string[]; + minDifference?: number; + limit?: number; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1699,7 +1718,14 @@ export abstract class Exchange { } } - async fetchMatchedPrices(params?: any): Promise { + async fetchMatchedPrices(params?: { + marketId?: string; + slug?: string; + category?: string; + limit?: number; + minDifference?: number; + sort?: string; +}): Promise { await this.initPromise; try { const args: any[] = []; @@ -1749,7 +1775,12 @@ export abstract class Exchange { } } - async fetchArbitrage(params?: any): Promise { + async fetchArbitrage(params?: { + minSpread?: number; + category?: string; + limit?: number; + relations?: MatchRelation | MatchRelation[]; +}): Promise { await this.initPromise; try { const args: any[] = []; From 42c27cedf6ff48a6aec662771d4c0be3338c93c7 Mon Sep 17 00:00:00 2001 From: AbhilashG12 Date: Sat, 4 Jul 2026 21:54:05 +0530 Subject: [PATCH 4/4] fix(typescript): add router method parameter types to models.ts - Add FetchMarketMatchesParams interface - Add FetchEventMatchesParams interface - Add CompareMarketPricesParams interface - Add FetchMatchedPricesParams interface - Add FetchArbitrageParams interface - Import all types in client.ts Fixes #1403 --- sdks/typescript/pmxt/client.ts | 66 +++++------------ sdks/typescript/pmxt/models.ts | 72 +++++++++++++++++++ .../scripts/generate-client-methods.js | 20 ++++++ 3 files changed, 109 insertions(+), 49 deletions(-) diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index 3729e207..1b98f44a 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -45,13 +45,19 @@ import { UnifiedMarket, UnifiedSeries, UserTrade, + FirehoseEvent, + MatchRelation, + FetchMatchedMarketClustersParams, + FetchMarketMatchesParams, + FetchEventMatchesParams, + CompareMarketPricesParams, + FetchMatchedPricesParams, + FetchArbitrageParams, MatchResult, EventMatchResult, PriceComparison, ArbitrageOpportunity, - MatchRelation, - FirehoseEvent, - FetchMatchedMarketClustersParams, + } from "./models.js"; import { ServerManager } from "./server-manager.js"; @@ -1542,18 +1548,7 @@ export abstract class Exchange { } } - async fetchMarketMatches(params?: { - market?: UnifiedMarket; - marketId?: string; - slug?: string; - url?: string; - query?: string; - category?: string; - relation?: MatchRelation; - minConfidence?: number; - limit?: number; - includePrices?: boolean; -}): Promise { + async fetchMarketMatches(params?: FetchMarketMatchesParams): Promise { await this.initPromise; try { const args: any[] = []; @@ -1578,7 +1573,7 @@ export abstract class Exchange { } } - async fetchMatches(params: any): Promise { + async fetchMatches(params: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1603,17 +1598,7 @@ export abstract class Exchange { } } - async fetchEventMatches(params?: { - event?: UnifiedEvent; - eventId?: string; - slug?: string; - query?: string; - category?: string; - relation?: MatchRelation; - minConfidence?: number; - limit?: number; - includePrices?: boolean; -}): Promise { + async fetchEventMatches(params?: FetchEventMatchesParams): Promise { await this.initPromise; try { const args: any[] = []; @@ -1638,12 +1623,7 @@ export abstract class Exchange { } } - async compareMarketPrices(params: { - marketId: string; - targetMarketIds?: string[]; - minDifference?: number; - limit?: number; -}): Promise { + async compareMarketPrices(params: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1668,7 +1648,7 @@ export abstract class Exchange { } } - async fetchRelatedMarkets(params: any): Promise { + async fetchRelatedMarkets(params: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1718,14 +1698,7 @@ export abstract class Exchange { } } - async fetchMatchedPrices(params?: { - marketId?: string; - slug?: string; - category?: string; - limit?: number; - minDifference?: number; - sort?: string; -}): Promise { + async fetchMatchedPrices(params?: FetchMatchedPricesParams): Promise { await this.initPromise; try { const args: any[] = []; @@ -1750,7 +1723,7 @@ export abstract class Exchange { } } - async fetchHedges(params: any): Promise { + async fetchHedges(params: any): Promise { await this.initPromise; try { const args: any[] = []; @@ -1775,12 +1748,7 @@ export abstract class Exchange { } } - async fetchArbitrage(params?: { - minSpread?: number; - category?: string; - limit?: number; - relations?: MatchRelation | MatchRelation[]; -}): Promise { + async fetchArbitrage(params?: FetchArbitrageParams): Promise { await this.initPromise; try { const args: any[] = []; diff --git a/sdks/typescript/pmxt/models.ts b/sdks/typescript/pmxt/models.ts index fc5ca349..0f88d0c8 100644 --- a/sdks/typescript/pmxt/models.ts +++ b/sdks/typescript/pmxt/models.ts @@ -1,3 +1,75 @@ + + + +// ===== Router Method Parameter Types ===== + +/** + * Parameters for fetchMarketMatches + */ +export interface FetchMarketMatchesParams { + query?: string; + category?: string; + market?: UnifiedMarket; + marketId?: string; + slug?: string; + url?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; + minDifference?: number; + sort?: string; +} + +/** + * Parameters for fetchEventMatches + */ +export interface FetchEventMatchesParams { + query?: string; + category?: string; + event?: UnifiedEvent; + eventId?: string; + slug?: string; + relation?: MatchRelation; + minConfidence?: number; + limit?: number; + includePrices?: boolean; +} + +/** + * Parameters for compareMarketPrices + */ +export interface CompareMarketPricesParams { + marketId: string; + targetMarketIds?: string[]; + minDifference?: number; + limit?: number; +} + +/** + * Parameters for fetchMatchedPrices + */ +export interface FetchMatchedPricesParams { + marketId?: string; + slug?: string; + category?: string; + limit?: number; + minDifference?: number; + sort?: string; +} + +/** + * Parameters for fetchArbitrage + */ +export interface FetchArbitrageParams { + minSpread?: number; + category?: string; + limit?: number; + relations?: MatchRelation | MatchRelation[]; +} + + + /** * Data models for PMXT TypeScript SDK. * diff --git a/sdks/typescript/scripts/generate-client-methods.js b/sdks/typescript/scripts/generate-client-methods.js index d32faf2b..d33e9599 100644 --- a/sdks/typescript/scripts/generate-client-methods.js +++ b/sdks/typescript/scripts/generate-client-methods.js @@ -88,6 +88,16 @@ const TYPE_MAP = { // Pagination wrapper — gets its own response handler PaginatedMarketsResult: { converter: null, pattern: 'paginatedMarkets' }, PaginatedEventsResult: { converter: null, pattern: 'paginatedEvents' }, + + 'FetchMarketMatchesParams': 'FetchMarketMatchesParams', + 'FetchEventMatchesParams': 'FetchEventMatchesParams', + 'CompareMarketPricesParams': 'CompareMarketPricesParams', + 'FetchMatchedPricesParams': 'FetchMatchedPricesParams', + 'FetchArbitrageParams': 'FetchArbitrageParams', + 'MatchResult': 'MatchResult', + 'EventMatchResult': 'EventMatchResult', + 'PriceComparison': 'PriceComparison', + 'ArbitrageOpportunity': 'ArbitrageOpportunity', }; // SDK types that can appear in generated signatures without extra imports @@ -101,6 +111,16 @@ const SDK_PARAM_TYPES = new Set([ 'MyTradesParams', 'OrderHistoryParams', 'CreateOrderParams', 'MarketFilterCriteria', 'EventFilterCriteria', 'SubscriptionOption', + + 'FetchMarketMatchesParams', + 'FetchEventMatchesParams', + 'CompareMarketPricesParams', + 'FetchMatchedPricesParams', + 'FetchArbitrageParams', + 'MatchResult', + 'EventMatchResult', + 'PriceComparison', + 'ArbitrageOpportunity', ]); // Parameter names that represent outcome IDs and should accept MarketOutcome.