-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Plutarch dependency to use the PlutusV3 stable release (#9)
* release * inprogress * fix build issues due to new type system
- Loading branch information
Showing
20 changed files
with
412 additions
and
339 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Plutarch.Core.Context ( | ||
paddressCredential, ptxOutAddress, ptxOutCredential, ptxOutValue, ptxInInfoResolved, ptxInInfoOutRef, pscriptContextTxInfo, ptxInfoSignatories) where | ||
|
||
import Plutarch.Prelude ( Term, pmatch, PAsData, PBuiltinList ) | ||
import Plutarch.LedgerApi.V3 | ||
( AmountGuarantees(Positive), | ||
PValue, | ||
PAddress(paddress'credential), | ||
PCredential, | ||
PTxOut(ptxOut'value, ptxOut'address), | ||
PTxInInfo(ptxInInfo'outRef, ptxInInfo'resolved), | ||
PTxOutRef, PScriptContext, PTxInfo, pscriptContext'txInfo, PPubKeyHash, ptxInfo'signatories ) | ||
import qualified Plutarch.LedgerApi.AssocMap as AssocMap | ||
|
||
paddressCredential :: Term s PAddress -> Term s PCredential | ||
paddressCredential addr = | ||
pmatch addr $ \addr' -> | ||
paddress'credential addr' | ||
|
||
ptxOutAddress :: Term s PTxOut -> Term s PAddress | ||
ptxOutAddress = | ||
flip pmatch $ \txo -> | ||
ptxOut'address txo | ||
|
||
ptxOutCredential :: Term s PTxOut -> Term s PCredential | ||
ptxOutCredential = | ||
paddressCredential . ptxOutAddress | ||
|
||
ptxOutValue :: Term s PTxOut -> Term s (PAsData (PValue 'AssocMap.Sorted 'Positive)) | ||
ptxOutValue = | ||
flip pmatch $ \txo -> | ||
ptxOut'value txo | ||
|
||
ptxInInfoResolved :: Term s PTxInInfo -> Term s PTxOut | ||
ptxInInfoResolved txInInfo = | ||
pmatch txInInfo $ \txInInfo' -> | ||
ptxInInfo'resolved txInInfo' | ||
|
||
ptxInInfoOutRef :: Term s PTxInInfo -> Term s PTxOutRef | ||
ptxInInfoOutRef txInInfo = | ||
pmatch txInInfo $ \txInInfo' -> | ||
ptxInInfo'outRef txInInfo' | ||
|
||
pscriptContextTxInfo :: Term s PScriptContext -> Term s PTxInfo | ||
pscriptContextTxInfo ctx = | ||
pmatch ctx $ \ctx' -> | ||
pscriptContext'txInfo ctx' | ||
|
||
ptxInfoSignatories :: Term s PTxInfo -> Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))) | ||
ptxInfoSignatories = | ||
flip pmatch $ \txInfo -> | ||
ptxInfo'signatories txInfo |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Plutarch.Core.Integrity ( | ||
pisScriptCredential, | ||
pisPubKeyCredential, | ||
pdeserializeCredential, | ||
) where | ||
|
||
import Plutarch.Core.List | ||
import Plutarch.Prelude | ||
import Plutarch.LedgerApi.V3 (PCredential) | ||
|
||
-- | Check that a data-encoded Credential is a ScriptCredential. | ||
-- This does not guarantee that the data-encoded term is structurally a valid Credential. | ||
-- So this should only be used if the data-encoded term is known to be a Credential. | ||
-- If the term is obtained from relevant fields of the ScriptContext or TxInfo, then this check is safe | ||
-- because the ledger guarantees the structural validity of the Credential. | ||
pisScriptCredential :: Term s (PAsData PCredential) -> Term s PBool | ||
pisScriptCredential cred = (pfstBuiltin # (pasConstr # pforgetData cred)) #== 1 | ||
|
||
-- | Check if the provided data-encoded Credential is a PubKeyCredential. | ||
-- This does not guarantee that the data-encoded term is structurally a valid Credential. | ||
-- So this should only be used if the data-encoded term is known to be a Credential. | ||
-- If the term is obtained from relevant fields of the ScriptContext or TxInfo, then this check is safe | ||
-- because the ledger guarantees the structural validity of the Credential. | ||
pisPubKeyCredential :: Term s (PAsData PCredential) -> Term s PBool | ||
pisPubKeyCredential cred = (pfstBuiltin # (pasConstr # pforgetData cred)) #== 0 | ||
|
||
-- | Check if the provided data-encoded term has the expected builtin data representation of a credential. | ||
pdeserializeCredential :: Term s (PAsData PCredential) -> Term s (PAsData PCredential) | ||
pdeserializeCredential term = | ||
plet (pasConstr # pforgetData term) $ \constrPair -> | ||
plet (pfstBuiltin # constrPair) $ \constrIdx -> | ||
pif (plengthBS # (pasByteStr # (pheadSingleton # (psndBuiltin # constrPair))) #== 28) | ||
( | ||
pcond | ||
[ ( constrIdx #== 0 , term) | ||
, ( constrIdx #== 1 , term) | ||
] | ||
(ptraceInfoError "Invalid credential") | ||
) | ||
perror |
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
Oops, something went wrong.