Skip to content

fix: address 4 review findings in SuiBets exchange integration#663

Open
elpou88 wants to merge 7 commits into
pmxt-dev:mainfrom
elpou88:fix/suibets-review-findings
Open

fix: address 4 review findings in SuiBets exchange integration#663
elpou88 wants to merge 7 commits into
pmxt-dev:mainfrom
elpou88:fix/suibets-review-findings

Conversation

@elpou88
Copy link
Copy Markdown
Contributor

@elpou88 elpou88 commented May 25, 2026

Summary

Addresses all 4 findings from the code review of the SuiBets exchange integration.


Finding 1 — Hardcoded localhost URL → production URL

config.ts, api.ts, normalizer.ts, index.ts

All references to http://localhost:8080 replaced with https://www.suibets.com.
Added ALLOWED_HOSTS allowlist + validateBaseUrl() SSRF guard.

Finding 2 — HTML-response detection in error mapper

errors.ts

extractErrorMessage now detects when the response body is an HTML string (Cloudflare / nginx error page) and returns a human-readable [status] Server returned HTML instead of JSON message instead of leaking raw HTML into the error.

Finding 3 — Type guard + typed return for fetchRawPositions

fetcher.ts

  • Added isSuibetsRawOffer(value: unknown): value is SuibetsRawOffer type guard
  • fetchRawPositions now returns SuibetsRawPositions (typed struct) instead of unknown[]
  • createdOffers filtered through the guard before normalisation — prevents silent garbage output when matchedBets/parlays arrays are accidentally passed as offers

Finding 4 — SuiBetsOptions interface + walletAddress in SDK client

sdks/typescript/pmxt/client.ts

  • Added SuiBetsOptions interface with optional walletAddress and baseUrl
  • Wired through to SuiBetsExchange constructor so callers can pass a Sui wallet address for position fetching without casting

All changes are backwards-compatible. No new dependencies.

elpou88 added 7 commits May 25, 2026 19:42
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
- Use www.suibets.com as canonical base URL (no localhost)
- Add HTML-response detection in error mapper
- Add isSuibetsRawOffer type guard; typed fetchRawPositions return
- Add SuiBetsOptions + walletAddress to SDK client
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.

1 participant