Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dea2567
Remove eon parameterization from some of the experimental api's
Jimbo4350 Nov 21, 2025
94cff6e
Move UnsignedTx to its own module
Jimbo4350 Nov 21, 2025
3f1ee17
Implement new TxBodyContent
Jimbo4350 Nov 21, 2025
958a41a
Implement misc instances
Jimbo4350 Nov 25, 2025
114efae
Expose new TxBodyContent via Cardano.Api.Experimental.Tx
Jimbo4350 Nov 25, 2025
cfe1700
Expose more ledger types
Jimbo4350 Nov 25, 2025
85a1968
Update tests
Jimbo4350 Nov 25, 2025
56f943b
Fix TxBodyContent param
Jimbo4350 Nov 25, 2025
4a8ccf3
Expose convertToNewScriptWitness
Jimbo4350 Nov 25, 2025
e99cec7
Add more setters
Jimbo4350 Nov 25, 2025
a001fc8
Add legacy datum conversion
Jimbo4350 Nov 26, 2025
ed5297b
Implement and expose mkTxCertificates
Jimbo4350 Nov 26, 2025
e03f6bd
Implement mkTxVotingProcedures
Jimbo4350 Nov 27, 2025
5290903
Implement mkTxProposalProcedures
Jimbo4350 Nov 27, 2025
8855a86
Expose setTxTreasuryDonation
Jimbo4350 Nov 27, 2025
9fcf34b
Refactor makeUnsignedTx
Jimbo4350 Nov 27, 2025
bb953c0
Transaction balancing functions
Jimbo4350 Nov 27, 2025
3b132f1
TODO: Write EQ instance for AnyScriptWitness
Jimbo4350 Dec 8, 2025
c24fb9c
Write Eq instance for PlutusScriptWitness
Jimbo4350 Dec 8, 2025
7f90092
More progress
Jimbo4350 Dec 8, 2025
7f5ec42
Final changes
Jimbo4350 Dec 9, 2025
beaddf5
Implement plutusScriptInEraLanguage
Jimbo4350 Dec 9, 2025
be85c6d
More mods
Jimbo4350 Dec 9, 2025
749da38
Implement FromLedgerPlutusLanguage
Jimbo4350 Dec 9, 2025
7dfd044
Implement plutusScriptInEraLanguage
Jimbo4350 Dec 10, 2025
1fda4fe
Implement mkLegacyPolicyId
Jimbo4350 Dec 10, 2025
001afa9
Implement plutusScriptInEraToScript
Jimbo4350 Dec 10, 2025
8283f34
Expose collectTxBodyScriptWitnesses
Jimbo4350 Dec 10, 2025
38ac9f8
Implement createPlutusSpendingScriptWitness
Jimbo4350 Dec 10, 2025
d50863b
Add serialisation instances for PlutusScriptInEra
Jimbo4350 Dec 10, 2025
03d69c9
Implement deserialisePlutusScriptInEra
Jimbo4350 Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ library
Cardano.Api.Era
Cardano.Api.Error
Cardano.Api.Experimental
Cardano.Api.Experimental.AnyScriptWitness
Cardano.Api.Experimental.Certificate
Cardano.Api.Experimental.Era
Cardano.Api.Experimental.Plutus
Expand Down Expand Up @@ -229,13 +230,13 @@ library
Cardano.Api.Experimental.Plutus.Internal.Shim.LegacyScripts
Cardano.Api.Experimental.Serialise.TextEnvelope.Internal
Cardano.Api.Experimental.Tx.Internal.AnyWitness
Cardano.Api.Experimental.Tx.Internal.Body
Cardano.Api.Experimental.Tx.Internal.BodyContent.New
Cardano.Api.Experimental.Tx.Internal.Certificate
Cardano.Api.Experimental.Tx.Internal.Certificate.Compatible
Cardano.Api.Experimental.Tx.Internal.Certificate.Type
Cardano.Api.Experimental.Tx.Internal.Compatible
Cardano.Api.Experimental.Tx.Internal.Fee
Cardano.Api.Experimental.Tx.Internal.TxScriptWitnessRequirements
Cardano.Api.Experimental.Tx.Internal.Type
Cardano.Api.Genesis.Internal
Cardano.Api.Genesis.Internal.Parameters
Cardano.Api.Governance.Internal.Action.ProposalProcedure
Expand Down Expand Up @@ -306,6 +307,7 @@ library gen
Test.Gen.Cardano.Api
Test.Gen.Cardano.Api.Byron
Test.Gen.Cardano.Api.Era
Test.Gen.Cardano.Api.Experimental
Test.Gen.Cardano.Api.Hardcoded
Test.Gen.Cardano.Api.Metadata
Test.Gen.Cardano.Api.Orphans
Expand Down Expand Up @@ -343,6 +345,7 @@ library gen
hedgehog-extras,
hedgehog-quickcheck,
iproute,
ordered-containers,
quickcheck-instances,
random,
tasty,
Expand Down Expand Up @@ -388,6 +391,7 @@ test-suite cardano-api-test
hedgehog-quickcheck,
microlens,
mtl,
ordered-containers,
ouroboros-consensus,
ouroboros-consensus-protocol,
raw-strings-qq,
Expand Down
89 changes: 89 additions & 0 deletions cardano-api/gen/Test/Gen/Cardano/Api/Experimental.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
module Test.Gen.Cardano.Api.Experimental
( genScriptWitnessedTxCertificates
, genScriptWitnessedTxIn
, genScriptWitnessedTxMintValue
, genScriptWitnessedTxProposals
, genScriptWitnesssedTxVotingProcedures
, genScriptWitnessedTxWithdrawals
)
where

import Cardano.Api (TxIn)
import Cardano.Api.Experimental
import Cardano.Api.Experimental.AnyScriptWitness
import Cardano.Api.Experimental.Tx
import Cardano.Api.Ledger qualified as L

import Data.Map.Ordered.Strict qualified as OMap

import Test.Gen.Cardano.Api.Typed (genExecutionUnits, genHashableScriptData, genTxIn)

import Hedgehog (Gen)
import Hedgehog.Gen qualified as Gen

genAnyWitness :: Gen (AnyWitness era)
genAnyWitness =
Gen.choice
[ return AnyKeyWitnessPlaceholder
, AnySimpleScriptWitness <$> genAnySimpleScriptWitness
, Gen.choice
[ genAnyPlutusScriptWitnessV1
, genAnyPlutusScriptWitnessV2
, genAnyPlutusScriptWitnessV3
, genAnyPlutusScriptWitnessV4
]
]

genAnyPlutusScriptWitnessV1 :: Gen (AnyWitness era)
genAnyPlutusScriptWitnessV1 =
AnyPlutusScriptWitness <$> fmap AnyPlutusMintingScriptWitness (genPlutusScriptWitness L.SPlutusV1)

genAnyPlutusScriptWitnessV2 :: Gen (AnyWitness era)
genAnyPlutusScriptWitnessV2 =
AnyPlutusScriptWitness <$> error "TODO" -- genPlutusScriptWitness L.SPlutusV2

genAnyPlutusScriptWitnessV3 :: Gen (AnyWitness era)
genAnyPlutusScriptWitnessV3 =
AnyPlutusScriptWitness <$> error "TODO" -- genPlutusScriptWitness L.SPlutusV3

genAnyPlutusScriptWitnessV4 :: Gen (AnyWitness era)
genAnyPlutusScriptWitnessV4 =
AnyPlutusScriptWitness <$> error "TODO" -- genPlutusScriptWitness L.SPlutusV4

genAnySimpleScriptWitness :: Gen (SimpleScriptOrReferenceInput era)
genAnySimpleScriptWitness = SReferenceScript <$> genTxIn

-- TODO: <|> (SScript <$> genSimpleScriptWitness)

genPlutusScriptWitness :: L.SLanguage lang -> Gen (PlutusScriptWitness lang purpose era)
genPlutusScriptWitness l =
PlutusScriptWitness l
<$> genPlutusScript
<*> genMaybeDatum
<*> genHashableScriptData
<*> genExecutionUnits

genPlutusScript :: Gen (PlutusScriptOrReferenceInput era lang)
genPlutusScript = PReferenceScript <$> genTxIn

genMaybeDatum :: Gen (PlutusScriptDatum lang purpose)
genMaybeDatum = return NoScriptDatum -- TODO: Write proper generator

genScriptWitnessedTxIn :: Gen (TxIn, AnyWitness era)
genScriptWitnessedTxIn = do
(,) <$> genTxIn <*> genAnyWitness

genScriptWitnessedTxMintValue :: Gen (TxMintValue era)
genScriptWitnessedTxMintValue = return $ TxMintValue mempty

genScriptWitnessedTxCertificates :: Gen (TxCertificates era)
genScriptWitnessedTxCertificates = return $ TxCertificates OMap.empty

genScriptWitnessedTxWithdrawals :: Gen (TxWithdrawals era)
genScriptWitnessedTxWithdrawals = return $ TxWithdrawals mempty

genScriptWitnesssedTxVotingProcedures :: Gen (TxVotingProcedures era)
genScriptWitnesssedTxVotingProcedures = return $ TxVotingProcedures (L.VotingProcedures mempty) mempty

genScriptWitnessedTxProposals :: Gen (TxProposalProcedures era)
genScriptWitnessedTxProposals = return $ TxProposalProcedures OMap.empty
3 changes: 2 additions & 1 deletion cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import Cardano.Api hiding (txIns)
import Cardano.Api qualified as Api
import Cardano.Api.Byron qualified as Byron
import Cardano.Api.Experimental qualified as Exp
import Cardano.Api.Experimental.AnyScriptWitness
import Cardano.Api.Ledger qualified as L
import Cardano.Api.Parser.Text qualified as P
import Cardano.Api.Tx qualified as A
Expand Down Expand Up @@ -1572,7 +1573,7 @@ genIndexedPlutusScriptWitness = do
Exp.IndexedPlutusScriptWitness
<$> genWitnessable
<*> genPlutusPurpose index witnessable
<*> genPlutusScriptWitness
<*> fmap (AnyPlutusSpendingScriptWitness . PlutusSpendingScriptWitnessV3) genPlutusScriptWitness

genPlutusPurpose
:: Word32
Expand Down
44 changes: 21 additions & 23 deletions cardano-api/src/Cardano/Api/Certificate/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

-- | Certificates embedded in transactions
module Cardano.Api.Certificate.Internal
Expand Down Expand Up @@ -105,7 +104,6 @@ import Data.Maybe
import Data.Text (Text)
import Data.Text qualified as Text
import Data.Text.Encoding qualified as Text
import Data.Type.Equality (TestEquality (..))
import Data.Typeable
import GHC.Exts (IsList (..), fromString)
import Network.Socket (PortNumber)
Expand Down Expand Up @@ -145,27 +143,27 @@ deriving instance Ord (Certificate era)

deriving instance Show (Certificate era)

instance TestEquality Certificate where
testEquality (ShelleyRelatedCertificate _ c) (ShelleyRelatedCertificate _ c') =
shelleyCertTypeEquality c c'
testEquality (ConwayCertificate _ c) (ConwayCertificate _ c') =
conwayCertTypeEquality c c'
testEquality ShelleyRelatedCertificate{} ConwayCertificate{} = Nothing
testEquality ConwayCertificate{} ShelleyRelatedCertificate{} = Nothing

conwayCertTypeEquality
:: (Typeable eraA, Typeable eraB)
=> Ledger.ConwayTxCert (ShelleyLedgerEra eraA)
-> Ledger.ConwayTxCert (ShelleyLedgerEra eraB)
-> Maybe (eraA :~: eraB)
conwayCertTypeEquality _ _ = eqT

shelleyCertTypeEquality
:: (Typeable eraA, Typeable eraB)
=> Ledger.ShelleyTxCert (ShelleyLedgerEra eraA)
-> Ledger.ShelleyTxCert (ShelleyLedgerEra eraB)
-> Maybe (eraA :~: eraB)
shelleyCertTypeEquality _ _ = eqT
-- instance TestEquality Certificate where
-- testEquality (ShelleyRelatedCertificate _ c) (ShelleyRelatedCertificate _ c') =
-- shelleyCertTypeEquality c c'
-- testEquality (ConwayCertificate _ c) (ConwayCertificate _ c') =
-- conwayCertTypeEquality c c'
-- testEquality ShelleyRelatedCertificate{} ConwayCertificate{} = Nothing
-- testEquality ConwayCertificate{} ShelleyRelatedCertificate{} = Nothing

-- conwayCertTypeEquality
-- :: (Typeable eraA, Typeable eraB)
-- => Ledger.ConwayTxCert (ShelleyLedgerEra eraA)
-- -> Ledger.ConwayTxCert (ShelleyLedgerEra eraB)
-- -> Maybe (eraA :~: eraB)
-- conwayCertTypeEquality _ _ = eqT
--
-- shelleyCertTypeEquality
-- :: (Typeable eraA, Typeable eraB)
-- => Ledger.ShelleyTxCert (ShelleyLedgerEra eraA)
-- -> Ledger.ShelleyTxCert (ShelleyLedgerEra eraB)
-- -> Maybe (eraA :~: eraB)
-- shelleyCertTypeEquality _ _ = eqT

instance Typeable era => HasTypeProxy (Certificate era) where
data AsType (Certificate era) = AsCertificate
Expand Down
3 changes: 2 additions & 1 deletion cardano-api/src/Cardano/Api/Experimental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module Cardano.Api.Experimental

-- ** Transaction fee related
, estimateBalancedTxBody
, evaluateTransactionFee
, collectTxBodyScriptWitnesses

-- ** Era-related
, BabbageEra
Expand Down Expand Up @@ -100,6 +102,5 @@ import Cardano.Api.Experimental.Plutus.Internal.ScriptWitness
import Cardano.Api.Experimental.Plutus.Internal.Shim.LegacyScripts
import Cardano.Api.Experimental.Simple.Script
import Cardano.Api.Experimental.Tx
import Cardano.Api.Experimental.Tx.Internal.Compatible
import Cardano.Api.Experimental.Tx.Internal.Fee
import Cardano.Api.Tx.Internal.Fee (evaluateTransactionExecutionUnitsShelley)
Loading