Copyright | 2020 Input Output (Hong Kong) Ltd. 2021-2022 Input Output Global Inc. (IOG) 2023-2025 Intersect |
---|---|
License | Apache-2.0 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Cardano.Address.Script
Description
Synopsis
- data Script (elem :: Type)
- = 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 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
Script
data Script (elem :: Type) Source #
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
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 # | |
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 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
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:
- script
- drep
- cc_cold
- cc_hot
- drep_script
- cc_cold_script
- cc_hot_script
If if hex is encountered it is converted in rawly fashion
Since: 4.0.0