Skip to content

Commit

Permalink
Update plutus scripts in Testnet.Defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Jun 20, 2024
1 parent ff48d91 commit 71f025b
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions cardano-testnet/src/Testnet/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module Testnet.Defaults
, plutusV3SpendingScript
) where

import Cardano.Api (AnyCardanoEra (..), CardanoEra (..), File (..), pshow)
import Cardano.Api (AnyCardanoEra (..), CardanoEra (..), File (..), pshow,
unsafeBoundedRational)
import qualified Cardano.Api.Shelley as Api

import Cardano.Ledger.Alonzo.Core (PParams (..))
Expand Down Expand Up @@ -60,16 +61,13 @@ import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Key as Key
import qualified Data.Aeson.KeyMap as KeyMapAeson
import qualified Data.Default.Class as DefaultClass
import Data.Maybe
import Data.Proxy
import Data.Ratio
import Data.Scientific
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Time (UTCTime)
import Data.Typeable
import qualified Data.Vector as Vector
import GHC.Stack
import Lens.Micro
import Numeric.Natural
import System.FilePath ((</>))
Expand Down Expand Up @@ -573,35 +571,13 @@ defaultDelegatorStakeKeyPair n =
, signingKey = File $ "stake-delegators" </> ("delegator" <> show n) </> "staking.skey"
}

-- TODO: We should not hardcode a script like this. We need to move
-- plutus-example from plutus apps to cardano-node-testnet. This will
-- let us directly compile the plutus validators and avoid bit rotting of
-- hardcoded plutus scripts.
-- | Default plutus script that succeeds regardless of redeemer
-- NB: This cannot be used as a spending script
plutusV3NonSpendingScript :: Text
plutusV3NonSpendingScript =
Text.unlines ["{"
, "\"type\": \"PlutusScriptV3\""
, ",\"description\": \"\""
, ",\"cborHex\": \"4746010100228001\""
, "}"
]
"{ \"type\": \"PlutusScriptV3\", \"description\": \"\", \"cborHex\": \"46450101002499\" }"

-- | Default plutus spending script that succeeds regardless of redeemer
plutusV3SpendingScript :: Text
plutusV3SpendingScript =
Text.unlines ["{"
, "\"type\": \"PlutusScriptV3\""
, ",\"description\": \"\""
, ",\"cborHex\": \"484701010022280001\""
, "}"
]

-- TODO: move to cardano-api
unsafeBoundedRational :: forall r. (HasCallStack, Typeable r, BoundedRational r)
=> Rational
-> r
unsafeBoundedRational x = fromMaybe (error errMessage) $ boundRational x
where
errMessage = show (typeRep (Proxy @r)) <> " is out of bounds: " <> show x
"{ \"type\": \"PlutusScriptV3\", \"description\": \"\", \"cborHex\": \"46450101002499\" }"

0 comments on commit 71f025b

Please sign in to comment.