Skip to content

feat(cards): card trading market — list cards + coin-sweetened offers - #396

Open
xpoes123 wants to merge 5 commits into
mainfrom
feat/card-trade-market
Open

feat(cards): card trading market — list cards + coin-sweetened offers#396
xpoes123 wants to merge 5 commits into
mainfrom
feat/card-trade-market

Conversation

@xpoes123

Copy link
Copy Markdown
Owner

Ports the nsba-markets card trading market onto SharpLab. Selected scope (from brainstorming): web trade offers + coin-sweetened trades. Out of scope: fixed-price auto-buy marketplace, timed auctions.

Spec: docs/superpowers/specs/2026-08-19-card-trade-market-design.md

What it does

Owners list cards on a public board (with an optional "looking for…" note). Anyone browses the Market tab and makes an offer — their card(s) ± coins for a listed card. The owner accepts/declines; accept atomically swaps cards and coins. Extends the existing directed /cardtrade system (was Discord-only, no coins).

Data model (idempotent migrations)

  • card_trades.coins — signed sweetener (+N offerer adds, −N offerer requests)
  • card_trade_listings(instance_id PK, owner_id, note, created_at) — the board; auto-clears on trade/sell/unlist and self-heals if a card changes hands

Backend

  • accept_card_trade moves coins inside the existing BEGIN IMMEDIATE swap — no escrow, balance verified at accept; clears listings for swapped cards. sell_instance clears listings too.
  • Queries: create/remove/list_trade_market, list_outgoing_card_trades, get_instances_public; get_collection returns a listed flag.
  • Web endpoints: GET /market, POST /list · /unlist · /trade · GET /trades, POST /trades/{id}/accept|decline|cancel.

Web UI (screenshots below)

  • Market tab — "Offers to you" (accept/decline) + "Your sent offers" (cancel), each showing the ⇄ swap + coin delta; then the "on the block" grid.
  • List for trade / Unlist buttons on your collection tiles + a "🔖 Listed" badge.
  • Make-offer modal — pick cards to give + a signed coin sweetener.
  • Incoming-offer count badge on the Market tab.

Discord

/cardtrade offer gains an optional coins arg (positive = you add, negative = you want back); pure-coin offers allowed.

Tests

tests/test_cards.py — 43 pass. New: coin swap both signs, insufficient-coins rollback, pure-coin offer, listing lifecycle + self-heal, sell/accept clear listings, web list→offer→accept round-trip, reject unowned/unlisted.

Verified all views via headless render (?mock=1): Market board + offers, the offer modal, and the collection tab with Sell + List buttons.

Deploy is manual — merging does not auto-deploy. Note: adds coin-moving trade accepts on the live economy, same as the sell feature.

🤖 Generated with Claude Code

xpoes123 and others added 5 commits August 19, 2026 01:03
…tened offers)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- card_trades.coins (signed sweetener) + card_trade_listings table + migrations
- accept_card_trade moves coins atomically (no escrow, verified at accept) and
  clears listings for swapped cards; sell_instance clears listings too
- queries: create/remove/list trade listings, list_outgoing, get_instances_public
- 12 tests: coin swap both signs, insufficient-coins rollback, pure-coin offer,
  listing lifecycle + self-heal, sell/accept clear listings

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…des/accept/decline/cancel)

Offer resolves target owner from the listing; validates ownership + coin balance;
trades decorated with card previews in one query. Round-trip + reject tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…odal)

- Market tab: incoming/outgoing offers (accept/decline/cancel) + 'on the block' grid
- List for trade / Unlist buttons on own collection tiles; 'Listed' badge (get_collection
  now returns listed flag)
- Make-offer modal: pick cards to give + signed coin sweetener
- cardTile takes an opts object (sellable/listable/offerable); mock fixtures for previews

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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