Skip to content

Update Mango library to match current Manifold API - #7

Merged
jonnyspicer merged 24 commits into
mainfrom
update-api
Feb 15, 2026
Merged

jonnyspicer merged 24 commits into
mainfrom
update-api

Conversation

@jonnyspicer

Copy link
Copy Markdown
Owner

Summary

  • 13 new API endpoints: user lite/portfolio, market prob, multi-bet, transactions, managram, leagues, bounties, post answer
  • 5 bug fixes: Pool struct, unexported JSON fields in CloseMarket/AddMarketToGroup, PostComment URL, Fees int64→float64
  • Infrastructure: authenticated GET requests, error response bodies, Go 1.21, SearchMarkets full params (breaking change)
  • Testing: 27 unit tests (httptest mocks) + 26 integration tests behind //go:build integration tag; legacy real-API tests moved behind build tag

Breaking Changes

  • SearchMarkets(terms ...string)SearchMarkets(req SearchMarketsRequest) with full filter/sort support
  • Pool struct replaced with map[string]float64
  • Fees fields changed from int64 to float64

Test plan

  • go build ./... — clean build
  • go test ./... — 27 unit tests pass (no credentials needed)
  • go test ./... -tags=integration — 26 integration tests pass against live API
  • go vet ./... — clean

🤖 Generated with Claude Code

jonnyspicer and others added 24 commits February 15, 2026 21:08
Documents the plan to modernize the library with parallel agent teams,
covering missing endpoints, data structure fixes, and testing strategy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 tasks organized into 3 phases: core infrastructure, domain endpoints
(parallel), and integration tests. Includes TDD steps for each task.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Pool type previously hardcoded Option0..Option19 fields which breaks
for markets with >20 answers and is brittle. A dynamic map supports any
number of outcomes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CloseMarket and AddMarketToGroup used lowercase field names in anonymous
structs, causing json.Marshal to produce {} instead of the intended body.
Capitalizing the field names fixes serialization while preserving the
JSON tag casing. Tests added to verify the fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Renamed postRequest to doRequest since it handles any authenticated
request. Added getRequest helper that sends the Authorization header
for GET requests, replacing bare http.Get() calls that bypassed auth
and the client's configured timeout. Simplified GetAuthenticatedUser
to use the new helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added readErrorBody helper that reads up to 512 bytes from error
responses. All POST endpoint error messages now include the response
body, making it much easier to diagnose API errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nge)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Manifold API returns floating point values for fee fields, causing
json.Unmarshal errors with the previous int64 type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Created integration_test.go with //go:build integration tag
- Added 14 read-only integration tests (users, markets, bets, transactions)
- Added write integration test with shared market (1 mana, CANCEL resolution)
- Moved 12 legacy real-API tests from api_test.go behind integration tag

Bug fixes discovered during integration testing:
- PostComment: was incorrectly passing marketId in URL path
- PostMarketRequest: added required LiquidityTier field
- client.go: fixed unused fmt.Errorf (now fmt.Printf)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Upgrade Go from 1.19 to 1.21 to match go.mod
- Update actions/checkout@v3 → v4, actions/setup-go@v3 → v5
- Remove debug echo of API key
- Split into unit (always) and integration (push to main only) jobs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
doRequest() rejects empty API keys, so tests that use POST endpoints
failed in CI where no .env or MANIFOLD_API_KEY env var exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- gofmt: fix comment indentation and struct field alignment
- staticcheck SA1006: use t.Error(s) instead of t.Errorf(s) for
  dynamic strings without format verbs
- staticcheck U1000: remove unused getMarketProb constant

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jonnyspicer
jonnyspicer merged commit cf13043 into main Feb 15, 2026
3 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.

1 participant