feat(contracts): NFTPrizeEscrow — hold ERC-721 per gameId, validator-signed WIN/REFUND release

Aperta
#755 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
blockchain
Ambito
blockchain

Direzione di ricerca

Start with the design doc at ui/docs/designs/play-for-nft.md, then read SngWinNFT.sol and CosmosBridge.sol in poker-vm/contracts/contracts/ for the validator-signature check and the Vault interface. Create NFTPrizeEscrow.sol in the same directory, implementing onERC721Received and release as specified. Done when the listed guards (single release, recipient bound into the signed hash, REFUND pinned to depositor, duplicate and zero gameId rejected, replay rejected) each have a passing test that follows the existing contract test setup.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Part of #196 (Play for NFTs). Design: ui/docs/designs/play-for-nft.md.

Scope

New Ethereum contract NFTPrizeEscrow.sol (in poker-vm/contracts/contracts/) that holds one ERC-721 prize per gameId and releases it on a validator-signed unlock. Mirrors SngWinNFT's auth model (validator signature verified via IValidator(vault).isValidator), but holds the asset instead of minting it.

Requirements

  • Deposit (one tx, no approve): implement onERC721Received(operator, from, tokenId, data). Decode bytes32 gameId from data; require gameId != 0 and no existing prize for that gameId; record Prize{nftContract: msg.sender, tokenId, depositor: from, released: false}; emit PrizeDeposited(gameId, nftContract, tokenId, depositor); return the ERC721_RECEIVED selector.
  • Release: release(bytes32 gameId, address recipient, uint8 kind, bytes32 nonce, bytes signature):
    • kind ∈ {1 WIN, 2 REFUND}.
    • Verify !released; for kind == REFUND require recipient == prize.depositor.
    • Recover signer from EIP-191(keccak256(abi.encodePacked(gameId, recipient, kind, nonce))); require IValidator(vault).isValidator(signer).
    • Set released = true; safeTransferFrom(escrow → recipient); emit PrizeReleased(gameId, recipient, kind, nonce).
  • vault address (the same Vault the bridge uses) set at construction.

Guards / tests

  • WIN and REFUND are mutually exclusive — first valid release consumes the prize; second reverts (released).
  • Recipient is inside the signed hash → a WIN signature can't be redirected.
  • REFUND additionally pinned to depositor by the contract.
  • Non-validator signer rejected; replayed signature rejected after release.
  • onERC721Received rejects zero gameId and duplicate gameId.

Match the Solidity style/test setup of the existing contracts (SngWinNFT.sol, CosmosBridge.sol).

Lingua principale
TypeScript
Stelle
2
Fork
5
Merge medio
22h 35m
PR unite (30g)
91

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di block52/ui

Tutte le issue di block52/ui

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.