| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.Skeleton.User
Contents
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
- type VScript = Versioned Script
- type ToVScript = ToVersioned Script
- toVScript :: ToVScript script => script -> VScript
- data UserMode
- data UserKind
- data User :: UserKind -> UserMode -> Type where
- UserPubKey :: forall pkh kind mode. (kind ∈ '[IsPubKey, IsEither], ToPubKeyHash pkh, Typeable pkh) => pkh -> User kind mode
- UserScript :: forall script kind. (kind ∈ '[IsScript, IsEither], ToVScript script, Typeable script) => script -> User kind Allocation
- UserRedeemedScript :: forall script kind. (kind ∈ [IsScript, IsEither], ToVScript script, Typeable script) => script -> TxSkelRedeemer -> User kind Redemption
- type Peer = User IsPubKey Allocation
- userHashG :: forall kind mode. Getter (User kind mode) BuiltinByteString
- userCredentialG :: Getter (User kind mode) Credential
- userTxSkelRedeemerAT :: AffineTraversal' (User kind mode) TxSkelRedeemer
- userVScriptAT :: AffineTraversal' (User kind mode) VScript
- userScriptHashAF :: AffineFold (User kind mode) ScriptHash
- userPubKeyHashAT :: AffineTraversal' (User kind mode) PubKeyHash
- userPubKeyHashI :: Iso' (User IsPubKey mode) PubKeyHash
- userVScriptL :: Lens' (User IsScript mode) VScript
- userScriptHashG :: Getter (User IsScript mode) ScriptHash
- userTxSkelRedeemerL :: Lens' (User IsScript Redemption) TxSkelRedeemer
- userEitherScriptP :: Prism' (User IsEither mode) (User IsScript mode)
- userEitherPubKeyP :: Prism' (User IsEither mode) (User IsPubKey mode)
- userTypedAF :: forall user kind mode. Typeable user => AffineFold (User kind mode) user
- userTypedScriptAT :: forall userScript mode. (ToVScript userScript, Typeable userScript) => AffineTraversal' (User IsScript mode) userScript
- userTypedPubKeyAT :: forall userPK mode. (ToPubKeyHash userPK, Typeable userPK) => AffineTraversal' (User IsPubKey mode) userPK
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
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
The UserKind corresponds to the requirement on the type of users. Some
elements will require specifically a script and some others a pubkey.
Instances
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
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 #
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
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