feat(cards): card trading market — list cards + coin-sweetened offers - #396
Open
xpoes123 wants to merge 5 commits into
Open
feat(cards): card trading market — list cards + coin-sweetened offers#396xpoes123 wants to merge 5 commits into
xpoes123 wants to merge 5 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdWhat 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
/cardtradesystem (was Discord-only, no coins).Data model (idempotent migrations)
card_trades.coins— signed sweetener (+Nofferer adds,−Nofferer 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 handsBackend
accept_card_trademoves coins inside the existingBEGIN IMMEDIATEswap — no escrow, balance verified at accept; clears listings for swapped cards.sell_instanceclears listings too.list_trade_market,list_outgoing_card_trades,get_instances_public;get_collectionreturns alistedflag.GET /market,POST /list·/unlist·/trade·GET /trades,POST /trades/{id}/accept|decline|cancel.Web UI (screenshots below)
Discord
/cardtrade offergains an optionalcoinsarg (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