Copyright | (c) 2024 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- data GYSimpleScript
- simpleScriptToApi ∷ GYSimpleScript → SimpleScript
- simpleScriptFromApi ∷ SimpleScript → GYSimpleScript
- readSimpleScript ∷ FilePath → IO GYSimpleScript
- getTotalKeysInSimpleScript ∷ GYSimpleScript → Set GYPaymentKeyHash
- hashSimpleScript ∷ GYSimpleScript → GYScriptHash
- hashSimpleScript' ∷ GYSimpleScript → ScriptHash
- simpleScriptFromCBOR ∷ Text → Maybe GYSimpleScript
- simpleScriptFromCBOR' ∷ ByteString → Maybe GYSimpleScript
- simpleScriptFromJSON ∷ Value → Maybe GYSimpleScript
Docspec setup
>>>
:set -XOverloadedStrings -XTypeApplications
>>>
>>>
import GeniusYield.Types
>>>
import Data.Set qualified as Set
Simple script
data GYSimpleScript #
A simple (aka native / timelock) script that can be used in a transaction.
RequireSignature !GYPaymentKeyHash | |
RequireTimeBefore !GYSlot | |
RequireTimeAfter !GYSlot | |
RequireAllOf ![GYSimpleScript] | |
RequireAnyOf ![GYSimpleScript] | |
RequireMOf !Int ![GYSimpleScript] |
Instances
FromJSON GYSimpleScript # | |
ToJSON GYSimpleScript # | |
Defined in GeniusYield.Types.Script.SimpleScript toJSON ∷ GYSimpleScript → Value # toEncoding ∷ GYSimpleScript → Encoding # toJSONList ∷ [GYSimpleScript] → Value # toEncodingList ∷ [GYSimpleScript] → Encoding # omitField ∷ GYSimpleScript → Bool # | |
Show GYSimpleScript # | |
Defined in GeniusYield.Types.Script.SimpleScript showsPrec ∷ Int → GYSimpleScript → ShowS # show ∷ GYSimpleScript → String # showList ∷ [GYSimpleScript] → ShowS # | |
Eq GYSimpleScript # | |
Defined in GeniusYield.Types.Script.SimpleScript (==) ∷ GYSimpleScript → GYSimpleScript → Bool # (/=) ∷ GYSimpleScript → GYSimpleScript → Bool # | |
Ord GYSimpleScript # | |
Defined in GeniusYield.Types.Script.SimpleScript compare ∷ GYSimpleScript → GYSimpleScript → Ordering # (<) ∷ GYSimpleScript → GYSimpleScript → Bool # (<=) ∷ GYSimpleScript → GYSimpleScript → Bool # (>) ∷ GYSimpleScript → GYSimpleScript → Bool # (>=) ∷ GYSimpleScript → GYSimpleScript → Bool # |
readSimpleScript ∷ FilePath → IO GYSimpleScript #
Read a GYSimpleScript
represented as JSON from a file.
getTotalKeysInSimpleScript ∷ GYSimpleScript → Set GYPaymentKeyHash #
Get the total number of unique GYPaymentKeyHash
mentioned in a GYSimpleScript
.
This is useful for estimating the number of signatures required for a transaction.
>>>
reqSigA = RequireSignature "e1cbb80db89e292269aeb93ec15eb963dda5176b66949fe1c2a6a38a"
>>>
reqSigB = RequireSignature "e1cbb80db89e292269aeb93ec15eb963dda5176b66949fe1c2a6a38b"
>>>
reqSigC = RequireSignature "e1cbb80db89e292269aeb93ec15eb963dda5176b66949fe1c2a6a38c"
>>>
reqSigD = RequireSignature "e1cbb80db89e292269aeb93ec15eb963dda5176b66949fe1c2a6a38d"
>>>
reqSigE = RequireSignature "e1cbb80db89e292269aeb93ec15eb963dda5176b66949fe1c2a6a38e"
>>>
Set.size $ getTotalKeysInSimpleScript $ RequireMOf 2 [RequireAllOf [reqSigA, reqSigB, reqSigC], RequireAnyOf [reqSigA, reqSigD], reqSigE]
5