Skip to content

Commit

Permalink
playground usecases: Update game
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Feb 17, 2020
1 parent 746d830 commit ce429f8
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions plutus-playground-server/usecases/Game.hs
Expand Up @@ -31,11 +31,10 @@ import IOTS (IotsType)
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (pure, (<$>))
import Ledger (Address, DataValue (DataValue), PendingTx, RedeemerValue (RedeemerValue),
Validator, Value, mkValidatorScript, scriptAddress)
import Ledger (Address, PendingTx,
Validator, Value, scriptAddress)
import qualified Ledger.Constraints as Constraints
import qualified Ledger.Typed.Scripts as Scripts
import Ledger.Typed.Scripts (wrapValidator)
import Playground.Contract
import qualified Prelude

Expand Down Expand Up @@ -81,20 +80,7 @@ validateGuess (HashedString actual) (ClearString guess') _ = actual == sha2_256

-- | The validator script of the game.
gameValidator :: Validator
gameValidator = Ledger.mkValidatorScript $$(PlutusTx.compile [|| validator ||])
where validator = wrapValidator validateGuess

-- create a data script for the guessing game by hashing the string
-- and lifting the hash to its on-chain representation
gameDataScript :: String -> DataValue
gameDataScript =
Ledger.DataValue . PlutusTx.toData . HashedString . sha2_256 . C.pack

-- create a redeemer script for the guessing game by lifting the
-- string to its on-chain representation
gameRedeemerValue :: String -> RedeemerValue
gameRedeemerValue =
Ledger.RedeemerValue . PlutusTx.toData . ClearString . C.pack
gameValidator = Scripts.validatorScript gameInstance

-- | The address of the game (the hash of its validator script)
gameAddress :: Address
Expand Down

0 comments on commit ce429f8

Please sign in to comment.