Skip to content

Commit

Permalink
Add utils to convert stake pool key hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodvp committed Jul 16, 2024
1 parent aa9552b commit d8fc532
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/base/lib/Convex/PlutusLedger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module Convex.PlutusLedger(
transStakeKeyHash,
unTransStakeKeyHash,

transStakePoolKeyHash,
unTransStakePoolKeyHash,

-- * Asset names
transAssetName,
toMaryAssetName,
Expand Down Expand Up @@ -139,6 +142,14 @@ unTransStakeKeyHash (PV1.PubKeyHash pkh) =
let bsx = PlutusTx.fromBuiltin pkh
in C.deserialiseFromRawBytes (C.AsHash C.AsStakeKey) bsx

transStakePoolKeyHash :: C.Hash C.StakePoolKey -> PV1.PubKeyHash
transStakeKeyHash = PV1.PubKeyHash . PlutusTx.toBuiltin . C.serialiseToRawBytes

unTransStakePoolKeyHash :: PV1.PubKeyHash -> Either C.SerialiseAsRawBytesError (C.Hash C.StakePoolKey)
unTransStakeKeyHash (PV1.PubKeyHash pkh) =
let bsx = PlutusTx.fromBuiltin pkh
in C.deserialiseFromRawBytes (C.AsHash C.AsStakePoolKey) bsx

unTransCredential :: PV1.Credential -> Either C.SerialiseAsRawBytesError C.PaymentCredential
unTransCredential = \case
PV1.PubKeyCredential c -> C.PaymentCredentialByKey <$> unTransPubKeyHash c
Expand Down

0 comments on commit d8fc532

Please sign in to comment.