Skip to content

fix: expose Polymarket auth initialization in SDKs#601

Merged
realfishsam merged 2 commits into
pmxt-dev:mainfrom
iccccccccccccc:fix-polymarket-init-auth-sdk
May 24, 2026
Merged

fix: expose Polymarket auth initialization in SDKs#601
realfishsam merged 2 commits into
pmxt-dev:mainfrom
iccccccccccccc:fix-polymarket-init-auth-sdk

Conversation

@iccccccccccccc

Copy link
Copy Markdown
Contributor

Fixes #505

Changes

  • add Polymarket.initAuth() to the TypeScript SDK
  • generate Polymarket.init_auth() for the Python SDK so it survives the exchange wrapper generator
  • add a small regression test that checks the Python wrapper keeps forwarding to the core initAuth method

Verification

  • node core/scripts/generate-python-exchanges.js
  • python -m pytest sdks/python/tests/test_public_exports.py
  • TypeScript syntax check via typescript.transpileModule on sdks/typescript/pmxt/client.ts
  • git diff --check

I couldn't run the full TypeScript package build in this Windows checkout: the clean script uses rm -rf, and generating the missing OpenAPI client locally needs Java, which isn't installed here.

@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: PASS (NOT VERIFIED)

Reviewed by: evidence-first bot review

What This Does

Exposes Polymarket.initAuth() in both SDKs. This method already exists in core (core/src/exchanges/polymarket/index.ts:142) but was unreachable from Python and TypeScript SDK consumers. The PR:

  1. TS SDK: Adds initAuth() to the Polymarket class in client.ts, plus a new sidecarPostRequest() helper on the base Exchange class for POST-only method dispatch.
  2. Python SDK: Adds init_auth() via the generate-python-exchanges.js generator (new methods override in OVERRIDES), so the method survives regeneration.
  3. Test: Adds an AST-based regression test verifying the generated Python wrapper calls _call_method("initAuth").

A second commit ("sync generated SDK surfaces") brings the branch up to date with current generator output -- this is unrelated to initAuth but all 6 CI checks pass, confirming it matches what the generators produce.

Blast Radius

In scope (commit 1):

  • core/scripts/generate-python-exchanges.js -- generator learns methods override
  • sdks/python/pmxt/_exchanges.py -- generated file, now includes init_auth()
  • sdks/typescript/pmxt/client.ts -- new sidecarPostRequest() on base class + initAuth() on Polymarket
  • sdks/python/tests/test_public_exports.py -- regression test

Out of scope but legitimate sync (commit 2):

  • sdks/python/pmxt/client.py -- removes _convert_params_to_camel from 5 methods, changes 9 return type annotations from specific types (MatchResult, PriceComparison, etc.) to List[Any]
  • sdks/typescript/pmxt/client.ts -- fetchMarketsPaginated param type MarketFetchParams -> any
  • Both API_REFERENCE.md files -- adds cursor to EventFetchParams, subaccount param to GetBalance

Findings

1. MEDIUM -- sidecarPostRequest duplicates existing POST logic
The new sidecarPostRequest() helper on the TS base Exchange class duplicates the POST fallback path already in sidecarReadRequest() (lines 597-610). This is functionally correct but adds ~20 lines of near-identical error handling. Not blocking, but worth noting for future consolidation.

2. LOW -- Python init_auth returns None explicitly
The generated Python method does self._call_method("initAuth") then return None. The _call_method already returns the parsed response (which will be None/undefined for a void method). The explicit return None is harmless but redundant.

3. INFO -- Type annotation downgrades in commit 2
Nine Python return types changed from specific classes (List[MatchResult], List[PriceComparison], List[ArbitrageOpportunity]) to List[Any], and one TS param type from MarketFetchParams to any. These pass CI ("Verify client.py/ts methods are up-to-date"), meaning the generators now produce these looser types. This is a separate concern from initAuth -- the contributor is just syncing to match generator output.

PMXT Pipeline Check

  • Field propagation: N/A (no new data fields)
  • OpenAPI sync: N/A (initAuth is Polymarket-specific, not a BaseExchange method, so no OpenAPI spec change needed)
  • Type safety: OK (both SDKs dispatch to the correct core method; no type mismatches on the initAuth path)
  • Auth safety: OK (initAuth stores credentials server-side only; the response is void/undefined -- no credentials flow back through the HTTP response to the SDK)

Semver Impact

Minor -- additive new public method on Polymarket class in both SDKs. No breaking changes. Backward-compatible.

Risk

Low. The initAuth path is additive and only fires when explicitly called by the user. The sync changes in commit 2 are generator-validated by CI. The only concern is the type annotation downgrades (specific types to Any), but those are a pre-existing generator concern, not introduced by this PR's intent.

Core builds. TS SDK type-checks clean. All 6 CI checks pass.

@realfishsam realfishsam merged commit 7d1f36b into pmxt-dev:main May 24, 2026
6 checks passed
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.

Polymarket.initAuth() is in core and documented in both SDK API references but missing from both SDK source files

2 participants