-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose PlutusV3-related functions (#244)
* Remove lenses `_PlutusScriptWitnessV1`, `_PlutusScriptWitnessV2`, `_PlutusScriptWitnessV3` * Add `_PlutusScriptWitness` lens * Replace Convex.PlutusLeger module with Convex.PlutusLedger.V1 * Add Convex.PlutusLedger.V3 module
- Loading branch information
1 parent
563599c
commit 134a3f1
Showing
8 changed files
with
58 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-| Translating between cardano-api/cardano-ledger and plutus V3 representations | ||
-} | ||
module Convex.PlutusLedger.V3 ( | ||
-- * Tx IDs | ||
unTransTxOutRef, | ||
transTxOutRef, | ||
) where | ||
|
||
import qualified Cardano.Api.Shelley as C | ||
import qualified PlutusLedgerApi.V3 as PV3 | ||
import qualified PlutusTx.Prelude as PlutusTx | ||
|
||
unTransTxOutRef :: PV3.TxOutRef -> Either C.SerialiseAsRawBytesError C.TxIn | ||
unTransTxOutRef PV3.TxOutRef{PV3.txOutRefId = PV3.TxId bs, PV3.txOutRefIdx} = | ||
let i = C.deserialiseFromRawBytes C.AsTxId $ PlutusTx.fromBuiltin bs | ||
in C.TxIn <$> i <*> pure (C.TxIx $ fromIntegral txOutRefIdx) | ||
|
||
transTxOutRef :: C.TxIn -> PV3.TxOutRef | ||
transTxOutRef (C.TxIn txId (C.TxIx ix)) = | ||
let i = PV3.TxId $ PlutusTx.toBuiltin $ C.serialiseToRawBytes txId | ||
in PV3.TxOutRef i (fromIntegral ix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters