cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Skeleton.User

Description

This module exposes the notion of user used everywhere in our TxSkel. A user can either be a script or a pubkey, and might be used in a redemption or an allocation setting. All of this is grouped under a single data type. Typically, users should rarely be created by hands, and instead, smart constructors adapted to the user's location in the skeleton should be used.

Synopsis

Aliases

type VScript = Versioned Script Source #

VScript is a convenient alias as we have versioned scripts everywhere.

type ToVScript = ToVersioned Script Source #

The ToVScript alias will come in handy when dealing with constrains.

toVScript :: ToVScript script => script -> VScript Source #

The toVScript alias will come in handy to default the type parameter of toVersioned to Script.

Data types

data UserMode Source #

The UserMode corresponds to the way the user will be used in our TxSkel which can either be for allocation (allocation a certain entity to a user) or for redemption (using this user as a witness in a transaction).

Constructors

Allocation 
Redemption 

Instances

Instances details
Show UserMode Source # 
Instance details

Defined in Cooked.Skeleton.User

Eq UserMode Source # 
Instance details

Defined in Cooked.Skeleton.User

data UserKind Source #

The UserKind corresponds to the requirement on the type of users. Some elements will require specifically a script and some others a pubkey.

Constructors

IsScript 
IsPubKey 
IsEither 
IsNone 

Instances

Instances details
Show UserKind Source # 
Instance details

Defined in Cooked.Skeleton.User

Eq UserKind Source # 
Instance details

Defined in Cooked.Skeleton.User

data User :: UserKind -> UserMode -> Type where Source #

Building users. The type exposes the mode for which the user has been built, and the requirements on the kind of the user.

Constructors

UserPubKey :: forall pkh kind mode. (kind '[IsPubKey, IsEither], ToPubKeyHash pkh, Typeable pkh) => pkh -> User kind mode

A pubkey user. This can be used whenever a pubkey is needed, and for either of the possible modes.

UserScript :: forall script kind. (kind '[IsScript, IsEither], ToVScript script, Typeable script) => script -> User kind Allocation

A script user. This can be used whenever a script is needed, but only for the allocation mode.

UserRedeemedScript :: forall script kind. (kind [IsScript, IsEither], ToVScript script, Typeable script) => script -> TxSkelRedeemer -> User kind Redemption

A script user with an associated redeemer. This can be used whenever a script is needed for redemption mode.

Instances

Instances details
PrettyCooked Peer Source # 
Instance details

Defined in Cooked.Pretty.MockChain

Show (User kind mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

Methods

showsPrec :: Int -> User kind mode -> ShowS #

show :: User kind mode -> String #

showList :: [User kind mode] -> ShowS #

PrettyCookedList (User req mode) Source # 
Instance details

Defined in Cooked.Pretty.Skeleton

IsTxSkelOutAllowedOwner (User 'IsEither 'Allocation) Source # 
Instance details

Defined in Cooked.Skeleton.Output

IsTxSkelOutAllowedOwner (User 'IsPubKey 'Allocation) Source # 
Instance details

Defined in Cooked.Skeleton.Output

Eq (User kind mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

Methods

(==) :: User kind mode -> User kind mode -> Bool #

(/=) :: User kind mode -> User kind mode -> Bool #

Ord (User kind mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

Methods

compare :: User kind mode -> User kind mode -> Ordering #

(<) :: User kind mode -> User kind mode -> Bool #

(<=) :: User kind mode -> User kind mode -> Bool #

(>) :: User kind mode -> User kind mode -> Bool #

(>=) :: User kind mode -> User kind mode -> Bool #

max :: User kind mode -> User kind mode -> User kind mode #

min :: User kind mode -> User kind mode -> User kind mode #

ToAddress (User kind mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

Methods

toAddress :: User kind mode -> Address #

ToCredential (User kind mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

Methods

toCredential :: User kind mode -> Credential #

ToPubKeyHash (User 'IsPubKey mode) Source # 
Instance details

Defined in Cooked.Skeleton.User

type Peer = User IsPubKey Allocation Source #

An alias for 'User IsPubKey Allocation'

Optics

userHashG :: forall kind mode. Getter (User kind mode) BuiltinByteString Source #

Retrieves the hash of the script or pubkey represented by this user

userCredentialG :: Getter (User kind mode) Credential Source #

Extracts the Credential from a User

userTxSkelRedeemerAT :: AffineTraversal' (User kind mode) TxSkelRedeemer Source #

Focusing on the possible TxSkelRedeemer of this User

userVScriptAT :: AffineTraversal' (User kind mode) VScript Source #

Focusing on the possible VScript of this User

userScriptHashAF :: AffineFold (User kind mode) ScriptHash Source #

Focusing on the possible ScriptHash of this User

userPubKeyHashAT :: AffineTraversal' (User kind mode) PubKeyHash Source #

Focusing on the possible PubKeyHash of this User

userPubKeyHashI :: Iso' (User IsPubKey mode) PubKeyHash Source #

An isomorphism between users required to be pubkeys and PubKeyHash

userVScriptL :: Lens' (User IsScript mode) VScript Source #

Focusing on the VScript from a script

userScriptHashG :: Getter (User IsScript mode) ScriptHash Source #

Focusing on the ScriptHash from a script

userTxSkelRedeemerL :: Lens' (User IsScript Redemption) TxSkelRedeemer Source #

Focus on the TxSkelRedeemer from a script being redeemed

userEitherScriptP :: Prism' (User IsEither mode) (User IsScript mode) Source #

Builds a User IsEither from a User IsScript

userEitherPubKeyP :: Prism' (User IsEither mode) (User IsPubKey mode) Source #

Builds a User IsEither from a User IsPubKey

userTypedAF :: forall user kind mode. Typeable user => AffineFold (User kind mode) user Source #

Retrieves a possible typed user from a User

userTypedScriptAT :: forall userScript mode. (ToVScript userScript, Typeable userScript) => AffineTraversal' (User IsScript mode) userScript Source #

Focuses on a possible typed script in this User

userTypedPubKeyAT :: forall userPK mode. (ToPubKeyHash userPK, Typeable userPK) => AffineTraversal' (User IsPubKey mode) userPK Source #

Focuses on a possible typed pubkey in this User