From 0638b1b18dbdd0cab595ef8a8460cc114870fdf7 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Sat, 14 Dec 2024 16:51:47 +0530 Subject: [PATCH] feat(#22): update to plutusv3 --- bet-ref/betref.cabal | 127 ++++++++------- bet-ref/onchain/BetRef/OnChain/BetRef.hs | 145 +++++++++--------- .../onchain/BetRef/OnChain/BetRef/Compiled.hs | 7 +- bet-ref/server-lib/BetRef/Api/BetRef.hs | 2 +- bet-ref/server-lib/BetRef/Api/Operations.hs | 22 +-- bet-ref/tests/BetRef/Tests/PlaceBet.hs | 2 +- cabal.project | 4 +- vesting/offchain/Vesting/Api.hs | 4 +- vesting/offchain/Vesting/Script.hs | 4 +- vesting/vesting.cabal | 94 +++++++----- 10 files changed, 221 insertions(+), 190 deletions(-) diff --git a/bet-ref/betref.cabal b/bet-ref/betref.cabal index 151efbc..74a462a 100644 --- a/bet-ref/betref.cabal +++ b/bet-ref/betref.cabal @@ -1,9 +1,9 @@ -cabal-version: 3.6 -name: betref -version: 0.1.0 +cabal-version: 3.6 +name: betref +version: 0.1.0 common common - default-language: GHC2021 + default-language: GHC2021 default-extensions: DataKinds DeriveAnyClass @@ -19,92 +19,105 @@ common common UndecidableInstances ViewPatterns - ghc-options: -Wall -Wincomplete-uni-patterns -Wunused-packages + ghc-options: + -Wall + -Wincomplete-uni-patterns + -Wunused-packages -- speed-ups GHCi considerably - ghc-options: -fno-show-valid-hole-fits + ghc-options: -fno-show-valid-hole-fits common plutus-ghc-options -- so unfoldings are present even when compiled without optmizations ghc-options: - -fno-ignore-interface-pragmas -fno-omit-interface-pragmas + -fno-ignore-interface-pragmas + -fno-omit-interface-pragmas -Wno-partial-type-signatures -- expose all unfoldings, so plutustx compiler can do its job ghc-options: - -fexpose-all-unfoldings -fobject-code - -fplugin-opt PlutusTx.Plugin:defer-errors - - -- set target plutus-core version - ghc-options: -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 + -fexpose-all-unfoldings + -fobject-code + -fplugin-opt + PlutusTx.Plugin:defer-errors library betref-onchain - import: common, plutus-ghc-options - hs-source-dirs: onchain + import: common, plutus-ghc-options + hs-source-dirs: onchain exposed-modules: BetRef.OnChain.BetRef BetRef.OnChain.BetRef.Compiled + build-depends: - , base - , plutus-core - , plutus-ledger-api - , plutus-tx - , plutus-tx-plugin + base, + plutus-core, + plutus-ledger-api, + plutus-tx, + plutus-tx-plugin, library betref-server-lib - import: common - hs-source-dirs: server-lib + import: common + hs-source-dirs: server-lib exposed-modules: BetRef.Api.Api BetRef.Api.BetRef BetRef.Api.Context BetRef.Api.Operations BetRef.Api.Tx + build-depends: - , base - , aeson - , betref:betref-onchain - , atlas-cardano - , swagger2 - , servant-server - , servant-swagger - , containers - , text + aeson, + atlas-cardano, + base, + betref:betref-onchain, + containers, + servant-server, + servant-swagger, + swagger2, + text, executable betref-server - import: common - hs-source-dirs: server - main-is: server-main.hs + import: common + hs-source-dirs: server + main-is: server-main.hs ghc-options: - -O2 -threaded -rtsopts -with-rtsopts=-T + -O2 + -threaded + -rtsopts + -with-rtsopts=-T + build-depends: - , aeson-pretty - , base - , bytestring - , atlas-cardano - , betref:betref-server-lib - , servant-server - , transformers - , wai-cors - , http-types - , warp + aeson-pretty, + atlas-cardano, + base, + betref:betref-server-lib, + bytestring, + http-types, + servant-server, + transformers, + wai-cors, + warp, test-suite betref-tests - import: common - ghc-options: -threaded -rtsopts - type: exitcode-stdio-1.0 - main-is: betref-tests.hs + import: common + ghc-options: + -threaded + -rtsopts + + type: exitcode-stdio-1.0 + main-is: betref-tests.hs hs-source-dirs: tests other-modules: BetRef.Tests.PlaceBet BetRef.Tests.TakeBetPot + build-depends: - , base - , containers - , betref:betref-onchain - , betref:betref-server-lib - , extra - , text - , atlas-cardano - , mtl - , tasty \ No newline at end of file + atlas-cardano, + base, + betref:betref-onchain, + betref:betref-server-lib, + containers, + extra, + mtl, + tasty, + text, \ No newline at end of file diff --git a/bet-ref/onchain/BetRef/OnChain/BetRef.hs b/bet-ref/onchain/BetRef/OnChain/BetRef.hs index a49c854..75a22da 100644 --- a/bet-ref/onchain/BetRef/OnChain/BetRef.hs +++ b/bet-ref/onchain/BetRef/OnChain/BetRef.hs @@ -19,8 +19,8 @@ module BetRef.OnChain.BetRef ( import PlutusLedgerApi.V1.Address (toPubKeyHash) import PlutusLedgerApi.V1.Interval (contains) import PlutusLedgerApi.V1.Value (geq) -import PlutusLedgerApi.V2 -import PlutusLedgerApi.V2.Contexts ( +import PlutusLedgerApi.V3 +import PlutusLedgerApi.V3.Contexts ( findDatum, findOwnInput, getContinuingOutputs, @@ -48,7 +48,7 @@ data BetRefParams = BetRefParams , brpBetStep :: Value -- ^ Each newly placed bet must be more than previous bet by `brpBetStep` amount. } - deriving stock Show + deriving stock (Show) -- PlutusTx.makeLift ''BetRefParams PlutusTx.unstableMakeIsData ''BetRefParams @@ -75,80 +75,81 @@ PlutusTx.unstableMakeIsData ''BetRefAction {-# INLINEABLE mkBetRefValidator #-} -- | Untyped wrapper around `mkBetRefValidator'`. -mkBetRefValidator :: BuiltinData -> BuiltinData -> BuiltinData -> BuiltinData -> () -mkBetRefValidator params dat' red' ctx' - | mkBetRefValidator' (unsafeFromBuiltinData params) (unsafeFromBuiltinData dat') (unsafeFromBuiltinData red') (unsafeFromBuiltinData ctx') = () +mkBetRefValidator :: BuiltinData -> BuiltinData -> () +mkBetRefValidator params ctx' + | mkBetRefValidator' (unsafeFromBuiltinData params) (unsafeFromBuiltinData ctx') = () | otherwise = error () {-# INLINEABLE mkBetRefValidator' #-} -- | Core smart contract logic. Read its description from Atlas guide. -mkBetRefValidator' :: BetRefParams -> BetRefDatum -> BetRefAction -> ScriptContext -> Bool -mkBetRefValidator' (BetRefParams oraclePkh betUntil betReveal betStep) (BetRefDatum previousGuesses previousBet) brAction ctx = - case brAction of - Bet guess -> - let - sOut = case getContinuingOutputs ctx of - [sOut'] -> sOut' - _anyOtherMatch -> traceError "Expected only one continuing output." - outValue = txOutValue sOut - -- Using the 'maybe' utility here makes validation fail... for some reason... - -- Why is PlutusTx still allowed to exist? - inValue = case findOwnInput ctx of - Nothing -> traceError "Joever!" - Just x -> txOutValue (txInInfoResolved x) - -- inValue = txOutValue sIn - (guessesOut, betOut) = case outputToDatum sOut of - Nothing -> traceError "Could not resolve for script output datum" - Just (BetRefDatum guessesOut' betOut') -> (guessesOut', betOut') - in - traceIfFalse - "Must be before `BetUntil` time" - (to betUntil `contains` validRange) - && traceIfFalse - "Guesses update is wrong" - ((signerPkh, guess) : previousGuesses == guessesOut) - && traceIfFalse - "The current bet must be more than the previous bet by atleast `brpBetStep` amount" - (outValue `geq` (inValue <> previousBet <> betStep)) - && traceIfFalse - "Out bet is wrong" - (inValue == outValue - betOut) - Take -> - let - -- Note that `find` returns the first match. Since we were always prepending, this is valid. - Just guess = find ((== signerPkh) . fst) previousGuesses - oracleIn = case filter (isNothing . txOutReferenceScript) (txInInfoResolved <$> txInfoReferenceInputs info) of - [oracleIn'] -> oracleIn' - [] -> traceError "No reference input provided" - _anyOtherMatch -> traceError "Expected only one reference input" - oracleAnswer = case outputToDatum oracleIn of - Nothing -> traceError "Could not resolve for datum" - (Just (OracleAnswerDatum oracleAnswer')) -> oracleAnswer' - guessDiff = getGuessDiff $ snd guess - getGuessDiff (OracleAnswerDatum g) = abs (oracleAnswer - g) - -- Unwrapping the 'Maybe' here to extract the 'Just' (and trace error for 'Nothing') kills PlutusTx compilation - -- the issue is that GHC will fire the worker wrapper transformation combining this with the equality with 'oraclePkh' - -- code down below. Which will cause issues with BuiltinByteString also being unwrapped into primitive pointers. - -- See: https://github.com/IntersectMBO/plutus/issues/4193 - mOracleInPkh = toPubKeyHash (txOutAddress oracleIn) - in - traceIfFalse - "Must be after `RevealTime`" - (from betReveal `contains` validRange) - && traceIfFalse - "Must fully spend Script" - (null (getContinuingOutputs ctx)) - && traceIfFalse - "Reference input must be from Oracle address (wrt Payment part)" - (mOracleInPkh == Just oraclePkh) - && traceIfFalse - "Guess is not closest" - (all (\pg -> getGuessDiff (snd pg) >= guessDiff) previousGuesses) +mkBetRefValidator' :: BetRefParams -> ScriptContext -> Bool +mkBetRefValidator' (BetRefParams oraclePkh betUntil betReveal betStep) ctx@(ScriptContext info red purpose) = + let brAction :: BetRefAction = unsafeFromBuiltinData (getRedeemer red) + (BetRefDatum previousGuesses previousBet) = case purpose of + SpendingScript _ (Just dat) -> unsafeFromBuiltinData (getDatum dat) + _anyOther -> traceError "Expected SpendingScript with Just Datum" + in case brAction of + Bet guess -> + let + sOut = case getContinuingOutputs ctx of + [sOut'] -> sOut' + _anyOtherMatch -> traceError "Expected only one continuing output." + outValue = txOutValue sOut + -- Using the 'maybe' utility here makes validation fail... for some reason... + -- Why is PlutusTx still allowed to exist? + inValue = case findOwnInput ctx of + Nothing -> traceError "Joever!" + Just x -> txOutValue (txInInfoResolved x) + -- inValue = txOutValue sIn + (guessesOut, betOut) = case outputToDatum sOut of + Nothing -> traceError "Could not resolve for script output datum" + Just (BetRefDatum guessesOut' betOut') -> (guessesOut', betOut') + in + traceIfFalse + "Must be before `BetUntil` time" + (to betUntil `contains` validRange) + && traceIfFalse + "Guesses update is wrong" + ((signerPkh, guess) : previousGuesses == guessesOut) + && traceIfFalse + "The current bet must be more than the previous bet by atleast `brpBetStep` amount" + (outValue `geq` (inValue <> previousBet <> betStep)) + && traceIfFalse + "Out bet is wrong" + (inValue == outValue - betOut) + Take -> + let + -- Note that `find` returns the first match. Since we were always prepending, this is valid. + Just guess = find ((== signerPkh) . fst) previousGuesses + oracleIn = case filter (isNothing . txOutReferenceScript) (txInInfoResolved <$> txInfoReferenceInputs info) of + [oracleIn'] -> oracleIn' + [] -> traceError "No reference input provided" + _anyOtherMatch -> traceError "Expected only one reference input" + oracleAnswer = case outputToDatum oracleIn of + Nothing -> traceError "Could not resolve for datum" + (Just (OracleAnswerDatum oracleAnswer')) -> oracleAnswer' + guessDiff = getGuessDiff $ snd guess + getGuessDiff (OracleAnswerDatum g) = abs (oracleAnswer - g) + -- Unwrapping the 'Maybe' here to extract the 'Just' (and trace error for 'Nothing') kills PlutusTx compilation + -- the issue is that GHC will fire the worker wrapper transformation combining this with the equality with 'oraclePkh' + -- code down below. Which will cause issues with BuiltinByteString also being unwrapped into primitive pointers. + -- See: https://github.com/IntersectMBO/plutus/issues/4193 + mOracleInPkh = toPubKeyHash (txOutAddress oracleIn) + in + traceIfFalse + "Must be after `RevealTime`" + (from betReveal `contains` validRange) + && traceIfFalse + "Must fully spend Script" + (null (getContinuingOutputs ctx)) + && traceIfFalse + "Reference input must be from Oracle address (wrt Payment part)" + (mOracleInPkh == Just oraclePkh) + && traceIfFalse + "Guess is not closest" + (all (\pg -> getGuessDiff (snd pg) >= guessDiff) previousGuesses) where - info :: TxInfo - info = scriptContextTxInfo ctx - validRange :: POSIXTimeRange validRange = txInfoValidRange info @@ -158,7 +159,7 @@ mkBetRefValidator' (BetRefParams oraclePkh betUntil betReveal betStep) (BetRefDa [] -> traceError "No signatory" _anyOtherMatch -> traceError "Expected only one signatory" - outputToDatum :: FromData b => TxOut -> Maybe b + outputToDatum :: (FromData b) => TxOut -> Maybe b outputToDatum o = case txOutDatum o of NoOutputDatum -> Nothing OutputDatum d -> processDatum d diff --git a/bet-ref/onchain/BetRef/OnChain/BetRef/Compiled.hs b/bet-ref/onchain/BetRef/OnChain/BetRef/Compiled.hs index 032be01..b7993ed 100644 --- a/bet-ref/onchain/BetRef/OnChain/BetRef/Compiled.hs +++ b/bet-ref/onchain/BetRef/OnChain/BetRef/Compiled.hs @@ -2,7 +2,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 #-} module BetRef.OnChain.BetRef.Compiled ( betRefValidator, @@ -12,13 +11,13 @@ module BetRef.OnChain.BetRef.Compiled ( BetRefAction (..), ) where -import PlutusCore.Version (plcVersion100) +import PlutusCore.Version (plcVersion110) import PlutusTx qualified import BetRef.OnChain.BetRef -- Since makeLift doesn't seem to work on BetRefParams. We just convert it to data and apply that instead. -betRefValidator :: BetRefParams -> PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ()) +betRefValidator :: BetRefParams -> PlutusTx.CompiledCode (PlutusTx.BuiltinData -> ()) betRefValidator betRefParams = $$(PlutusTx.compile [||mkBetRefValidator||]) - `PlutusTx.unsafeApplyCode` PlutusTx.liftCode plcVersion100 (PlutusTx.toBuiltinData betRefParams) + `PlutusTx.unsafeApplyCode` PlutusTx.liftCode plcVersion110 (PlutusTx.toBuiltinData betRefParams) diff --git a/bet-ref/server-lib/BetRef/Api/BetRef.hs b/bet-ref/server-lib/BetRef/Api/BetRef.hs index 0a278b5..d73d99f 100644 --- a/bet-ref/server-lib/BetRef/Api/BetRef.hs +++ b/bet-ref/server-lib/BetRef/Api/BetRef.hs @@ -149,7 +149,7 @@ handleAddRefScript ctx AddRefScriptParams{..} = do pure $ addRefScript' arsPutAddress validator let refs = findRefScriptsInBody txBody - outRef <- case Map.lookup (GYPlutusScript (validatorToScript validator)) refs of + outRef <- case Map.lookup (GYPlutusScript validator) refs of Nothing -> fail "Shouldn't happen: No reference for added Script in body" Just ref -> return ref pure $ unSignedTxWithFee txBody $ Just outRef diff --git a/bet-ref/server-lib/BetRef/Api/Operations.hs b/bet-ref/server-lib/BetRef/Api/Operations.hs index b356519..e465514 100644 --- a/bet-ref/server-lib/BetRef/Api/Operations.hs +++ b/bet-ref/server-lib/BetRef/Api/Operations.hs @@ -26,7 +26,7 @@ mkScript :: GYPubKeyHash -> -- | Bet step value GYValue -> - m (BetRefParams, GYScript PlutusV2) + m (BetRefParams, GYScript PlutusV3) mkScript betUntil betReveal oraclePkh betStep = do currSlot <- slotToInteger <$> slotOfCurrentBlock -- Calculate params for the script @@ -41,11 +41,11 @@ mkScript betUntil betReveal oraclePkh betStep = do (timeToPlutus betRevealTime) (valueToPlutus betStep) gyLogDebug' "" $ printf "Parameters: %s" (show params) - pure (params, validatorToScript $ betRefValidator' params) + pure (params, betRefValidator' params) -- | Validator in question, obtained after giving required parameters. -betRefValidator' :: BetRefParams -> GYScript 'PlutusV2 -betRefValidator' brp = validatorFromPlutus $ betRefValidator brp +betRefValidator' :: BetRefParams -> GYScript 'PlutusV3 +betRefValidator' brp = scriptFromPlutus $ betRefValidator brp -- | Address of the validator, given params. betRefAddress :: (HasCallStack, GYTxQueryMonad m) => BetRefParams -> m GYAddress @@ -66,7 +66,7 @@ placeBet :: GYAddress -> -- | Reference to previous bets UTxO (if any). Maybe GYTxOutRef -> - m (GYTxSkeleton 'PlutusV2) + m (GYTxSkeleton 'PlutusV3) placeBet refScript brp guess bet ownAddr mPreviousBetsUtxoRef = do gyLogDebug' "" $ printf "ownAddr: %s" (show ownAddr) gyLogDebug' "" $ printf "refOut: %s" (show mPreviousBetsUtxoRef) @@ -121,7 +121,7 @@ takeBets :: GYAddress -> -- | Oracle reference input. GYTxOutRef -> - m (GYTxSkeleton 'PlutusV2) + m (GYTxSkeleton 'PlutusV3) takeBets refScript brp previousBetsUtxoRef ownAddr oracleRefInput = do pkh <- addressToPubKeyHash' ownAddr previousUtxo <- utxoAtTxOutRef' previousBetsUtxoRef @@ -134,25 +134,25 @@ takeBets refScript brp previousBetsUtxoRef ownAddr oracleRefInput = do <> mustBeSignedBy pkh -- | Utility function to consume script UTxO. -input :: BetRefParams -> GYTxOutRef -> GYTxOutRef -> BetRefDatum -> BetRefAction -> GYTxSkeleton 'PlutusV2 +input :: BetRefParams -> GYTxOutRef -> GYTxOutRef -> BetRefDatum -> BetRefAction -> GYTxSkeleton 'PlutusV3 input brp refScript inputRef dat red = mustHaveInput GYTxIn { gyTxInTxOutRef = inputRef , gyTxInWitness = GYTxInWitnessScript - (GYInReference refScript $ validatorToScript $ betRefValidator' brp) + (GYInReference refScript $ betRefValidator' brp) (datumFromPlutusData dat) (redeemerFromPlutusData red) } -- | Add UTxO to be used as reference input at a given address with given datum. -addRefInput' :: GYAddress -> OracleAnswerDatum -> GYTxSkeleton 'PlutusV2 +addRefInput' :: GYAddress -> OracleAnswerDatum -> GYTxSkeleton 'PlutusV3 addRefInput' addr dat = mustHaveOutput $ GYTxOut addr mempty (Just (datumFromPlutusData dat, GYTxOutUseInlineDatum)) Nothing -- Note that the value can be empty as tx building logic would add the needed minimum UTxO ada. -- | Add Reference Script UTxO. -addRefScript' :: GYAddress -> GYScript 'PlutusV2 -> GYTxSkeleton 'PlutusV2 -addRefScript' addr script = mustHaveOutput $ GYTxOut addr mempty (Just (datumFromPlutusData (), GYTxOutDontUseInlineDatum)) (Just $ GYPlutusScript $ validatorToScript script) +addRefScript' :: GYAddress -> GYScript 'PlutusV3 -> GYTxSkeleton 'PlutusV3 +addRefScript' addr script = mustHaveOutput $ GYTxOut addr mempty (Just (datumFromPlutusData (), GYTxOutDontUseInlineDatum)) (Just $ GYPlutusScript script) diff --git a/bet-ref/tests/BetRef/Tests/PlaceBet.hs b/bet-ref/tests/BetRef/Tests/PlaceBet.hs index ac4783f..8429ebe 100644 --- a/bet-ref/tests/BetRef/Tests/PlaceBet.hs +++ b/bet-ref/tests/BetRef/Tests/PlaceBet.hs @@ -82,7 +82,7 @@ simpleTxTest (testWallets -> Wallets{w1}) = do gyLogDebug' "" $ printf "tx submitted, txId: %s" txId -- Pretend off-chain code written in 'GYTxUserQueryMonad m' -mkTrivialTx :: (GYTxUserQueryMonad m) => m (GYTxSkeleton 'PlutusV2) +mkTrivialTx :: (GYTxUserQueryMonad m) => m (GYTxSkeleton 'PlutusV3) mkTrivialTx = do addr <- maybeM diff --git a/cabal.project b/cabal.project index a37137f..ca464ea 100644 --- a/cabal.project +++ b/cabal.project @@ -21,8 +21,8 @@ index-state: source-repository-package type: git location: https://github.com/geniusyield/atlas - tag: v0.6.2 - --sha256: sha256-LTAC8xMH3HBU+b9Q48KSebeSP3q1kxqoT956XnzinV4= + tag: 30ca7dd6b7eddea21a59215d8c4948c67dbaaece + --sha256: FIXME: -------- Begin contents from @atlas@'s @cabal.project@ file. -------- diff --git a/vesting/offchain/Vesting/Api.hs b/vesting/offchain/Vesting/Api.hs index c607cbd..f8d07ee 100644 --- a/vesting/offchain/Vesting/Api.hs +++ b/vesting/offchain/Vesting/Api.hs @@ -14,7 +14,7 @@ import Vesting.Script (vestingValidator) vestingAddress :: (GYTxQueryMonad m) => GYPubKeyHash -> m GYAddress vestingAddress = scriptAddress . vestingValidator -placeVesting :: (GYTxQueryMonad m) => GYPubKeyHash -> GYTime -> GYValue -> m (GYTxSkeleton 'PlutusV2) +placeVesting :: (GYTxQueryMonad m) => GYPubKeyHash -> GYTime -> GYValue -> m (GYTxSkeleton 'PlutusV3) placeVesting beneficiary deadline value = do addr <- vestingAddress beneficiary return $ @@ -40,7 +40,7 @@ availableVestings beneficiary = do , now > deadline' ] -retrieveVestings :: (GYTxQueryMonad m) => GYPubKeyHash -> [(GYTxOutRef, GYTime)] -> m (GYTxSkeleton 'PlutusV2) +retrieveVestings :: (GYTxQueryMonad m) => GYPubKeyHash -> [(GYTxOutRef, GYTime)] -> m (GYTxSkeleton 'PlutusV3) retrieveVestings beneficiary orefs = do slot <- slotOfCurrentBlock return $ diff --git a/vesting/offchain/Vesting/Script.hs b/vesting/offchain/Vesting/Script.hs index e6b9478..af2e0a6 100644 --- a/vesting/offchain/Vesting/Script.hs +++ b/vesting/offchain/Vesting/Script.hs @@ -5,5 +5,5 @@ module Vesting.Script ( import GeniusYield.Types import Vesting.OnChain.Vesting.Compiled qualified as OnChain -vestingValidator :: GYPubKeyHash -> GYScript 'PlutusV2 -vestingValidator = validatorFromPlutus . OnChain.vestingValidator . pubKeyHashToPlutus +vestingValidator :: GYPubKeyHash -> GYScript 'PlutusV3 +vestingValidator = scriptFromPlutus . OnChain.vestingValidator . pubKeyHashToPlutus diff --git a/vesting/vesting.cabal b/vesting/vesting.cabal index 5679e0b..062cf28 100644 --- a/vesting/vesting.cabal +++ b/vesting/vesting.cabal @@ -1,9 +1,9 @@ -cabal-version: 3.6 -name: vesting -version: 0.1.0 +cabal-version: 3.6 +name: vesting +version: 0.1.0 common common - default-language: GHC2021 + default-language: GHC2021 default-extensions: DataKinds DeriveAnyClass @@ -19,69 +19,87 @@ common common UndecidableInstances ViewPatterns - ghc-options: -Wall -Wincomplete-uni-patterns -Wunused-packages + ghc-options: + -Wall + -Wincomplete-uni-patterns + -Wunused-packages -- speed-ups GHCi considerably - ghc-options: -fno-show-valid-hole-fits + ghc-options: -fno-show-valid-hole-fits common plutus-ghc-options -- so unfoldings are present even when compiled without optmizations ghc-options: - -fno-ignore-interface-pragmas -fno-omit-interface-pragmas + -fno-ignore-interface-pragmas + -fno-omit-interface-pragmas -Wno-partial-type-signatures -- expose all unfoldings, so plutustx compiler can do its job ghc-options: - -fexpose-all-unfoldings -fobject-code - -fplugin-opt PlutusTx.Plugin:defer-errors + -fexpose-all-unfoldings + -fobject-code + -fplugin-opt + PlutusTx.Plugin:defer-errors -- set target plutus-core version - ghc-options: -fplugin-opt PlutusTx.Plugin:target-version=1.0.0 + ghc-options: + -fplugin-opt + PlutusTx.Plugin:target-version=1.0.0 library vesting-onchain - import: common, plutus-ghc-options - hs-source-dirs: onchain + import: common, plutus-ghc-options + hs-source-dirs: onchain exposed-modules: Vesting.OnChain.Vesting Vesting.OnChain.Vesting.Compiled + build-depends: - , base - , plutus-core - , plutus-ledger-api - , plutus-tx - , plutus-tx-plugin + base, + plutus-core, + plutus-ledger-api, + plutus-tx, + plutus-tx-plugin, library vesting-offchain - import: common - hs-source-dirs: offchain + import: common + hs-source-dirs: offchain exposed-modules: Vesting.Api Vesting.Script + build-depends: - , base - , atlas-cardano - , containers - , vesting:vesting-onchain + atlas-cardano, + base, + containers, + vesting:vesting-onchain, executable place-vesting - import: common - hs-source-dirs: app - main-is: place.hs + import: common + hs-source-dirs: app + main-is: place.hs ghc-options: - -O2 -threaded -rtsopts -with-rtsopts=-T + -O2 + -threaded + -rtsopts + -with-rtsopts=-T + build-depends: - , base - , atlas-cardano - , text - , vesting:vesting-offchain + atlas-cardano, + base, + text, + vesting:vesting-offchain, executable retrieve-vesting - import: common - hs-source-dirs: app - main-is: retrieve.hs + import: common + hs-source-dirs: app + main-is: retrieve.hs ghc-options: - -O2 -threaded -rtsopts -with-rtsopts=-T + -O2 + -threaded + -rtsopts + -with-rtsopts=-T + build-depends: - , base - , atlas-cardano - , vesting:vesting-offchain + atlas-cardano, + base, + vesting:vesting-offchain,