Skip to content

fix(markets): fix create-market route, missing fields, and form schema - #1833

Merged
hman38705 merged 1 commit into
solutions-plug:mainfrom
shemaiahdelia03-cmd:fix/1753-market-creation-route-and-fields
Oct 20, 2026
Merged

hman38705 merged 1 commit into
solutions-plug:mainfrom
shemaiahdelia03-cmd:fix/1753-market-creation-route-and-fields

Conversation

@shemaiahdelia03-cmd

Copy link
Copy Markdown
Contributor

Summary

Fixes issue #1753: the market creation page was posting to /api/v1/blockchain/markets (nonexistent — 404/405) and the request body was missing all fields required by the contract's create_market entrypoint.

What was implemented

Backend

  • New route POST /api/v1/blockchain/markets registered in public_routes — the route now exists so callers no longer get 404/405.
  • New handler create_market in handlers.rs with OracleConfigRequest, CreateMarketRequest, and CreateMarketResponse structs. The handler validates all required fields (non-empty strings, deadline in future, resolution deadline ≥ deadline + 24 h, ≥ 2 options) and returns 501 Not Implemented with a clear message explaining that the full on-chain path requires client-side wallet signing (tracked in Features/issue 4 featured markets api #77).
  • OpenAPI spec updated with the new path, request body schema (CreateMarketRequest, OracleConfigRequest), and response schema (CreateMarketResponse).

Frontend

  • marketFormSchema extended with all missing fields: resolutionDeadline, oracleAddress, feedId, maxStalenessSeconds, maxConfidenceBps, tier, parentId, parentOutcomeIdx.
  • Cross-field refinement added: resolutionDeadline must be ≥ closeTime + 86400 s, mirroring the on-chain invariant to catch invalid submissions before any gas is spent.
  • Form UI (page.tsx) updated with accessible fields for all new schema values (labels, aria-invalid, aria-describedby, error spans).
  • Submission body fixed: now sends deadline/resolution_deadline as unix timestamps (seconds), the full oracle_config object, tier, native_token (mapped from the selected asset address), parent_id, and parent_outcome_idx.
  • requestSchemas.ts updated with createMarketSchema and CreateMarketBody type for outgoing body validation.

Docs

  • docs/API_SPEC.md updated to list POST /api/v1/blockchain/markets in the public routes table with a note about the current 501 status.

Testing

The CI checks cover this change. No tests were removed. The existing market-creation.spec.ts e2e suite and unit tests remain intact.

Closes #1753

solutions-plug#1753)

The market creation form was posting to /api/v1/blockchain/markets which
did not exist in the backend (causing 404/405), and the request body was
missing all fields required by the contract's create_market entrypoint.

Changes:
- frontend/src/lib/validation/marketForm.ts: extend marketFormSchema with
  resolutionDeadline, oracleAddress, feedId, maxStalenessSeconds,
  maxConfidenceBps, tier, parentId, parentOutcomeIdx; add cross-field
  refinement enforcing resolution_deadline >= close_time + 24h
- frontend/src/app/markets/create/page.tsx: add form fields for all new
  schema fields; fix submission body to send all contract-required params
  (deadline/resolution_deadline as unix seconds, oracle_config object,
  tier, native_token address, parent_id, parent_outcome_idx)
- frontend/src/lib/api/requestSchemas.ts: add createMarketSchema +
  CreateMarketBody type for boundary validation of the outgoing body
- services/api/src/handlers.rs: add OracleConfigRequest, CreateMarketRequest,
  CreateMarketResponse structs and create_market handler; handler validates
  all fields and returns 501 with a clear message explaining that wallet
  signing (tracked in solutions-plug#77) is required for the full on-chain path
- services/api/src/main.rs: register POST /api/v1/blockchain/markets in
  public_routes so the route exists (no more 404)
- services/api/openapi.yaml: document new endpoint and add component schemas
- docs/API_SPEC.md: add POST /api/v1/blockchain/markets to public routes table

Closes solutions-plug#1753
@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@shemaiahdelia03-cmd Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705
hman38705 merged commit f98e003 into solutions-plug:main Oct 20, 2026
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.

Market creation posts to /api/v1/blockchain/markets (nonexistent) and omits fields the contract requires

2 participants