| Copyright | 2020 Input Output (Hong Kong) Ltd. 2021-2022 Input Output Global Inc. (IOG) 2023-2025 Intersect |
|---|---|
| License | Apache-2.0 |
| Safe Haskell | None |
| Language | Haskell2010 |
Cardano.Address.Script
Description
Synopsis
- data Script elem
- = RequireSignatureOf !elem
- | RequireAllOf ![Script elem]
- | RequireAnyOf ![Script elem]
- | RequireSomeOf Word8 ![Script elem]
- | ActiveFromSlot Natural
- | ActiveUntilSlot Natural
- serializeScript :: Script KeyHash -> ByteString
- foldScript :: (a -> b -> b) -> b -> Script a -> b
- data ScriptTemplate = ScriptTemplate {}
- newtype Cosigner = Cosigner Word8
- data ValidationLevel
- data ErrValidateScript
- data ErrRecommendedValidateScript
- data ErrValidateScriptTemplate
- validateScript :: ValidationLevel -> Script KeyHash -> Either ErrValidateScript ()
- validateScriptTemplate :: ValidationLevel -> ScriptTemplate -> Either ErrValidateScriptTemplate ()
- validateScriptOfTemplate :: ValidationLevel -> Script Cosigner -> Either ErrValidateScript ()
- prettyErrValidateScript :: ErrValidateScript -> String
- prettyErrValidateScriptTemplate :: ErrValidateScriptTemplate -> String
- newtype ScriptHash = ScriptHash {}
- toScriptHash :: Script KeyHash -> ScriptHash
- scriptHashFromBytes :: ByteString -> Maybe ScriptHash
- scriptHashToText :: ScriptHash -> KeyRole -> Maybe GovernanceType -> Text
- scriptHashFromText :: Text -> Either ErrScriptHashFromText ScriptHash
- prettyErrScriptHashFromText :: ErrScriptHashFromText -> String
Script
A Script type represents multi signature script. The script embodies conditions
that need to be satisfied to make it valid.
Since: 3.0.0
Constructors
| RequireSignatureOf !elem | |
| RequireAllOf ![Script elem] | |
| RequireAnyOf ![Script elem] | |
| RequireSomeOf Word8 ![Script elem] | |
| ActiveFromSlot Natural | |
| ActiveUntilSlot Natural |
Instances
serializeScript :: Script KeyHash -> ByteString Source #
This function realizes what cardano-node's `Api.serialiseToCBOR script` realizes This is basically doing the symbolically following: toCBOR [0,multisigScript]
Since: 3.0.0
foldScript :: (a -> b -> b) -> b -> Script a -> b Source #
Script folding
Since: 3.2.0
Script template
data ScriptTemplate Source #
Represents the script template that show the structure of the script and determines the expected place of verification keys corresponding to given cosigners.
Since: 3.2.0
Instances
| FromJSON ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Methods parseJSON :: Value -> Parser ScriptTemplate # parseJSONList :: Value -> Parser [ScriptTemplate] # | |||||
| ToJSON ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Methods toJSON :: ScriptTemplate -> Value # toEncoding :: ScriptTemplate -> Encoding # toJSONList :: [ScriptTemplate] -> Value # toEncodingList :: [ScriptTemplate] -> Encoding # omitField :: ScriptTemplate -> Bool # | |||||
| Generic ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Associated Types
Methods from :: ScriptTemplate -> Rep ScriptTemplate x # to :: Rep ScriptTemplate x -> ScriptTemplate # | |||||
| Show ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ScriptTemplate -> ShowS # show :: ScriptTemplate -> String # showList :: [ScriptTemplate] -> ShowS # | |||||
| NFData ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Methods rnf :: ScriptTemplate -> () # | |||||
| Eq ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script Methods (==) :: ScriptTemplate -> ScriptTemplate -> Bool # (/=) :: ScriptTemplate -> ScriptTemplate -> Bool # | |||||
| type Rep ScriptTemplate Source # | |||||
Defined in Cardano.Address.Script type Rep ScriptTemplate = D1 ('MetaData "ScriptTemplate" "Cardano.Address.Script" "cardano-addresses-4.0.1-12OTt85pRZ623XqhieiIYs" 'False) (C1 ('MetaCons "ScriptTemplate" 'PrefixI 'True) (S1 ('MetaSel ('Just "cosigners") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Cosigner XPub)) :*: S1 ('MetaSel ('Just "template") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Script Cosigner)))) | |||||
Represents the cosigner of the script, ie., party that co-shares the script.
Since: 3.2.0
Instances
| FromJSON Cosigner Source # | |||||
Defined in Cardano.Address.Script | |||||
| ToJSON Cosigner Source # | |||||
| Generic Cosigner Source # | |||||
Defined in Cardano.Address.Script Associated Types
| |||||
| Show Cosigner Source # | |||||
| NFData Cosigner Source # | |||||
Defined in Cardano.Address.Script | |||||
| Eq Cosigner Source # | |||||
| Ord Cosigner Source # | |||||
Defined in Cardano.Address.Script | |||||
| Hashable Cosigner Source # | |||||
Defined in Cardano.Address.Script | |||||
| FromJSON (Script Cosigner) Source # | |||||
| type Rep Cosigner Source # | |||||
Defined in Cardano.Address.Script | |||||
Validation
data ValidationLevel Source #
Validation level. Required level does basic check that will make sure the script is accepted in ledger. Recommended level collects a number of checks that will warn about dangerous, unwise and redundant things present in the script.
Since: 3.2.0
Constructors
| RequiredValidation | |
| RecommendedValidation |
Instances
| Generic ValidationLevel Source # | |||||
Defined in Cardano.Address.Script Associated Types
Methods from :: ValidationLevel -> Rep ValidationLevel x # to :: Rep ValidationLevel x -> ValidationLevel # | |||||
| Show ValidationLevel Source # | |||||
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ValidationLevel -> ShowS # show :: ValidationLevel -> String # showList :: [ValidationLevel] -> ShowS # | |||||
| NFData ValidationLevel Source # | |||||
Defined in Cardano.Address.Script Methods rnf :: ValidationLevel -> () # | |||||
| Eq ValidationLevel Source # | |||||
Defined in Cardano.Address.Script Methods (==) :: ValidationLevel -> ValidationLevel -> Bool # (/=) :: ValidationLevel -> ValidationLevel -> Bool # | |||||
| type Rep ValidationLevel Source # | |||||
Defined in Cardano.Address.Script | |||||
data ErrValidateScript Source #
Possible validation errors when validating a script
Since: 3.0.0
Constructors
| LedgerIncompatible | |
| WrongKeyHash | |
| NotUniformKeyType | |
| Malformed | |
| NotRecommended ErrRecommendedValidateScript |
Instances
| Show ErrValidateScript Source # | |
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ErrValidateScript -> ShowS # show :: ErrValidateScript -> String # showList :: [ErrValidateScript] -> ShowS # | |
| Eq ErrValidateScript Source # | |
Defined in Cardano.Address.Script Methods (==) :: ErrValidateScript -> ErrValidateScript -> Bool # (/=) :: ErrValidateScript -> ErrValidateScript -> Bool # | |
data ErrRecommendedValidateScript Source #
Possible recommended validation errors when validating a script
Since: 3.2.0
Instances
| Show ErrRecommendedValidateScript Source # | |
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ErrRecommendedValidateScript -> ShowS # show :: ErrRecommendedValidateScript -> String # showList :: [ErrRecommendedValidateScript] -> ShowS # | |
| Eq ErrRecommendedValidateScript Source # | |
Defined in Cardano.Address.Script Methods (==) :: ErrRecommendedValidateScript -> ErrRecommendedValidateScript -> Bool # (/=) :: ErrRecommendedValidateScript -> ErrRecommendedValidateScript -> Bool # | |
data ErrValidateScriptTemplate Source #
Possible validation errors when validating a script template
Since: 3.2.0
Constructors
| WrongScript ErrValidateScript | |
| DuplicateXPubs | |
| UnknownCosigner | |
| MissingCosignerXPub | |
| NoCosignerInScript | |
| NoCosignerXPub |
Instances
| Show ErrValidateScriptTemplate Source # | |
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ErrValidateScriptTemplate -> ShowS # show :: ErrValidateScriptTemplate -> String # showList :: [ErrValidateScriptTemplate] -> ShowS # | |
| Eq ErrValidateScriptTemplate Source # | |
Defined in Cardano.Address.Script Methods (==) :: ErrValidateScriptTemplate -> ErrValidateScriptTemplate -> Bool # (/=) :: ErrValidateScriptTemplate -> ErrValidateScriptTemplate -> Bool # | |
validateScript :: ValidationLevel -> Script KeyHash -> Either ErrValidateScript () Source #
Validate a Script, semantically
Since: 3.0.0
validateScriptTemplate :: ValidationLevel -> ScriptTemplate -> Either ErrValidateScriptTemplate () Source #
Validate a ScriptTemplate, semantically
Since: 3.2.0
validateScriptOfTemplate :: ValidationLevel -> Script Cosigner -> Either ErrValidateScript () Source #
Validate a script in ScriptTemplate
Since: 3.5.0
prettyErrValidateScript :: ErrValidateScript -> String Source #
Pretty-print a script validation error.
Since: 3.0.0
prettyErrValidateScriptTemplate :: ErrValidateScriptTemplate -> String Source #
Pretty-print a script template validation error.
Since: 3.2.0
Hashing
newtype ScriptHash Source #
A ScriptHash type represents script hash. The hash is expected to have size of
28-byte.
Since: 3.0.0
Constructors
| ScriptHash | |
Fields | |
Instances
| Generic ScriptHash Source # | |||||
Defined in Cardano.Address.Script Associated Types
| |||||
| Show ScriptHash Source # | |||||
Defined in Cardano.Address.Script Methods showsPrec :: Int -> ScriptHash -> ShowS # show :: ScriptHash -> String # showList :: [ScriptHash] -> ShowS # | |||||
| NFData ScriptHash Source # | |||||
Defined in Cardano.Address.Script Methods rnf :: ScriptHash -> () # | |||||
| Eq ScriptHash Source # | |||||
Defined in Cardano.Address.Script | |||||
| Ord ScriptHash Source # | |||||
Defined in Cardano.Address.Script Methods compare :: ScriptHash -> ScriptHash -> Ordering # (<) :: ScriptHash -> ScriptHash -> Bool # (<=) :: ScriptHash -> ScriptHash -> Bool # (>) :: ScriptHash -> ScriptHash -> Bool # (>=) :: ScriptHash -> ScriptHash -> Bool # max :: ScriptHash -> ScriptHash -> ScriptHash # min :: ScriptHash -> ScriptHash -> ScriptHash # | |||||
| type Rep ScriptHash Source # | |||||
Defined in Cardano.Address.Script type Rep ScriptHash = D1 ('MetaData "ScriptHash" "Cardano.Address.Script" "cardano-addresses-4.0.1-12OTt85pRZ623XqhieiIYs" 'True) (C1 ('MetaCons "ScriptHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "unScriptHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |||||
toScriptHash :: Script KeyHash -> ScriptHash Source #
Computes the hash of a given script, by first serializing it to CBOR.
Since: 3.0.0
scriptHashFromBytes :: ByteString -> Maybe ScriptHash Source #
Construct an ScriptHash from raw ByteString (28 bytes).
Since: 3.0.0
scriptHashToText :: ScriptHash -> KeyRole -> Maybe GovernanceType -> Text Source #
Encode a ScriptHash to bech32 Text or hex if key role is unknown.
In the case of governance role, if one wants to include additional byte
as specified in CIP-0129
unless the function is called with CIP0105.
One byte is prepended to script hash only in governance context. The rules how to contruct it are summarized below
drep 0010.... hot 0000.... key type cold 0001.... scripthash ....0011 credential type
This is on top of X_script, where X={drep, cc_hot, cc_hot}, which lacks the additional byte.
In scriptHashFromText we additionally
support reading legacy X which also lacks the additional byte, and has the same payload as
as the corresponding X_script.
Since: 4.0.0
scriptHashFromText :: Text -> Either ErrScriptHashFromText ScriptHash Source #
Construct a ScriptHash from Text. It should be
Bech32 encoded text with one of following hrp:
scriptdrepcc_coldcc_hotdrep_scriptcc_cold_scriptcc_hot_script
If if hex is encountered it is converted in rawly fashion
Since: 4.0.0
prettyErrScriptHashFromText :: ErrScriptHashFromText -> String Source #
Possible errors when deserializing a script hash from text.
Since: 4.0.0